@@ -87,6 +87,7 @@ var caps = []string{
8787 "engine_forkchoiceUpdatedV1" ,
8888 "engine_forkchoiceUpdatedV2" ,
8989 "engine_forkchoiceUpdatedV3" ,
90+ "engine_forkchoiceUpdatedV4" ,
9091 "engine_forkchoiceUpdatedWithWitnessV1" ,
9192 "engine_forkchoiceUpdatedWithWitnessV2" ,
9293 "engine_forkchoiceUpdatedWithWitnessV3" ,
@@ -252,7 +253,7 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV3(update engine.ForkchoiceStateV1, pa
252253 return engine .STATUS_INVALID , attributesErr ("missing withdrawals" )
253254 case params .BeaconRoot == nil :
254255 return engine .STATUS_INVALID , attributesErr ("missing beacon root" )
255- case ! api .checkFork (params .Timestamp , forks .Cancun , forks .Prague , forks .Osaka , forks . Eip7805 ):
256+ case ! api .checkFork (params .Timestamp , forks .Cancun , forks .Prague , forks .Osaka ):
256257 return engine .STATUS_INVALID , unsupportedForkErr ("fcuV3 must only be called for cancun or prague payloads" )
257258 }
258259 }
@@ -263,6 +264,22 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV3(update engine.ForkchoiceStateV1, pa
263264 return api .forkchoiceUpdated (update , params , engine .PayloadV3 , false )
264265}
265266
267+ // ForkchoiceUpdatedV4 is equivalent to V3 with the addition of inclusion list
268+ // in the payload attributes. It supports only PayloadAttributesV4.
269+ func (api * ConsensusAPI ) ForkchoiceUpdatedV4 (update engine.ForkchoiceStateV1 , params * engine.PayloadAttributes ) (engine.ForkChoiceResponse , error ) {
270+ if params != nil {
271+ switch {
272+ case params .Withdrawals == nil :
273+ return engine .STATUS_INVALID , attributesErr ("missing withdrawals" )
274+ case params .BeaconRoot == nil :
275+ return engine .STATUS_INVALID , attributesErr ("missing beacon root" )
276+ case ! api .checkFork (params .Timestamp , forks .Eip7805 ):
277+ return engine .STATUS_INVALID , unsupportedForkErr ("fcuV4 must only be called for eip7805 payloads" )
278+ }
279+ }
280+ return api .forkchoiceUpdated (update , params , engine .PayloadV4 , false )
281+ }
282+
266283func (api * ConsensusAPI ) forkchoiceUpdated (update engine.ForkchoiceStateV1 , payloadAttributes * engine.PayloadAttributes , payloadVersion engine.PayloadVersion , payloadWitness bool ) (engine.ForkChoiceResponse , error ) {
267284 api .forkchoiceLock .Lock ()
268285 defer api .forkchoiceLock .Unlock ()
@@ -390,18 +407,20 @@ func (api *ConsensusAPI) forkchoiceUpdated(update engine.ForkchoiceStateV1, payl
390407 // will replace it arbitrarily many times in between.
391408 if payloadAttributes != nil {
392409 args := & miner.BuildPayloadArgs {
393- Parent : update .HeadBlockHash ,
394- Timestamp : payloadAttributes .Timestamp ,
395- FeeRecipient : payloadAttributes .SuggestedFeeRecipient ,
396- Random : payloadAttributes .Random ,
397- Withdrawals : payloadAttributes .Withdrawals ,
398- BeaconRoot : payloadAttributes .BeaconRoot ,
399- Version : payloadVersion ,
410+ Parent : update .HeadBlockHash ,
411+ Timestamp : payloadAttributes .Timestamp ,
412+ FeeRecipient : payloadAttributes .SuggestedFeeRecipient ,
413+ Random : payloadAttributes .Random ,
414+ Withdrawals : payloadAttributes .Withdrawals ,
415+ BeaconRoot : payloadAttributes .BeaconRoot ,
416+ InclusionList : payloadAttributes .InclusionList ,
417+ Version : payloadVersion ,
400418 }
401419 id := args .Id ()
402420 // If we already are busy generating this work, then we do not need
403421 // to start a second process.
404- if api .localBlocks .has (id ) {
422+ if payload := api .localBlocks .peek (id ); payload != nil {
423+ payload .UpdateInclusionList (payloadAttributes .InclusionList )
405424 return valid (& id ), nil
406425 }
407426 payload , err := api .eth .Miner ().BuildPayload (args , payloadWitness )
0 commit comments