reth/commands/debug_cmd/
mod.rs
1use 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;
10use std::sync::Arc;
11
12mod build_block;
13mod execution;
14mod in_memory_merkle;
15mod merkle;
16
17#[derive(Debug, Parser)]
19pub struct Command<C: ChainSpecParser> {
20 #[command(subcommand)]
21 command: Subcommands<C>,
22}
23
24#[derive(Subcommand, Debug)]
26pub enum Subcommands<C: ChainSpecParser> {
27 Execution(execution::Command<C>),
29 Merkle(merkle::Command<C>),
31 InMemoryMerkle(in_memory_merkle::Command<C>),
33 BuildBlock(build_block::Command<C>),
35}
36
37impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
38 pub async fn execute<
40 N: CliNodeTypes<
41 Payload = EthEngineTypes,
42 Primitives = EthPrimitives,
43 ChainSpec = C::ChainSpec,
44 >,
45 >(
46 self,
47 ctx: CliContext,
48 ) -> eyre::Result<()> {
49 match self.command {
50 Subcommands::Execution(command) => command.execute::<N>(ctx).await,
51 Subcommands::Merkle(command) => command.execute::<N>(ctx).await,
52 Subcommands::InMemoryMerkle(command) => command.execute::<N>(ctx).await,
53 Subcommands::BuildBlock(command) => command.execute::<N>(ctx).await,
54 }
55 }
56 pub const fn chain_spec(&self) -> Option<&Arc<C::ChainSpec>> {
58 match &self.command {
59 Subcommands::Execution(command) => command.chain_spec(),
60 Subcommands::Merkle(command) => command.chain_spec(),
61 Subcommands::InMemoryMerkle(command) => command.chain_spec(),
62 Subcommands::BuildBlock(command) => command.chain_spec(),
63 }
64 }
65}