Normalise GenesisDoc before saving to state (#6059) (#9458)

This commit is contained in:
JayT106
2022-09-21 05:06:13 -04:00
committed by GitHub
parent 080dfab992
commit fe0aa4d30e
3 changed files with 7 additions and 1 deletions

View File

@@ -77,6 +77,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)
- [crypto/ed25519] \#5632 Adopt zip215 `ed25519` verification. (@marbar3778)
- [crypto/ed25519] \#6526 Use [curve25519-voi](https://github.com/oasisprotocol/curve25519-voi) for `ed25519` signing and verification. (@Yawning)

View File

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

@@ -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