Skip to content

Commit

Permalink
feat(debug): add debug_executionWitness to debug api (#1649)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected authored Nov 14, 2024
1 parent 8d6c579 commit 49245f2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ alloy-rpc-client.workspace = true
alloy-rpc-types-admin = { workspace = true, optional = true }
alloy-rpc-types-anvil = { workspace = true, optional = true }
alloy-rpc-types-eth = { workspace = true, features = ["serde"] }
alloy-rpc-types-debug = { workspace = true, optional = true }
alloy-rpc-types-trace = { workspace = true, optional = true }
alloy-rpc-types-txpool = { workspace = true, optional = true }
alloy-rpc-types-engine = { workspace = true, optional = true, features = [
Expand Down Expand Up @@ -118,7 +119,7 @@ anvil-node = [
"dep:alloy-signer-local",
"dep:alloy-signer",
]
debug-api = ["dep:alloy-rpc-types-trace"]
debug-api = ["dep:alloy-rpc-types-trace", "dep:alloy-rpc-types-debug"]
erc4337-api = []
engine-api = ["dep:alloy-rpc-types-engine"]
net-api = []
Expand Down
23 changes: 23 additions & 0 deletions crates/provider/src/ext/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use crate::Provider;
use alloy_network::Network;
use alloy_primitives::{hex, Bytes, TxHash, B256};
use alloy_rpc_types_debug::ExecutionWitness;
use alloy_rpc_types_eth::{
BadBlock, BlockId, BlockNumberOrTag, Bundle, StateContext, TransactionRequest,
};
Expand Down Expand Up @@ -128,6 +129,21 @@ pub trait DebugApi<N, T>: Send + Sync {
state_context: StateContext,
trace_options: GethDebugTracingCallOptions,
) -> TransportResult<Vec<GethTrace>>;

/// The `debug_executionWitness` method allows for re-execution of a block with the purpose of
/// generating an execution witness. The witness comprises of a map of all hashed trie nodes to
/// their preimages that were required during the execution of the block, including during
/// state root recomputation.
///
/// The first argument is the block number or block hash.
///
/// # Note
///
/// Not all nodes support this call.
async fn debug_execution_witness(
&self,
block: BlockNumberOrTag,
) -> TransportResult<ExecutionWitness>;
}

#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))]
Expand Down Expand Up @@ -216,6 +232,13 @@ where
) -> TransportResult<Vec<GethTrace>> {
self.client().request("debug_traceCallMany", (bundles, state_context, trace_options)).await
}

async fn debug_execution_witness(
&self,
block: BlockNumberOrTag,
) -> TransportResult<ExecutionWitness> {
self.client().request("debug_executionWitness", block).await
}
}

#[cfg(test)]
Expand Down

0 comments on commit 49245f2

Please sign in to comment.