Browse Source

Normalise GenesisDoc before saving to state (#6059)

Co-authored-by: Callum <cmwaters19@gmail.com>
pull/6177/head
Silas Davis 4 years ago
committed by GitHub
parent
commit
9498cd80bd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions
  1. +1
    -0
      CHANGELOG_PENDING.md
  2. +5
    -0
      node/node.go
  3. +1
    -1
      state/state.go

+ 1
- 0
CHANGELOG_PENDING.md View File

@ -65,6 +65,7 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
- [consensus] \#5987 Remove `time_iota_ms` from consensus params. Merge `tmproto.ConsensusParams` and `abci.ConsensusParams`. (@marbar3778) - [consensus] \#5987 Remove `time_iota_ms` from consensus params. Merge `tmproto.ConsensusParams` and `abci.ConsensusParams`. (@marbar3778)
- [types] \#5994 Reduce the use of protobuf types in core logic. (@marbar3778) - [types] \#5994 Reduce the use of protobuf types in core logic. (@marbar3778)
- `ConsensusParams`, `BlockParams`, `ValidatorParams`, `EvidenceParams`, `VersionParams`, `sm.Version` and `version.Consensus` have become native types. They still utilize protobuf when being sent over the wire or written to disk. - `ConsensusParams`, `BlockParams`, `ValidatorParams`, `EvidenceParams`, `VersionParams`, `sm.Version` and `version.Consensus` have become native types. They still utilize protobuf when being sent over the wire or written to disk.
- [node] \#6059 Validate and complete genesis doc before saving to state store (@silasdavis)
### BUG FIXES ### BUG FIXES


+ 5
- 0
node/node.go View File

@ -1650,6 +1650,11 @@ func LoadStateFromDBOrGenesisDocProvider(
if err != nil { if err != nil {
return sm.State{}, nil, err 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 // 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. // was changed, accidentally or not). Also good for audit trail.
if err := saveGenesisDoc(stateDB, genDoc); err != nil { if err := saveGenesisDoc(stateDB, genDoc); err != nil {


+ 1
- 1
state/state.go View File

@ -337,7 +337,7 @@ func MakeGenesisDocFromFile(genDocFile string) (*types.GenesisDoc, error) {
func MakeGenesisState(genDoc *types.GenesisDoc) (State, error) { func MakeGenesisState(genDoc *types.GenesisDoc) (State, error) {
err := genDoc.ValidateAndComplete() err := genDoc.ValidateAndComplete()
if err != nil { 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 var validatorSet, nextValidatorSet *types.ValidatorSet


Loading…
Cancel
Save