Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add chain spec hardfork #56

Merged
merged 43 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
36010de
add hardfork
georgehao Nov 28, 2024
dac4a42
complete hardfork lib.rs
georgehao Nov 28, 2024
73f33b5
complete
georgehao Dec 2, 2024
62d984e
add scroll bootnode
georgehao Dec 2, 2024
c55aa00
remove duplicated code
georgehao Dec 2, 2024
c329f83
update
georgehao Dec 2, 2024
91381be
tweak a comment
georgehao Dec 2, 2024
e6598ec
format
georgehao Dec 3, 2024
5f1f0be
fix hardfork
georgehao Dec 3, 2024
9e456d7
fix format
georgehao Dec 3, 2024
65339ce
fix genesis hash error
georgehao Dec 3, 2024
7f03d87
update unit test
georgehao Dec 3, 2024
f61684d
update
georgehao Dec 3, 2024
a78017c
update
georgehao Dec 3, 2024
ca15c76
remove unused dependence
georgehao Dec 3, 2024
83b6ada
fix
georgehao Dec 3, 2024
22e2262
add std
georgehao Dec 3, 2024
e90b2cd
update
georgehao Dec 3, 2024
8368780
Update crates/net/peers/src/bootnodes/mod.rs
georgehao Dec 3, 2024
cd3f50e
address comment
georgehao Dec 4, 2024
9b43e66
update hardfork
georgehao Dec 4, 2024
21954d1
Merge branch 'feat/add_chain_spec_hardfork' of github.com:scroll-tech…
georgehao Dec 4, 2024
2fd11cf
update
georgehao Dec 4, 2024
f111f6f
fix comment
georgehao Dec 4, 2024
67d4e7e
Merge branch 'scroll' of github.com:scroll-tech/reth into feat/add_ch…
georgehao Dec 4, 2024
164d9bb
address comment
georgehao Dec 4, 2024
70abe38
address comment
georgehao Dec 4, 2024
5aea8e8
address comment
georgehao Dec 4, 2024
404f5ff
fix unit test
georgehao Dec 4, 2024
c2a88a5
fix unit test
georgehao Dec 4, 2024
66b7e00
address comments
georgehao Dec 4, 2024
34fbf24
Merge branch 'scroll' of github.com:scroll-tech/reth into feat/add_ch…
georgehao Dec 6, 2024
c6ca5aa
fix scroll genesis baseFee
georgehao Dec 6, 2024
8b7a17f
Merge branch 'scroll' of github.com:scroll-tech/reth into feat/add_ch…
georgehao Dec 6, 2024
0cee1ba
address comments
georgehao Dec 6, 2024
0ad055a
fix unit test
georgehao Dec 6, 2024
cfd062e
fix unit test
georgehao Dec 6, 2024
4b92f77
address comments
georgehao Dec 6, 2024
1a69d3a
address comments
georgehao Dec 6, 2024
13f2f59
fix conflict
georgehao Dec 9, 2024
7fd8e97
resolve conflct
georgehao Dec 9, 2024
f47663d
add hardforks doc
georgehao Dec 9, 2024
a188c1b
update the doc
georgehao Dec 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ members = [
"crates/rpc/rpc-testing-util/",
"crates/rpc/rpc-types-compat/",
"crates/rpc/rpc/",
"crates/scroll/chainspec",
"crates/scroll/execution",
"crates/scroll/hardforks",
"crates/scroll/primitives",
"crates/scroll/revm",
"crates/scroll/storage",
Expand Down Expand Up @@ -411,6 +413,7 @@ reth-scroll-execution = { path = "crates/scroll/execution" }
reth-scroll-primitives = { path = "crates/scroll/primitives" }
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 All @@ -437,7 +440,7 @@ revm-primitives = { version = "14.0.0", features = [
], default-features = false }

# eth
alloy-chains = "0.1.32"
alloy-chains = "0.1.48"
georgehao marked this conversation as resolved.
Show resolved Hide resolved
alloy-dyn-abi = "0.8.11"
alloy-primitives = { version = "0.8.11", default-features = false }
alloy-rlp = "0.3.4"
Expand Down
8 changes: 7 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,10 @@ impl ChainSpec {

/// Get the initial base fee of the genesis block.
pub fn initial_base_fee(&self) -> Option<u64> {
if self.chain == Chain::scroll_mainnet() || self.chain == Chain::scroll_sepolia() {
return Some(0)
georgehao marked this conversation as resolved.
Show resolved Hide resolved
}

// 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 +575,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
georgehao marked this conversation as resolved.
Show resolved Hide resolved
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
Thegaram marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions crates/scroll/chainspec/res/genesis/sepolia_scroll.json
georgehao marked this conversation as resolved.
Show resolved Hide resolved

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
Loading