Skip to content

Commit a88175e

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 2ae4473 + 8f804d3 commit a88175e

File tree

17 files changed

+310
-93
lines changed

17 files changed

+310
-93
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ tokio-tungstenite = "0.26.2"
597597
tokio-util = { version = "0.7.4", features = ["codec"] }
598598

599599
# async
600+
async-compression = { version = "0.4", default-features = false }
600601
async-stream = "0.3"
601602
async-trait = "0.1.68"
602603
futures = "0.3"

crates/cli/cli/src/chainspec.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ pub trait ChainSpecParser: Clone + Send + Sync + 'static {
3939
/// List of supported chains.
4040
const SUPPORTED_CHAINS: &'static [&'static str];
4141

42+
/// The default value for the chain spec parser.
43+
fn default_value() -> Option<&'static str> {
44+
Self::SUPPORTED_CHAINS.first().copied()
45+
}
46+
4247
/// Parses the given string into a chain spec.
4348
///
4449
/// # Arguments

crates/cli/commands/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub struct EnvironmentArgs<C: ChainSpecParser> {
4848
long,
4949
value_name = "CHAIN_OR_PATH",
5050
long_help = C::help_message(),
51-
default_value = C::SUPPORTED_CHAINS[0],
51+
default_value = C::default_value(),
5252
value_parser = C::parser(),
5353
global = true
5454
)]

crates/cli/commands/src/dump_genesis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct DumpGenesisCommand<C: ChainSpecParser> {
1515
long,
1616
value_name = "CHAIN_OR_PATH",
1717
long_help = C::help_message(),
18-
default_value = C::SUPPORTED_CHAINS[0],
18+
default_value = C::default_value(),
1919
value_parser = C::parser()
2020
)]
2121
chain: Arc<C::ChainSpec>,

crates/cli/commands/src/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub struct NodeCommand<C: ChainSpecParser, Ext: clap::Args + fmt::Debug = NoArgs
3232
long,
3333
value_name = "CHAIN_OR_PATH",
3434
long_help = C::help_message(),
35-
default_value = C::SUPPORTED_CHAINS[0],
35+
default_value = C::default_value(),
3636
default_value_if("dev", "true", "dev"),
3737
value_parser = C::parser(),
3838
required = false,

crates/cli/commands/src/p2p/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ pub struct DownloadArgs<C: ChainSpecParser> {
151151
long,
152152
value_name = "CHAIN_OR_PATH",
153153
long_help = C::help_message(),
154-
default_value = C::SUPPORTED_CHAINS[0],
154+
default_value = C::default_value(),
155155
value_parser = C::parser()
156156
)]
157157
chain: Arc<C::ChainSpec>,

crates/cli/commands/src/stage/dump/merkle.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,8 @@ fn unwind_and_copy<N: ProviderNodeTypes>(
9292
reth_stages::ExecInput { target: Some(to), checkpoint: Some(StageCheckpoint::new(from)) };
9393

9494
// Unwind hashes all the way to FROM
95-
96-
StorageHashingStage::default().unwind(&provider, unwind).unwrap();
97-
AccountHashingStage::default().unwind(&provider, unwind).unwrap();
98-
95+
StorageHashingStage::default().unwind(&provider, unwind)?;
96+
AccountHashingStage::default().unwind(&provider, unwind)?;
9997
MerkleStage::default_unwind().unwind(&provider, unwind)?;
10098

10199
// Bring Plainstate to TO (hashing stage execution requires it)
@@ -127,15 +125,13 @@ fn unwind_and_copy<N: ProviderNodeTypes>(
127125
commit_threshold: u64::MAX,
128126
etl_config: EtlConfig::default(),
129127
}
130-
.execute(&provider, execute_input)
131-
.unwrap();
128+
.execute(&provider, execute_input)?;
132129
StorageHashingStage {
133130
clean_threshold: u64::MAX,
134131
commit_threshold: u64::MAX,
135132
etl_config: EtlConfig::default(),
136133
}
137-
.execute(&provider, execute_input)
138-
.unwrap();
134+
.execute(&provider, execute_input)?;
139135

140136
let unwind_inner_tx = provider.into_tx();
141137

crates/cli/commands/src/stage/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub mod unwind;
1717
#[derive(Debug, Parser)]
1818
pub struct Command<C: ChainSpecParser> {
1919
#[command(subcommand)]
20-
command: Subcommands<C>,
20+
pub command: Subcommands<C>,
2121
}
2222

2323
/// `reth stage` subcommands

crates/cli/commands/src/stage/unwind.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ impl Subcommands {
220220

221221
#[cfg(test)]
222222
mod tests {
223-
use reth_ethereum_cli::chainspec::EthereumChainSpecParser;
224-
225223
use super::*;
224+
use reth_chainspec::SEPOLIA;
225+
use reth_ethereum_cli::chainspec::EthereumChainSpecParser;
226226

227227
#[test]
228228
fn parse_unwind() {
@@ -244,4 +244,13 @@ mod tests {
244244
]);
245245
assert_eq!(cmd.command, Subcommands::NumBlocks { amount: 100 });
246246
}
247+
248+
#[test]
249+
fn parse_unwind_chain() {
250+
let cmd = Command::<EthereumChainSpecParser>::parse_from([
251+
"reth", "--chain", "sepolia", "to-block", "100",
252+
]);
253+
assert_eq!(cmd.command, Subcommands::ToBlock { target: BlockHashOrNumber::Number(100) });
254+
assert_eq!(cmd.env.chain.chain_id(), SEPOLIA.chain_id());
255+
}
247256
}

0 commit comments

Comments
 (0)