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 logs_bloom: Bloom,
pub difficulty: U256,
pub number: BlockNumber,
pub gas_limit: u64,
pub gas_used: u64,
pub timestamp: u64,
pub extra_data: Bytes,
pub mix_hash: B256,
pub nonce: B64,
pub base_fee_per_gas: Option<u64>,
pub withdrawals_root: Option<B256>,
pub blob_gas_used: Option<u64>,
pub excess_blob_gas: Option<u64>,
pub parent_beacon_block_root: Option<B256>,
pub requests_hash: Option<B256>,
}
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.
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: u64
A scalar value equal to the current limit of gas expenditure per block; formally Hl.
gas_used: u64
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.
extra_data: Bytes
An arbitrary byte array containing data relevant to this block. This must be 32 bytes or fewer; formally Hx.
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<u64>
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.
withdrawals_root: Option<B256>
The Keccak 256-bit hash of the withdrawals list portion of this block. https://eips.ethereum.org/EIPS/eip-4895
blob_gas_used: Option<u64>
The total amount of blob gas consumed by the transactions within the block, added in EIP-4844.
excess_blob_gas: Option<u64>
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_hash: Option<B256>
The Keccak 256-bit hash of the an RLP encoded list with each EIP-7685 request in the block body.
Implementations§
Source§impl Header
impl Header
Sourcepub fn hash_slow(&self) -> B256
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.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks if the header is empty - has no transactions and no ommers
Sourcepub fn ommers_hash_is_empty(&self) -> bool
pub fn ommers_hash_is_empty(&self) -> bool
Check if the ommers hash equals to empty hash list.
Sourcepub fn transaction_root_is_empty(&self) -> bool
pub fn transaction_root_is_empty(&self) -> bool
Check if the transaction root equals to empty root.
Sourcepub fn blob_fee(&self) -> Option<u128>
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
Sourcepub fn next_block_blob_fee(&self) -> Option<u128>
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
Sourcepub fn next_block_base_fee(&self, base_fee_params: BaseFeeParams) -> Option<u64>
pub fn next_block_base_fee(&self, base_fee_params: BaseFeeParams) -> Option<u64>
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
Sourcepub fn next_block_excess_blob_gas(&self) -> Option<u64>
pub fn next_block_excess_blob_gas(&self) -> Option<u64>
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
Sourcepub const fn parent_num_hash(&self) -> BlockNumHash
pub const fn parent_num_hash(&self) -> BlockNumHash
Returns the parent block’s number and hash
Note: for the genesis block the parent number is 0 and the parent hash is the zero hash.
Sourcepub fn num_hash_slow(&self) -> BlockNumHash
pub fn num_hash_slow(&self) -> BlockNumHash
Returns the block’s number and hash.
Note: this hashes the header.
Sourcepub fn is_zero_difficulty(&self) -> bool
pub fn is_zero_difficulty(&self) -> bool
Checks if the block’s difficulty is set to zero, indicating a Proof-of-Stake header.
This function is linked to EIP-3675, proposing the consensus upgrade to Proof-of-Stake: EIP-3675
Verifies whether, as per the EIP, the block’s difficulty is updated to zero, signifying the transition to a Proof-of-Stake mechanism.
Returns true
if the block’s difficulty matches the constant zero set by the EIP.
Sourcepub const fn exceeds_allowed_future_timestamp(
&self,
present_timestamp: u64,
) -> bool
pub const fn exceeds_allowed_future_timestamp( &self, present_timestamp: u64, ) -> bool
Checks if the block’s timestamp is in the future based on the present timestamp.
Clock can drift but this can be consensus issue.
Note: This check is relevant only pre-merge.
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for Header
Available on crate feature arbitrary
only.
impl<'a> Arbitrary<'a> for Header
arbitrary
only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self
from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self
from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured
this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured
this type
needs to construct itself. Read moreSource§impl BlockHeader for Header
impl BlockHeader for Header
Source§fn parent_hash(&self) -> B256
fn parent_hash(&self) -> B256
Source§fn ommers_hash(&self) -> B256
fn ommers_hash(&self) -> B256
Source§fn beneficiary(&self) -> Address
fn beneficiary(&self) -> Address
Source§fn state_root(&self) -> B256
fn state_root(&self) -> B256
Source§fn transactions_root(&self) -> B256
fn transactions_root(&self) -> B256
Source§fn receipts_root(&self) -> B256
fn receipts_root(&self) -> B256
Source§fn withdrawals_root(&self) -> Option<B256>
fn withdrawals_root(&self) -> Option<B256>
Source§fn logs_bloom(&self) -> Bloom
fn logs_bloom(&self) -> Bloom
Source§fn difficulty(&self) -> U256
fn difficulty(&self) -> U256
Source§fn number(&self) -> BlockNumber
fn number(&self) -> BlockNumber
Source§fn base_fee_per_gas(&self) -> Option<u64>
fn base_fee_per_gas(&self) -> Option<u64>
Source§fn blob_gas_used(&self) -> Option<u64>
fn blob_gas_used(&self) -> Option<u64>
Source§fn excess_blob_gas(&self) -> Option<u64>
fn excess_blob_gas(&self) -> Option<u64>
Source§fn parent_beacon_block_root(&self) -> Option<B256>
fn parent_beacon_block_root(&self) -> Option<B256>
Source§fn requests_hash(&self) -> Option<B256>
fn requests_hash(&self) -> Option<B256>
Source§fn extra_data(&self) -> &Bytes
fn extra_data(&self) -> &Bytes
Source§impl<'de> Deserialize<'de> for Header
impl<'de> Deserialize<'de> for Header
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>,
Source§impl<'de> DeserializeAs<'de, Header> for Header<'de>
Available on crate features serde
and serde-bincode-compat
only.
impl<'de> DeserializeAs<'de, Header> for Header<'de>
serde
and serde-bincode-compat
only.Source§fn deserialize_as<D>(deserializer: D) -> Result<Header, D::Error>where
D: Deserializer<'de>,
fn deserialize_as<D>(deserializer: D) -> Result<Header, D::Error>where
D: Deserializer<'de>,
Source§impl<'a> From<&'a Header> for Header<'a>
Available on crate features serde
and serde-bincode-compat
only.
impl<'a> From<&'a Header> for Header<'a>
serde
and serde-bincode-compat
only.Source§impl<'a> From<Header<'a>> for Header
Available on crate features serde
and serde-bincode-compat
only.
impl<'a> From<Header<'a>> for Header
serde
and serde-bincode-compat
only.Source§impl Sealable for Header
impl Sealable for Header
Source§fn seal_ref_slow(&self) -> Sealed<&Self>
fn seal_ref_slow(&self) -> Sealed<&Self>
Source§fn seal_unchecked(self, seal: FixedBytes<32>) -> Sealed<Self>
fn seal_unchecked(self, seal: FixedBytes<32>) -> Sealed<Self>
Source§fn seal_ref_unchecked(&self, seal: FixedBytes<32>) -> Sealed<&Self>
fn seal_ref_unchecked(&self, seal: FixedBytes<32>) -> Sealed<&Self>
Source§impl SerializeAs<Header> for Header<'_>
Available on crate features serde
and serde-bincode-compat
only.
impl SerializeAs<Header> for Header<'_>
serde
and serde-bincode-compat
only.Source§fn serialize_as<S>(source: &Header, serializer: S) -> Result<S::Ok, S::Error>where
S: Serializer,
fn serialize_as<S>(source: &Header, serializer: S) -> Result<S::Ok, S::Error>where
S: Serializer,
impl Eq for Header
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)