From 3837d6d26d6b44d289be993a342ebafc9ff8d822 Mon Sep 17 00:00:00 2001 From: Max Revitt Date: Wed, 18 Jan 2023 13:31:25 +0000 Subject: [PATCH] fix: payload version error return (#6618) See https://github.com/ethereum/execution-apis/pull/337 --- ethdb/privateapi/ethbackend.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/ethdb/privateapi/ethbackend.go b/ethdb/privateapi/ethbackend.go index 099b79e37..6a981baf2 100644 --- a/ethdb/privateapi/ethbackend.go +++ b/ethdb/privateapi/ethbackend.go @@ -46,7 +46,7 @@ const MaxBuilders = 128 var UnknownPayloadErr = rpc.CustomError{Code: -38001, Message: "Unknown payload"} var InvalidForkchoiceStateErr = rpc.CustomError{Code: -38002, Message: "Invalid forkchoice state"} var InvalidPayloadAttributesErr = rpc.CustomError{Code: -38003, Message: "Invalid payload attributes"} -var ErrWithdrawalsNotSupported = rpc.CustomError{Code: -38004, Message: "Withdrawals not supported"} +var InvalidParamsErr = rpc.CustomError{Code: -32602, Message: "Invalid params"} type EthBackendServer struct { remote.UnimplementedETHBACKENDServer // must be embedded to have forward compatible implementations. @@ -315,6 +315,10 @@ func (s *EthBackendServer) engineNewPayload(req *types2.ExecutionPayload, withdr header.WithdrawalsHash = &wh } + if !s.config.IsShanghai(header.Time) && withdrawals != nil || s.config.IsShanghai(header.Time) && withdrawals == nil { + return nil, &InvalidParamsErr + } + blockHash := gointerfaces.ConvertH256ToHash(req.BlockHash) if header.Hash() != blockHash { log.Error("[NewPayload] invalid block hash", "stated", libcommon.Hash(blockHash), "actual", header.Hash()) @@ -646,14 +650,8 @@ func (s *EthBackendServer) engineForkChoiceUpdated(ctx context.Context, reqForkc } // If pre-Shanghai and there are withdrawals, we should error - if reqWithdrawals != nil && !s.config.IsShanghai(payloadAttributes.Timestamp) { - return &remote.EngineForkChoiceUpdatedReply{ - PayloadStatus: &remote.EnginePayloadStatus{ - Status: remote.EngineStatus_INVALID, - LatestValidHash: gointerfaces.ConvertHashToH256(headHash), - }, - PayloadId: s.payloadId, - }, &ErrWithdrawalsNotSupported + if !s.config.IsShanghai(headHeader.Time) && reqWithdrawals != nil { + return nil, &InvalidParamsErr } // Initiate payload building