Trait BlockHeader

Source
pub trait BlockHeader<TYPES: NodeType>:
    Serialize
    + Clone
    + Debug
    + Hash
    + PartialEq
    + Eq
    + Send
    + Sync
    + DeserializeOwned
    + Committable {
    type Error: Error + Debug + Send + Sync;

    // Required methods
    fn new(
        parent_state: &TYPES::ValidatedState,
        instance_state: &<TYPES::ValidatedState as ValidatedState<TYPES>>::Instance,
        parent_leaf: &Leaf2<TYPES>,
        payload_commitment: VidCommitment,
        builder_commitment: BuilderCommitment,
        metadata: <TYPES::BlockPayload as BlockPayload<TYPES>>::Metadata,
        builder_fee: BuilderFee<TYPES>,
        version: Version,
        view_number: u64,
    ) -> impl Future<Output = Result<Self, Self::Error>> + Send;
    fn genesis<V: Versions>(
        instance_state: &<TYPES::ValidatedState as ValidatedState<TYPES>>::Instance,
        payload: TYPES::BlockPayload,
        metadata: &<TYPES::BlockPayload as BlockPayload<TYPES>>::Metadata,
    ) -> Self;
    fn block_number(&self) -> u64;
    fn timestamp(&self) -> u64;
    fn timestamp_millis(&self) -> u64;
    fn payload_commitment(&self) -> VidCommitment;
    fn metadata(
        &self,
    ) -> &<TYPES::BlockPayload as BlockPayload<TYPES>>::Metadata;
    fn builder_commitment(&self) -> BuilderCommitment;
    fn get_light_client_state(
        &self,
        view: TYPES::View,
    ) -> Result<LightClientState>;
    fn auth_root(&self) -> Result<FixedBytes<32>>;
}
Expand description

Header of a block, which commits to a BlockPayload.

Required Associated Types§

Source

type Error: Error + Debug + Send + Sync

Error type for this type of block header

Required Methods§

Source

fn new( parent_state: &TYPES::ValidatedState, instance_state: &<TYPES::ValidatedState as ValidatedState<TYPES>>::Instance, parent_leaf: &Leaf2<TYPES>, payload_commitment: VidCommitment, builder_commitment: BuilderCommitment, metadata: <TYPES::BlockPayload as BlockPayload<TYPES>>::Metadata, builder_fee: BuilderFee<TYPES>, version: Version, view_number: u64, ) -> impl Future<Output = Result<Self, Self::Error>> + Send

Build a header with the parent validate state, instance-level state, parent leaf, payload and builder commitments, and metadata. This is only used in pre-marketplace versions

Source

fn genesis<V: Versions>( instance_state: &<TYPES::ValidatedState as ValidatedState<TYPES>>::Instance, payload: TYPES::BlockPayload, metadata: &<TYPES::BlockPayload as BlockPayload<TYPES>>::Metadata, ) -> Self

Build the genesis header, payload, and metadata.

Source

fn block_number(&self) -> u64

Get the block number.

Source

fn timestamp(&self) -> u64

Get the timestamp.

Source

fn timestamp_millis(&self) -> u64

Get the timestamp in milliseconds.

Source

fn payload_commitment(&self) -> VidCommitment

Get the payload commitment.

Source

fn metadata(&self) -> &<TYPES::BlockPayload as BlockPayload<TYPES>>::Metadata

Get the metadata.

Source

fn builder_commitment(&self) -> BuilderCommitment

Get the builder commitment

Source

fn get_light_client_state(&self, view: TYPES::View) -> Result<LightClientState>

Get the light client state

Source

fn auth_root(&self) -> Result<FixedBytes<32>>

Returns the auth_root value for versions >= V4 (DrbAndHeaderUpgrade).

For versions < V4, this will return None.

The auth_root is a 32-byte hash calculated using the reward Merkle tree digest and other values.
It is used by the reward claim contract to verify the reward claim

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§