Skip to content

Commit

Permalink
chore: store audit changes (#11989)
Browse files Browse the repository at this point in the history
## Description

ref: #11362 



---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
likhita-809 committed May 18, 2022
1 parent b647802 commit 0b810ba
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions store/firstlast.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
sdkkv "github.com/cosmos/cosmos-sdk/types/kv"
)

// Gets the first item.
// First gets the first item.
func First(st KVStore, start, end []byte) (kv sdkkv.Pair, ok bool) {
iter := st.Iterator(start, end)
if !iter.Valid() {
Expand All @@ -18,7 +18,7 @@ func First(st KVStore, start, end []byte) (kv sdkkv.Pair, ok bool) {
return sdkkv.Pair{Key: iter.Key(), Value: iter.Value()}, true
}

// Gets the last item. `end` is exclusive.
// Last gets the last item. `end` is exclusive.
func Last(st KVStore, start, end []byte) (kv sdkkv.Pair, ok bool) {
iter := st.ReverseIterator(end, start)
if !iter.Valid() {
Expand Down
2 changes: 1 addition & 1 deletion store/tools/ics23/iavl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ current value). This returns an error if the key does not exist in the tree.

`func CreateNonMembershipProof(tree *iavl.MutableTree, key []byte) (*proofs.CommitmentProof, error)`
produces a CommitmentProof that the given key doesn't exist in the iavl tree.
This returns an error if the key does not exist in the tree.
This returns an error if the key exists in the tree.

Generalized range proofs are lower in priority, as they are just an optimization of the
two basic proof types, and don't provide any additional capabilities.
Expand Down
4 changes: 2 additions & 2 deletions store/tools/ics23/iavl/helpers/helpers.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Package helpers contains functions to build sample data for tests/testgen
In it's own package to avoid poluting the godoc for ics23-iavl
In it's own package to avoid polluting the godoc for ics23-iavl
*/
package helpers

Expand Down Expand Up @@ -56,7 +56,7 @@ func GenerateIavlResult(size int, loc tmproofs.Where) (*IavlResult, error) {
return res, nil
}

// GetKey this returns a key, on Left/Right/Middle
// GetKey returns a key, on Left/Right/Middle
func GetKey(allkeys [][]byte, loc tmproofs.Where) []byte {
if loc == tmproofs.Left {
return allkeys[0]
Expand Down
2 changes: 1 addition & 1 deletion store/tools/ics23/smt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ It exposes a two main functions :
produces a CommitmentProof that the given key exists in the SMT (and contains the current value). This returns an error if the key does not exist in the tree.

`func CreateNonMembershipProof(tree *smt.SparseMerkleTree, key []byte, preimages PreimageMap) (*ics23.CommitmentProof, error)`
produces a CommitmentProof that the given key doesn't exist in the SMT. This returns an error if the key does not exist in the tree.
produces a CommitmentProof that the given key doesn't exist in the SMT. This returns an error if the key exists in the tree.
This relies on an auxiliary `PreimageMap` object which provides access to the preimages of all keys in the tree based on their (hashed) path ordering.


Expand Down
2 changes: 1 addition & 1 deletion store/tools/ics23/smt/helpers/helpers.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Package helpers contains functions to build sample data for tests/testgen
In it's own package to avoid poluting the godoc for ics23-smt
In it's own package to avoid polluting the godoc for ics23-smt
*/
package helpers

Expand Down
4 changes: 2 additions & 2 deletions store/tracekv/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ func (tkv *Store) Has(key []byte) bool {
}

// Iterator implements the KVStore interface. It delegates the Iterator call
// the to the parent KVStore.
// to the parent KVStore.
func (tkv *Store) Iterator(start, end []byte) types.Iterator {
return tkv.iterator(start, end, true)
}

// ReverseIterator implements the KVStore interface. It delegates the
// ReverseIterator call the to the parent KVStore.
// ReverseIterator call to the parent KVStore.
func (tkv *Store) ReverseIterator(start, end []byte) types.Iterator {
return tkv.iterator(start, end, false)
}
Expand Down
6 changes: 3 additions & 3 deletions store/types/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type StoreRename struct {
NewKey string `json:"new_key"`
}

// IsDeleted returns true if the given key should be added
// IsAdded returns true if the given key should be added
func (s *StoreUpgrades) IsAdded(key string) bool {
if s == nil {
return false
Expand Down Expand Up @@ -192,7 +192,7 @@ type CommitMultiStore interface {

// BasicKVStore is a simple interface to get/set data
type BasicKVStore interface {
// Get returns nil iff key doesn't exist. Panics on nil key.
// Get returns nil if key doesn't exist. Panics on nil key.
Get(key []byte) []byte

// Has checks if a key exists. Panics on nil key.
Expand Down Expand Up @@ -338,7 +338,7 @@ type StoreKey interface {
}

// CapabilityKey represent the Cosmos SDK keys for object-capability
// generation in the IBC protocol as defined in https://github.com/cosmos/ics/tree/master/spec/ics-005-port-allocation#data-structures
// generation in the IBC protocol as defined in https://github.com/cosmos/ibc/tree/master/spec/core/ics-005-port-allocation#data-structures
type CapabilityKey StoreKey

// KVStoreKey is used for accessing substores.
Expand Down
4 changes: 2 additions & 2 deletions store/types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"github.com/cosmos/cosmos-sdk/types/kv"
)

// Iterator over all the keys with a certain prefix in ascending order
// KVStorePrefixIterator iterates over all the keys with a certain prefix in ascending order
func KVStorePrefixIterator(kvs KVStore, prefix []byte) Iterator {
return kvs.Iterator(prefix, PrefixEndBytes(prefix))
}

// Iterator over all the keys with a certain prefix in descending order.
// KVStoreReversePrefixIterator iterates over all the keys with a certain prefix in descending order.
func KVStoreReversePrefixIterator(kvs KVStore, prefix []byte) Iterator {
return kvs.ReverseIterator(prefix, PrefixEndBytes(prefix))
}
Expand Down
4 changes: 2 additions & 2 deletions store/types/validity.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package types

// Check if the key is valid(key is not nil)
// AssertValidKey checks if the key is valid(key is not nil)
func AssertValidKey(key []byte) {
if len(key) == 0 {
panic("key is nil")
}
}

// Check if the value is valid(value is not nil)
// AssertValidValue checks if the value is valid(value is not nil)
func AssertValidValue(value []byte) {
if value == nil {
panic("value is nil")
Expand Down

0 comments on commit 0b810ba

Please sign in to comment.