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

Prestate Tracer reported incorrect nonce for address being created #28439

Closed
noel2004 opened this issue Oct 31, 2023 · 3 comments
Closed

Prestate Tracer reported incorrect nonce for address being created #28439

noel2004 opened this issue Oct 31, 2023 · 3 comments
Labels

Comments

@noel2004
Copy link

System information

Geth version: Above 12.0, with debug API enabled in RPC

Expected behaviour

For a deployment tx. While calling debug_tracedTransaction with prestate tracer being specified, since the contract at 0x0b96fec58064f3407ca8336426054d0352a48567 is beging deployed so the nonce in prestate for this address should be 0. Or there should be no any entry for this address (according to some discussion for the creation

Actual behaviour

prestate tracer reported 0x0b96fec58064f3407ca8336426054d0352a48567 with nonce of 1:

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "0x0b96fec58064f3407ca8336426054d0352a48567": {
            "balance": "0x0",
            "nonce": 1,
            "storage": {
                "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0x0000000000000000000000000000000000000000000000000000000000000005": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0x0000000000000000000000000000000000000000000000000000000000000006": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0x0000000000000000000000000000000000000000000000000000000000000007": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0x0000000000000000000000000000000000000000000000000000000000000008": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0x0000000000000000000000000000000000000000000000000000000000000009": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0x000000000000000000000000000000000000000000000000000000000000000a": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0x000000000000000000000000000000000000000000000000000000000000000b": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0x000000000000000000000000000000000000000000000000000000000000000c": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0x000000000000000000000000000000000000000000000000000000000000000d": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0x000000000000000000000000000000000000000000000000000000000000000e": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0x000000000000000000000000000000000000000000000000000000000000000f": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0x0000000000000000000000000000000000000000000000000000000000000010": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0x0000000000000000000000000000000000000000000000000000000000000011": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0x0000000000000000000000000000000000000000000000000000000000000012": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0x0000000000000000000000000000000000000000000000000000000000000013": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0xb315cdd88ca22ece6d4f62a7e497509bef421e4416dbb9ed70552ccabf555f5d": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0xb5404d7cb54ab2e7b3ead812eae081c4b9e3f52c2a8d91d2a1b746239103f1ea": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0xe8606e3a62d90ea1b10be4c36159d8ee53cb53db4ee3bbe8cc66661363b7e3e3": "0x0000000000000000000000000000000000000000000000000000000000000000"
            }
        },
...
}

Steps to reproduce the behaviour

Call the debug API of a geth node, for example, using following cmd:

curl <URL for RPC node> \
-X POST \
-H "Content-Type: application/json" \
--data '{"method":"debug_traceTransaction","params":["0x4544af322f2b63d8dbe4dcd41c6c80535095d93406b316087706adca97e662b3", {"tracer": "prestateTracer"}], "id":1,"jsonrpc":"2.0"}'

Discussion

Note that there is more account being created in the tx above like 0x9426105341f2fe684f3218f33987c453faf42de4, and prestate tracer report correct nonce (0) for this address. We note that 0x0b96fec58064f3407ca8336426054d0352a48567 should have be traced in the CaptureStart hook, where the to address has been initialized and nonce being set to 1 rather than 0. This has also made the exist method return true and the address is not pruned in the final result.

@s1na
Copy link
Contributor

s1na commented Nov 3, 2023

This will be fixed as part of the #27629 refactor. Thanks for reporting.

@holiman
Copy link
Contributor

holiman commented Dec 4, 2023

This error was introduced here: #25996 . So,

  • Previously, we deleted the prestate (e.g. there could be existing balance) on deployments.
  • It was changed, so that the prestate was not deleted,
  • However, turns out the change didn't take into account that the info from lookupAccount was not the origianl in-state value, but rather the value after nonce-increase and balance-increase (?)

@holiman
Copy link
Contributor

holiman commented Apr 24, 2024

I think this was fixed by #29189 . Please reopen if that's not the case (cc @s1na )

@holiman holiman closed this as completed Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants