Skip to content

Commit

Permalink
engineapi: Add version-based check for requests list (#12979)
Browse files Browse the repository at this point in the history
As per the
[specs](https://github.com/ethereum/execution-apis/blob/main/src/engine/prague.md#engine_newpayloadv4)
`V4`-Prague follows on from `V3`-Cancun, plus the added changes. So, in
my interpretation, the following checks should hold:
- Params validation precedes over fork-version check. 
- Param validation for the additional param `executionRequests` should
have the same semantics as point (1) from "Specification" section of
[`newPayloadV3`](https://github.com/ethereum/execution-apis/blob/main/src/engine/cancun.md#engine_getpayloadv3)

(This may break some opinionated hive tests, and potentially some spec
tests)
  • Loading branch information
somnathb1 authored Dec 4, 2024
1 parent cd6312c commit 5d99935
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions turbo/engineapi/engine_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,16 @@ func (s *EngineServer) checkWithdrawalsPresence(time uint64, withdrawals types.W
return nil
}

func (s *EngineServer) checkRequestsPresence(time uint64, executionRequests []hexutility.Bytes) error {
if !s.config.IsPrague(time) {
if executionRequests != nil {
return &rpc.InvalidParamsError{Message: "requests before Prague"}
}
func (s *EngineServer) checkRequestsPresence(version clparams.StateVersion, executionRequests []hexutility.Bytes) error {
if version < clparams.ElectraVersion && executionRequests != nil {
return &rpc.InvalidParamsError{Message: "requests in EngineAPI not supported before Prague"}
}
if executionRequests == nil {
return &rpc.InvalidParamsError{Message: "missing requests list"}
}
if len(executionRequests) != len(types.KnownRequestTypes) {
return &rpc.InvalidParamsError{Message: "invalid requests lists"}
}
// if s.config.IsPrague(time) {
// if len(executionRequests) < 3 {
// return &rpc.InvalidParamsError{Message: "missing requests list"}
// }
// }
return nil
}

Expand Down Expand Up @@ -204,7 +203,7 @@ func (s *EngineServer) newPayload(ctx context.Context, req *engine_types.Executi
}

var requests types.FlatRequests
if err := s.checkRequestsPresence(header.Time, executionRequests); err != nil {
if err := s.checkRequestsPresence(version, executionRequests); err != nil {
return nil, err
}
if version >= clparams.ElectraVersion {
Expand Down

0 comments on commit 5d99935

Please sign in to comment.