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: store genesis allocation and recommit them if necessary #24460

Merged
merged 2 commits into from
Mar 22, 2022

Conversation

rjl493456442
Copy link
Member

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.

// 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 {
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

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 added this to the 1.10.17 milestone Mar 22, 2022
@holiman holiman merged commit 7ae6c4a into ethereum:master Mar 22, 2022
sidhujag pushed a commit to syscoin/go-ethereum that referenced this pull request Mar 23, 2022
JacekGlen pushed a commit to JacekGlen/go-ethereum that referenced this pull request May 26, 2022
…um#24460)

* core: store genesis allocation and recommit them if necessary

* core: recover predefined genesis allocation if possible
cp-wjhan pushed a commit to cp-yoonjin/go-wemix that referenced this pull request Nov 16, 2022
…um#24460)

* core: store genesis allocation and recommit them if necessary

* core: recover predefined genesis allocation if possible
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.

3 participants