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

Introduce Symphony chains replacing Eth chain structures from ethers #26

Open
wants to merge 9 commits into
base: symphony-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
59 changes: 59 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ thiserror = "1.0.37"
serde_json = "1.0.94"
serde = { version = "1.0", default-features = false }
rand = "0.8.5"
parse-display = { version = "0.8.1"}
dereksione marked this conversation as resolved.
Show resolved Hide resolved


## tokio
Expand Down
1 change: 1 addition & 0 deletions bin/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ hex = "0.4"
thiserror = { workspace = true }
pretty_assertions = "1.3.0"
humantime = "2.1.0"
parse-display.workspace = true
dereksione marked this conversation as resolved.
Show resolved Hide resolved

[features]
jemalloc = ["dep:jemallocator", "dep:jemalloc-ctl"]
Expand Down
14 changes: 7 additions & 7 deletions bin/reth/src/args/utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Clap parser utilities

use reth_primitives::{AllGenesisFormats, BlockHashOrNumber, ChainSpec, GOERLI, MAINNET, SEPOLIA};
use reth_primitives::{AllGenesisFormats, BlockHashOrNumber, ChainSpec, TESTNET_SPEC, MAINNET_SPEC, DEVNET_SPEC};
use reth_revm::primitives::B256 as H256;
use std::{
net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs},
Expand All @@ -20,9 +20,9 @@ pub fn parse_duration_from_secs(arg: &str) -> eyre::Result<Duration, std::num::P
/// to a custom one.
pub fn chain_spec_value_parser(s: &str) -> eyre::Result<Arc<ChainSpec>, eyre::Error> {
Ok(match s {
"mainnet" => MAINNET.clone(),
"goerli" => GOERLI.clone(),
"sepolia" => SEPOLIA.clone(),
"mainnet" => MAINNET_SPEC.clone(),
"testnet" => TESTNET_SPEC.clone(),
"devnet" => DEVNET_SPEC.clone(),
_ => {
let raw = std::fs::read_to_string(PathBuf::from(shellexpand::full(s)?.into_owned()))?;
serde_json::from_str(&raw)?
Expand All @@ -34,9 +34,9 @@ pub fn chain_spec_value_parser(s: &str) -> eyre::Result<Arc<ChainSpec>, eyre::Er
/// to a custom one.
pub fn genesis_value_parser(s: &str) -> eyre::Result<Arc<ChainSpec>, eyre::Error> {
Ok(match s {
"mainnet" => MAINNET.clone(),
"goerli" => GOERLI.clone(),
"sepolia" => SEPOLIA.clone(),
"mainnet" => MAINNET_SPEC.clone(),
"testnet" => TESTNET_SPEC.clone(),
"devnet" => DEVNET_SPEC.clone(),
_ => {
let raw = std::fs::read_to_string(PathBuf::from(shellexpand::full(s)?.into_owned()))?;
let genesis: AllGenesisFormats = serde_json::from_str(&raw)?;
Expand Down
8 changes: 4 additions & 4 deletions bin/reth/src/dirs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use std::{
pub fn config_path_prefix(chain: Chain) -> String {
if chain == Chain::mainnet() {
"mainnet".to_string()
} else if chain == Chain::goerli() {
"goerli".to_string()
} else if chain == Chain::sepolia() {
"sepolia".to_string()
} else if chain == Chain::devnet() {
"devnet".to_string()
} else if chain == Chain::testnet() {
"testnet".to_string()
} else {
chain.id().to_string()
}
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/beacon/src/beacon_consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Consensus for BeaconConsensus {
// Goerli exception:
// * If the network is goerli pre-merge, ignore the extradata check, since we do not
// support clique.
if self.chain_spec.chain != Chain::goerli() {
if self.chain_spec.chain != Chain::devnet() {
validate_header_extradata(header)?;
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/common/src/calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn base_block_reward(
block_difficulty: U256,
total_difficulty: U256,
) -> Option<u128> {
if chain_spec.chain == Chain::goerli() ||
if chain_spec.chain == Chain::devnet() ||
chain_spec.fork(Hardfork::Paris).active_at_ttd(total_difficulty, block_difficulty)
{
None
Expand Down
3 changes: 3 additions & 0 deletions crates/net/eth-wire/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ bytes.workspace = true
thiserror = { workspace = true }
serde = { workspace = true, optional = true }

#symphony
symphony-primitives = { workspace = true }

# reth
reth-codecs = { path = "../../storage/codecs" }
reth-primitives = { workspace = true }
Expand Down
9 changes: 5 additions & 4 deletions crates/net/eth-wire/src/types/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ use crate::{EthVersion, StatusBuilder};

use reth_codecs::derive_arbitrary;
use reth_primitives::{
hex, Chain, ChainSpec, ForkId, Genesis, Hardfork, Head, H256, MAINNET, U256,
hex, Chain, ChainSpec, ForkId, Genesis, Hardfork, Head, H256, MAINNET_SPEC, U256,
};
use reth_rlp::{RlpDecodable, RlpEncodable};
use symphony_primitives::SymphonyChains;
use std::fmt::{Debug, Display};

#[cfg(feature = "serde")]
Expand Down Expand Up @@ -132,15 +133,15 @@ impl Debug for Status {
// <https://etherscan.io/block/0>
impl Default for Status {
fn default() -> Self {
let mainnet_genesis = MAINNET.genesis_hash();
let mainnet_genesis = MAINNET_SPEC.genesis_hash();
Status {
version: EthVersion::Eth68 as u8,
chain: Chain::Named(ethers_core::types::Chain::Mainnet),
chain: Chain::Named(SymphonyChains::Mainnet),
total_difficulty: U256::from(17_179_869_184u64),
blockhash: mainnet_genesis,
genesis: mainnet_genesis,
forkid: Hardfork::Frontier
.fork_id(&MAINNET)
.fork_id(&MAINNET_SPEC)
.expect("The Frontier hardfork should always exist"),
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/net/network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use reth_discv4::{Discv4Config, Discv4ConfigBuilder, DEFAULT_DISCOVERY_PORT};
use reth_dns_discovery::DnsDiscoveryConfig;
use reth_ecies::util::pk2id;
use reth_eth_wire::{HelloMessage, Status};
use reth_primitives::{ChainSpec, ForkFilter, Head, NodeRecord, PeerId, MAINNET};
use reth_primitives::{ChainSpec, ForkFilter, Head, NodeRecord, PeerId, MAINNET_SPEC};
use reth_provider::{BlockReader, HeaderProvider};
use reth_tasks::{TaskSpawner, TokioTaskExecutor};
use secp256k1::SECP256K1;
Expand Down Expand Up @@ -160,7 +160,7 @@ impl NetworkConfigBuilder {
listener_addr: None,
peers_config: None,
sessions_config: None,
chain_spec: MAINNET.clone(),
chain_spec: MAINNET_SPEC.clone(),
network_mode: Default::default(),
executor: None,
hello_message: None,
Expand Down Expand Up @@ -456,7 +456,7 @@ mod tests {

#[test]
fn test_network_fork_filter_default() {
let mut chain_spec = Arc::clone(&MAINNET);
let mut chain_spec = Arc::clone(&MAINNET_SPEC);

// remove any `next` fields we would have by removing all hardforks
Arc::make_mut(&mut chain_spec).hardforks = BTreeMap::new();
Expand Down
4 changes: 4 additions & 0 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ repository.workspace = true
description = "Commonly used types in reth."

[dependencies]
#symphony
symphony-primitives = { workspace = true }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize I have never thought about this too much - but why is this a workspace dependency rather than a path dependency? I.e.:

symphony-primitives = { path = "../symphony-primitives" }


# reth
reth-rlp = { workspace = true, features = ["std", "derive", "ethereum-types"] }
reth-rlp-derive = { path = "../rlp/rlp-derive" }
Expand Down Expand Up @@ -56,6 +59,7 @@ url = "2.3"
impl-serde = "0.4.0"
once_cell = "1.17.0"
zstd = { version = "0.12", features = ["experimental"] }
parse-display = { workspace = true }

# proof related
triehash = "0.8"
Expand Down
Loading
Loading