Skip to content

Commit

Permalink
Merge branch 'paradigmxyz:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Arindam2407 authored Nov 8, 2023
2 parents f1038e6 + e056bfb commit 1cf8f10
Show file tree
Hide file tree
Showing 140 changed files with 2,973 additions and 1,448 deletions.
14 changes: 14 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
[alias]
docs = "doc --workspace --all-features --no-deps"

[target.x86_64-pc-windows-msvc]
rustflags = [
# Increases the stack size to 10MB, which is
# in line with Linux (whereas default for Windows is 1MB)
"-Clink-arg=/STACK:10000000",
]

[target.i686-pc-windows-msvc]
rustflags = [
# Increases the stack size to 10MB, which is
# in line with Linux (whereas default for Windows is 1MB)
"-Clink-arg=/STACK:10000000",
]
7 changes: 7 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[profile.default]
retries = { backoff = "exponential", count = 2, delay = "2s", jitter = true }
slow-timeout = { period = "30s", terminate-after = 4 }

[[profile.default.overrides]]
filter = "test(general_state_tests)"
slow-timeout = { period = "1m", terminate-after = 4 }
22 changes: 7 additions & 15 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ concurrency:

jobs:
test:
name: test (${{ matrix.network }} | ${{ matrix.partition }}/${{ strategy.job-total }})
name: test / ${{ matrix.network }} (${{ matrix.partition }}/2)
runs-on:
group: Reth
strategy:
Expand All @@ -35,21 +35,12 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Set binary value
id: binary
run: |
if [[ "${{ matrix.network }}" == "ethereum" ]]; then
echo "binary=reth" >> $GITHUB_OUTPUT
else
echo "binary=op-reth" >> $GITHUB_OUTPUT
fi
- name: Run tests
run: |
cargo nextest run \
--locked --features "${{ matrix.network }}" \
--bin ${{ steps.binary.outputs.binary }} \
--workspace --exclude examples --exclude ef-tests \
--partition hash:${{ matrix.partition }}/${{ strategy.job-total }} \
--partition hash:${{ matrix.partition }}/2 \
-E 'kind(test)'
sync:
Expand All @@ -69,15 +60,16 @@ jobs:
cache-on-failure: true
- name: Run sync
run: |
cargo run --profile release --features jemalloc,min-error-logs \
--bin reth -- node \
cargo run --release --features jemalloc,min-error-logs --bin reth \
-- node \
--debug.tip 0x91c90676cab257a59cd956d7cb0bceb9b1a71d79755c23c7277a0697ccfaf8c4 \
--debug.max-block 100000 \
--debug.terminate
- name: Verify the target block hash
run: |
cargo run --profile release -- \
db get CanonicalHeaders 100000 \
cargo run --release --bin reth \
-- db \
get CanonicalHeaders 100000 \
| grep 0x91c90676cab257a59cd956d7cb0bceb9b1a71d79755c23c7277a0697ccfaf8c4
integration-success:
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,24 @@ env:

jobs:
clippy:
name: clippy
name: clippy / ${{ matrix.network }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
include:
- binary: "reth"
network: "ethereum"
- binary: "op-reth"
network: "optimism"
- binary: reth
network: ethereum
- binary: op-reth
network: optimism
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@clippy
with:
toolchain: nightly-2023-10-29
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run: cargo clippy --bin "${{ matrix.binary }}" --workspace --features "${{ matrix.network }}"
- run:
cargo clippy --bin "${{ matrix.binary }}" --workspace --features "${{ matrix.network }}"
env:
RUSTFLAGS: -D warnings

Expand Down
13 changes: 2 additions & 11 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ concurrency:

jobs:
test:
name: tests (${{ matrix.network }} | ${{ matrix.partition }}/${{ strategy.job-total }})
name: test / ${{ matrix.network }} (${{ matrix.partition }}/2)
runs-on:
group: Reth
strategy:
Expand All @@ -33,21 +33,12 @@ jobs:
with:
cache-on-failure: true
- uses: taiki-e/install-action@nextest
- name: Set binary value
id: binary
run: |
if [[ "${{ matrix.network }}" == "ethereum" ]]; then
echo "binary=reth" >> $GITHUB_OUTPUT
else
echo "binary=op-reth" >> $GITHUB_OUTPUT
fi
- name: Run tests
run: |
cargo nextest run \
--locked --features "${{ matrix.network }}" \
--bin ${{ steps.binary.outputs.binary }} \
--workspace --exclude examples --exclude ef-tests \
--partition hash:${{ matrix.partition }}/${{ strategy.job-total }} \
--partition hash:${{ matrix.partition }}/2 \
-E "kind(lib) | kind(bin) | kind(proc-macro)"
state:
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

23 changes: 12 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ codegen-units = 1
incremental = false

[workspace.dependencies]
## reth
# reth
reth = { path = "./bin/reth" }
reth-primitives = { path = "./crates/primitives" }
reth-interfaces = { path = "./crates/interfaces" }
Expand All @@ -110,11 +110,12 @@ reth-eth-wire = { path = "./crates/net/eth-wire" }
reth-ecies = { path = "./crates/net/ecies" }
reth-tracing = { path = "./crates/tracing" }
reth-tokio-util = { path = "crates/tokio-util" }

# revm
revm = { git = "https://github.com/bluealloy/revm", rev = "1609e07c68048909ad1682c98cf2b9baa76310b5" }
revm-primitives = { git = "https://github.com/bluealloy/revm", rev = "1609e07c68048909ad1682c98cf2b9baa76310b5" }

## eth
# eth
alloy-primitives = "0.4"
alloy-dyn-abi = "0.4"
alloy-sol-types = "0.4"
Expand All @@ -126,11 +127,11 @@ ethers-middleware = { version = "2.0", default-features = false }
discv5 = { git = "https://github.com/sigp/discv5", rev = "f289bbd4c57d499bb1bdb393af3c249600a1c662" }
igd = { git = "https://github.com/stevefan1999-personal/rust-igd", rev = "c2d1f83eb1612a462962453cb0703bc93258b173" }

## js
# js
boa_engine = "0.17"
boa_gc = "0.17"

## misc
# misc
aquamarine = "0.3"
bytes = "1.5"
bitflags = "2.4"
Expand All @@ -151,27 +152,27 @@ hex-literal = "0.4"
once_cell = "1.17"
syn = "2.0"

### proc-macros
# proc-macros
proc-macro2 = "1.0"
quote = "1.0"

## tokio
# tokio
tokio-stream = "0.1.11"
tokio = { version = "1.21", default-features = false }
tokio-util = { version = "0.7.4", features = ["codec"] }

## async
# async
async-trait = "0.1.68"
futures = "0.3.26"
pin-project = "1.0.12"
futures-util = "0.3.25"

## json
# rpc
jsonrpsee = { version = "0.20" }
jsonrpsee-core = { version = "0.20" }
jsonrpsee-types = { version = "0.20" }

## crypto
# crypto
secp256k1 = { version = "0.27.0", default-features = false, features = [
"global-context",
"rand-std",
Expand All @@ -181,11 +182,11 @@ enr = { version = "0.9", default-features = false, features = ["k256"] }
# for eip-4844
c-kzg = "0.4.0"

## config
# config
confy = "0.5"
toml = "0.8"

### misc-testing
# misc-testing
arbitrary = "1.1"
assert_matches = "1.5.0"
tempfile = "3.8"
Expand Down
90 changes: 39 additions & 51 deletions bin/reth/src/args/utils.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//! Clap parser utilities

use reth_primitives::{
fs, AllGenesisFormats, BlockHashOrNumber, ChainSpec, B256, DEV, GOERLI, HOLESKY, MAINNET,
SEPOLIA,
};
use reth_primitives::{fs, AllGenesisFormats, BlockHashOrNumber, ChainSpec, B256};
use std::{
net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs},
path::PathBuf,
Expand All @@ -15,6 +12,16 @@ use std::{
#[cfg(feature = "optimism")]
use reth_primitives::{BASE_GOERLI, BASE_MAINNET};

#[cfg(not(feature = "optimism"))]
use reth_primitives::{DEV, GOERLI, HOLESKY, MAINNET, SEPOLIA};

#[cfg(feature = "optimism")]
/// Chains supported by op-reth. First value should be used as the default.
pub const SUPPORTED_CHAINS: &[&str] = &["base", "base_goerli"];
#[cfg(not(feature = "optimism"))]
/// Chains supported by reth. First value should be used as the default.
pub const SUPPORTED_CHAINS: &[&str] = &["mainnet", "sepolia", "goerli", "holesky", "dev"];

/// Helper to parse a [Duration] from seconds
pub fn parse_duration_from_secs(arg: &str) -> eyre::Result<Duration, std::num::ParseIntError> {
let seconds = arg.parse()?;
Expand All @@ -25,13 +32,18 @@ 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 {
#[cfg(not(feature = "optimism"))]
"mainnet" => MAINNET.clone(),
#[cfg(not(feature = "optimism"))]
"goerli" => GOERLI.clone(),
#[cfg(not(feature = "optimism"))]
"sepolia" => SEPOLIA.clone(),
#[cfg(not(feature = "optimism"))]
"holesky" => HOLESKY.clone(),
#[cfg(not(feature = "optimism"))]
"dev" => DEV.clone(),
#[cfg(feature = "optimism")]
"base-goerli" => BASE_GOERLI.clone(),
"base_goerli" | "base-goerli" => BASE_GOERLI.clone(),
#[cfg(feature = "optimism")]
"base" => BASE_MAINNET.clone(),
_ => {
Expand All @@ -41,60 +53,45 @@ pub fn chain_spec_value_parser(s: &str) -> eyre::Result<Arc<ChainSpec>, eyre::Er
})
}

/// The help info for the --chain flag
pub fn chain_help() -> String {
format!("The chain this node is running.\nPossible values are either a built-in chain or the path to a chain specification file.\n\nBuilt-in chains:\n {}", SUPPORTED_CHAINS.join(", "))
}

/// Clap value parser for [ChainSpec]s.
///
/// The value parser matches either a known chain, the path
/// to a json file, or a json formatted string in-memory. The json can be either
/// a serialized [ChainSpec] or Genesis struct.
pub fn genesis_value_parser(s: &str) -> eyre::Result<Arc<ChainSpec>, eyre::Error> {
Ok(match s {
#[cfg(not(feature = "optimism"))]
"mainnet" => MAINNET.clone(),
#[cfg(not(feature = "optimism"))]
"goerli" => GOERLI.clone(),
#[cfg(not(feature = "optimism"))]
"sepolia" => SEPOLIA.clone(),
#[cfg(not(feature = "optimism"))]
"holesky" => HOLESKY.clone(),
#[cfg(not(feature = "optimism"))]
"dev" => DEV.clone(),
#[cfg(feature = "optimism")]
"base-goerli" => BASE_GOERLI.clone(),
"base_goerli" | "base-goerli" => BASE_GOERLI.clone(),
#[cfg(feature = "optimism")]
"base" => BASE_MAINNET.clone(),
_ => {
// try to read json from path first
let mut raw =
match fs::read_to_string(PathBuf::from(shellexpand::full(s)?.into_owned())) {
Ok(raw) => raw,
Err(io_err) => {
// valid json may start with "\n", but must contain "{"
if s.contains('{') {
s.to_string()
} else {
return Err(io_err.into()) // assume invalid path
}
let raw = match fs::read_to_string(PathBuf::from(shellexpand::full(s)?.into_owned())) {
Ok(raw) => raw,
Err(io_err) => {
// valid json may start with "\n", but must contain "{"
if s.contains('{') {
s.to_string()
} else {
return Err(io_err.into()) // assume invalid path
}
};

// The ethereum mainnet TTD is 58750000000000000000000, and geth serializes this
// without quotes, because that is how golang `big.Int`s marshal in JSON. Numbers
// are arbitrary precision in JSON, so this is valid JSON. This number is also
// greater than a `u64`.
//
// Unfortunately, serde_json only supports parsing up to `u64`, resorting to `f64`
// once `u64` overflows:
// <https://github.com/serde-rs/json/blob/4bc1eaa03a6160593575bc9bc60c94dba4cab1e3/src/de.rs#L1411-L1415>
// <https://github.com/serde-rs/json/blob/4bc1eaa03a6160593575bc9bc60c94dba4cab1e3/src/de.rs#L479-L484>
// <https://github.com/serde-rs/json/blob/4bc1eaa03a6160593575bc9bc60c94dba4cab1e3/src/de.rs#L102-L108>
//
// serde_json does have an arbitrary precision feature, but this breaks untagged
// enums in serde:
// <https://github.com/serde-rs/serde/issues/2230>
// <https://github.com/serde-rs/serde/issues/1183>
//
// To solve this, we surround the mainnet TTD with quotes, which our custom Visitor
// accepts.
if raw.contains("58750000000000000000000") &&
!raw.contains("\"58750000000000000000000\"")
{
raw = raw.replacen("58750000000000000000000", "\"58750000000000000000000\"", 1);
}
}
};

// both serialized Genesis and ChainSpec structs supported
let genesis: AllGenesisFormats = serde_json::from_str(&raw)?;
Expand Down Expand Up @@ -167,18 +164,9 @@ mod tests {
use secp256k1::rand::thread_rng;
use std::collections::HashMap;

#[cfg(feature = "optimism")]
#[test]
fn parse_optimism_chain_spec() {
for chain in ["base-goerli", "base"] {
chain_spec_value_parser(chain).unwrap();
genesis_value_parser(chain).unwrap();
}
}

#[test]
fn parse_known_chain_spec() {
for chain in ["mainnet", "sepolia", "goerli", "holesky"] {
for chain in SUPPORTED_CHAINS {
chain_spec_value_parser(chain).unwrap();
genesis_value_parser(chain).unwrap();
}
Expand Down
Loading

0 comments on commit 1cf8f10

Please sign in to comment.