From 7c265500646c301b12a6a1fe00eec032b1908396 Mon Sep 17 00:00:00 2001 From: Alexey Shekhirin Date: Mon, 22 Aug 2022 17:48:02 +0100 Subject: [PATCH] fix(core): clarify Geth trace structs (#1626) * fix(core): clarify Geth trace structs * add geth references * add fields matching to geth --- ethers-core/src/types/trace/geth.rs | 36 ++++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/ethers-core/src/types/trace/geth.rs b/ethers-core/src/types/trace/geth.rs index 786099c9..5cb38509 100644 --- a/ethers-core/src/types/trace/geth.rs +++ b/ethers-core/src/types/trace/geth.rs @@ -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, + pub struct_logs: Vec, } +// 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, - gas: u64, + pub depth: u64, + #[serde(skip_serializing_if = "Option::is_none")] + pub error: Option, + pub gas: u64, #[serde(rename = "gasCost")] - gas_cost: u64, - memory: Option>, - op: String, - pc: U256, - stack: Vec, - storage: BTreeMap, + pub gas_cost: u64, + #[serde(skip_serializing_if = "Option::is_none")] + pub memory: Option>, + pub op: String, + pub pc: U256, + #[serde(rename = "refund", skip_serializing_if = "Option::is_none")] + pub refund_counter: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub stack: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub storage: Option>>, } /// Bindings for additional `debug_traceTransaction` options