revm_statetest_types/spec.rs
1use primitives::hardfork::SpecId;
2use serde::Deserialize;
3
4/// Ethereum specification names
5#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Deserialize, Hash)]
6pub enum SpecName {
7 /// Frontier hardfork (Ethereum launch, July 2015)
8 Frontier,
9 /// Transition from Frontier to Homestead at block 5
10 FrontierToHomesteadAt5,
11 /// Homestead hardfork (March 2016)
12 Homestead,
13 /// Transition from Homestead to DAO fork at block 5
14 HomesteadToDaoAt5,
15 /// Transition from Homestead to EIP-150 at block 5
16 HomesteadToEIP150At5,
17 /// EIP-150 hardfork (Tangerine Whistle, October 2016)
18 #[serde(alias = "TangerineWhistle")]
19 EIP150,
20 /// EIP-158/EIP-161 hardfork (Spurious Dragon, November 2016)
21 #[serde(alias = "SpuriousDragon")]
22 EIP158, // EIP-161: State trie clearing
23 /// Transition from EIP-158 to Byzantium at block 5
24 EIP158ToByzantiumAt5,
25 /// Byzantium hardfork (October 2017)
26 Byzantium,
27 /// Transition from Byzantium to Constantinople at block 5 (skipped)
28 ByzantiumToConstantinopleAt5, // SKIPPED
29 /// Transition from Byzantium to Constantinople Fix at block 5
30 ByzantiumToConstantinopleFixAt5,
31 /// Constantinople hardfork (skipped due to reentrancy bug)
32 Constantinople, // SKIPPED
33 /// Constantinople Fix hardfork (Petersburg, February 2019)
34 ConstantinopleFix,
35 /// Istanbul hardfork (December 2019)
36 Istanbul,
37 /// Berlin hardfork (April 2021)
38 Berlin,
39 /// Transition from Berlin to London at block 5
40 BerlinToLondonAt5,
41 /// London hardfork (August 2021, includes EIP-1559)
42 London,
43 /// Paris hardfork (part of The Merge)
44 Paris,
45 /// The Merge (September 2022, PoW to PoS transition)
46 Merge,
47 /// Shanghai hardfork (April 2023, includes withdrawals)
48 Shanghai,
49 /// Cancun hardfork (March 2024, includes EIP-4844)
50 Cancun,
51 /// Prague hardfork (future)
52 Prague,
53 /// Osaka hardfork
54 Osaka,
55 /// Amsterdam hardfork
56 Amsterdam,
57 /// Unknown or unsupported specification
58 #[serde(other)]
59 Unknown,
60}
61
62impl SpecName {
63 /// Converts to a [SpecId].
64 pub fn to_spec_id(&self) -> SpecId {
65 match self {
66 Self::Frontier => SpecId::FRONTIER,
67 Self::Homestead | Self::FrontierToHomesteadAt5 => SpecId::HOMESTEAD,
68 Self::EIP150 | Self::HomesteadToDaoAt5 | Self::HomesteadToEIP150At5 => {
69 SpecId::TANGERINE
70 }
71 Self::EIP158 => SpecId::SPURIOUS_DRAGON,
72 Self::Byzantium | Self::EIP158ToByzantiumAt5 => SpecId::BYZANTIUM,
73 Self::ConstantinopleFix | Self::ByzantiumToConstantinopleFixAt5 => SpecId::PETERSBURG,
74 Self::Istanbul => SpecId::ISTANBUL,
75 Self::Berlin => SpecId::BERLIN,
76 Self::London | Self::BerlinToLondonAt5 => SpecId::LONDON,
77 Self::Paris | Self::Merge => SpecId::MERGE,
78 Self::Shanghai => SpecId::SHANGHAI,
79 Self::Cancun => SpecId::CANCUN,
80 Self::Prague => SpecId::PRAGUE,
81 Self::Osaka => SpecId::OSAKA,
82 Self::Amsterdam => SpecId::AMSTERDAM,
83 Self::ByzantiumToConstantinopleAt5 | Self::Constantinople => {
84 panic!("Overridden with PETERSBURG")
85 }
86 Self::Unknown => panic!("Unknown spec"),
87 }
88 }
89}