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