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

core/rawdb: improve state scheme checking #28724

Merged
merged 1 commit into from
Dec 22, 2023

Conversation

rjl493456442
Copy link
Member

@rjl493456442 rjl493456442 commented Dec 22, 2023

This pull request improves the condition to check if path state scheme is ever used.

Originally root node presence is used as the indicator if path scheme is used or not. However due to fact that root node will be deleted during the initial snap sync, this condition is no longer useful.

Therefore, one more condition is added if the root node is not present => The presence of PersistentStateID is also checked, reasons:

  • PersistentStateID is only available in path scheme
  • PersistentStateID is only committed once we successfully update the persistent state, e.g. Initialize genesis state
  • PersistentStateID entry won't be deleted ever.

If PersistentStateID is present, it can prove we did write state in path scheme before and it's a good indicator for path scheme.

@rjl493456442 rjl493456442 added this to the 1.13.8 milestone Dec 22, 2023
@rjl493456442
Copy link
Member Author

With this fix, we can successfully detect the path scheme after aborting the snap sync

ubuntu@ubuntu:~/gary/sepolia$ ./fix-scheme-flag --sepolia --state.scheme hash --port 30389 --authrpc.port 9898 --datadir .
INFO [12-22|03:14:53.778] Starting Geth on Sepolia testnet...
INFO [12-22|03:14:53.803] Maximum peer count                       ETH=50 total=50
INFO [12-22|03:14:53.805] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [12-22|03:14:53.808] Set global gas cap                       cap=50,000,000
INFO [12-22|03:14:53.809] Initializing the KZG library             backend=gokzg
INFO [12-22|03:14:53.830] Allocated trie memory caches             clean=154.00MiB dirty=256.00MiB
INFO [12-22|03:14:53.831] Using pebble as the backing database
INFO [12-22|03:14:53.831] Allocated cache and file handles         database=/home/ubuntu/gary/sepolia/geth/chaindata cache=512.00MiB handles=524,288
INFO [12-22|03:14:54.820] Opened ancient database                  database=/home/ubuntu/gary/sepolia/geth/chaindata/ancient/chain readonly=false
Fatal: Failed to register the Ethereum service: incompatible state scheme, stored: path, provided: hash

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM

@holiman holiman merged commit f469470 into ethereum:master Dec 22, 2023
2 of 3 checks passed
Doozers pushed a commit to kilnfi/pgeth that referenced this pull request Dec 22, 2023
This pull request improves the condition to check if path state scheme is in use. 

Originally, root node presence was used as the indicator if path scheme is used or not. However due to fact that root node will be deleted during the initial snap sync, this condition is no longer useful.

If PersistentStateID is present, it shows that we've already configured for path scheme.
Dergarcon pushed a commit to specialmechanisms/mev-geth-0x2mev that referenced this pull request Jan 31, 2024
This pull request improves the condition to check if path state scheme is in use. 

Originally, root node presence was used as the indicator if path scheme is used or not. However due to fact that root node will be deleted during the initial snap sync, this condition is no longer useful.

If PersistentStateID is present, it shows that we've already configured for path scheme.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants