fix(core): clarify Geth trace structs (#1626)

* fix(core): clarify Geth trace structs

* add geth references

* add fields matching to geth
This commit is contained in:
Alexey Shekhirin 2022-08-22 17:48:02 +01:00 committed by GitHub
parent 98174863c9
commit 7c26550064
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 14 deletions

View File

@ -1,29 +1,37 @@
use crate::types::{Bytes, H256, U256}; use crate::types::{Bytes, H160, H256, U256};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::BTreeMap; use std::collections::BTreeMap;
// https://github.com/ethereum/go-ethereum/blob/a9ef135e2dd53682d106c6a2aede9187026cc1de/eth/tracers/logger/logger.go#L406-L411
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct GethTrace { pub struct GethTrace {
failed: bool, pub failed: bool,
gas: u64, pub gas: u64,
#[serde(rename = "returnValue")] #[serde(rename = "returnValue")]
return_value: Bytes, pub return_value: Bytes,
#[serde(rename = "structLogs")] #[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)] #[derive(Serialize, Deserialize, Debug)]
pub struct StructLog { pub struct StructLog {
depth: u64, pub depth: u64,
error: Option<String>, #[serde(skip_serializing_if = "Option::is_none")]
gas: u64, pub error: Option<String>,
pub gas: u64,
#[serde(rename = "gasCost")] #[serde(rename = "gasCost")]
gas_cost: u64, pub gas_cost: u64,
memory: Option<Vec<String>>, #[serde(skip_serializing_if = "Option::is_none")]
op: String, pub memory: Option<Vec<u8>>,
pc: U256, pub op: String,
stack: Vec<String>, pub pc: U256,
storage: BTreeMap<H256, H256>, #[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 /// Bindings for additional `debug_traceTransaction` options