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

Normalise GenesisDoc before saving to state #6059

Merged
merged 5 commits into from
Feb 23, 2021

Conversation

silasdavis
Copy link
Contributor

Please feel free to close and replace this is more work or a better approach is needed, just opening to illustrate.

fixes #5986

@codecov
Copy link

codecov bot commented Feb 6, 2021

Codecov Report

Merging #6059 (9be25fa) into master (c1ca749) will increase coverage by 0.07%.
The diff coverage is 25.00%.

@@            Coverage Diff             @@
##           master    #6059      +/-   ##
==========================================
+ Coverage   60.70%   60.78%   +0.07%     
==========================================
  Files         276      276              
  Lines       25706    25709       +3     
==========================================
+ Hits        15606    15627      +21     
+ Misses       8478     8463      -15     
+ Partials     1622     1619       -3     
Impacted Files Coverage Δ
state/state.go 85.09% <0.00%> (ø)
node/node.go 57.55% <33.33%> (-0.09%) ⬇️
statesync/snapshots.go 91.59% <0.00%> (-1.69%) ⬇️
mempool/reactor.go 64.28% <0.00%> (-1.43%) ⬇️
p2p/switch.go 58.50% <0.00%> (-1.40%) ⬇️
statesync/syncer.go 79.60% <0.00%> (-0.81%) ⬇️
consensus/peer_state.go 84.21% <0.00%> (ø)
consensus/state.go 66.32% <0.00%> (+0.09%) ⬆️
p2p/pex/pex_reactor.go 77.08% <0.00%> (+0.59%) ⬆️
p2p/transport_mconn.go 82.67% <0.00%> (+0.99%) ⬆️
... and 5 more

@cmwaters
Copy link
Contributor

cmwaters commented Feb 8, 2021

Hey @silasdavis, thanks for the PR. This does seem to me like a more appropriate place to validate and complete the genesis doc. I will just check if there are any cases we might be missing. It also feels like we are making this whole "get latest state or if none extract it from genesis" logic a lot more convoluted than perhaps it needs to be.

@@ -335,11 +335,6 @@ func MakeGenesisDocFromFile(genDocFile string) (*types.GenesisDoc, error) {

// MakeGenesisState creates state from types.GenesisDoc.
func MakeGenesisState(genDoc *types.GenesisDoc) (State, error) {
err := genDoc.ValidateAndComplete()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd instead leave this because, if the state is partially gone (due to FS corruption or other reasons; stateKey is gone, but genesisDocKey is there, although the probability is very low), LoadFromDBOrGenesisDoc makes sure we always validate genDoc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes why not. Two rights make a right.

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale for use by stalebot label Feb 20, 2021
@cmwaters cmwaters removed the stale for use by stalebot label Feb 23, 2021
@cmwaters cmwaters self-assigned this Feb 23, 2021
Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

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

👍

@cmwaters cmwaters merged commit 9498cd8 into tendermint:master Feb 23, 2021
JayT106 pushed a commit to JayT106/tendermint that referenced this pull request Sep 19, 2022
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.

initialHeight == 0 not treated identically to initialHeight == 1
3 participants