0xPolygonHermez / zkevm-node

Go implementation of a node that operates the Polygon zkEVM Network
Other
539 stars 699 forks source link

Failed to trace a first block #3454

Closed begmaroman closed 8 months ago

begmaroman commented 8 months ago

System information

zkEVM Node version: v0.0.X-RCXX OS & Version: OSX Commit hash : 567d1df3b05ec37d6d4eb9a3ef5d0b24764aa826 Network: Mainnet/Testnet

Expected behaviour

After running a network, I can successfully trace a first block using "debug_traceBlockByNumber" endpoint.

Actual behaviour

"debug_traceBlockByNumber" endpoint of the first block returns the following error:

failed to get trace for transaction 0xfcd9fff0177d0e86727354a93ac01e15b7c682ddfbbcc33a54dcece43f7db268: failed to get trace: batch v2 must start with changeL2Block before Tx (suspect a V1 Batch or a ForcedBatch?))

Steps to reproduce the behaviour

  1. cd test
  2. make run
  3. pull https://github.com/0xPolygonHermez/zkevm-node/compare/bug/tracing-first-block-issue?expand=1 bracnh and run "Test_DebugFirstBatch" test

Backtrace

=== RUN   Test_DebugFirstBatch
    debug_1batch_test.go:31: {
          "jsonrpc": "2.0",
          "id": 1,
          "error": {
            "code": -32000,
            "message": "failed to get trace for transaction 0xfcd9fff0177d0e86727354a93ac01e15b7c682ddfbbcc33a54dcece43f7db268: failed to get trace: batch v2 must start with changeL2Block before Tx (suspect a V1 Batch or a ForcedBatch?))"
          }
        }
--- PASS: Test_DebugFirstBatch (0.02s)
PASS
tclemos commented 8 months ago

This happens because networks starting with a forkID from Etrog will have their first block containing a particular transaction called Injected TX.

This Injected TX requires a different way to be executed. I've adapted the code to process this particular transaction when tracing it In this commit https://github.com/0xPolygonHermez/zkevm-node/commit/97696723906bb4893d5c6760e1cd318aa456af48