Skip to content

Commit

Permalink
engineapi: Fix req list check (#11191)
Browse files Browse the repository at this point in the history
  • Loading branch information
somnathb1 authored Jul 17, 2024
1 parent ba07b2a commit febcfc1
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions turbo/engineapi/engine_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,16 @@ func (s *EngineServer) checkWithdrawalsPresence(time uint64, withdrawals types.W
return nil
}

func (s *EngineServer) checkRequestsPresence(time uint64, requests types.Requests) error {
if !s.config.IsPrague(time) && requests != nil {
return &rpc.InvalidParamsError{Message: "requests before Prague"}
func (s *EngineServer) checkRequestsPresence(time uint64, payload *engine_types.ExecutionPayload) error {
if !s.config.IsPrague(time) {
if payload.DepositRequests != nil || payload.WithdrawalRequests != nil || payload.ConsolidationRequests != nil {
return &rpc.InvalidParamsError{Message: "requests before Prague"}
}
}
if s.config.IsPrague(time) && requests == nil {
return &rpc.InvalidParamsError{Message: "missing requests list"}
if s.config.IsPrague(time) {
if payload.DepositRequests == nil || payload.WithdrawalRequests == nil || payload.ConsolidationRequests == nil {
return &rpc.InvalidParamsError{Message: "missing requests list"}
}
}
return nil
}
Expand Down Expand Up @@ -202,14 +206,16 @@ func (s *EngineServer) newPayload(ctx context.Context, req *engine_types.Executi
}

var requests types.Requests
if version >= clparams.ElectraVersion && req.DepositRequests != nil {
if err := s.checkRequestsPresence(header.Time, req); err != nil {
return nil, err
}
if version >= clparams.ElectraVersion {
requests = make(types.Requests, 0)
requests = append(requests, req.DepositRequests.Requests()...)
requests = append(requests, req.WithdrawalRequests.Requests()...)
requests = append(requests, req.ConsolidationRequests.Requests()...)
}
if err := s.checkRequestsPresence(header.Time, requests); err != nil {
return nil, err
}

if requests != nil {
rh := types.DeriveSha(requests)
header.RequestsRoot = &rh
Expand Down

0 comments on commit febcfc1

Please sign in to comment.