OffchainLabs / go-ethereum

GNU Lesser General Public License v3.0
58 stars 98 forks source link

Resurrect freezer migrate #244

Closed Tristan-Wilson closed 1 year ago

Tristan-Wilson commented 1 year ago

This PR brings back the "geth db freezer-migrate" tool in order for Nitro users to migrate legacy RLP receipts. Legacy receipt support, including support for migration, was dropped in v1.11.0 of geth and its users were supposed to have migrated before upgrading.

For Arbitrum One, classic (pre-nitro) receipts were encoded in the legacy format, so eth_getLogs requests were failing for classic blocks: https://github.com/OffchainLabs/nitro/issues/1745

Testing done

Migrate the snapshot

$ mkdir -p /home/tristan/offchain/geth-upgrade/freezer-repair-7/arb1
$ tar xf ~/Downloads/nitro-genesis.tar -C /home/tristan/offchain/geth-upgrade/freezer-repair-7/arb1
$ ./build/bin/geth db freezer-migrate --datadir "/home/tristan/offchain/geth-upgrade/freezer-repair-7/arb1" --datadir.chaindata "../nitro/l2chaindata"
...
INFO [07-26|16:18:18.670] Replacing old table files with migrated ones elapsed=8m10.089s
[[[sync /home/tristan/offchain/geth-upgrade/freezer-repair-7/arb1/nitro/l2chaindata/ancient/receipts.0004.cdat: file already closed]]]

The final error message about trying to sync a closed file can be ignored, the migration is complete.

Start older Nitro version

Start a version of Nitro where the support for legacy receipts has been removed.

$ ./target/bin/nitro --parent-chain.connection.url {L1 ID} --chain.id=42161 --node.rpc.classic-redirect=https://arb1.arbitrum.io/rpc   --http.api=net,web3,eth,debug --http.corsdomain=* --http.addr=0.0.0.0 --http.vhosts=*  --persistent.global-config /home/tristan/offchain/geth-upgrade/freezer-repair-7

test eth_getLogs

Check the block reported by @kaber2 (165)

$ curl 'http://localhost:8547' -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":0,"method":"eth_getLogs","params":[{"fromBlock":"0xA5", "toBlock":"0xA5"}]}' > a5_local
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2269    0  2172  100    97  1831k  83765 --:--:-- --:--:-- --:--:-- 2215k
$ curl 'https://arb1.arbitrum.io/rpc' -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":0,"method":"eth_getLogs","params":[{"fromBlock":"0xA5", "toBlock":"0xA5"}]}' > a5_remote
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2269    0  2172  100    97  24358   1087 --:--:-- --:--:-- --:--:-- 25211
$ diff a5_local a5_remote 

Check around the classic/nitro boundary (first nitro block is = 22207817)

$ curl 'https://arb1.arbitrum.io/rpc' -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":0,"method":"eth_getLogs","params":[{"fromBlock":"0x152DD40", "toBlock":"0x152DD50"}]}' > classic_nitro_remote
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12542    0 12435  100   107   172k   1518 --:--:-- --:--:-- --:--:--  174k
$ curl 'http://localhost:8547' -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":0,"method":"eth_getLogs","params":[{"fromBlock":"0x152DD40", "toBlock":"0x152DD50"}]}' > classic_nitro_local
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12542    0 12435  100   107  4129k  36382 --:--:-- --:--:-- --:--:-- 6124k
$ diff classic_nitro_local classic_nitro_remote
Tristan-Wilson commented 1 year ago

Closed in favor of https://github.com/OffchainLabs/go-ethereum/pull/245