Skip to content

Commit

Permalink
Merge branch 'scroll' into feat/execution-strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
greged93 committed Dec 9, 2024
2 parents 1ee6050 + c3c2dde commit d41b561
Show file tree
Hide file tree
Showing 19 changed files with 1,778 additions and 24 deletions.
78 changes: 55 additions & 23 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 @@ -100,9 +100,11 @@ members = [
"crates/rpc/rpc-testing-util/",
"crates/rpc/rpc-types-compat/",
"crates/rpc/rpc/",
"crates/scroll/chainspec",
"crates/scroll/consensus",
"crates/scroll/evm",
"crates/scroll/execution",
"crates/scroll/hardforks",
"crates/scroll/primitives",
"crates/scroll/revm",
"crates/scroll/storage",
Expand Down Expand Up @@ -419,6 +421,7 @@ reth-scroll-state-commitment = { path = "crates/scroll/state-commitment" }
reth-scroll-trie = { path = "crates/scroll/trie" }
reth-scroll-revm = { path = "crates/scroll/revm" }
reth-scroll-storage = { path = "crates/scroll/storage" }
reth-scroll-forks = { path = "crates/scroll/hardforks" }
reth-stages = { path = "crates/stages/stages" }
reth-stages-api = { path = "crates/stages/api" }
reth-stages-types = { path = "crates/stages/types" }
Expand Down
11 changes: 10 additions & 1 deletion crates/chainspec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use reth_ethereum_forks::{
};
use reth_network_peers::{
base_nodes, base_testnet_nodes, holesky_nodes, mainnet_nodes, op_nodes, op_testnet_nodes,
sepolia_nodes, NodeRecord,
scroll_nodes, scroll_sepolia_nodes, sepolia_nodes, NodeRecord,
};
use reth_primitives_traits::SealedHeader;
use reth_trie_common::root::state_root_ref_unhashed;
Expand Down Expand Up @@ -317,6 +317,13 @@ impl ChainSpec {

/// Get the initial base fee of the genesis block.
pub fn initial_base_fee(&self) -> Option<u64> {
// TODO(scroll): migrate to Chain::scroll() (introduced in https://github.com/alloy-rs/chains/pull/112) when alloy-chains is bumped to version 0.1.48
if self.chain == Chain::from_named(NamedChain::Scroll) ||
self.chain == Chain::from_named(NamedChain::ScrollSepolia)
{
return None
}

// If the base fee is set in the genesis block, we use that instead of the default.
let genesis_base_fee =
self.genesis.base_fee_per_gas.map(|fee| fee as u64).unwrap_or(INITIAL_BASE_FEE);
Expand Down Expand Up @@ -571,8 +578,10 @@ impl ChainSpec {
C::Holesky => Some(holesky_nodes()),
C::Base => Some(base_nodes()),
C::Optimism => Some(op_nodes()),
C::Scroll => Some(scroll_nodes()),
C::BaseGoerli | C::BaseSepolia => Some(base_testnet_nodes()),
C::OptimismSepolia | C::OptimismGoerli | C::OptimismKovan => Some(op_testnet_nodes()),
C::ScrollSepolia => Some(scroll_sepolia_nodes()),
_ => None,
}
}
Expand Down
13 changes: 13 additions & 0 deletions crates/net/peers/src/bootnodes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ pub use ethereum::*;
mod optimism;
pub use optimism::*;

mod scroll;
pub use scroll::*;

/// Returns parsed mainnet nodes
pub fn mainnet_nodes() -> Vec<NodeRecord> {
parse_nodes(&MAINNET_BOOTNODES[..])
Expand Down Expand Up @@ -43,6 +46,16 @@ pub fn base_testnet_nodes() -> Vec<NodeRecord> {
parse_nodes(OP_TESTNET_BOOTNODES)
}

/// Returns parsed scroll mainnet nodes
pub fn scroll_nodes() -> Vec<NodeRecord> {
parse_nodes(SCROLL_BOOTNODES)
}

/// Returns parsed scroll seplo nodes
pub fn scroll_sepolia_nodes() -> Vec<NodeRecord> {
parse_nodes(SCROLL_SEPOLIA_BOOTNODES)
}

/// Parses all the nodes
pub fn parse_nodes(nodes: impl IntoIterator<Item = impl AsRef<str>>) -> Vec<NodeRecord> {
nodes.into_iter().map(|s| s.as_ref().parse().unwrap()).collect()
Expand Down
17 changes: 17 additions & 0 deletions crates/net/peers/src/bootnodes/scroll.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//! Scroll bootnodes come from <https://github.com/scroll-tech/go-ethereum/blob/develop/params/bootnodes.go>
/// Scroll mainnet boot nodes.
pub static SCROLL_BOOTNODES: &[&str] = &[
"enode://c6ac91f43df3d63916ac1ae411cdd5ba249d55d48a7bec7f8cd5bb351a31aba437e5a69e8a1de74d73fdfeba8af1cfe9caf9846ecd3abf60d1ffdf4925b55b23@54.186.123.248:30303",
"enode://fdcc807b5d1353f3a1e98b90208ce6ef1b7d446136e51eaa8ad657b55518a2f8b37655e42375d61622e6ea18f3faf9d070c9bbdf012cf5484bcbad33b7a15fb1@44.227.91.206:30303",
"enode://6beb5a3efbb39be73d17630b6da48e94c0ce7ec665172111463cb470197b20c12faa1fa6f835b81c28571277d1017e65c4e426cc92a46141cf69118ecf28ac03@44.237.194.52:30303",
"enode://7cf893d444eb8e129dca0f6485b3df579911606e7c728be4fa55fcc5f155a37c3ce07d217ccec5447798bde465ac2bdba2cb8763d107e9f3257e787579e9f27e@52.35.203.107:30303",
"enode://c7b2d94e95da343db6e667a01cef90376a592f2d277fbcbf6e9c9186734ed8003d01389571bd10cdbab7a6e5adfa6f0c7b55644d0db24e0b9deb4ec80f842075@54.70.236.187:30303",
];

/// Scroll sepolia boot nodes.
pub static SCROLL_SEPOLIA_BOOTNODES: &[&str] = &[
"enode://ceb1636bac5cbb262e5ad5b2cd22014bdb35ffe7f58b3506970d337a63099481814a338dbcd15f2d28757151e3ecd40ba38b41350b793cd0d910ff0436654f8c@35.85.84.250:30303",
"enode://29cee709c400533ae038a875b9ca975c8abef9eade956dcf3585e940acd5c0ae916968f514bd37d1278775aad1b7db30f7032a70202a87fd7365bd8de3c9f5fc@44.242.39.33:30303",
"enode://dd1ac5433c5c2b04ca3166f4cb726f8ff6d2da83dbc16d9b68b1ea83b7079b371eb16ef41c00441b6e85e32e33087f3b7753ea9e8b1e3f26d3e4df9208625e7f@54.148.111.168:30303",
];
59 changes: 59 additions & 0 deletions crates/scroll/chainspec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[package]
name = "reth-scroll-chainspec"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
description = "EVM chain spec implementation for scroll."

[lints]
workspace = true

[dependencies]
# reth
reth-chainspec.workspace = true
reth-ethereum-forks.workspace = true
reth-primitives-traits.workspace = true
reth-network-peers.workspace = true

# scroll-reth
reth-scroll-forks.workspace = true

# ethereum
alloy-chains.workspace = true
alloy-genesis.workspace = true
alloy-primitives.workspace = true
alloy-consensus.workspace = true
alloy-eips.workspace = true
alloy-serde.workspace = true

# io
serde_json.workspace = true
serde = { workspace = true, features = ["derive"] }

# misc
derive_more.workspace = true
once_cell.workspace = true

[dev-dependencies]
reth-chainspec = { workspace = true, features = ["test-utils"] }
alloy-genesis.workspace = true

[features]
default = ["std"]
std = [
"alloy-chains/std",
"alloy-genesis/std",
"alloy-primitives/std",
"alloy-eips/std",
"alloy-serde/std",
"reth-chainspec/std",
"reth-ethereum-forks/std",
"reth-primitives-traits/std",
"reth-scroll-forks/std",
"alloy-consensus/std",
"once_cell/std",
"serde/std"
]
1 change: 1 addition & 0 deletions crates/scroll/chainspec/res/genesis/dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"nonce":"0x0","timestamp":"0x6490fdd2","extraData":"0x","gasLimit":"0x1c9c380","difficulty":"0x0","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","coinbase":"0x0000000000000000000000000000000000000000","stateRoot":"0x5eb6e371a698b8d68f665192350ffcecbbbf322916f4b51bd79bb6887da3f494","alloc":{"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266":{"balance":"0xD3C21BCECCEDA1000000"},"0x70997970C51812dc3A010C7d01b50e0d17dc79C8":{"balance":"0xD3C21BCECCEDA1000000"},"0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC":{"balance":"0xD3C21BCECCEDA1000000"},"0x90F79bf6EB2c4f870365E785982E1f101E93b906":{"balance":"0xD3C21BCECCEDA1000000"},"0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65":{"balance":"0xD3C21BCECCEDA1000000"},"0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc":{"balance":"0xD3C21BCECCEDA1000000"},"0x976EA74026E726554dB657fA54763abd0C3a0aa9":{"balance":"0xD3C21BCECCEDA1000000"},"0x14dC79964da2C08b23698B3D3cc7Ca32193d9955":{"balance":"0xD3C21BCECCEDA1000000"},"0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f":{"balance":"0xD3C21BCECCEDA1000000"},"0xa0Ee7A142d267C1f36714E4a8F75612F20a79720":{"balance":"0xD3C21BCECCEDA1000000"},"0xBcd4042DE499D14e55001CcbB24a551F3b954096":{"balance":"0xD3C21BCECCEDA1000000"},"0x71bE63f3384f5fb98995898A86B02Fb2426c5788":{"balance":"0xD3C21BCECCEDA1000000"},"0xFABB0ac9d68B0B445fB7357272Ff202C5651694a":{"balance":"0xD3C21BCECCEDA1000000"},"0x1CBd3b2770909D4e10f157cABC84C7264073C9Ec":{"balance":"0xD3C21BCECCEDA1000000"},"0xdF3e18d64BC6A983f673Ab319CCaE4f1a57C7097":{"balance":"0xD3C21BCECCEDA1000000"},"0xcd3B766CCDd6AE721141F452C550Ca635964ce71":{"balance":"0xD3C21BCECCEDA1000000"},"0x2546BcD3c84621e976D8185a91A922aE77ECEc30":{"balance":"0xD3C21BCECCEDA1000000"},"0xbDA5747bFD65F08deb54cb465eB87D40e51B197E":{"balance":"0xD3C21BCECCEDA1000000"},"0xdD2FD4581271e230360230F9337D5c0430Bf44C0":{"balance":"0xD3C21BCECCEDA1000000"},"0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199":{"balance":"0xD3C21BCECCEDA1000000"}},"number":"0x0","gasUsed":"0x0","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000"}
1 change: 1 addition & 0 deletions crates/scroll/chainspec/res/genesis/scroll.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions crates/scroll/chainspec/res/genesis/sepolia_scroll.json

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions crates/scroll/chainspec/src/dev.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//! Chain specification in dev mode for custom chain.
use alloc::sync::Arc;

use alloy_chains::Chain;
use alloy_consensus::constants::DEV_GENESIS_HASH;
use alloy_primitives::U256;
use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec};
use reth_scroll_forks::DEV_HARDFORKS;

use crate::{LazyLock, ScrollChainSpec};

/// Scroll dev testnet specification
///
/// Includes 20 prefunded accounts with `10_000` ETH each derived from mnemonic "test test test test
/// test test test test test test test junk".
pub static SCROLL_DEV: LazyLock<Arc<ScrollChainSpec>> = LazyLock::new(|| {
ScrollChainSpec {
inner: ChainSpec {
chain: Chain::dev(),
genesis: serde_json::from_str(include_str!("../res/genesis/dev.json"))
.expect("Can't deserialize Dev testnet genesis json"),
genesis_hash: once_cell_set(DEV_GENESIS_HASH),
paris_block_and_final_difficulty: Some((0, U256::from(0))),
hardforks: DEV_HARDFORKS.clone(),
base_fee_params: BaseFeeParamsKind::Constant(BaseFeeParams::ethereum()),
..Default::default()
},
}
.into()
});
Loading

0 comments on commit d41b561

Please sign in to comment.