Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
feat: activate prague always
Browse files Browse the repository at this point in the history
  • Loading branch information
onbjerg committed Sep 12, 2024
1 parent fdfc200 commit 671519f
Show file tree
Hide file tree
Showing 11 changed files with 150 additions and 57 deletions.
78 changes: 40 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ reth = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb", features = [
"optimism",
] }
reth-cli = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb" }
reth-cli-util = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb" }
reth-node-api = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb" }
reth-node-builder = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb" }
Expand Down Expand Up @@ -101,6 +102,8 @@ reth-tracing = { git = "https://github.com/paradigmxyz/reth.git", rev = "c1b5fbb
clap = "4"
eyre = "0.6.12"
tracing = "0.1.0"
serde_json = "1"
once_cell = "1.19"

# misc-testing
rstest = "0.18.2"
6 changes: 3 additions & 3 deletions bin/alphanet/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
//! - `min-debug-logs`: Disables all logs below `debug` level.
//! - `min-trace-logs`: Disables all logs below `trace` level.
use alphanet_node::node::AlphaNetNode;
use alphanet_node::{chainspec::AlphanetChainSpecParser, node::AlphaNetNode};
use clap::Parser;
use reth_node_optimism::args::RollupArgs;
use reth_optimism_cli::{chainspec::OpChainSpecParser, Cli};
use reth_optimism_cli::Cli;
use reth_optimism_rpc::eth::rpc::SequencerClient;

// We use jemalloc for performance reasons.
Expand All @@ -45,7 +45,7 @@ fn main() {
}

if let Err(err) =
Cli::<OpChainSpecParser, RollupArgs>::parse().run(|builder, rollup_args| async move {
Cli::<AlphanetChainSpecParser, RollupArgs>::parse().run(|builder, rollup_args| async move {
let node = builder
.node(AlphaNetNode::new(rollup_args.clone()))
.extend_rpc_modules(move |ctx| {
Expand Down
4 changes: 4 additions & 0 deletions crates/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ categories.workspace = true

[dependencies]
alphanet-precompile.workspace = true
once_cell.workspace = true
reth-cli.workspace = true
reth-node-api.workspace = true
reth-node-builder.workspace = true
reth-node-core.workspace = true
reth-node-optimism.workspace = true
reth-chainspec.workspace = true
reth-primitives.workspace = true
reth-revm.workspace = true
serde_json.workspace = true

eyre.workspace = true

Expand Down
84 changes: 84 additions & 0 deletions crates/node/src/chainspec.rs
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)
}
})
}
}
Loading

0 comments on commit 671519f

Please sign in to comment.