Skip to content

Commit e2778cd

Browse files
authored
eth/catalyst: allow payload attributes v1 in fcu v2 (#28882)
At some point, `ForkchoiceUpdatedV2` stopped working for `PayloadAttributesV1` while `paris` was active. This was causing a few failures in hive. This PR fixes that, and also adds a gate in `ForkchoiceUpdatedV1` to disallow `PayloadAttributesV3`.
1 parent db98cc4 commit e2778cd

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

eth/catalyst/api.go

+17-9
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ func newConsensusAPIWithoutHeartbeat(eth *eth.Ethereum) *ConsensusAPI {
173173
// and return its payloadID.
174174
func (api *ConsensusAPI) ForkchoiceUpdatedV1(update engine.ForkchoiceStateV1, payloadAttributes *engine.PayloadAttributes) (engine.ForkChoiceResponse, error) {
175175
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"))
178178
}
179179
if api.eth.BlockChain().Config().IsShanghai(api.eth.BlockChain().Config().LondonBlock, payloadAttributes.Timestamp) {
180180
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
183183
return api.forkchoiceUpdated(update, payloadAttributes, engine.PayloadV1, false)
184184
}
185185

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.
187188
func (api *ConsensusAPI) ForkchoiceUpdatedV2(update engine.ForkchoiceStateV1, params *engine.PayloadAttributes) (engine.ForkChoiceResponse, error) {
188189
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"))
191201
}
192202
if params.BeaconRoot != nil {
193203
return engine.STATUS_INVALID, engine.InvalidParams.With(errors.New("unexpected beacon root"))
194204
}
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-
}
198205
}
199206
return api.forkchoiceUpdated(update, params, engine.PayloadV2, false)
200207
}
201208

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.
203211
func (api *ConsensusAPI) ForkchoiceUpdatedV3(update engine.ForkchoiceStateV1, params *engine.PayloadAttributes) (engine.ForkChoiceResponse, error) {
204212
if params != nil {
205213
// TODO(matt): according to https://github.com/ethereum/execution-apis/pull/498,

0 commit comments

Comments
 (0)