This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 792
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(debug_traceTransaction): initial commit (#1469)
* feat(debug_traceTransaction): initial commit * chore(changelog): updated changelog * feat(debug_traceTransaction): type adjusments * feat(debug_traceTransaction): type adjusments * Update ethers-providers/src/provider.rs Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * Update ethers-providers/src/provider.rs Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * chore(format): cargo +nightly fmt Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
- Loading branch information
1 parent
d22fb2b
commit cb7e586
Showing
6 changed files
with
94 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use crate::types::{Bytes, H256, U256}; | ||
use serde::{Deserialize, Serialize}; | ||
use std::collections::BTreeMap; | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub struct GethTrace { | ||
failed: bool, | ||
gas: u64, | ||
#[serde(rename = "returnValue")] | ||
return_value: Bytes, | ||
#[serde(rename = "structLogs")] | ||
struct_logs: Vec<StructLog>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub struct StructLog { | ||
depth: u64, | ||
error: Option<String>, | ||
gas: u64, | ||
#[serde(rename = "gasCost")] | ||
gas_cost: u64, | ||
memory: Option<Vec<String>>, | ||
op: String, | ||
pc: U256, | ||
stack: Vec<String>, | ||
storage: BTreeMap<H256, H256>, | ||
} | ||
|
||
/// Bindings for additional `debug_traceTransaction` options | ||
/// | ||
/// See <https://geth.ethereum.org/docs/rpc/ns-debug#debug_tracetransaction> | ||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Default)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct GethDebugTracingOptions { | ||
#[serde(default, skip_serializing_if = "Option::is_none")] | ||
pub disable_storage: Option<bool>, | ||
#[serde(default, skip_serializing_if = "Option::is_none")] | ||
pub disable_stack: Option<bool>, | ||
#[serde(default, skip_serializing_if = "Option::is_none")] | ||
pub enable_memory: Option<bool>, | ||
#[serde(default, skip_serializing_if = "Option::is_none")] | ||
pub enable_return_data: Option<bool>, | ||
#[serde(default, skip_serializing_if = "Option::is_none")] | ||
pub tracer: Option<String>, | ||
#[serde(default, skip_serializing_if = "Option::is_none")] | ||
pub timeout: Option<String>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use ethers::prelude::*; | ||
use eyre::Result; | ||
use std::{env, str::FromStr}; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
let rpc_url: String = env::var("RPC_URL")?; | ||
let client = Provider::<Http>::try_from(rpc_url)?; | ||
let tx_hash = "0x97a02abf405d36939e5b232a5d4ef5206980c5a6661845436058f30600c52df7"; | ||
let h: H256 = H256::from_str(tx_hash)?; | ||
let options: GethDebugTracingOptions = GethDebugTracingOptions::default(); | ||
let traces = client.debug_trace_transaction(h, options).await?; | ||
println!("{:?}", traces); | ||
|
||
Ok(()) | ||
} |