alloy_consensus/block/meta.rs
1//! Commonly used types that contain metadata of a block.
2
3use alloy_primitives::{Address, Bloom, B256, U256};
4
5/// Essential info extracted from a header.
6#[derive(Debug, Clone, Copy, Default, Eq, PartialEq)]
7pub struct HeaderInfo {
8 /// The number of ancestor blocks of this block (block height).
9 pub number: u64,
10 /// Beneficiary (Coinbase or miner) is a address that have signed the block.
11 ///
12 /// This is the receiver address of all the gas spent in the block.
13 pub beneficiary: Address,
14 /// The timestamp of the block in seconds since the UNIX epoch
15 pub timestamp: u64,
16 /// The gas limit of the block
17 pub gas_limit: u64,
18 /// The base fee per gas, added in the London upgrade with [EIP-1559]
19 ///
20 /// [EIP-1559]: https://eips.ethereum.org/EIPS/eip-1559
21 pub base_fee_per_gas: Option<u64>,
22 /// A running total of blob gas consumed in excess of the target, prior to the block. Blocks
23 /// with above-target blob gas consumption increase this value, blocks with below-target blob
24 /// gas consumption decrease it (bounded at 0). This was added in EIP-4844.
25 pub excess_blob_gas: Option<u64>,
26 /// The total amount of blob gas consumed by the transactions within the block, added in
27 /// EIP-4844.
28 pub blob_gas_used: Option<u64>,
29 /// The difficulty of the block
30 ///
31 /// Unused after the Paris (AKA the merge) upgrade and replaced by `prevrandao` and expected to
32 /// be 0.
33 pub difficulty: U256,
34 /// The output of the randomness beacon provided by the beacon chain
35 ///
36 /// Replaces `difficulty` after the Paris (AKA the merge) upgrade with [EIP-4399].
37 ///
38 /// Note: `prevrandao` can be found in a block in place of `mix_hash`.
39 ///
40 /// [EIP-4399]: https://eips.ethereum.org/EIPS/eip-4399
41 pub mix_hash: Option<B256>,
42}
43
44/// Roots contained in a block header.
45#[derive(Debug, Clone, Copy, Default, Eq, PartialEq)]
46pub struct HeaderRoots {
47 /// The Keccak 256-bit hash of the root node of the state trie, after all transactions are
48 /// executed and finalisations applied.
49 pub state_root: B256,
50 /// The Keccak 256-bit hash of the root node of the trie structure populated with each
51 /// transaction in the transactions list portion of the block.
52 pub transactions_root: B256,
53 /// The Keccak 256-bit hash of the root node of the trie structure populated with the receipts
54 /// of each transaction in the transactions list portion of the block; formally He.
55 pub receipts_root: B256,
56 /// The Keccak 256-bit hash of the withdrawals list portion of this block.
57 pub withdrawals_root: Option<B256>,
58 /// The hash of the parent beacon block's root is included in execution blocks, as proposed by
59 /// EIP-4788.
60 pub parent_beacon_block_root: Option<B256>,
61 /// The Bloom filter composed from indexable information (logger address and log topics)
62 /// contained in each log entry from the receipt of each transaction in the transactions list.
63 pub logs_bloom: Bloom,
64}