@@ -140,16 +140,26 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV1(update beacon.ForkchoiceStateV1, pa
140
140
return beacon.ForkChoiceResponse {PayloadStatus : beacon .INVALID_TERMINAL_BLOCK , PayloadID : nil }, nil
141
141
}
142
142
}
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
+ }
144
149
if rawdb .ReadCanonicalHash (api .eth .ChainDb (), block .NumberU64 ()) != update .HeadBlockHash {
145
150
// Block is not canonical, set head.
146
151
if latestValid , err := api .eth .BlockChain ().SetCanonical (block ); err != nil {
147
152
return beacon.ForkChoiceResponse {PayloadStatus : beacon.PayloadStatusV1 {Status : beacon .INVALID , LatestValidHash : & latestValid }}, err
148
153
}
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.
149
158
} else {
150
159
// If the head block is already in our canonical chain, the beacon client is
151
160
// probably resyncing. Ignore the update.
152
161
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
153
163
}
154
164
api .eth .SetSynced ()
155
165
@@ -183,12 +193,6 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV1(update beacon.ForkchoiceStateV1, pa
183
193
return beacon .STATUS_INVALID , beacon .InvalidForkChoiceState .With (errors .New ("safe block not in canonical chain" ))
184
194
}
185
195
}
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
- }
192
196
// If payload generation was requested, create a new block to be potentially
193
197
// sealed by the beacon client. The payload will be requested later, and we
194
198
// might replace it arbitrarily many times in between.
0 commit comments