Skip to content

Commit

Permalink
Normalise GenesisDoc before saving to state (tendermint#6059)
Browse files Browse the repository at this point in the history
Co-authored-by: Callum <cmwaters19@gmail.com>
  • Loading branch information
2 people authored and JayT106 committed Sep 19, 2022
1 parent 21a3bbd commit a36423a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
- [proto] \#9356 Migrate from `gogo/protobuf` to `cosmos/gogoproto` (@julienrbrt)
- [rpc] \#9276 Added `header` and `header_by_hash` queries to the RPC client (@samricotta)
- [abci] \#5706 Added `AbciVersion` to `RequestInfo` allowing applications to check ABCI version when connecting to Tendermint. (@marbar3778)
- [node] \#6059 Validate and complete genesis doc before saving to state store (@silasdavis)

### BUG FIXES

Expand Down
5 changes: 5 additions & 0 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,11 @@ func LoadStateFromDBOrGenesisDocProvider(
if err != nil {
return sm.State{}, nil, err
}

err = genDoc.ValidateAndComplete()
if err != nil {
return sm.State{}, nil, fmt.Errorf("error in genesis doc: %w", err)
}
// save genesis doc to prevent a certain class of user errors (e.g. when it
// was changed, accidentally or not). Also good for audit trail.
if err := saveGenesisDoc(stateDB, genDoc); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func MakeGenesisDocFromFile(genDocFile string) (*types.GenesisDoc, error) {
func MakeGenesisState(genDoc *types.GenesisDoc) (State, error) {
err := genDoc.ValidateAndComplete()
if err != nil {
return State{}, fmt.Errorf("error in genesis file: %v", err)
return State{}, fmt.Errorf("error in genesis doc: %w", err)
}

var validatorSet, nextValidatorSet *types.ValidatorSet
Expand Down

0 comments on commit a36423a

Please sign in to comment.