optimism icon indicating copy to clipboard operation
optimism copied to clipboard

Nonce too low error

Open ninjascant opened this issue 4 years ago • 6 comments

Describe the bug The Optimism Geth node returns an error while trying to trace some transactions. The error is:

{"code":-32000,"message":"tracing failed: nonce too low"}} To Reproduce Run this query that is trying to get traces for tx 0x8ed7d752c57d29bfbae73f8c80efe197a904ef44834865594589c4e2cc35f5b7:

curl -X POST --data '{"jsonrpc": "2.0", "method": "debug_traceTransaction", "params": ["0x8ed7d752c57d29bfbae73f8c80efe197a904ef44834865594589c4e2cc35f5b7", {"tracer": "callTracer"}], "id": 1}' -H "Content-Type: application/json" <provider_uri>

The same behaviour can be obtained with some other txs, like this: 0x0b9b8aebd6dc5ac693ea3337feec05e2472e968614d425f789949ffbcb63ccf6, and also while using debug_traceBlockByNumber method for blocks that contain such txs

Expected behavior Node returns traces for txs that are already included in the chain

ninjascant avatar Apr 12 '21 06:04 ninjascant

Also, there is a similar error: nonce too high. It can be reproduced with this query:

curl -X POST --data '{"jsonrpc": "2.0", "method": "debug_traceBlockByNumber", "params": ["0x18d53", {"tracer": "callTracer"}], "id": 1}' -H "Content-Type: application/json" <provider_uri>

ninjascant avatar Apr 12 '21 06:04 ninjascant

Which provider URI are you using? Is this on a local network after you created a specific transaction?

gakonst avatar Apr 12 '21 13:04 gakonst

Which provider URI are you using?

I use a private node provided by quicknode.io.

Is this on a local network after you created a specific transaction?

No. The errors were obtained when I tried to run debug_traceTransaction/debug_traceBlockByNumber on txs from Optimism main chain

ninjascant avatar Apr 13 '21 07:04 ninjascant

It appears as if both of these queries came from before the regenesis as both of the commands that you pasted resulted in transaction/block not found.

I was able to reproduce the problem post regenesis. I first started up a replica using this script https://github.com/ethereum-optimism/optimism/issues/473 (also added the debug namespace to the RPC) and then started iterating through blocks until I found one that deterministically caused the problem - height 7

#!/bin/bash

function trace() {
    DATA=$(printf '{"jsonrpc":"2.0","method":"debug_traceBlockByNumber","params":["0x%x",{"tracer":"callTracer"}],"id":1}' $1)
    echo "Querying height $1"
    curl --silent -X POST \
        --data "$DATA" \
         -H "Content-Type: application/json" \
         http://localhost:8045 | jq .error
}

trace 7
exit

# To find the transactions that cause problems
for i in {0..10}
do
    trace $i
done

tynes avatar Apr 20 '21 02:04 tynes

The root cause is that queue origin L1 to L2 transactions (sent via enqueue) do not have a from and do not increment a nonce in the state. The queue index is set as the nonce in the RLP encoded transaction to prevent hash collisions. debug_traceBlockByNumber will not work for L1 to L2 transactions currently

tynes avatar Apr 20 '21 03:04 tynes

@tynes does this still happen? It seems important for debug_trace* to work for deposits.

smartcontracts avatar Nov 04 '21 19:11 smartcontracts

Closing for lack of activity. I believe this is fixed. We can reopen if anyone runs into the same issue in the future.

smartcontracts avatar Sep 06 '22 18:09 smartcontracts