gakonst / ethers-rs

Complete Ethereum & Celo library and wallet implementation in Rust. https://docs.rs/ethers
Apache License 2.0
2.47k stars 796 forks source link

debug_trace_transaction with Erigon #2276

Open andy-thomason opened 1 year ago

andy-thomason commented 1 year ago

Version 2.0.0

Platform Linux sc-devbox-01 5.13.0-52-generic #59~20.04.1-Ubuntu SMP Thu Jun 16 21:21:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Description

Erigon StructLog has error as an Object, not a string.

I would suggest substituting a Value for string:

https://github.com/gakonst/ethers-rs/blob/master/ethers-core/src/types/trace/geth.rs#L37

s/String/Value/

pub struct StructLog {
    pub depth: u64,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub error: Option<String>,
   ...

Test data:

      {
        "pc": 131,
        "op": "SSTORE",
        "gas": 18441,
        "gasCost": 20000,
        "depth": 1,
        "error": {},
        "stack": [
          "0xa2e62045",
          "0x85",
          "0x1",
          "0x0"
        ],
        "memory": [
          "0000000000000000000000000000000000000000000000000000000000000000",
          "0000000000000000000000000000000000000000000000000000000000000000",
          "0000000000000000000000000000000000000000000000000000000000000060"
        ],
        "storage": {
          "0000000000000000000000000000000000000000000000000000000000000000": "0000000000000000000000000000000000000000000000000000000000000001"
        }
      }
mattsse commented 1 year ago

hmm this should serialize as string, right?

https://github.com/ethereum/go-ethereum/blob/ee530c0d5aa70d2c00ab5691a89ab431b73f8165/eth/tracers/logger/logger.go#L77-L77

mind checking the erigon code if that differs and if {} is just null?

because the error in structlog is supposed to be a string: https://geth.ethereum.org/docs/developers/evm-tracing/built-in-tracers

andy-thomason commented 1 year ago

I have no doubt that it is an Erigon bug. I'll take a look at the source code.

The example I gave contained an out of gas error (following a divergence reproducing the DAO fork).