Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trace response of traceBlockByHash is non-deterministic and get "execution reverted" error #23205

Closed
ghost opened this issue Jul 13, 2021 · 13 comments · Fixed by #24283 or #24286
Closed

Comments

@ghost
Copy link

ghost commented Jul 13, 2021

System information

Geth version: v1.10.2

Expected behaviour

  1. When getting block traces using traceBlockByHash, the response should be deterministic
  2. For a transaction with Success status, should not get "execution reverted" trace error

Actual behaviour

In Ethereum mainnet

  1. Run debug.traceBlockByHash("0x27049febec8fd16fb662d0d8c00f5ff7cec571b71585b18c30e0c6d2df93b4fe", {"tracer": "callTracer", "timeout": "60s"}) twice, get different trace result for the transaction 0x44de5f0ce469c09e4003f974e4ae119aea69ac461fdb0974fe410a1657284ce5

First time tx trace result:

    result: {
      calls: [{...}],
      from: "0x00000000c0293c8ca34dac9bcc0f953532d34e4d",
      gas: "0xa7ac",
      gasUsed: "0x6876",
      input: "0xca722cdc5ae6e1d89dcdb255d8851f3b47f374103d5022146b4e29a3bf4aea91993ae06fdd3d5766c2b7db16c171487fdb4800eaabf851f35488b76b33e53faa21b36588",
      output: "0x",
      time: "86.428742ms",
      to: "0xd1ceeeeee83f8bcf3bedad437202b6154e9f5405",
      type: "CALL",
      value: "0x0"
    }
}

Second time tx trace result:

{
    result: {
      error: "execution reverted",
      from: "0x00000000c0293c8ca34dac9bcc0f953532d34e4d",
      gas: "0xa7ac",
      gasUsed: "0xa8f",
      input: "0xca722cdc5ae6e1d89dcdb255d8851f3b47f374103d5022146b4e29a3bf4aea91993ae06fdd3d5766c2b7db16c171487fdb4800eaabf851f35488b76b33e53faa21b36588",
      time: "15.241119ms",
      to: "0xd1ceeeeee83f8bcf3bedad437202b6154e9f5405",
      type: "CALL",
      value: "0x0"
    }
}
  1. Why get "execution reverted" error for the successful transaction 0x44de5f0ce469c09e4003f974e4ae119aea69ac461fdb0974fe410a1657284ce5 at the second traceBlockByHash call
@ghost ghost added the type:bug label Jul 13, 2021
@ghost ghost changed the title Trace response of traceBlockByHash is non-deterministic and get "execution reverted" error randomly Trace response of traceBlockByHash is non-deterministic and get "execution reverted" error Jul 13, 2021
@rjl493456442
Copy link
Member

So I ran the tracing for a few times with the latest master code, but I can't reproduce your issue. Can you please try the latest master if it still happens to you?

geth attach ./ssd/geth_data/geth.ipc --exec "debug.traceBlockByHash('0x27049febec8fd16fb662d0d8c00f5ff7cec571b71585b18c30e0c6d2df93b4fe', {'tracer': 'callTracer',
'timeout': '60s'})" > output

@jiezhang
Copy link

jiezhang commented Jul 14, 2021

Here's another repro using a newer version v1.10.4. It returned out-of-gas error in the first call and subsequently traced the transaction successfully.

The transaction with non-deterministic tracing result is linked here.

After you try the following commands, you may need to wait for a while before you can repro the issue again, potentially due to some state being cached in the node.

Welcome to the Geth JavaScript console!

instance: Geth/v1.10.4-stable-aa637fd3/linux-amd64/go1.15.13
at block: 12826894 (Wed Jul 14 2021 12:06:57 GMT-0700 (PDT))
 modules: debug:1.0 eth:1.0 net:1.0 rpc:1.0 web3:1.0

To exit, press ctrl-d
> debug.traceBlockByNumber(11087337, {"tracer": "callTracer", "timeout": "60s"})[30]
{
  result: {
    calls: [{
        from: "0x06012c8cf97bead5deae237070f9587f8e7a266d",
        gas: "0x345fe",
        gasUsed: "0x19b0c",
        input: "0x0d9f5aed00006ad0859dab4a46372c493304c1a46c0a0a24b092428a07255b20582794e1000032d2b71c84498013aca2004ce7bd4578c8c7b1ea5398c4217a2a84a198030000000000000000000000000000000000000000000000000000000000a92da9",
        output: "0x00006ad28391c4480235b8450818e7a8650bc8c4bc8a430ac7215b50822198e1",
        to: "0xb77feddb7e627a78140a2a32cac65a49ed1dba8e",
        type: "CALL",
        value: "0x0"
    }],
    error: "out of gas",
    from: "0x09191d18729da57a83a9afc8ace0c8d7d104e118",
    gas: "0x38c86",
    gasUsed: "0x38c86",
    input: "0x88c2a0bf0000000000000000000000000000000000000000000000000000000000183e2c",
    time: "659.691392ms",
    to: "0x06012c8cf97bead5deae237070f9587f8e7a266d",
    type: "CALL",
    value: "0x0"
  }
}
> debug.traceBlockByNumber(11087337, {"tracer": "callTracer", "timeout": "60s"})[30]
{
  result: {
    calls: [{
        from: "0x06012c8cf97bead5deae237070f9587f8e7a266d",
        gas: "0x345fe",
        gasUsed: "0x195e2",
        input: "0x0d9f5aed00006ad0859dab4a46372c493304c1a46c0a0a24b092428a07255b20582794e1000032d2b71c84498013aca2004ce7bd4578c8c7b1ea5398c4217a2a84a198030000000000000000000000000000000000000000000000000000000000a92da9",
        output: "0x00006ad28590eb48d2172c4b0044c7a4651bc2c63df2428a07255b2a982198e0",
        to: "0xb77feddb7e627a78140a2a32cac65a49ed1dba8e",
        type: "CALL",
        value: "0x0"
    }, {
        from: "0x06012c8cf97bead5deae237070f9587f8e7a266d",
        input: "0x",
        output: "0x",
        to: "0x09191d18729da57a83a9afc8ace0c8d7d104e118",
        type: "CALL",
        value: "0x1c6bf526340000"
    }],
    from: "0x09191d18729da57a83a9afc8ace0c8d7d104e118",
    gas: "0x38c86",
    gasUsed: "0x383dd",
    input: "0x88c2a0bf0000000000000000000000000000000000000000000000000000000000183e2c",
    output: "0x00000000000000000000000000000000000000000000000000000000001e1289",
    time: "1.073330468s",
    to: "0x06012c8cf97bead5deae237070f9587f8e7a266d",
    type: "CALL",
    value: "0x0"
  }
}

@jiezhang
Copy link

We have observed lots of transactions exhibiting this non-deterministic tracing behavior. Coincidentally they all seem to interact with following two contracts:

@karalabe
Copy link
Member

Do you have some logs from the Geth node executing these? Do you see warnings that it might be running out of file descriptors? If the database remains without those, it starts returning empty responses to state requests, which might explain occasional bad traces.

@MariusVanDerWijden
Copy link
Member

@max-mapper
Copy link

max-mapper commented Oct 6, 2021

I am able to reproduce this issue by tracing the hash shared by OP: curl -X POST -H "Content-Type: application/json" --data '{"method":"debug_traceBlockByHash","params":["0x27049febec8fd16fb662d0d8c00f5ff7cec571b71585b18c30e0c6d2df93b4fe",{"tracer":"callTracer","timeout":null}],"id":15293,"jsonrpc":"2.0"}' http://localhost:8545

I ran that twice (on geth master, archive mode), the first time it took 30 seconds to complete, and the second 1.5 seconds. The only difference was this:

image

I'm also seeing many execution reverted errors on other blocks. Edit: there's nothing weird in our geth logs, and our ulimit -n is set to 1048576

@holiman
Copy link
Contributor

holiman commented Oct 7, 2021

@maxogden thanks, I'll try to debug this next week

@holiman
Copy link
Contributor

holiman commented Oct 11, 2021

I'm having some problems obtaining the data to repro this, since the blocks are so old. Does anyone have a more recent example to try and repro this with?

@ghost
Copy link
Author

ghost commented Jan 21, 2022

@holiman
Copy link
Contributor

holiman commented Jan 24, 2022

could you help take a look on this? Thanks

Yup, will do

@holiman holiman self-assigned this Jan 24, 2022
@holiman
Copy link
Contributor

holiman commented Jan 24, 2022

Ok, managed to repro it!

@holiman
Copy link
Contributor

holiman commented Jan 24, 2022

Out of 7 blockdumps, two are different from the other five. I set the node to archive-mode as it was processing that block, so this has nothing to do with any errors during the reexec-phase -- all the trie data is at hand.
Very curious.

1733636 jan 24 16:42 out.1
1733636 jan 24 16:43 out.2
1738663 jan 24 16:43 out.3
1733636 jan 24 16:43 out.4
1733636 jan 24 16:43 out.5
1738663 jan 24 16:43 out.6
1733636 jan 24 16:43 out.7

@ghost
Copy link
Author

ghost commented Jan 26, 2022

@holiman Thanks for the fix! Any idea when will this get released? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants