-
Notifications
You must be signed in to change notification settings - Fork 20.3k
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: store genesis allocation and recommit them if necessary #24460
Conversation
core/blockchain.go
Outdated
// block stored in the chain if the historical chain pruning is enabled. | ||
// In that case the logic needs to be improved here. | ||
if newHeadBlock.NumberU64() == 0 { | ||
if err := CommitGenesisState(bc.db, bc.genesisBlock.Hash()); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this error out in backwards-incompatible way? I mean, if the genesis state already exists, but we haven't stored the genesis json?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right... thanks for catching it. Let me think how to solve it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added two additional checks for it.
- if the genesis state is still available, do nothing here
- if the genesis state is gone and relevant genesis allocation can be recovered(mainnet, testnets), recover it
However, if it's a private network and the allocation is not persisted, and the genesis state is gone, then we can do nothing here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…um#24460) * core: store genesis allocation and recommit them if necessary * core: recover predefined genesis allocation if possible
…um#24460) * core: store genesis allocation and recommit them if necessary * core: recover predefined genesis allocation if possible
This PR is an alternative of #24450.
It will store the genesis allocation information into the disk,
and whenever we want to rewind the state to genesis, the
genesis allocation can be loaded and generate the genesis
states.