mega_system_contracts/lib.rs
1//! System contracts for the `MegaETH` EVM.
2//!
3//! This crate provides bytecode constants for system contracts used by mega-evm.
4//! When building from the repository with Foundry installed, the build script validates that
5//! the pre-generated constants match the compiled Solidity source.
6//! When building from a published crate (without Foundry), the pre-generated constants are used
7//! directly.
8
9#![cfg_attr(not(feature = "std"), no_std)]
10#![warn(missing_docs)]
11#![warn(unused_crate_dependencies)]
12#![deny(unused_must_use)]
13
14pub use alloy_primitives;
15
16/// Oracle contract bytecode and interface.
17///
18/// Bytecode constants are pre-generated from the versioned artifacts in the `artifacts/`
19/// directory.
20/// Interface bindings are generated from the Solidity source.
21pub mod oracle {
22 include!("generated/oracle_artifacts.rs");
23
24 alloy_sol_types::sol!("contracts/interfaces/IOracle.sol");
25}
26
27/// `KeylessDeploy` contract bytecode and interface.
28///
29/// Bytecode constants are pre-generated from the versioned artifacts in the `artifacts/`
30/// directory.
31/// Interface bindings are generated from the Solidity source.
32pub mod keyless_deploy {
33 include!("generated/keyless_deploy_artifacts.rs");
34
35 alloy_sol_types::sol!("contracts/interfaces/IKeylessDeploy.sol");
36}
37
38/// `MegaAccessControl` contract bytecode and interface.
39///
40/// Bytecode constants are pre-generated from the versioned artifacts in the `artifacts/`
41/// directory.
42/// Interface bindings are generated from the Solidity source.
43#[allow(missing_docs)]
44pub mod access_control {
45 include!("generated/access_control_artifacts.rs");
46
47 alloy_sol_types::sol!(
48 #[sol(all_derives)]
49 "contracts/interfaces/IMegaAccessControl.sol"
50 );
51}
52
53/// `MegaLimitControl` contract bytecode and interface.
54///
55/// Bytecode constants are pre-generated from the versioned artifacts in the `artifacts/`
56/// directory.
57/// Interface bindings are generated from the Solidity source.
58pub mod limit_control {
59 include!("generated/limit_control_artifacts.rs");
60
61 alloy_sol_types::sol!("contracts/interfaces/IMegaLimitControl.sol");
62}
63
64/// `SequencerRegistry` contract bytecode and interface.
65///
66/// Bytecode constants are pre-generated from the versioned artifacts in the `artifacts/`
67/// directory.
68/// Interface bindings are generated from the Solidity source.
69#[allow(missing_docs)]
70pub mod sequencer_registry {
71 include!("generated/sequencer_registry_artifacts.rs");
72
73 alloy_sol_types::sol!(
74 #[sol(all_derives)]
75 "contracts/interfaces/ISequencerRegistry.sol"
76 );
77
78 /// Flat storage slot constants for `SequencerRegistry`.
79 pub mod storage_slots {
80 use alloy_primitives::U256;
81
82 /// Storage slot for `_currentSystemAddress`.
83 pub const CURRENT_SYSTEM_ADDRESS: U256 = U256::ZERO;
84
85 /// Storage slot for `_currentSequencer`.
86 pub const CURRENT_SEQUENCER: U256 = U256::from_limbs([1, 0, 0, 0]);
87
88 /// Storage slot for `_admin`.
89 pub const ADMIN: U256 = U256::from_limbs([2, 0, 0, 0]);
90
91 /// Storage slot for `_pendingAdmin`.
92 pub const PENDING_ADMIN: U256 = U256::from_limbs([3, 0, 0, 0]);
93
94 /// Storage slot for `_initialSystemAddress`.
95 pub const INITIAL_SYSTEM_ADDRESS: U256 = U256::from_limbs([4, 0, 0, 0]);
96
97 /// Storage slot for `_initialSequencer`.
98 pub const INITIAL_SEQUENCER: U256 = U256::from_limbs([5, 0, 0, 0]);
99
100 /// Storage slot for `_initialFromBlock`.
101 pub const INITIAL_FROM_BLOCK: U256 = U256::from_limbs([6, 0, 0, 0]);
102
103 /// Storage slot for `_pendingSystemAddress`.
104 pub const PENDING_SYSTEM_ADDRESS: U256 = U256::from_limbs([7, 0, 0, 0]);
105
106 /// Storage slot for `_systemAddressActivationBlock`.
107 pub const SYSTEM_ADDRESS_ACTIVATION_BLOCK: U256 = U256::from_limbs([8, 0, 0, 0]);
108
109 /// Storage slot for `_pendingSequencer`.
110 pub const PENDING_SEQUENCER: U256 = U256::from_limbs([9, 0, 0, 0]);
111
112 /// Storage slot for `_sequencerActivationBlock`.
113 pub const SEQUENCER_ACTIVATION_BLOCK: U256 = U256::from_limbs([10, 0, 0, 0]);
114
115 // Slots 11 (`_systemAddressHistory`) and 12 (`_sequencerHistory`) are Solidity
116 // dynamic arrays. By the standard layout, the slot itself stores `array.length` and
117 // element `i` lives at `keccak256(bytes32(slot)) + i`. Concretely:
118 //
119 // `_systemAddressHistory[0]` is at
120 // `keccak256(bytes32(uint256(11)))`
121 // = `0x0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db9`
122 // `_sequencerHistory[0]` is at
123 // `keccak256(bytes32(uint256(12)))`
124 // = `0xdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c7`
125 //
126 // Rust never reads or writes these arrays directly — `systemAddressAt` and
127 // `sequencerAt` are on-chain getters that iterate them — so there is no flat slot
128 // constant.
129 }
130}