DebugNode

Trait DebugNode 

Source
pub trait DebugNode<N: FullNodeComponents>: Node<N> {
    type RpcBlock: Serialize + DeserializeOwned + 'static;

    // Required methods
    fn rpc_to_primitive_block(rpc_block: Self::RpcBlock) -> BlockTy<Self>;
    fn local_payload_attributes_builder(
        chain_spec: &Self::ChainSpec,
    ) -> impl PayloadAttributesBuilder<<<Self as NodeTypes>::Payload as PayloadTypes>::PayloadAttributes>;
}
Expand description

Node extension with support for debugging utilities.

This trait provides additional necessary conversion from RPC block type to the node’s primitive block type, e.g. alloy_rpc_types_eth::Block to the node’s internal block representation.

This is used in conjunction with the DebugNodeLauncher to enable debugging features such as:

  • Etherscan Integration: Use Etherscan as a consensus client to follow the chain and submit blocks to the local engine.
  • RPC Consensus Client: Connect to an external RPC endpoint to fetch blocks and submit them to the local engine to follow the chain.

See DebugNodeLauncher for the launcher that enables these features.

§Implementation

To implement this trait, you need to:

  1. Define the RPC block type (typically alloy_rpc_types_eth::Block)
  2. Implement the conversion from RPC format to your primitive block type

§Example

impl<N: FullNodeComponents<Types = Self>> DebugNode<N> for MyNode {
    type RpcBlock = alloy_rpc_types_eth::Block;

    fn rpc_to_primitive_block(rpc_block: Self::RpcBlock) -> BlockTy<Self> {
        // Convert from RPC format to primitive format by converting the transactions
        rpc_block.into_consensus().convert_transactions()
    }
}

Required Associated Types§

Source

type RpcBlock: Serialize + DeserializeOwned + 'static

RPC block type. Used by [DebugConsensusClient] to fetch blocks and submit them to the engine. This is intended to match the block format returned by the external RPC endpoint.

Required Methods§

Source

fn rpc_to_primitive_block(rpc_block: Self::RpcBlock) -> BlockTy<Self>

Converts an RPC block to a primitive block.

This method handles the conversion between the RPC block format and the internal primitive block format used by the node’s consensus engine.

§Example

For Ethereum nodes, this typically converts from alloy_rpc_types_eth::Block to the node’s internal block representation.

Source

fn local_payload_attributes_builder( chain_spec: &Self::ChainSpec, ) -> impl PayloadAttributesBuilder<<<Self as NodeTypes>::Payload as PayloadTypes>::PayloadAttributes>

Creates a payload attributes builder for local mining in dev mode.

It will be used by the LocalMiner when dev mode is enabled.

The builder is responsible for creating the payload attributes that define how blocks should be constructed during local mining.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§