Skip to main content

ethrex_vm/
system_contracts.rs

1use ethrex_common::{H160, types::Fork, types::Fork::*};
2
3pub use ethrex_common::constants::SYSTEM_ADDRESS;
4
5pub struct SystemContract {
6    pub address: H160,
7    pub name: &'static str,
8    pub active_since_fork: Fork,
9}
10
11pub const DEPOSIT_CONTRACT_ADDRESS: SystemContract = SystemContract {
12    address: H160([
13        0x00, 0x00, 0x00, 0x00, 0x21, 0x9A, 0xB5, 0x40, 0x35, 0x6C, 0xBB, 0x83, 0x9C, 0xBE, 0x05,
14        0x30, 0x3D, 0x77, 0x05, 0xFA,
15    ]),
16    name: "DEPOSIT_CONTRACT_ADDRESS",
17    active_since_fork: Prague,
18};
19
20pub const BEACON_ROOTS_ADDRESS: SystemContract = SystemContract {
21    address: H160([
22        0x00, 0x0F, 0x3D, 0xF6, 0xD7, 0x32, 0x80, 0x7E, 0xF1, 0x31, 0x9F, 0xB7, 0xB8, 0xBB, 0x85,
23        0x22, 0xD0, 0xBE, 0xAC, 0x02,
24    ]),
25    name: "BEACON_ROOTS_ADDRESS",
26    active_since_fork: Paris,
27};
28
29pub const HISTORY_STORAGE_ADDRESS: SystemContract = SystemContract {
30    address: H160([
31        0x00, 0x00, 0xF9, 0x08, 0x27, 0xF1, 0xC5, 0x3A, 0x10, 0xCB, 0x7A, 0x02, 0x33, 0x5B, 0x17,
32        0x53, 0x20, 0x00, 0x29, 0x35,
33    ]),
34    name: "HISTORY_STORAGE_ADDRESS",
35    active_since_fork: Prague,
36};
37
38pub const WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS: SystemContract = SystemContract {
39    address: H160([
40        0x00, 0x00, 0x09, 0x61, 0xEF, 0x48, 0x0E, 0xB5, 0x5E, 0x80, 0xD1, 0x9A, 0xD8, 0x35, 0x79,
41        0xA6, 0x4C, 0x00, 0x70, 0x02,
42    ]),
43    name: "WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS",
44    active_since_fork: Prague,
45};
46
47pub const CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS: SystemContract = SystemContract {
48    address: H160([
49        0x00, 0x00, 0xBB, 0xDD, 0xC7, 0xCE, 0x48, 0x86, 0x42, 0xFB, 0x57, 0x9F, 0x8B, 0x00, 0xF3,
50        0xA5, 0x90, 0x00, 0x72, 0x51,
51    ]),
52    name: "CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS",
53    active_since_fork: Prague,
54};
55
56// EIP-8282 builder deposit predeploy — Nick's-method address from sys-asm#43
57// (0x0000884d2AA32eAa155F59A2f24eFa73D9008282).
58pub const BUILDER_DEPOSIT_CONTRACT_ADDRESS: SystemContract = SystemContract {
59    address: H160([
60        0x00, 0x00, 0x88, 0x4D, 0x2A, 0xA3, 0x2E, 0xAA, 0x15, 0x5F, 0x59, 0xA2, 0xF2, 0x4E, 0xFA,
61        0x73, 0xD9, 0x00, 0x82, 0x82,
62    ]),
63    name: "BUILDER_DEPOSIT_CONTRACT_ADDRESS",
64    active_since_fork: Amsterdam,
65};
66
67// EIP-8282 builder exit predeploy — Nick's-method address from sys-asm#43
68// (0x000014574A74c805590AFF9499fc7A690f008282).
69pub const BUILDER_EXIT_CONTRACT_ADDRESS: SystemContract = SystemContract {
70    address: H160([
71        0x00, 0x00, 0x14, 0x57, 0x4A, 0x74, 0xC8, 0x05, 0x59, 0x0A, 0xFF, 0x94, 0x99, 0xFC, 0x7A,
72        0x69, 0x0F, 0x00, 0x82, 0x82,
73    ]),
74    name: "BUILDER_EXIT_CONTRACT_ADDRESS",
75    active_since_fork: Amsterdam,
76};
77
78pub const SYSTEM_CONTRACTS: [SystemContract; 7] = [
79    BEACON_ROOTS_ADDRESS,
80    HISTORY_STORAGE_ADDRESS,
81    DEPOSIT_CONTRACT_ADDRESS,
82    WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS,
83    CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS,
84    BUILDER_DEPOSIT_CONTRACT_ADDRESS,
85    BUILDER_EXIT_CONTRACT_ADDRESS,
86];
87
88pub fn system_contracts_for_fork(fork: Fork) -> impl Iterator<Item = SystemContract> {
89    SYSTEM_CONTRACTS
90        .into_iter()
91        .filter(move |system_contract| system_contract.active_since_fork <= fork)
92}
93
94pub const PRAGUE_SYSTEM_CONTRACTS: [SystemContract; 2] = [
95    WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS,
96    CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS,
97];
98
99// EIP-8282 request predeploys (builder deposit/exit). Active from Amsterdam.
100// Empty code at these addresses on an Amsterdam+ block invalidates the block,
101// mirroring the PRAGUE_SYSTEM_CONTRACTS empty-code-failure rule.
102pub const AMSTERDAM_REQUEST_PREDEPLOYS: [SystemContract; 2] = [
103    BUILDER_DEPOSIT_CONTRACT_ADDRESS,
104    BUILDER_EXIT_CONTRACT_ADDRESS,
105];