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

fix(core): clarify Geth trace structs #1626

Merged
merged 3 commits into from
Aug 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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