fix(eth): write L1Origin even if the payload is already in the cache (#396)

This commit is contained in:
David 2025-03-15 16:41:15 +09:00 committed by GitHub
parent 516eff7ae9
commit 43a60b36ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -453,6 +453,12 @@ func (api *ConsensusAPI) forkchoiceUpdated(update engine.ForkchoiceStateV1, payl
return valid(nil), engine.InvalidPayloadAttributes.With(err)
}
// L1Origin **MUST NOT** be nil, it's a required field in PayloadAttributesV1.
l1Origin := payloadAttributes.L1Origin
// Set the block hash before inserting the L1Origin into database.
l1Origin.L2BlockHash = block.Hash()
// Use the tx list hash as the beacon root.
txListHash := crypto.Keccak256Hash(payloadAttributes.BlockMetadata.TxList[:])
// Cache the mined block for later use.
@ -469,6 +475,8 @@ func (api *ConsensusAPI) forkchoiceUpdated(update engine.ForkchoiceStateV1, payl
// If we already are busy generating this work, then we do not need
// to start a second process.
if api.localBlocks.has(id) {
// Write L1Origin even if the payload is already in the cache.
rawdb.WriteL1Origin(api.eth.ChainDb(), l1Origin.BlockID, l1Origin)
return valid(&id), nil
}
payload, err := api.eth.Miner().BuildPayload(args, false)
@ -481,12 +489,6 @@ func (api *ConsensusAPI) forkchoiceUpdated(update engine.ForkchoiceStateV1, payl
api.localBlocks.put(id, payload)
// L1Origin **MUST NOT** be nil, it's a required field in PayloadAttributesV1.
l1Origin := payloadAttributes.L1Origin
// Set the block hash before inserting the L1Origin into database.
l1Origin.L2BlockHash = block.Hash()
// Write L1Origin.
rawdb.WriteL1Origin(api.eth.ChainDb(), l1Origin.BlockID, l1Origin)