Skip to main content

BlockHeader

Struct BlockHeader 

Source
pub struct BlockHeader {
    pub height: BlockHeight,
    pub view: u64,
    pub prev_hash: Hash,
    pub tx_root: Hash,
    pub state_root: Hash,
    pub timestamp: Timestamp,
    pub proposer: Address,
    pub consensus_proof: ConsensusProof,
    pub metadata: BlockMetadata,
}
Expand description

A block header containing metadata about a block

The header includes cryptographic commitments to the block’s contents and links to the previous block.

Fields§

§height: BlockHeight

The height of this block

§view: u64

The HotStuff-2 view at which this block was proposed.

Required for view-sync on inbound proposals: receivers must advance their local view to match view before voting, so that the resulting vote is bucketed at the same view as the proposer’s self-vote and a quorum can form. See tenzro-consensus::HotStuff2Engine::on_proposal.

Mirrors HotStuff-2 (Malkhi & Nayak, eprint 2023/397) Figure 1: the proposal message ⟨propose, B_k, v, C_{v'}(B_{k-1})⟩_{L_v} carries v as a first-class field. Equivalent to Aptos Block::round().

§prev_hash: Hash

Hash of the previous block

§tx_root: Hash

Merkle root of all transactions in the block

§state_root: Hash

Merkle root of the state after executing this block

§timestamp: Timestamp

Block timestamp

§proposer: Address

Address of the block proposer

§consensus_proof: ConsensusProof

Consensus proof for this block

§metadata: BlockMetadata

Additional metadata

Implementations§

Source§

impl BlockHeader

Source

pub fn new( height: BlockHeight, prev_hash: Hash, tx_root: Hash, state_root: Hash, proposer: Address, consensus_proof: ConsensusProof, ) -> Self

Creates a new block header at view 0.

For consensus-driven proposals use BlockHeader::new_at_view to stamp the proposer’s current view. Genesis uses view 0.

Source

pub fn new_at_view( height: BlockHeight, view: u64, prev_hash: Hash, tx_root: Hash, state_root: Hash, proposer: Address, consensus_proof: ConsensusProof, ) -> Self

Creates a new block header stamped with the proposer’s view.

Source

pub fn hash(&self) -> Hash

Computes the hash of the block header using canonical binary encoding.

Fields are hashed in order: height, view, prev_hash, tx_root, state_root, timestamp, proposer, gas_used, gas_limit, tx_count, protocol_version, base_fee_per_gas. Using LE bytes for integer fields ensures deterministic output regardless of platform or serialization format.

base_fee_per_gas is encoded as a presence-tagged u128: [0u8] for None, [1u8] || u128_le for Some(_). This distinguishes a zero base fee from an unset base fee while keeping the canonical encoding deterministic. Per EIP-1559 + go-ethereum VerifyEIP1559Header, the base fee is part of the signed block hash so validators reach byzantine agreement on it.

Trait Implementations§

Source§

impl Clone for BlockHeader

Source§

fn clone(&self) -> BlockHeader

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BlockHeader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BlockHeader

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for BlockHeader

Source§

impl PartialEq for BlockHeader

Source§

fn eq(&self, other: &BlockHeader) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for BlockHeader

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for BlockHeader

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.