|
1 | | -//! Chain specification for the Base Mainnet network. |
| 1 | +//! Chain specification for the Fraxtal Mainnet network. |
2 | 2 |
|
3 | 3 | use std::sync::{Arc, LazyLock}; |
4 | 4 |
|
5 | | -use alloy_chains::Chain; |
6 | | -use alloy_primitives::b256; |
7 | | -use alloy_primitives::U256; |
8 | | -use reth_chainspec::{BaseFeeParams, BaseFeeParamsKind, ChainHardforks, ChainSpec, ForkCondition}; |
9 | | -use reth_ethereum_forks::EthereumHardfork; |
10 | | -use reth_ethereum_forks::Hardfork; |
11 | | -use reth_optimism_chainspec::make_op_genesis_header; |
| 5 | +use alloy_genesis::Genesis; |
12 | 6 | use reth_optimism_chainspec::OpChainSpec; |
13 | | -use reth_optimism_forks::OpHardfork; |
14 | | -use reth_primitives_traits::SealedHeader; |
15 | 7 |
|
16 | | -/// The Base mainnet spec |
| 8 | +/// The Fraxtal Mainnet spec. |
| 9 | +/// |
| 10 | +/// This uses `OpChainSpec::from(genesis)` to dynamically extract hardforks |
| 11 | +/// from the genesis file instead of hardcoding them, ensuring the computed |
| 12 | +/// genesis hash matches the expected value. |
17 | 13 | pub(crate) static FRAXTAL_MAINNET: LazyLock<Arc<OpChainSpec>> = LazyLock::new(|| { |
18 | | - let genesis = serde_json::from_str(include_str!("../res/genesis/mainnet.json")) |
19 | | - .expect("Can't deserialize Fraxtal genesis json"); |
20 | | - let hardforks = FRAXTAL_MAINNET_HARDFORKS.clone(); |
21 | | - OpChainSpec { |
22 | | - inner: ChainSpec { |
23 | | - chain: Chain::fraxtal(), |
24 | | - genesis_header: SealedHeader::new( |
25 | | - make_op_genesis_header(&genesis, &hardforks), |
26 | | - b256!("0x521982bd54239dc71269eefb58601762cc15cfb2978e0becb46af7962ed6bfaa"), |
27 | | - ), |
28 | | - genesis, |
29 | | - paris_block_and_final_difficulty: Some((0, U256::from(0))), |
30 | | - hardforks, |
31 | | - base_fee_params: BaseFeeParamsKind::Variable( |
32 | | - vec![ |
33 | | - (EthereumHardfork::London.boxed(), BaseFeeParams::optimism()), |
34 | | - ( |
35 | | - OpHardfork::Canyon.boxed(), |
36 | | - BaseFeeParams { |
37 | | - max_change_denominator: 250, |
38 | | - elasticity_multiplier: 10, |
39 | | - }, |
40 | | - ), |
41 | | - ] |
42 | | - .into(), |
43 | | - ), |
44 | | - ..Default::default() |
45 | | - }, |
46 | | - } |
47 | | - .into() |
48 | | -}); |
49 | | - |
50 | | -static FRAXTAL_MAINNET_HARDFORKS: LazyLock<ChainHardforks> = LazyLock::new(|| { |
51 | | - ChainHardforks::new(vec![ |
52 | | - (EthereumHardfork::Frontier.boxed(), ForkCondition::Block(0)), |
53 | | - (EthereumHardfork::Homestead.boxed(), ForkCondition::Block(0)), |
54 | | - (EthereumHardfork::Tangerine.boxed(), ForkCondition::Block(0)), |
55 | | - ( |
56 | | - EthereumHardfork::SpuriousDragon.boxed(), |
57 | | - ForkCondition::Block(0), |
58 | | - ), |
59 | | - (EthereumHardfork::Byzantium.boxed(), ForkCondition::Block(0)), |
60 | | - ( |
61 | | - EthereumHardfork::Constantinople.boxed(), |
62 | | - ForkCondition::Block(0), |
63 | | - ), |
64 | | - ( |
65 | | - EthereumHardfork::Petersburg.boxed(), |
66 | | - ForkCondition::Block(0), |
67 | | - ), |
68 | | - (EthereumHardfork::Istanbul.boxed(), ForkCondition::Block(0)), |
69 | | - ( |
70 | | - EthereumHardfork::MuirGlacier.boxed(), |
71 | | - ForkCondition::Block(0), |
72 | | - ), |
73 | | - (EthereumHardfork::Berlin.boxed(), ForkCondition::Block(0)), |
74 | | - (EthereumHardfork::London.boxed(), ForkCondition::Block(0)), |
75 | | - ( |
76 | | - EthereumHardfork::ArrowGlacier.boxed(), |
77 | | - ForkCondition::Block(0), |
78 | | - ), |
79 | | - ( |
80 | | - EthereumHardfork::GrayGlacier.boxed(), |
81 | | - ForkCondition::Block(0), |
82 | | - ), |
83 | | - ( |
84 | | - EthereumHardfork::Paris.boxed(), |
85 | | - ForkCondition::TTD { |
86 | | - activation_block_number: 0, |
87 | | - fork_block: Some(0), |
88 | | - total_difficulty: U256::ZERO, |
89 | | - }, |
90 | | - ), |
91 | | - (OpHardfork::Bedrock.boxed(), ForkCondition::Block(0)), |
92 | | - (OpHardfork::Regolith.boxed(), ForkCondition::Timestamp(0)), |
93 | | - ( |
94 | | - EthereumHardfork::Shanghai.boxed(), |
95 | | - ForkCondition::Timestamp(0), |
96 | | - ), |
97 | | - (OpHardfork::Canyon.boxed(), ForkCondition::Timestamp(0)), |
98 | | - ( |
99 | | - EthereumHardfork::Cancun.boxed(), |
100 | | - ForkCondition::Timestamp(1717009201), |
101 | | - ), |
102 | | - ( |
103 | | - OpHardfork::Ecotone.boxed(), |
104 | | - ForkCondition::Timestamp(1717009201), |
105 | | - ), |
106 | | - ( |
107 | | - OpHardfork::Fjord.boxed(), |
108 | | - ForkCondition::Timestamp(1733947201), |
109 | | - ), |
110 | | - ( |
111 | | - OpHardfork::Granite.boxed(), |
112 | | - ForkCondition::Timestamp(1738958401), |
113 | | - ), |
114 | | - ( |
115 | | - OpHardfork::Holocene.boxed(), |
116 | | - ForkCondition::Timestamp(1744052401), |
117 | | - ), |
118 | | - ( |
119 | | - EthereumHardfork::Prague.boxed(), |
120 | | - ForkCondition::Timestamp(1755716401), |
121 | | - ), |
122 | | - ( |
123 | | - OpHardfork::Isthmus.boxed(), |
124 | | - ForkCondition::Timestamp(1755716401), |
125 | | - ), |
126 | | - ]) |
| 14 | + let genesis: Genesis = serde_json::from_str(include_str!("../res/genesis/mainnet.json")) |
| 15 | + .expect("Can't deserialize Fraxtal mainnet genesis json"); |
| 16 | + Arc::new(OpChainSpec::from(genesis)) |
127 | 17 | }); |
0 commit comments