Skip to main content

ethrex_common/
constants.rs

1use crate::{H160, H256};
2use ethrex_crypto::keccak::keccak_hash;
3use ethrex_rlp::constants::RLP_NULL;
4use std::{str::FromStr, sync::LazyLock};
5
6/// SYSTEM_ADDRESS used for system contract calls and BAL filtering.
7/// 0xfffffffffffffffffffffffffffffffffffffffe
8pub const SYSTEM_ADDRESS: H160 = H160([
9    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
10    0xFF, 0xFF, 0xFF, 0xFE,
11]);
12
13// = Keccak256(RLP([])) as of EIP-3675
14pub static DEFAULT_OMMERS_HASH: LazyLock<H256> = LazyLock::new(|| {
15    H256::from_slice(
16        &hex::decode("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347")
17            .expect("Failed to decode hex from string"),
18    )
19});
20
21// = Sha256([])) as of EIP-7685
22pub static DEFAULT_REQUESTS_HASH: LazyLock<H256> = LazyLock::new(|| {
23    H256::from_slice(
24        &hex::decode("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
25            .expect("Failed to decode hex from string"),
26    )
27});
28
29// = Root of empty Trie as of EIP-4895
30pub static EMPTY_WITHDRAWALS_HASH: LazyLock<H256> = LazyLock::new(|| {
31    H256::from_slice(
32        &hex::decode("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
33            .expect("Failed to decode hex from string"),
34    )
35});
36
37// Keccak256(""), represents the code hash for an account without code
38pub static EMPTY_KECCAK_HASH: LazyLock<H256> = LazyLock::new(|| {
39    H256::from_slice(
40        &hex::decode("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")
41            .expect("Failed to decode hex from string"),
42    )
43});
44
45pub static EMPTY_TRIE_HASH: LazyLock<H256> = LazyLock::new(|| H256(keccak_hash([RLP_NULL])));
46
47// Request related
48pub static DEPOSIT_TOPIC: LazyLock<H256> = LazyLock::new(|| {
49    H256::from_str("649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5")
50        .expect("Failed to decode hex from string")
51});
52
53// = Keccak256(RLP([])) as of EIP-7928
54pub static EMPTY_BLOCK_ACCESS_LIST_HASH: LazyLock<H256> = LazyLock::new(|| {
55    H256::from_slice(
56        &hex::decode("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347")
57            .expect("Failed to decode hex from string"),
58    )
59});
60
61// === EIP-4844 constants ===
62
63/// Gas consumption of a single data blob (== blob byte size).
64pub const GAS_PER_BLOB: u32 = 1 << 17;
65
66// Minimum base fee per blob
67pub const MIN_BASE_FEE_PER_BLOB_GAS: u64 = 1;
68
69// === EIP-7934 constants ===
70
71pub const MAX_BLOCK_SIZE: u64 = 10_485_760;
72pub const RLP_BLOCK_SIZE_SAFETY_MARGIN: u64 = 2_097_152;
73pub const MAX_RLP_BLOCK_SIZE: u64 = MAX_BLOCK_SIZE - RLP_BLOCK_SIZE_SAFETY_MARGIN;
74// Blob base cost defined in EIP-7918
75pub const BLOB_BASE_COST: u64 = 8192;
76
77// === EIP-7825 constants ===
78// https://eips.ethereum.org/EIPS/eip-7825
79pub const POST_OSAKA_GAS_LIMIT_CAP: u64 = 16777216;
80pub const TX_MAX_GAS_LIMIT_AMSTERDAM: u64 = 1 << 24; // 16,777,216
81
82// === EIP-7928 BAL size cap constants ===
83/// GAS_BLOCK_ACCESS_LIST_ITEM = GAS_WARM_ACCESS (100) + TX_ACCESS_LIST_STORAGE_KEY_COST (1900)
84pub const BAL_ITEM_COST: u64 = 2000;