From 43a60b36ea53a416ba01f271749d20f1251ce607 Mon Sep 17 00:00:00 2001 From: David Date: Sat, 15 Mar 2025 16:41:15 +0900 Subject: [PATCH] fix(eth): write `L1Origin` even if the payload is already in the cache (#396) --- eth/catalyst/api.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index 44e00debea..e93b975a86 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -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)