Normalise GenesisDoc before saving to state (#6059)

Co-authored-by: Callum <cmwaters19@gmail.com>
This commit is contained in:
Silas Davis
2021-02-23 13:27:42 +01:00
committed by GitHub
parent c1ca749afa
commit 9498cd80bd
3 changed files with 7 additions and 1 deletions

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)
- [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.
- [node] \#6059 Validate and complete genesis doc before saving to state store (@silasdavis)
### BUG FIXES

View File

@@ -1650,6 +1650,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 {

View File

@@ -337,7 +337,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