arb_primitives/
arbos_versions.rs

1use alloy_primitives::{Address, Bytes, address, bytes};
2
3/// EIP-2935 history storage address.
4pub const HISTORY_STORAGE_ADDRESS: Address = address!("0000F90827F1C53a10cb7A02335B175320002935");
5
6/// EIP-2935 history storage contract code for Arbitrum.
7pub const HISTORY_STORAGE_CODE_ARBITRUM: Bytes = bytes!(
8    "3373fffffffffffffffffffffffffffffffffffffffe1460605760203603605c575f3563a3b1b31d5f5260205f6004601c60645afa15605c575f51600181038211605c57816205ffd0910311605c576205ffd09006545f5260205ff35b5f5ffd5b5f356205ffd0600163a3b1b31d5f5260205f6004601c60645afa15605c575f5103065500"
9);
10
11/// Precompile addresses and the ArbOS version that introduced them.
12///
13/// During version upgrades, newly introduced precompiles get their code
14/// set to `[INVALID]` to mark them as existing accounts.
15pub static PRECOMPILE_MIN_ARBOS_VERSIONS: &[(Address, u64)] = &[
16    // ArbWasm: introduced in ArbOS 30 (Stylus)
17    (address!("0000000000000000000000000000000000000071"), 30),
18    // ArbWasmCache: introduced in ArbOS 30
19    (address!("0000000000000000000000000000000000000072"), 30),
20    // ArbNativeTokenManager: introduced in ArbOS 41
21    (address!("0000000000000000000000000000000000000073"), 41),
22    // ArbFilteredTransactionsManager: introduced in ArbOS 60
23    (address!("0000000000000000000000000000000000000074"), 60),
24];
25
26/// ArbOS version identifiers.
27///
28/// Controls version-gated behavior across the node.
29#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
30#[repr(u64)]
31pub enum ArbOSVersion {
32    V1 = 1,
33    V2 = 2,
34    V3 = 3,
35    V4 = 4,
36    V5 = 5,
37    V10 = 10,
38    V11 = 11,
39    V20 = 20,
40    V30 = 30,
41    V31 = 31,
42    V32 = 32,
43    V40 = 40,
44    V41 = 41,
45    V50 = 50,
46    V51 = 51,
47    V60 = 60,
48}
49
50impl ArbOSVersion {
51    pub fn from_u64(v: u64) -> Option<Self> {
52        match v {
53            1 => Some(Self::V1),
54            2 => Some(Self::V2),
55            3 => Some(Self::V3),
56            4 => Some(Self::V4),
57            5 => Some(Self::V5),
58            10 => Some(Self::V10),
59            11 => Some(Self::V11),
60            20 => Some(Self::V20),
61            30 => Some(Self::V30),
62            31 => Some(Self::V31),
63            32 => Some(Self::V32),
64            40 => Some(Self::V40),
65            41 => Some(Self::V41),
66            50 => Some(Self::V50),
67            51 => Some(Self::V51),
68            60 => Some(Self::V60),
69            _ => None,
70        }
71    }
72
73    pub fn as_u64(self) -> u64 {
74        self as u64
75    }
76
77    /// Returns true if this version is reserved for Orbit-chain custom upgrades.
78    pub fn is_orbit_reserved(version: u64) -> bool {
79        matches!(
80            version,
81            12..=19 | 21..=29 | 33..=39 | 42..=49 | 52..=59
82        )
83    }
84}