core: derive receipts at end of block in GenerateChain

This ensures the returned receipts match what would be returned by the RPC API.
This commit is contained in:
Felix Lange 2023-10-30 19:05:44 +01:00
parent fd5d33a33b
commit fd9a83315e

View file

@ -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