Skip to content

Commit 1883438

Browse files
authored
eth/catalyst: return invalid payload attributes instead of invalid parms for bad fcu payload (ethereum#29115)
1 parent 9986a69 commit 1883438

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

eth/catalyst/api.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -190,21 +190,21 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV1(update engine.ForkchoiceStateV1, pa
190190
// attributes. It supports both PayloadAttributesV1 and PayloadAttributesV2.
191191
func (api *ConsensusAPI) ForkchoiceUpdatedV2(update engine.ForkchoiceStateV1, params *engine.PayloadAttributes) (engine.ForkChoiceResponse, error) {
192192
if params != nil {
193+
if params.BeaconRoot != nil {
194+
return engine.STATUS_INVALID, engine.InvalidPayloadAttributes.With(errors.New("unexpected beacon root"))
195+
}
193196
switch api.eth.BlockChain().Config().LatestFork(params.Timestamp) {
194197
case forks.Paris:
195198
if params.Withdrawals != nil {
196-
return engine.STATUS_INVALID, engine.InvalidParams.With(errors.New("withdrawals before shanghai"))
199+
return engine.STATUS_INVALID, engine.InvalidPayloadAttributes.With(errors.New("withdrawals before shanghai"))
197200
}
198201
case forks.Shanghai:
199202
if params.Withdrawals == nil {
200-
return engine.STATUS_INVALID, engine.InvalidParams.With(errors.New("missing withdrawals"))
203+
return engine.STATUS_INVALID, engine.InvalidPayloadAttributes.With(errors.New("missing withdrawals"))
201204
}
202205
default:
203206
return engine.STATUS_INVALID, engine.UnsupportedFork.With(errors.New("forkchoiceUpdatedV2 must only be called with paris and shanghai payloads"))
204207
}
205-
if params.BeaconRoot != nil {
206-
return engine.STATUS_INVALID, engine.InvalidParams.With(errors.New("unexpected beacon root"))
207-
}
208208
}
209209
return api.forkchoiceUpdated(update, params, engine.PayloadV2, false)
210210
}
@@ -213,15 +213,11 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV2(update engine.ForkchoiceStateV1, pa
213213
// in the payload attributes. It supports only PayloadAttributesV3.
214214
func (api *ConsensusAPI) ForkchoiceUpdatedV3(update engine.ForkchoiceStateV1, params *engine.PayloadAttributes) (engine.ForkChoiceResponse, error) {
215215
if params != nil {
216-
// TODO(matt): according to https://github.com/ethereum/execution-apis/pull/498,
217-
// payload attributes that are invalid should return error
218-
// engine.InvalidPayloadAttributes. Once hive updates this, we should update
219-
// on our end.
220216
if params.Withdrawals == nil {
221-
return engine.STATUS_INVALID, engine.InvalidParams.With(errors.New("missing withdrawals"))
217+
return engine.STATUS_INVALID, engine.InvalidPayloadAttributes.With(errors.New("missing withdrawals"))
222218
}
223219
if params.BeaconRoot == nil {
224-
return engine.STATUS_INVALID, engine.InvalidParams.With(errors.New("missing beacon root"))
220+
return engine.STATUS_INVALID, engine.InvalidPayloadAttributes.With(errors.New("missing beacon root"))
225221
}
226222
if api.eth.BlockChain().Config().LatestFork(params.Timestamp) != forks.Cancun {
227223
return engine.STATUS_INVALID, engine.UnsupportedFork.With(errors.New("forkchoiceUpdatedV3 must only be called for cancun payloads"))

0 commit comments

Comments
 (0)