fix: payload version error return (#6618)

See https://github.com/ethereum/execution-apis/pull/337
This commit is contained in:
Max Revitt 2023-01-18 13:31:25 +00:00 committed by GitHub
parent 3f07c66928
commit 3837d6d26d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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