Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hive: Do not validate payload attributes if nil or syncing and pre-cancun check #9413

Merged
merged 3 commits into from
Feb 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions turbo/engineapi/engine_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ func (s *EngineServer) newPayload(ctx context.Context, req *engine_types.Executi
return nil, err
}

if version <= clparams.CapellaVersion {
if req.BlobGasUsed != nil {
return nil, &rpc.InvalidParamsError{Message: "Unexpected pre-cancun blobGasUsed"}
}
if req.ExcessBlobGas != nil {
return nil, &rpc.InvalidParamsError{Message: "Unexpected pre-cancun excessBlobGas"}
}
}

if version >= clparams.DenebVersion {
if req.BlobGasUsed == nil || req.ExcessBlobGas == nil || parentBeaconBlockRoot == nil {
return nil, &rpc.InvalidParamsError{Message: "blobGasUsed/excessBlobGas/beaconRoot missing"}
Expand Down Expand Up @@ -450,35 +459,32 @@ func (s *EngineServer) forkchoiceUpdated(ctx context.Context, forkchoiceState *e
}
}

if payloadAttributes != nil {
if version < clparams.DenebVersion && payloadAttributes.ParentBeaconBlockRoot != nil {
return nil, &engine_helpers.InvalidPayloadAttributesErr // Unexpected Beacon Root
}
if version >= clparams.DenebVersion && payloadAttributes.ParentBeaconBlockRoot == nil {
return nil, &engine_helpers.InvalidPayloadAttributesErr // Beacon Root missing
}

timestamp := uint64(payloadAttributes.Timestamp)
if !s.config.IsCancun(timestamp) && version >= clparams.DenebVersion { // V3 before cancun
return nil, &rpc.UnsupportedForkError{Message: "Unsupported fork"}
}
if s.config.IsCancun(timestamp) && version < clparams.DenebVersion { // Not V3 after cancun
return nil, &rpc.UnsupportedForkError{Message: "Unsupported fork"}
}
}

// No need for payload building
if payloadAttributes == nil || status.Status != engine_types.ValidStatus {
return &engine_types.ForkChoiceUpdatedResponse{PayloadStatus: status}, nil
}

if version < clparams.DenebVersion && payloadAttributes.ParentBeaconBlockRoot != nil {
return nil, &engine_helpers.InvalidPayloadAttributesErr // Unexpected Beacon Root
}
if version >= clparams.DenebVersion && payloadAttributes.ParentBeaconBlockRoot == nil {
return nil, &engine_helpers.InvalidPayloadAttributesErr // Beacon Root missing
}

timestamp := uint64(payloadAttributes.Timestamp)
if !s.config.IsCancun(timestamp) && version >= clparams.DenebVersion { // V3 before cancun
return nil, &rpc.UnsupportedForkError{Message: "Unsupported fork"}
}
if s.config.IsCancun(timestamp) && version < clparams.DenebVersion { // Not V3 after cancun
return nil, &rpc.UnsupportedForkError{Message: "Unsupported fork"}
}

if !s.proposing {
return nil, fmt.Errorf("execution layer not running as a proposer. enable proposer by taking out the --proposer.disable flag on startup")
}

headHeader := s.chainRW.GetHeaderByHash(forkchoiceState.HeadHash)

timestamp := uint64(payloadAttributes.Timestamp)
if headHeader.Time >= timestamp {
return nil, &engine_helpers.InvalidPayloadAttributesErr
}
Expand Down
Loading