ethereum-optimism / op-geth

GNU Lesser General Public License v3.0
281 stars 735 forks source link

Snap Sync: How to handle unprefixed code #195

Closed trianglesphere closed 8 months ago

trianglesphere commented 10 months ago

We had to revert an upstream geth change around using ContractCodeWithPrefix to just getting ContractCode. We may need to do this migration ourselves. This is the change we should look into undoing: https://github.com/ethereum-optimism/op-geth/pull/105/files

trianglesphere commented 8 months ago

I've confirmed that the write path is correct with the prefixed code. Ideally we should be able to revert this change, but L2 Geth did not prefix the code which means that any datadir created with L2 Geth (basically OP mainnet starting datadir + end users syncing pre-bedrock) will not be able to serve snap sync.

Once we distribute pebble based database (& most people have migrated), we may be able to go from ContractCode to ContractCodeWithPrefix to improve performance, but it needs to be shelved for now.

The code prefix was introduced in https://github.com/ethereum/go-ethereum/pull/21080

L2 Geth DB Schema: https://github.com/ethereum-optimism/optimism-legacy/blob/develop/l2geth/core/rawdb/schema.go