Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
fix(core): clarify Geth trace structs (#1626)
Browse files Browse the repository at this point in the history
* fix(core): clarify Geth trace structs

* add geth references

* add fields matching to geth
  • Loading branch information
shekhirin authored Aug 22, 2022
1 parent 9817486 commit 7c26550
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions ethers-core/src/types/trace/geth.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
use crate::types::{Bytes, H256, U256};
use crate::types::{Bytes, H160, H256, U256};
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;

// https://github.com/ethereum/go-ethereum/blob/a9ef135e2dd53682d106c6a2aede9187026cc1de/eth/tracers/logger/logger.go#L406-L411
#[derive(Serialize, Deserialize, Debug)]
pub struct GethTrace {
failed: bool,
gas: u64,
pub failed: bool,
pub gas: u64,
#[serde(rename = "returnValue")]
return_value: Bytes,
pub return_value: Bytes,
#[serde(rename = "structLogs")]
struct_logs: Vec<StructLog>,
pub struct_logs: Vec<StructLog>,
}

// https://github.com/ethereum/go-ethereum/blob/366d2169fbc0e0f803b68c042b77b6b480836dbc/eth/tracers/logger/logger.go#L413-L426
#[derive(Serialize, Deserialize, Debug)]
pub struct StructLog {
depth: u64,
error: Option<String>,
gas: u64,
pub depth: u64,
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<String>,
pub gas: u64,
#[serde(rename = "gasCost")]
gas_cost: u64,
memory: Option<Vec<String>>,
op: String,
pc: U256,
stack: Vec<String>,
storage: BTreeMap<H256, H256>,
pub gas_cost: u64,
#[serde(skip_serializing_if = "Option::is_none")]
pub memory: Option<Vec<u8>>,
pub op: String,
pub pc: U256,
#[serde(rename = "refund", skip_serializing_if = "Option::is_none")]
pub refund_counter: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub stack: Option<Vec<U256>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub storage: Option<BTreeMap<H160, BTreeMap<H256, H256>>>,
}

/// Bindings for additional `debug_traceTransaction` options
Expand Down

0 comments on commit 7c26550

Please sign in to comment.