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 paramserror if this check fails. Any field havingnullvalue 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 paramserror if this check fails. Any field havingnullvalue MUST be considered as not provided. -
Extend point (7) of the
engine_forkchoiceUpdatedV1specification by defining the following sequence of checks that MUST be run overpayloadAttributes:payloadAttributesmatches thePayloadAttributesV3structure, return-38003: Invalid payload attributeson failure.payloadAttributes.timestampfalls within the time frame of the Cancun fork, return-38005: Unsupported forkon failure.payloadAttributes.timestampis greater thantimestampof a block referenced byforkchoiceState.headBlockHash, return-38003: Invalid payload attributeson failure.- If any of the above checks fails, the
forkchoiceStateupdate MUST NOT be rolled back.
For engine_newPayloadV3:
- Client software MUST return
-38005: Unsupported forkerror if thetimestampof the payload does not fall within the time frame of the Cancun fork.
For engine_newPayloadV4:
- Client software MUST return
-38005: Unsupported forkerror if thetimestampof 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.