pub trait EngineValidator<Types: PayloadTypes, N: NodePrimitives = <<Types as PayloadTypes>::BuiltPayload as BuiltPayload>::Primitives>:
Send
+ Sync
+ 'static {
// Required methods
fn validate_payload_attributes_against_header(
&self,
attr: &Types::PayloadAttributes,
header: &N::BlockHeader,
) -> Result<(), InvalidPayloadAttributesError>;
fn convert_payload_to_block(
&self,
payload: Types::ExecutionData,
) -> Result<SealedBlock<N::Block>, NewPayloadError>;
fn validate_payload(
&mut self,
payload: Types::ExecutionData,
ctx: TreeCtx<'_, N>,
) -> ValidationOutcome<N>;
fn validate_block(
&mut self,
block: SealedBlock<N::Block>,
ctx: TreeCtx<'_, N>,
) -> ValidationOutcome<N>;
fn on_inserted_executed_block(
&self,
block: BuiltPayloadExecutedBlock<N>,
) -> ProviderResult<ExecutedBlock<N>>;
fn payload_builder_resources(
&self,
parent_hash: B256,
parent_header: &N::BlockHeader,
timestamp: u64,
state: &mut EngineApiTreeState<N>,
) -> PayloadBuilderResources;
// Provided method
fn on_canonical_head_changed(
&self,
_hash: B256,
_state: &EngineApiTreeState<N>,
) { ... }
}Expand description
Type that validates the payloads processed by the engine.
This provides the necessary functions for validating/executing payloads/blocks.
Required Methods§
Sourcefn validate_payload_attributes_against_header(
&self,
attr: &Types::PayloadAttributes,
header: &N::BlockHeader,
) -> Result<(), InvalidPayloadAttributesError>
fn validate_payload_attributes_against_header( &self, attr: &Types::PayloadAttributes, header: &N::BlockHeader, ) -> Result<(), InvalidPayloadAttributesError>
Validates the payload attributes with respect to the header.
By default, this enforces that the payload attributes timestamp is greater than the timestamp according to:
- Client software MUST ensure that payloadAttributes.timestamp is greater than timestamp of a block referenced by forkchoiceState.headBlockHash.
See also: https://github.com/ethereum/execution-apis/blob/main/src/engine/common.md#specification-1
Sourcefn convert_payload_to_block(
&self,
payload: Types::ExecutionData,
) -> Result<SealedBlock<N::Block>, NewPayloadError>
fn convert_payload_to_block( &self, payload: Types::ExecutionData, ) -> Result<SealedBlock<N::Block>, NewPayloadError>
Ensures that the given payload does not violate any consensus rules that concern the block’s layout.
This function must convert the payload into the executable block and pre-validate its fields.
Implementers should ensure that the checks are done in the order that conforms with the engine-API specification.
Sourcefn validate_payload(
&mut self,
payload: Types::ExecutionData,
ctx: TreeCtx<'_, N>,
) -> ValidationOutcome<N>
fn validate_payload( &mut self, payload: Types::ExecutionData, ctx: TreeCtx<'_, N>, ) -> ValidationOutcome<N>
Validates a payload received from engine API.
Sourcefn validate_block(
&mut self,
block: SealedBlock<N::Block>,
ctx: TreeCtx<'_, N>,
) -> ValidationOutcome<N>
fn validate_block( &mut self, block: SealedBlock<N::Block>, ctx: TreeCtx<'_, N>, ) -> ValidationOutcome<N>
Validates a block downloaded from the network.
Sourcefn on_inserted_executed_block(
&self,
block: BuiltPayloadExecutedBlock<N>,
) -> ProviderResult<ExecutedBlock<N>>
fn on_inserted_executed_block( &self, block: BuiltPayloadExecutedBlock<N>, ) -> ProviderResult<ExecutedBlock<N>>
Hook called after an executed block is inserted directly into the tree.
This is invoked when blocks are inserted via InsertExecutedBlock (e.g., locally built
blocks by sequencers) to allow implementations to update internal state such as caches.
Sourcefn payload_builder_resources(
&self,
parent_hash: B256,
parent_header: &N::BlockHeader,
timestamp: u64,
state: &mut EngineApiTreeState<N>,
) -> PayloadBuilderResources
fn payload_builder_resources( &self, parent_hash: B256, parent_header: &N::BlockHeader, timestamp: u64, state: &mut EngineApiTreeState<N>, ) -> PayloadBuilderResources
Prepares the resources loaned to a payload builder job.
timestamp is taken from the payload attributes.
Provided Methods§
Sourcefn on_canonical_head_changed(&self, _hash: B256, _state: &EngineApiTreeState<N>)
fn on_canonical_head_changed(&self, _hash: B256, _state: &EngineApiTreeState<N>)
Notifies the validator that hash is the current canonical head.
This may also be called when a forkchoice update reaffirms the existing head.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".