0xPolygonHermez / zkevm-contracts

Polygon zkEVM Smart Contracts
Other
273 stars 314 forks source link

`etherMan.PolygonBridge.NetworkID` panic with error: "invalid opcode %!s(MISSING)" #141

Closed bap2pecs closed 1 year ago

bap2pecs commented 1 year ago

Problem

I was following https://wiki.polygon.technology/docs/zkevm/step3-fullzkevm/ and deployed the full zkEVM but I see zkevm-bridge-service exit with code 1.

Root Cause Analysis

By examining the contain logs, I see

zkevm-bridge-service       | 2023-09-18T04:03:57.386Z   ERROR   cmd/run.go:52   failed to execute the unsigned transaction

and

zkevm-json-rpc | 2023-09-18T06:59:18.199Z   ERROR   jsonrpc/server.go:397   failed to execute the unsigned transaction: invalid opcode %!s(MISSING) {"pid": 1, "version": "v0.3.1"}
zkevm-json-rpc             | 2023-09-18T06:46:58.257Z   INFO    jsonrpc/handler.go:144  failed call: [-32000]failed to execute the unsigned transaction. Params: [{"data":"0xbab161bf","from":"0x0000000000000000000000000000000000000000","to":"0x5798cfa36832d17b5074e462ef234c75afe884ba"},"latest"]     {"pid": 1, "version": "v0.3.1", "method": "eth_call", "requestId": 1}

I also verified that I can repro with:

$ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_call","params":[{"to": "0x5798cfa36832d17b5074e462ef234c75afe884ba", "data": "0xbab161bf", "from": "0x0000000000000000000000000000000000000000"}, "latest"],"id":1}' -H "Content-Type: application/json" http://3.81.29.192:8123

{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"failed to execute the unsigned transaction"}}

By digging deeper to the code at here and here, I suspect that the problem might be due to the L2 bridge contract was not deployed correctly so the bytecode was corrupted in the genesis file (why the NetworkID call failed):

image image

Additional Context 1

When I was deploying the contracts, npm run deploy:testnet:ZkEVM:goerli failed (likely due to the infura free tier RPC) so I had to redeploy. Then I increased the salt field and reran the command.

contracts seems to have deployed successfully but when I verify I got some failures (full output)

Failed to link proxy 0xdFe29aD5aF07D5a95B7cc23D023ab2e7b16Ff452 with its implementation. Reason: The implementation contract at 0x41de7ed8e9e5fd924a0919ab5ff22e81eafb3cdf does not seem to be verified. Please verify and publish the contract source before proceeding with this proxy verification.
Verifying proxy admin: 0x3BF649126307334c60718362a607975ba552886d
Failed to verify ProxyAdmin contract at 0x3BF649126307334c60718362a607975ba552886d: Bytecode does not match with the current version of ProxyAdmin in the Hardhat Upgrades plugin.

I checked those "failed to verify" contract on etherscan and they seem correct. not sure if that's related since it's the L1 contracts.

Additional Context 2

The tutorial was too old so I did some customizations to use the newer code / docker images:

bap2pecs commented 1 year ago

discussed w @arnaubennassar offline. the root cause is I have to set fork ID to be 5

it's likely related to the PUSH0 opcode which is used in the latest contracts. and this opcode is only added on forkID5