mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 09:08:05 -05:00
chore(cli): unify debugging routines into a single command (#2849)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
//! CLI definition and entrypoint to executable
|
||||
use crate::{
|
||||
chain, config, db,
|
||||
chain, config, db, debug_cmd,
|
||||
dirs::{LogsDir, PlatformPath},
|
||||
execution_debug, merkle_debug, node, p2p,
|
||||
node, p2p,
|
||||
runner::CliRunner,
|
||||
stage, test_vectors,
|
||||
version::{LONG_VERSION, SHORT_VERSION},
|
||||
@@ -36,10 +36,7 @@ pub fn run() -> eyre::Result<()> {
|
||||
Commands::P2P(command) => runner.run_until_ctrl_c(command.execute()),
|
||||
Commands::TestVectors(command) => runner.run_until_ctrl_c(command.execute()),
|
||||
Commands::Config(command) => runner.run_until_ctrl_c(command.execute()),
|
||||
Commands::MerkleDebug(command) => runner.run_until_ctrl_c(command.execute()),
|
||||
Commands::ExecutionDebug(command) => {
|
||||
runner.run_command_until_exit(|ctx| command.execute(ctx))
|
||||
}
|
||||
Commands::Debug(command) => runner.run_command_until_exit(|ctx| command.execute(ctx)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,12 +67,9 @@ pub enum Commands {
|
||||
/// Write config to stdout
|
||||
#[command(name = "config")]
|
||||
Config(config::Command),
|
||||
/// Debug state root calculation
|
||||
#[command(name = "merkle-debug")]
|
||||
MerkleDebug(merkle_debug::Command),
|
||||
/// Debug execution.
|
||||
#[command(name = "execution-debug")]
|
||||
ExecutionDebug(execution_debug::Command),
|
||||
/// Various debug routines
|
||||
#[command(name = "debug")]
|
||||
Debug(debug_cmd::Command),
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
|
||||
@@ -95,15 +95,11 @@ pub struct Command {
|
||||
|
||||
/// The block interval for sync and unwind.
|
||||
/// Defaults to `1000`.
|
||||
#[arg(long)]
|
||||
pub interval: Option<u64>,
|
||||
#[arg(long, default_value = "1000")]
|
||||
pub interval: u64,
|
||||
}
|
||||
|
||||
impl Command {
|
||||
fn interval(&self) -> u64 {
|
||||
self.interval.unwrap_or(1000)
|
||||
}
|
||||
|
||||
fn build_pipeline<DB, Client>(
|
||||
&self,
|
||||
config: &Config,
|
||||
@@ -262,11 +258,10 @@ impl Command {
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
let interval = self.interval();
|
||||
let mut current_max_block = latest_block_number;
|
||||
while current_max_block < self.to {
|
||||
let next_block = current_max_block + 1;
|
||||
let target_block = self.to.min(current_max_block + interval);
|
||||
let target_block = self.to.min(current_max_block + self.interval);
|
||||
let target_block_hash =
|
||||
self.fetch_block_hash(fetch_client.clone(), target_block).await?;
|
||||
|
||||
33
bin/reth/src/debug_cmd/mod.rs
Normal file
33
bin/reth/src/debug_cmd/mod.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
//! `reth debug` command. Collection of various debugging routines.
|
||||
use clap::{Parser, Subcommand};
|
||||
|
||||
use crate::runner::CliContext;
|
||||
|
||||
mod execution;
|
||||
mod merkle;
|
||||
|
||||
/// `reth debug` command
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Command {
|
||||
#[clap(subcommand)]
|
||||
command: Subcommands,
|
||||
}
|
||||
|
||||
/// `reth debug` subcommands
|
||||
#[derive(Subcommand, Debug)]
|
||||
pub enum Subcommands {
|
||||
/// Debug the roundtrip execution of blocks as well as the generated data.
|
||||
Execution(execution::Command),
|
||||
/// Debug the clean & incremental state root calculations.
|
||||
Merkle(merkle::Command),
|
||||
}
|
||||
|
||||
impl Command {
|
||||
/// Execute `debug` command
|
||||
pub async fn execute(self, ctx: CliContext) -> eyre::Result<()> {
|
||||
match self.command {
|
||||
Subcommands::Execution(command) => command.execute(ctx).await,
|
||||
Subcommands::Merkle(command) => command.execute().await,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,9 +12,8 @@ pub mod chain;
|
||||
pub mod cli;
|
||||
pub mod config;
|
||||
pub mod db;
|
||||
pub mod debug_cmd;
|
||||
pub mod dirs;
|
||||
pub mod execution_debug;
|
||||
pub mod merkle_debug;
|
||||
pub mod node;
|
||||
pub mod p2p;
|
||||
pub mod prometheus_exporter;
|
||||
|
||||
@@ -29,7 +29,7 @@ pub enum Subcommands {
|
||||
}
|
||||
|
||||
impl Command {
|
||||
/// Execute `db` command
|
||||
/// Execute `stage` command
|
||||
pub async fn execute(self) -> eyre::Result<()> {
|
||||
match self.command {
|
||||
Subcommands::Run(command) => command.execute().await,
|
||||
|
||||
Reference in New Issue
Block a user