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

refactor genesis handling to allow changing ChainID #1307

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

altergui
Copy link
Contributor

@altergui altergui commented Apr 29, 2024

refactor genesis package

* don't pass genesisBytes as arg on SetNode, NewVochain, newTendermint, etc

* drop genesis.AutoUpdateGenesis in favor of a new flag AutoWipeDataDir
* add AutoWipeCometBFT flag

* move SeedNodes from genesis into config package (DefaultSeedNodes)
* add config consts: DefaultCometBFTPath and DefaultGenesisPath

* testsuite: use genesis.go instead of hardcoded genesis.json
    this increases the code coverage of testsuite and helps
    developing refactors of genesis.go
* now testsuite network is `test` (instead of `dev`)

* app.genesisDoc is now populated during newTendermint, instead of
  pulling from app.NodeClient.Genesis, since it's needed during Info() handshake

* cometbft: removed redundant app.State.SetHeight(lastHeight) during Info()

* cometbft: now Info() supports doing a chain bump, if genesis InitialHeight > lastHeight

* genesis: remove copypasted types, use upstream comettypes directly

@coveralls
Copy link

coveralls commented Apr 29, 2024

Pull Request Test Coverage Report for Build 9208343016

Details

  • 188 of 303 (62.05%) changed or added relevant lines in 11 files are covered.
  • 14 unchanged lines in 7 files lost coverage.
  • Overall coverage increased (+0.04%) to 61.036%

Changes Missing Coverage Covered Lines Changed/Added Lines %
vochain/apputils.go 26 34 76.47%
service/vochain.go 8 30 26.67%
vochain/genesis/genesis.go 59 81 72.84%
vochain/start.go 55 84 65.48%
vochain/cometbft.go 21 55 38.18%
Files with Coverage Reduction New Missed Lines %
vochain/cometbft.go 1 66.91%
service/vochain.go 2 55.56%
types/encoding.go 2 81.08%
util/zk.go 2 86.84%
vochain/state/account.go 2 67.08%
vochain/transaction/election_tx.go 2 59.4%
vochain/start.go 3 71.74%
Totals Coverage Status
Change from base Build 9189775567: 0.04%
Covered Lines: 16025
Relevant Lines: 26255

💛 - Coveralls

@altergui altergui force-pushed the feat/genesis-fake-hash branch 2 times, most recently from 8367c77 to d66b908 Compare May 8, 2024 12:16
@altergui altergui requested a review from p4u May 8, 2024 12:17
@altergui altergui self-assigned this May 8, 2024
@altergui altergui marked this pull request as ready for review May 8, 2024 12:17
@altergui altergui changed the base branch from main to fix/small-fixes May 8, 2024 12:22
@altergui altergui changed the title refactor genesis handling to allow changing ChainID (WIP) refactor genesis handling to allow changing ChainID May 8, 2024
@altergui altergui force-pushed the feat/genesis-fake-hash branch 2 times, most recently from e20db43 to e1e345f Compare May 8, 2024 12:35
@altergui
Copy link
Contributor Author

altergui commented May 8, 2024

ready for review

@altergui
Copy link
Contributor Author

altergui commented May 8, 2024

compose test is failing due to a oneliner bug, i'll fix it asap but please ignore the failure, the PR is still ready to review

Base automatically changed from fix/small-fixes to main May 8, 2024 15:30
@altergui
Copy link
Contributor Author

altergui commented May 13, 2024

i fixed that bug but now hit another one, related to keykeeper, something is wrong during init, been chasing this and i'll push a fix asap. nevertheless, the essence of the PR will not change.

@altergui altergui force-pushed the feat/genesis-fake-hash branch 11 times, most recently from 8d48a21 to 2284015 Compare May 16, 2024 12:35
@altergui altergui linked an issue May 16, 2024 that may be closed by this pull request
* don't pass genesisBytes as arg on SetNode, NewVochain, newTendermint, etc

* notably, now cometbft has it's own datadir separate from our state,
  allowing to wipe cometbft data without wiping our state.

* drop genesis.AutoUpdateGenesis
* instead of comparing local and hardcoded genesis Hash, compare ChainID
  to decide wether to wipe out just cometbft, whole datadir, or do nothing
* cmd/node: add flags to override genesis ChainID, InitialHeight and AppHash
* cmd/node: add flag to schedule an EndOfChain (a new field of genesis.Doc)

* move SeedNodes from genesis into config package (DefaultSeedNodes)
* add config consts: DefaultCometBFTPath and DefaultGenesisPath

* testsuite: use genesis.go instead of hardcoded genesis.json
    this increases the code coverage of testsuite and helps
    developing refactors of genesis.go
* now testsuite network is `test` (instead of `dev`)

* app.genesisDoc is now populated during newTendermint, instead of
  pulling from app.NodeClient.Genesis, since it's needed during Info() handshake

* cometbft: removed redundant app.State.SetHeight(lastHeight) during Info()

* cometbft: now Info() supports doing a chain bump, if genesis InitialHeight > lastHeight
* cometbft: now ProcessProposal supports stopping the current chain at height config.Forks.EndOfChain

* genesis: remove copypasted types, use upstream comettypes directly
* genesis: deduplicate ConsensusParams literals using DefaultBlockParams, etc
* genesis: remove useless hardcoded StateSyncParams
* genesis: add some unit tests: TestSaveAsAndLoad, TestAvailableNetworks
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.

refactor genesis package
2 participants