revm_statetest_types/spec.rs
1use revm::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 (skipped)
52 Osaka, // SKIPPED
53 /// Unknown or unsupported specification
54 #[serde(other)]
55 Unknown,
56}
57
58impl SpecName {
59 /// Converts to a [SpecId].
60 pub fn to_spec_id(&self) -> SpecId {
61 match self {
62 Self::Frontier => SpecId::FRONTIER,
63 Self::Homestead | Self::FrontierToHomesteadAt5 => SpecId::HOMESTEAD,
64 Self::EIP150 | Self::HomesteadToDaoAt5 | Self::HomesteadToEIP150At5 => {
65 SpecId::TANGERINE
66 }
67 Self::EIP158 => SpecId::SPURIOUS_DRAGON,
68 Self::Byzantium | Self::EIP158ToByzantiumAt5 => SpecId::BYZANTIUM,
69 Self::ConstantinopleFix | Self::ByzantiumToConstantinopleFixAt5 => SpecId::PETERSBURG,
70 Self::Istanbul => SpecId::ISTANBUL,
71 Self::Berlin => SpecId::BERLIN,
72 Self::London | Self::BerlinToLondonAt5 => SpecId::LONDON,
73 Self::Paris | Self::Merge => SpecId::MERGE,
74 Self::Shanghai => SpecId::SHANGHAI,
75 Self::Cancun => SpecId::CANCUN,
76 Self::Prague => SpecId::PRAGUE,
77 Self::Osaka => SpecId::OSAKA,
78 Self::ByzantiumToConstantinopleAt5 | Self::Constantinople => {
79 panic!("Overridden with PETERSBURG")
80 }
81 Self::Unknown => panic!("Unknown spec"),
82 }
83 }
84}