pub fn validate_parent_beacon_block_root_presence<T: EthereumHardforks>(
chain_spec: &T,
version: EngineApiMessageVersion,
validation_kind: MessageValidationKind,
timestamp: u64,
has_parent_beacon_block_root: bool,
) -> Result<(), EngineObjectValidationError>
Expand description
Validate the presence of the parentBeaconBlockRoot
field according to the given timestamp.
This method is meant to be used with either a payloadAttributes
field or a full payload, with
the engine_forkchoiceUpdated
and engine_newPayload
methods respectively.
After Cancun, the parentBeaconBlockRoot
field must be Some.
Before Cancun, the parentBeaconBlockRoot
field must be None.
If the engine API message version is V1 or V2, and the timestamp is post-Cancun, then this will
return EngineObjectValidationError::UnsupportedFork
.
If the timestamp is before the Cancun fork and the engine API message version is V3, then this
will return EngineObjectValidationError::UnsupportedFork
.
If the engine API message version is V3, but the parentBeaconBlockRoot
is None, then
this will return VersionSpecificValidationError::NoParentBeaconBlockRootPostCancun
.
This implements the following Engine API spec rules:
- Client software MUST check that provided set of parameters and their fields strictly
matches the expected one and return
-32602: Invalid params
error if this check fails. Any field havingnull
value MUST be considered as not provided.
For engine_forkchoiceUpdatedV3
:
-
Client software MUST check that provided set of parameters and their fields strictly matches the expected one and return
-32602: Invalid params
error if this check fails. Any field havingnull
value MUST be considered as not provided. -
Extend point (7) of the
engine_forkchoiceUpdatedV1
specification by defining the following sequence of checks that MUST be run overpayloadAttributes
:payloadAttributes
matches thePayloadAttributesV3
structure, return-38003: Invalid payload attributes
on failure.payloadAttributes.timestamp
falls within the time frame of the Cancun fork, return-38005: Unsupported fork
on failure.payloadAttributes.timestamp
is greater thantimestamp
of a block referenced byforkchoiceState.headBlockHash
, return-38003: Invalid payload attributes
on failure.- If any of the above checks fails, the
forkchoiceState
update MUST NOT be rolled back.
For engine_newPayloadV3
:
- Client software MUST return
-38005: Unsupported fork
error if thetimestamp
of the payload does not fall within the time frame of the Cancun fork.
For engine_newPayloadV4
:
- Client software MUST return
-38005: Unsupported fork
error if thetimestamp
of the payload does not fall within the time frame of the Prague fork.
Returning the right error code (ie, if the client should return -38003: Invalid payload attributes
is handled by the message_validation_kind
parameter. If the parameter is
MessageValidationKind::Payload
, then the error code will be -32602: Invalid params
. If the
parameter is MessageValidationKind::PayloadAttributes
, then the error code will be -38003: Invalid payload attributes
.