From fd9a83315e32b1f39e8285d9534553ef6203239f Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 30 Oct 2023 19:05:44 +0100 Subject: [PATCH] core: derive receipts at end of block in GenerateChain This ensures the returned receipts match what would be returned by the RPC API. --- core/chain_makers.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/core/chain_makers.go b/core/chain_makers.go index baec098631..a097925b89 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -369,8 +369,19 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse if err != nil { panic(err) } - block, receipt := genblock(i, parent, triedb, statedb) - cm.add(block, receipt) + block, receipts := genblock(i, parent, triedb, statedb) + + // Post-process the receipts. + var blobGasPrice *big.Int + if block.ExcessBlobGas() != nil { + blobGasPrice = eip4844.CalcBlobFee(*block.ExcessBlobGas()) + } + if err := receipts.DeriveFields(config, block.Hash(), block.NumberU64(), block.Time(), block.BaseFee(), blobGasPrice, block.Transactions()); err != nil { + panic(err) + } + + // Advance the chain. + cm.add(block, receipts) parent = block } return cm.chain, cm.receipts