Skip to content

Commit

Permalink
trace err
Browse files Browse the repository at this point in the history
  • Loading branch information
rauljordan committed Jun 12, 2024
1 parent 95ff272 commit 06de217
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions replay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ libc.workspace = true
libloading.workspace = true
parking_lot.workspace = true
rustc-host.workspace = true
serde = { version = "1.0.203", features = ["derive"] }
sneks.workspace = true
tokio.workspace = true
19 changes: 18 additions & 1 deletion replay/src/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ use ethers::{
types::{
GethDebugTracerType, GethDebugTracingOptions, GethTrace, Transaction, TransactionReceipt,
},
utils::__serde_json::Value,
utils::__serde_json::{from_value, Value},
};
use eyre::{bail, Result};
use serde::{Deserialize, Serialize};
use sneks::SimpleSnakeNames;
use std::{collections::VecDeque, mem};

Expand Down Expand Up @@ -44,6 +45,17 @@ impl Trace {
bail!("malformed tracing result")
};

if let Value::Array(arr) = json.clone() {
if arr.is_empty() {
bail!("No trace frames found, perhaps you are attempting to trace the program deployment transaction");
}
}

let maybe_activation_trace: Result<Vec<ActivationTraceFrame>, _> = from_value(json.clone());
if maybe_activation_trace.is_ok() {
bail!("Your tx was a program activation transaction. It has no trace frames");
}

let to = receipt.to.map(|x| Address::from(x.0));
let top_frame = TraceFrame::parse_frame(to, json.clone())?;

Expand All @@ -63,6 +75,11 @@ impl Trace {
}
}

#[derive(Serialize, Deserialize)]
pub struct ActivationTraceFrame {
address: Value,
}

#[derive(Clone, Debug)]
pub struct TraceFrame {
steps: Vec<Hostio>,
Expand Down

0 comments on commit 06de217

Please sign in to comment.