reth/commands/debug_cmd/
mod.rs

1//! `reth debug` command. Collection of various debugging routines.
2
3use clap::{Parser, Subcommand};
4use reth_chainspec::ChainSpec;
5use reth_cli::chainspec::ChainSpecParser;
6use reth_cli_commands::common::CliNodeTypes;
7use reth_cli_runner::CliContext;
8use reth_ethereum_primitives::EthPrimitives;
9use reth_node_ethereum::EthEngineTypes;
10
11mod build_block;
12mod execution;
13mod in_memory_merkle;
14mod merkle;
15
16/// `reth debug` command
17#[derive(Debug, Parser)]
18pub struct Command<C: ChainSpecParser> {
19    #[command(subcommand)]
20    command: Subcommands<C>,
21}
22
23/// `reth debug` subcommands
24#[derive(Subcommand, Debug)]
25pub enum Subcommands<C: ChainSpecParser> {
26    /// Debug the roundtrip execution of blocks as well as the generated data.
27    Execution(execution::Command<C>),
28    /// Debug the clean & incremental state root calculations.
29    Merkle(merkle::Command<C>),
30    /// Debug in-memory state root calculation.
31    InMemoryMerkle(in_memory_merkle::Command<C>),
32    /// Debug block building.
33    BuildBlock(build_block::Command<C>),
34}
35
36impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
37    /// Execute `debug` command
38    pub async fn execute<
39        N: CliNodeTypes<Engine = EthEngineTypes, Primitives = EthPrimitives, ChainSpec = C::ChainSpec>,
40    >(
41        self,
42        ctx: CliContext,
43    ) -> eyre::Result<()> {
44        match self.command {
45            Subcommands::Execution(command) => command.execute::<N>(ctx).await,
46            Subcommands::Merkle(command) => command.execute::<N>(ctx).await,
47            Subcommands::InMemoryMerkle(command) => command.execute::<N>(ctx).await,
48            Subcommands::BuildBlock(command) => command.execute::<N>(ctx).await,
49        }
50    }
51}