mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
Engine API PR 498 (clarify payloadAttributes checks) (#8982)
Implements https://github.com/ethereum/execution-apis/pull/498
This commit is contained in:
parent
3b68d57c28
commit
b26d0f201e
@ -452,25 +452,20 @@ 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
|
||||
if payloadAttributes.ParentBeaconBlockRoot == nil {
|
||||
return nil, &rpc.InvalidParamsError{Message: "Beacon Root missing"}
|
||||
}
|
||||
return nil, &rpc.UnsupportedForkError{Message: "Unsupported fork"}
|
||||
}
|
||||
if s.config.IsCancun(timestamp) && version < clparams.DenebVersion { // Not V3 after cancun
|
||||
if payloadAttributes.ParentBeaconBlockRoot != nil {
|
||||
return nil, &rpc.InvalidParamsError{Message: "Unexpected Beacon Root"}
|
||||
}
|
||||
return nil, &rpc.UnsupportedForkError{Message: "Unsupported fork"}
|
||||
}
|
||||
|
||||
if s.config.IsCancun(timestamp) && version >= clparams.DenebVersion {
|
||||
if payloadAttributes.ParentBeaconBlockRoot == nil {
|
||||
return nil, &rpc.InvalidParamsError{Message: "Beacon Root missing"}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No need for payload building
|
||||
@ -484,19 +479,6 @@ func (s *EngineServer) forkchoiceUpdated(ctx context.Context, forkchoiceState *e
|
||||
|
||||
headHeader := s.chainRW.GetHeaderByHash(forkchoiceState.HeadHash)
|
||||
|
||||
if headHeader.Hash() != forkchoiceState.HeadHash {
|
||||
// Per Item 2 of https://github.com/ethereum/execution-apis/blob/v1.0.0-alpha.9/src/engine/specification.md#specification-1:
|
||||
// Client software MAY skip an update of the forkchoice state and
|
||||
// MUST NOT begin a payload build process if forkchoiceState.headBlockHash doesn't reference a leaf of the block tree.
|
||||
// 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.
|
||||
// In the case of such an event, client software MUST return
|
||||
// {payloadStatus: {status: VALID, latestValidHash: forkchoiceState.headBlockHash, validationError: null}, payloadId: null}.
|
||||
|
||||
s.logger.Warn("Skipping payload building because forkchoiceState.headBlockHash is not the head of the canonical chain",
|
||||
"forkChoice.HeadBlockHash", forkchoiceState.HeadHash, "headHeader.Hash", headHeader.Hash())
|
||||
return &engine_types.ForkChoiceUpdatedResponse{PayloadStatus: status}, nil
|
||||
}
|
||||
|
||||
timestamp := uint64(payloadAttributes.Timestamp)
|
||||
if headHeader.Time >= timestamp {
|
||||
return nil, &engine_helpers.InvalidPayloadAttributesErr
|
||||
|
Loading…
Reference in New Issue
Block a user