From dbd6c1324dda8bb93c7a8297446fce7998cab4e1 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Tue, 14 Feb 2023 19:39:00 +0100 Subject: [PATCH] eth/catalyst: return error if withdrawals are nil post-shanghai (#26691) Spec: https://github.com/ethereum/execution-apis/blob/main/src/engine/shanghai.md#request --- eth/catalyst/api.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index 01a29fc447dc..00c4772185b1 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -410,13 +410,20 @@ func (api *ConsensusAPI) getPayload(payloadID engine.PayloadID) (*engine.Executi // NewPayloadV1 creates an Eth1 block, inserts it in the chain, and returns the status of the chain. func (api *ConsensusAPI) NewPayloadV1(params engine.ExecutableData) (engine.PayloadStatusV1, error) { if params.Withdrawals != nil { - return engine.PayloadStatusV1{Status: engine.INVALID}, fmt.Errorf("withdrawals not supported in V1") + return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(fmt.Errorf("withdrawals not supported in V1")) } return api.newPayload(params) } // NewPayloadV2 creates an Eth1 block, inserts it in the chain, and returns the status of the chain. func (api *ConsensusAPI) NewPayloadV2(params engine.ExecutableData) (engine.PayloadStatusV1, error) { + if api.eth.BlockChain().Config().IsShanghai(params.Timestamp) { + if params.Withdrawals == nil { + return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(fmt.Errorf("nil withdrawals post-shanghai")) + } + } else if params.Withdrawals != nil { + return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(fmt.Errorf("non-nil withdrawals pre-shanghai")) + } return api.newPayload(params) }