From 672e4c512cdd99b6fcfb8dec9940a5150d5b16a7 Mon Sep 17 00:00:00 2001 From: Delweng Date: Tue, 23 Apr 2024 20:26:57 +0800 Subject: [PATCH] chore(bin/stage): add explicit doc of the use of to-block and hashing stage (#7805) Signed-off-by: jsvisa Co-authored-by: Oliver Nordbjerg --- bin/reth/src/commands/stage/unwind.rs | 9 +++++++-- crates/node-core/src/args/stage_args.rs | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/reth/src/commands/stage/unwind.rs b/bin/reth/src/commands/stage/unwind.rs index a1fe7d8a0..2682683d4 100644 --- a/bin/reth/src/commands/stage/unwind.rs +++ b/bin/reth/src/commands/stage/unwind.rs @@ -236,10 +236,12 @@ impl Command { /// `reth stage unwind` subcommand #[derive(Subcommand, Debug, Eq, PartialEq)] enum Subcommands { - /// Unwinds the database until the given block number (range is inclusive). + /// Unwinds the database from the latest block, until the given block number or hash has been + /// reached, that block is not included. #[command(name = "to-block")] ToBlock { target: BlockHashOrNumber }, - /// Unwinds the given number of blocks from the database. + /// Unwinds the database from the latest block, until the given number of blocks have been + /// reached. #[command(name = "num-blocks")] NumBlocks { amount: u64 }, } @@ -263,6 +265,9 @@ impl Subcommands { }, Subcommands::NumBlocks { amount } => last.saturating_sub(*amount), } + 1; + if target > last { + eyre::bail!("Target block number is higher than the latest block number") + } Ok(target..=last) } } diff --git a/crates/node-core/src/args/stage_args.rs b/crates/node-core/src/args/stage_args.rs index d90eabcfc..337f5a4a6 100644 --- a/crates/node-core/src/args/stage_args.rs +++ b/crates/node-core/src/args/stage_args.rs @@ -30,11 +30,11 @@ pub enum StageEnum { /// /// Manages operations related to hashing storage data. StorageHashing, - /// The hashing stage within the pipeline. + /// The account and storage hashing stages within the pipeline. /// /// Covers general data hashing operations. Hashing, - /// The Merkle stage within the pipeline. + /// The merkle stage within the pipeline. /// /// Handles Merkle tree-related computations and data processing. Merkle,