This repository has been archived by the owner on Nov 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
150 additions
and
57 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
//! Alphanet chainspec parsing logic. | ||
use once_cell::sync::Lazy; | ||
use reth_chainspec::{ | ||
BaseFeeParams, BaseFeeParamsKind, Chain, ChainHardforks, ChainSpec, EthereumHardfork, | ||
ForkCondition, OptimismHardfork, | ||
}; | ||
use reth_cli::chainspec::ChainSpecParser; | ||
use reth_node_core::args::utils::parse_custom_chain_spec; | ||
use reth_primitives::{b256, U256}; | ||
use std::sync::Arc; | ||
|
||
/// Development chain hardforks. | ||
pub static DEV_HARDFORKS: Lazy<ChainHardforks> = Lazy::new(|| { | ||
ChainHardforks::new(vec![ | ||
(EthereumHardfork::Frontier.boxed(), ForkCondition::Block(0)), | ||
(EthereumHardfork::Homestead.boxed(), ForkCondition::Block(0)), | ||
(EthereumHardfork::Dao.boxed(), ForkCondition::Block(0)), | ||
(EthereumHardfork::Tangerine.boxed(), ForkCondition::Block(0)), | ||
(EthereumHardfork::SpuriousDragon.boxed(), ForkCondition::Block(0)), | ||
(EthereumHardfork::Byzantium.boxed(), ForkCondition::Block(0)), | ||
(EthereumHardfork::Constantinople.boxed(), ForkCondition::Block(0)), | ||
(EthereumHardfork::Petersburg.boxed(), ForkCondition::Block(0)), | ||
(EthereumHardfork::Istanbul.boxed(), ForkCondition::Block(0)), | ||
(EthereumHardfork::Berlin.boxed(), ForkCondition::Block(0)), | ||
(EthereumHardfork::London.boxed(), ForkCondition::Block(0)), | ||
( | ||
EthereumHardfork::Paris.boxed(), | ||
ForkCondition::TTD { fork_block: None, total_difficulty: U256::ZERO }, | ||
), | ||
(EthereumHardfork::Shanghai.boxed(), ForkCondition::Timestamp(0)), | ||
(EthereumHardfork::Cancun.boxed(), ForkCondition::Timestamp(0)), | ||
(OptimismHardfork::Regolith.boxed(), ForkCondition::Timestamp(0)), | ||
(OptimismHardfork::Bedrock.boxed(), ForkCondition::Block(0)), | ||
(OptimismHardfork::Ecotone.boxed(), ForkCondition::Timestamp(0)), | ||
(OptimismHardfork::Canyon.boxed(), ForkCondition::Timestamp(0)), | ||
]) | ||
}); | ||
|
||
/// Alphanet dev testnet specification. | ||
pub static ALPHANET_DEV: Lazy<Arc<ChainSpec>> = Lazy::new(|| { | ||
{ | ||
ChainSpec { | ||
chain: Chain::dev(), | ||
genesis: serde_json::from_str(include_str!("../../../etc/alphanet-genesis.json")) | ||
.expect("Can't deserialize Dev testnet genesis json"), | ||
genesis_hash: Some(b256!( | ||
"2f980576711e3617a5e4d83dd539548ec0f7792007d505a3d2e9674833af2d7c" | ||
)), | ||
paris_block_and_final_difficulty: Some((0, U256::from(0))), | ||
hardforks: DEV_HARDFORKS.clone(), | ||
base_fee_params: BaseFeeParamsKind::Constant(BaseFeeParams::ethereum()), | ||
deposit_contract: None, | ||
..Default::default() | ||
} | ||
} | ||
.into() | ||
}); | ||
|
||
/// Alphanet chain specification parser. | ||
#[derive(Debug, Clone, Default)] | ||
pub struct AlphanetChainSpecParser; | ||
|
||
impl ChainSpecParser for AlphanetChainSpecParser { | ||
type ChainSpec = ChainSpec; | ||
|
||
const SUPPORTED_CHAINS: &'static [&'static str] = &["dev"]; | ||
|
||
fn parse(s: &str) -> eyre::Result<Arc<Self::ChainSpec>> { | ||
Ok(match s { | ||
"dev" => ALPHANET_DEV.clone(), | ||
s => { | ||
let mut chainspec = parse_custom_chain_spec(s)?; | ||
|
||
// NOTE(onbjerg): This is a temporary workaround until we figure out a better way to | ||
// activate Prague based on a custom fork name. Currently there does not seem to be | ||
// a good way to do it. | ||
chainspec.hardforks.insert(EthereumHardfork::Prague, ForkCondition::Timestamp(0)); | ||
|
||
Arc::new(chainspec) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.