Skip to content

Commit b26d0f2

Browse files
authored
Engine API PR 498 (clarify payloadAttributes checks) (#8982)
Implements ethereum/execution-apis#498
1 parent 3b68d57 commit b26d0f2

File tree

1 file changed

+7
-25
lines changed

1 file changed

+7
-25
lines changed

turbo/engineapi/engine_server.go

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -452,25 +452,20 @@ func (s *EngineServer) forkchoiceUpdated(ctx context.Context, forkchoiceState *e
452452
}
453453

454454
if payloadAttributes != nil {
455+
if version < clparams.DenebVersion && payloadAttributes.ParentBeaconBlockRoot != nil {
456+
return nil, &engine_helpers.InvalidPayloadAttributesErr // Unexpected Beacon Root
457+
}
458+
if version >= clparams.DenebVersion && payloadAttributes.ParentBeaconBlockRoot == nil {
459+
return nil, &engine_helpers.InvalidPayloadAttributesErr // Beacon Root missing
460+
}
461+
455462
timestamp := uint64(payloadAttributes.Timestamp)
456463
if !s.config.IsCancun(timestamp) && version >= clparams.DenebVersion { // V3 before cancun
457-
if payloadAttributes.ParentBeaconBlockRoot == nil {
458-
return nil, &rpc.InvalidParamsError{Message: "Beacon Root missing"}
459-
}
460464
return nil, &rpc.UnsupportedForkError{Message: "Unsupported fork"}
461465
}
462466
if s.config.IsCancun(timestamp) && version < clparams.DenebVersion { // Not V3 after cancun
463-
if payloadAttributes.ParentBeaconBlockRoot != nil {
464-
return nil, &rpc.InvalidParamsError{Message: "Unexpected Beacon Root"}
465-
}
466467
return nil, &rpc.UnsupportedForkError{Message: "Unsupported fork"}
467468
}
468-
469-
if s.config.IsCancun(timestamp) && version >= clparams.DenebVersion {
470-
if payloadAttributes.ParentBeaconBlockRoot == nil {
471-
return nil, &rpc.InvalidParamsError{Message: "Beacon Root missing"}
472-
}
473-
}
474469
}
475470

476471
// No need for payload building
@@ -484,19 +479,6 @@ func (s *EngineServer) forkchoiceUpdated(ctx context.Context, forkchoiceState *e
484479

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

487-
if headHeader.Hash() != forkchoiceState.HeadHash {
488-
// Per Item 2 of https://github.com/ethereum/execution-apis/blob/v1.0.0-alpha.9/src/engine/specification.md#specification-1:
489-
// Client software MAY skip an update of the forkchoice state and
490-
// MUST NOT begin a payload build process if forkchoiceState.headBlockHash doesn't reference a leaf of the block tree.
491-
// That is, the block referenced by forkchoiceState.headBlockHash is neither the head of the canonical chain nor a block at the tip of any other chain.
492-
// In the case of such an event, client software MUST return
493-
// {payloadStatus: {status: VALID, latestValidHash: forkchoiceState.headBlockHash, validationError: null}, payloadId: null}.
494-
495-
s.logger.Warn("Skipping payload building because forkchoiceState.headBlockHash is not the head of the canonical chain",
496-
"forkChoice.HeadBlockHash", forkchoiceState.HeadHash, "headHeader.Hash", headHeader.Hash())
497-
return &engine_types.ForkChoiceUpdatedResponse{PayloadStatus: status}, nil
498-
}
499-
500482
timestamp := uint64(payloadAttributes.Timestamp)
501483
if headHeader.Time >= timestamp {
502484
return nil, &engine_helpers.InvalidPayloadAttributesErr

0 commit comments

Comments
 (0)