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

Resurrect freezer migrate #244

Closed
wants to merge 4 commits into from
Closed

Conversation

Tristan-Wilson
Copy link
Member

@Tristan-Wilson Tristan-Wilson commented Jul 26, 2023

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: OffchainLabs/nitro#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

This reverts commit 10347c6.

This brings back legacy receipt types and the migration tool.
@cla-bot cla-bot bot added the s label Jul 26, 2023
@Tristan-Wilson Tristan-Wilson marked this pull request as ready for review July 26, 2023 23:54
w.WriteUint64(r.GasUsed)
w.WriteUint64(r.GasUsedForL1)
w.WriteUint64(r.Status)
rlp.Encode(w, r.ContractAddress)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to maintain the old encoding here or else gas used for old legacy receipts are wrong. Basically in Arbitrum Classic the cumulative gas used didn't match up with the gas used nicely IIRC. We should try querying for old receipt gas used values on a migrated databases and make sure they match (particularly for classic blocks with multiple txs)

@Tristan-Wilson
Copy link
Member Author

Closed in favor of #245

@tsahee tsahee deleted the resurrect-freezer-migrate branch November 28, 2023 17:48
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 this pull request may close these issues.

2 participants