@@ -140,16 +140,26 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV1(update beacon.ForkchoiceStateV1, pa
140140 return beacon.ForkChoiceResponse {PayloadStatus : beacon .INVALID_TERMINAL_BLOCK , PayloadID : nil }, nil
141141 }
142142 }
143-
143+ valid := func (id * beacon.PayloadID ) beacon.ForkChoiceResponse {
144+ return beacon.ForkChoiceResponse {
145+ PayloadStatus : beacon.PayloadStatusV1 {Status : beacon .VALID , LatestValidHash : & update .HeadBlockHash },
146+ PayloadID : id ,
147+ }
148+ }
144149 if rawdb .ReadCanonicalHash (api .eth .ChainDb (), block .NumberU64 ()) != update .HeadBlockHash {
145150 // Block is not canonical, set head.
146151 if latestValid , err := api .eth .BlockChain ().SetCanonical (block ); err != nil {
147152 return beacon.ForkChoiceResponse {PayloadStatus : beacon.PayloadStatusV1 {Status : beacon .INVALID , LatestValidHash : & latestValid }}, err
148153 }
154+ } else if api .eth .BlockChain ().CurrentBlock ().Hash () == update .HeadBlockHash {
155+ // If the specified head matches with our local head, do nothing and keep
156+ // generating the payload. It's a special corner case that a few slots are
157+ // missing and we are requested to generate the payload in slot.
149158 } else {
150159 // If the head block is already in our canonical chain, the beacon client is
151160 // probably resyncing. Ignore the update.
152161 log .Info ("Ignoring beacon update to old head" , "number" , block .NumberU64 (), "hash" , update .HeadBlockHash , "age" , common .PrettyAge (time .Unix (int64 (block .Time ()), 0 )), "have" , api .eth .BlockChain ().CurrentBlock ().NumberU64 ())
162+ return valid (nil ), nil
153163 }
154164 api .eth .SetSynced ()
155165
@@ -183,12 +193,6 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV1(update beacon.ForkchoiceStateV1, pa
183193 return beacon .STATUS_INVALID , beacon .InvalidForkChoiceState .With (errors .New ("safe block not in canonical chain" ))
184194 }
185195 }
186- valid := func (id * beacon.PayloadID ) beacon.ForkChoiceResponse {
187- return beacon.ForkChoiceResponse {
188- PayloadStatus : beacon.PayloadStatusV1 {Status : beacon .VALID , LatestValidHash : & update .HeadBlockHash },
189- PayloadID : id ,
190- }
191- }
192196 // If payload generation was requested, create a new block to be potentially
193197 // sealed by the beacon client. The payload will be requested later, and we
194198 // might replace it arbitrarily many times in between.
0 commit comments