Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.

Commit a9e134a

Browse files
committed
feat(core/types): Body and Block hooks
1 parent b999d7c commit a9e134a

File tree

15 files changed

+180
-373
lines changed

15 files changed

+180
-373
lines changed

consensus/dummy/consensus.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ func (eng *DummyEngine) Finalize(chain consensus.ChainHeaderReader, block *types
404404
if extDataGasUsed == nil {
405405
extDataGasUsed = new(big.Int).Set(common.Big0)
406406
}
407-
if blockExtDataGasUsed := block.ExtDataGasUsed(); blockExtDataGasUsed == nil || !blockExtDataGasUsed.IsUint64() || blockExtDataGasUsed.Cmp(extDataGasUsed) != 0 {
407+
if blockExtDataGasUsed := types.BlockExtDataGasUsed(block); blockExtDataGasUsed == nil || !blockExtDataGasUsed.IsUint64() || blockExtDataGasUsed.Cmp(extDataGasUsed) != 0 {
408408
return fmt.Errorf("invalid extDataGasUsed: have %d, want %d", blockExtDataGasUsed, extDataGasUsed)
409409
}
410410
blockGasCostStep := ApricotPhase4BlockGasCostStep
@@ -422,13 +422,13 @@ func (eng *DummyEngine) Finalize(chain consensus.ChainHeaderReader, block *types
422422
parent.Time, block.Time(),
423423
)
424424
// Verify the BlockGasCost set in the header matches the calculated value.
425-
if blockBlockGasCost := block.BlockGasCost(); blockBlockGasCost == nil || !blockBlockGasCost.IsUint64() || blockBlockGasCost.Cmp(blockGasCost) != 0 {
425+
if blockBlockGasCost := types.BlockGasCost(block); blockBlockGasCost == nil || !blockBlockGasCost.IsUint64() || blockBlockGasCost.Cmp(blockGasCost) != 0 {
426426
return fmt.Errorf("invalid blockGasCost: have %d, want %d", blockBlockGasCost, blockGasCost)
427427
}
428428
// Verify the block fee was paid.
429429
if err := eng.verifyBlockFee(
430430
block.BaseFee(),
431-
block.BlockGasCost(),
431+
types.BlockGasCost(block),
432432
block.Transactions(),
433433
receipts,
434434
contribution,

core/blockchain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,7 @@ func (bc *BlockChain) insertBlock(block *types.Block, writes bool) error {
13671367
"parentHash", block.ParentHash(),
13681368
"uncles", len(block.Uncles()), "txs", len(block.Transactions()), "gas", block.GasUsed(),
13691369
"elapsed", common.PrettyDuration(time.Since(start)),
1370-
"root", block.Root(), "baseFeePerGas", block.BaseFee(), "blockGasCost", block.BlockGasCost(),
1370+
"root", block.Root(), "baseFeePerGas", block.BaseFee(), "blockGasCost", types.BlockGasCost(block),
13711371
)
13721372

13731373
processedBlockGasUsedCounter.Inc(int64(block.GasUsed()))

core/rawdb/accessors_chain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ func ReadBlock(db ethdb.Reader, hash common.Hash, number uint64) *types.Block {
522522
if body == nil {
523523
return nil
524524
}
525-
return types.NewBlockWithHeader(header).WithBody(body.Transactions, body.Uncles).WithExtData(body.Version, body.ExtData)
525+
return types.NewBlockWithHeader(header).WithBody(*body)
526526
}
527527

528528
// WriteBlock serializes a block into the database, header and body separately.

core/types/block.go

Lines changed: 0 additions & 300 deletions
This file was deleted.

0 commit comments

Comments
 (0)