diff --git a/store/multistoreproof.go b/store/multistoreproof.go index e25f1cc1f2e8..518ef23aa69c 100644 --- a/store/multistoreproof.go +++ b/store/multistoreproof.go @@ -11,13 +11,16 @@ import ( type MultiStoreProof struct { StoreInfos []storeInfo StoreName string - RangeProof iavl.RangeProof + RangeProof *iavl.RangeProof } // buildMultiStoreProof build MultiStoreProof based on iavl proof and storeInfos func buildMultiStoreProof(iavlProof []byte, storeName string, storeInfos []storeInfo) []byte { - var rangeProof iavl.RangeProof - cdc.MustUnmarshalBinary(iavlProof, &rangeProof) + var rangeProof *iavl.RangeProof + if iavlProof != nil { + rangeProof = &iavl.RangeProof{} + cdc.MustUnmarshalBinary(iavlProof, rangeProof) + } msp := MultiStoreProof{ StoreInfos: storeInfos, @@ -32,14 +35,16 @@ func buildMultiStoreProof(iavlProof []byte, storeName string, storeInfos []store // VerifyMultiStoreCommitInfo verify multiStoreCommitInfo against appHash func VerifyMultiStoreCommitInfo(storeName string, storeInfos []storeInfo, appHash []byte) ([]byte, error) { var substoreCommitHash []byte + found := false var height int64 for _, storeInfo := range storeInfos { if storeInfo.Name == storeName { + found = true substoreCommitHash = storeInfo.Core.CommitID.Hash height = storeInfo.Core.CommitID.Version } } - if len(substoreCommitHash) == 0 { + if !found { return nil, cmn.NewError("failed to get substore root commit hash by store name") } @@ -56,6 +61,10 @@ func VerifyMultiStoreCommitInfo(storeName string, storeInfos []storeInfo, appHas // VerifyRangeProof verify iavl RangeProof func VerifyRangeProof(key, value []byte, substoreCommitHash []byte, rangeProof *iavl.RangeProof) error { + // Both rangeProof and substoreCommitHash are nil + if substoreCommitHash == nil && rangeProof == nil { + return nil + } // verify the proof to ensure data integrity. err := rangeProof.Verify(substoreCommitHash) diff --git a/store/rootmultistore.go b/store/rootmultistore.go index 783a5da47bcc..744f800b7e42 100644 --- a/store/rootmultistore.go +++ b/store/rootmultistore.go @@ -301,12 +301,9 @@ func (rs *rootMultiStore) Query(req abci.RequestQuery) abci.ResponseQuery { return res } - if len(res.Proof) == 0 { - if len(res.Value) == 0 { - return res - } + if len(res.Proof) == 0 && len(res.Value) != 0 { msg := fmt.Sprintf("proof from store %s is nil", storeName) - return sdk.ErrUnknownRequest(msg).QueryResult() + return sdk.ErrInternal(msg).QueryResult() } commitInfo, errMsg := getCommitInfo(rs.db, res.Height) diff --git a/x/stake/keeper/key.go b/x/stake/keeper/key.go index 502ec2654419..12e7b8c11fdc 100644 --- a/x/stake/keeper/key.go +++ b/x/stake/keeper/key.go @@ -32,7 +32,7 @@ var ( RedelegationByValDstIndexKey = []byte{0x0F} // prefix for each key for an redelegation, by destination validator owner ) -const maxDigitsForAccount = 12 // ~220,000,000 atoms created at launch +const maxDigitsForAccount = 30 // ~220,000,000 atoms created at launch // gets the key for the validator with address // VALUE: stake/types.Validator