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