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: BlockHeightThe height of this block
view: u64The 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: HashHash of the previous block
tx_root: HashMerkle root of all transactions in the block
state_root: HashMerkle root of the state after executing this block
timestamp: TimestampBlock timestamp
proposer: AddressAddress of the block proposer
consensus_proof: ConsensusProofConsensus proof for this block
metadata: BlockMetadataAdditional metadata
Implementations§
Source§impl BlockHeader
impl BlockHeader
Sourcepub fn new(
height: BlockHeight,
prev_hash: Hash,
tx_root: Hash,
state_root: Hash,
proposer: Address,
consensus_proof: ConsensusProof,
) -> Self
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.
Sourcepub fn new_at_view(
height: BlockHeight,
view: u64,
prev_hash: Hash,
tx_root: Hash,
state_root: Hash,
proposer: Address,
consensus_proof: ConsensusProof,
) -> Self
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.
Sourcepub fn hash(&self) -> Hash
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
impl Clone for BlockHeader
Source§fn clone(&self) -> BlockHeader
fn clone(&self) -> BlockHeader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BlockHeader
impl Debug for BlockHeader
Source§impl<'de> Deserialize<'de> for BlockHeader
impl<'de> Deserialize<'de> for BlockHeader
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for BlockHeader
Source§impl PartialEq for BlockHeader
impl PartialEq for BlockHeader
Source§fn eq(&self, other: &BlockHeader) -> bool
fn eq(&self, other: &BlockHeader) -> bool
self and other values to be equal, and is used by ==.