1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! `reth debug` command. Collection of various debugging routines.

use clap::{Parser, Subcommand};
use reth_cli_runner::CliContext;

mod build_block;
mod execution;
mod in_memory_merkle;
mod merkle;
mod replay_engine;

/// `reth debug` command
#[derive(Debug, Parser)]
pub struct Command {
    #[command(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),
    /// Debug in-memory state root calculation.
    InMemoryMerkle(in_memory_merkle::Command),
    /// Debug block building.
    BuildBlock(build_block::Command),
    /// Debug engine API by replaying stored messages.
    ReplayEngine(replay_engine::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(ctx).await,
            Subcommands::InMemoryMerkle(command) => command.execute(ctx).await,
            Subcommands::BuildBlock(command) => command.execute(ctx).await,
            Subcommands::ReplayEngine(command) => command.execute(ctx).await,
        }
    }
}