Struct alloy_consensus::header::Header

source ·
pub struct Header {
Show 21 fields pub parent_hash: B256, pub ommers_hash: B256, pub beneficiary: Address, pub state_root: B256, pub transactions_root: B256, pub receipts_root: B256, pub withdrawals_root: Option<B256>, pub logs_bloom: Bloom, pub difficulty: U256, pub number: BlockNumber, pub gas_limit: u128, pub gas_used: u128, pub timestamp: u64, pub mix_hash: B256, pub nonce: B64, pub base_fee_per_gas: Option<u128>, pub blob_gas_used: Option<u128>, pub excess_blob_gas: Option<u128>, pub parent_beacon_block_root: Option<B256>, pub requests_root: Option<B256>, pub extra_data: Bytes,
}
Expand description

Ethereum Block header

Fields§

§parent_hash: B256

The Keccak 256-bit hash of the parent block’s header, in its entirety; formally Hp.

§ommers_hash: B256

The Keccak 256-bit hash of the ommers list portion of this block; formally Ho.

§beneficiary: Address

The 160-bit address to which all fees collected from the successful mining of this block be transferred; formally Hc.

§state_root: B256

The Keccak 256-bit hash of the root node of the state trie, after all transactions are executed and finalisations applied; formally Hr.

§transactions_root: B256

The Keccak 256-bit hash of the root node of the trie structure populated with each transaction in the transactions list portion of the block; formally Ht.

§receipts_root: B256

The Keccak 256-bit hash of the root node of the trie structure populated with the receipts of each transaction in the transactions list portion of the block; formally He.

§withdrawals_root: Option<B256>

The Keccak 256-bit hash of the withdrawals list portion of this block. https://eips.ethereum.org/EIPS/eip-4895

§logs_bloom: Bloom

The Bloom filter composed from indexable information (logger address and log topics) contained in each log entry from the receipt of each transaction in the transactions list; formally Hb.

§difficulty: U256

A scalar value corresponding to the difficulty level of this block. This can be calculated from the previous block’s difficulty level and the timestamp; formally Hd.

§number: BlockNumber

A scalar value equal to the number of ancestor blocks. The genesis block has a number of zero; formally Hi.

§gas_limit: u128

A scalar value equal to the current limit of gas expenditure per block; formally Hl.

§gas_used: u128

A scalar value equal to the total gas used in transactions in this block; formally Hg.

§timestamp: u64

A scalar value equal to the reasonable output of Unix’s time() at this block’s inception; formally Hs.

§mix_hash: B256

A 256-bit hash which, combined with the nonce, proves that a sufficient amount of computation has been carried out on this block; formally Hm.

§nonce: B64

A 64-bit value which, combined with the mixhash, proves that a sufficient amount of computation has been carried out on this block; formally Hn.

§base_fee_per_gas: Option<u128>

A scalar representing EIP1559 base fee which can move up or down each block according to a formula which is a function of gas used in parent block and gas target (block gas limit divided by elasticity multiplier) of parent block. The algorithm results in the base fee per gas increasing when blocks are above the gas target, and decreasing when blocks are below the gas target. The base fee per gas is burned.

§blob_gas_used: Option<u128>

The total amount of blob gas consumed by the transactions within the block, added in EIP-4844.

§excess_blob_gas: Option<u128>

A running total of blob gas consumed in excess of the target, prior to the block. Blocks with above-target blob gas consumption increase this value, blocks with below-target blob gas consumption decrease it (bounded at 0). This was added in EIP-4844.

§parent_beacon_block_root: Option<B256>

The hash of the parent beacon block’s root is included in execution blocks, as proposed by EIP-4788.

This enables trust-minimized access to consensus state, supporting staking pools, bridges, and more.

The beacon roots contract handles root storage, enhancing Ethereum’s functionalities.

§requests_root: Option<B256>

The Keccak 256-bit hash of the root node of the trie structure populated with each EIP-7685 request in the block body.

§extra_data: Bytes

An arbitrary byte array containing data relevant to this block. This must be 32 bytes or fewer; formally Hx.

Implementations§

source§

impl Header

source

pub fn hash_slow(&self) -> B256

Heavy function that will calculate hash of data and will not save the change to metadata.

Use Header::seal_slow and unlock if you need the hash to be persistent.

source

pub fn is_empty(&self) -> bool

Checks if the header is empty - has no transactions and no ommers

source

pub fn ommers_hash_is_empty(&self) -> bool

Check if the ommers hash equals to empty hash list.

source

pub fn transaction_root_is_empty(&self) -> bool

Check if the transaction root equals to empty root.

source

pub fn blob_fee(&self) -> Option<u128>

Returns the blob fee for this block according to the EIP-4844 spec.

Returns None if excess_blob_gas is None

source

pub fn next_block_blob_fee(&self) -> Option<u128>

Returns the blob fee for the next block according to the EIP-4844 spec.

Returns None if excess_blob_gas is None.

See also Self::next_block_excess_blob_gas

source

pub fn next_block_base_fee( &self, base_fee_params: BaseFeeParams, ) -> Option<u128>

Calculate base fee for next block according to the EIP-1559 spec.

Returns a None if no base fee is set, no EIP-1559 support

source

pub fn next_block_excess_blob_gas(&self) -> Option<u128>

Calculate excess blob gas for the next block according to the EIP-4844 spec.

Returns a None if no excess blob gas is set, no EIP-4844 support

source

pub fn size(&self) -> usize

Calculate a heuristic for the in-memory size of the Header.

source

fn header_payload_length(&self) -> usize

Trait Implementations§

source§

impl Clone for Header

source§

fn clone(&self) -> Header

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Header

source§

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

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

impl Decodable for Header

source§

fn decode(buf: &mut &[u8]) -> Result<Self>

Decodes the blob into the appropriate type. buf must be advanced past the decoded object.
source§

impl Default for Header

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Header

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 Encodable for Header

source§

fn encode(&self, out: &mut dyn BufMut)

Encodes the type into the out buffer.
source§

fn length(&self) -> usize

Returns the length of the encoding of this type in bytes. Read more
source§

impl Hash for Header

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Header

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Sealable for Header

source§

fn hash(&self) -> B256

Calculate the seal hash, this may be slow.
source§

fn seal_slow(self) -> Sealed<Self>

Seal the object by calculating the hash. This may be slow.
source§

fn seal_unchecked(self, seal: B256) -> Sealed<Self>

Instantiate an unchecked seal. This should be used with caution.
source§

impl Serialize for Header

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 Eq for Header

source§

impl StructuralPartialEq for Header

Auto Trait Implementations§

§

impl !Freeze for Header

§

impl RefUnwindSafe for Header

§

impl Send for Header

§

impl Sync for Header

§

impl Unpin for Header

§

impl UnwindSafe for Header

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> 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

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

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 784 bytes