@@ -173,8 +173,8 @@ func newConsensusAPIWithoutHeartbeat(eth *eth.Ethereum) *ConsensusAPI {
173
173
// and return its payloadID.
174
174
func (api * ConsensusAPI ) ForkchoiceUpdatedV1 (update engine.ForkchoiceStateV1 , payloadAttributes * engine.PayloadAttributes ) (engine.ForkChoiceResponse , error ) {
175
175
if payloadAttributes != nil {
176
- if payloadAttributes .Withdrawals != nil {
177
- return engine .STATUS_INVALID , engine .InvalidParams .With (errors .New ("withdrawals not supported in V1" ))
176
+ if payloadAttributes .Withdrawals != nil || payloadAttributes . BeaconRoot != nil {
177
+ return engine .STATUS_INVALID , engine .InvalidParams .With (errors .New ("withdrawals and beacon root not supported in V1" ))
178
178
}
179
179
if api .eth .BlockChain ().Config ().IsShanghai (api .eth .BlockChain ().Config ().LondonBlock , payloadAttributes .Timestamp ) {
180
180
return engine .STATUS_INVALID , engine .InvalidParams .With (errors .New ("forkChoiceUpdateV1 called post-shanghai" ))
@@ -183,23 +183,31 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV1(update engine.ForkchoiceStateV1, pa
183
183
return api .forkchoiceUpdated (update , payloadAttributes , engine .PayloadV1 , false )
184
184
}
185
185
186
- // ForkchoiceUpdatedV2 is equivalent to V1 with the addition of withdrawals in the payload attributes.
186
+ // ForkchoiceUpdatedV2 is equivalent to V1 with the addition of withdrawals in the payload
187
+ // attributes. It supports both PayloadAttributesV1 and PayloadAttributesV2.
187
188
func (api * ConsensusAPI ) ForkchoiceUpdatedV2 (update engine.ForkchoiceStateV1 , params * engine.PayloadAttributes ) (engine.ForkChoiceResponse , error ) {
188
189
if params != nil {
189
- if params .Withdrawals == nil {
190
- return engine .STATUS_INVALID , engine .InvalidParams .With (errors .New ("missing withdrawals" ))
190
+ switch api .eth .BlockChain ().Config ().LatestFork (params .Timestamp ) {
191
+ case forks .Paris :
192
+ if params .Withdrawals != nil {
193
+ return engine .STATUS_INVALID , engine .InvalidParams .With (errors .New ("withdrawals before shanghai" ))
194
+ }
195
+ case forks .Shanghai :
196
+ if params .Withdrawals == nil {
197
+ return engine .STATUS_INVALID , engine .InvalidParams .With (errors .New ("missing withdrawals" ))
198
+ }
199
+ default :
200
+ return engine .STATUS_INVALID , engine .UnsupportedFork .With (errors .New ("forkchoiceUpdatedV2 must only be called with paris and shanghai payloads" ))
191
201
}
192
202
if params .BeaconRoot != nil {
193
203
return engine .STATUS_INVALID , engine .InvalidParams .With (errors .New ("unexpected beacon root" ))
194
204
}
195
- if api .eth .BlockChain ().Config ().LatestFork (params .Timestamp ) != forks .Shanghai {
196
- return engine .STATUS_INVALID , engine .UnsupportedFork .With (errors .New ("forkchoiceUpdatedV2 must only be called for shanghai payloads" ))
197
- }
198
205
}
199
206
return api .forkchoiceUpdated (update , params , engine .PayloadV2 , false )
200
207
}
201
208
202
- // ForkchoiceUpdatedV3 is equivalent to V2 with the addition of parent beacon block root in the payload attributes.
209
+ // ForkchoiceUpdatedV3 is equivalent to V2 with the addition of parent beacon block root
210
+ // in the payload attributes. It supports only PayloadAttributesV3.
203
211
func (api * ConsensusAPI ) ForkchoiceUpdatedV3 (update engine.ForkchoiceStateV1 , params * engine.PayloadAttributes ) (engine.ForkChoiceResponse , error ) {
204
212
if params != nil {
205
213
// TODO(matt): according to https://github.com/ethereum/execution-apis/pull/498,
0 commit comments