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: u64,
pub gas_used: u64,
pub timestamp: u64,
pub mix_hash: B256,
pub nonce: B64,
pub base_fee_per_gas: Option<u64>,
pub blob_gas_used: Option<u64>,
pub excess_blob_gas: Option<u64>,
pub parent_beacon_block_root: Option<B256>,
pub requests_hash: 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: 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.
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.
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.
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
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§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
)