Skip to content

Commit

Permalink
fix: payload version error return (#6618)
Browse files Browse the repository at this point in the history
  • Loading branch information
revitteth authored Jan 18, 2023
1 parent 3f07c66 commit 3837d6d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions ethdb/privateapi/ethbackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3837d6d

Please sign in to comment.