Skip to content

Commit

Permalink
Merge branch 'main' into ty/remove_redacted
Browse files Browse the repository at this point in the history
  • Loading branch information
technicallyty authored May 18, 2022
2 parents 4640253 + 0b810ba commit ebec0a8
Show file tree
Hide file tree
Showing 35 changed files with 293 additions and 107 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (types) [\#10948](https://github.com/cosmos/cosmos-sdk/issues/10948) Add `app-db-backend` to the `app.toml` config to replace the compile-time `types.DBbackend` variable.
* (authz)[\#11060](https://github.com/cosmos/cosmos-sdk/pull/11060) Support grant with no expire time.
* (rosetta) [\#11590](https://github.com/cosmos/cosmos-sdk/pull/11590) Add fee suggestion for rosetta and enable offline mode. Also force set events about Fees to Success to pass reconciliation test.
* (types) [\#11959](https://github.com/cosmos/cosmos-sdk/pull/11959) Added `sdk.Coins.Find` helper method to find a coin by denom.

### API Breaking Changes

Expand Down Expand Up @@ -222,6 +223,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* [#11969](https://github.com/cosmos/cosmos-sdk/pull/11969) Fix the panic error in `x/upgrade` when `AppVersion` is not set.
* (tests) [\#11940](https://github.com/cosmos/cosmos-sdk/pull/11940) Fix some client tests in the `x/gov` module
* [\#11772](https://github.com/cosmos/cosmos-sdk/pull/11772) Limit types.Dec length to avoid overflow.
* [\#11724](https://github.com/cosmos/cosmos-sdk/pull/11724) Fix data race issues with api.Server
Expand Down
2 changes: 1 addition & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/cosmos/cosmos-proto v1.0.0-alpha7
github.com/gogo/protobuf v1.3.2
google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb
google.golang.org/grpc v1.46.0
google.golang.org/grpc v1.46.2
google.golang.org/protobuf v1.28.0
)

Expand Down
4 changes: 2 additions & 2 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
google.golang.org/grpc v1.46.0 h1:oCjezcn6g6A75TGoKYBPgKmVBLexhYLM6MebdrPApP8=
google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/grpc v1.46.2 h1:u+MLGgVf7vRdjEYZ8wDFhAVNmhkbJ5hmrA1LMWK1CAQ=
google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
Expand Down
2 changes: 1 addition & 1 deletion orm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/regen-network/gocuke v0.6.2
github.com/stretchr/testify v1.7.1
github.com/tendermint/tm-db v0.6.7
google.golang.org/grpc v1.46.0
google.golang.org/grpc v1.46.2
google.golang.org/protobuf v1.28.0
gotest.tools/v3 v3.2.0
pgregory.net/rapid v0.4.7
Expand Down
4 changes: 2 additions & 2 deletions orm/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
google.golang.org/grpc v1.46.0 h1:oCjezcn6g6A75TGoKYBPgKmVBLexhYLM6MebdrPApP8=
google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/grpc v1.46.2 h1:u+MLGgVf7vRdjEYZ8wDFhAVNmhkbJ5hmrA1LMWK1CAQ=
google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
Expand Down
2 changes: 1 addition & 1 deletion store/cachekv/memiterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/store/types"
)

// Iterates over iterKVCache items.
// memIterator iterates over iterKVCache items.
// if key is nil, means it was deleted.
// Implements Iterator.
type memIterator struct {
Expand Down
6 changes: 4 additions & 2 deletions store/cachekv/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ import (
"github.com/cosmos/cosmos-sdk/types/kv"
)

// If value is nil but deleted is false, it means the parent doesn't have the
// key. (No need to delete upon Write())
// cValue represents a cached value.
// If dirty is true, it indicates the cached value is different from the underlying value.
type cValue struct {
value []byte
dirty bool
}

// Store wraps an in-memory cache around an underlying types.KVStore.
// If a cached value is nil but deleted is defined for the corresponding key,
// it means the parent doesn't have the key. (No need to delete upon Write())
type Store struct {
mtx sync.Mutex
cache map[string]*cValue
Expand Down
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/iavl/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ func getProofFromTree(tree *iavl.MutableTree, key []byte, exists bool) *tmcrypto

//----------------------------------------

// Implements types.Iterator.
// iavlIterator implements types.Iterator.
type iavlIterator struct {
*iavl.Iterator
}
Expand Down
65 changes: 61 additions & 4 deletions store/streaming/constructor_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package streaming
package streaming_test

import (
"testing"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
codecTypes "github.com/cosmos/cosmos-sdk/codec/types"
serverTypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/store/streaming"
"github.com/cosmos/cosmos-sdk/store/streaming/file"
"github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"

"github.com/stretchr/testify/require"
)
Expand All @@ -24,12 +30,12 @@ var (
)

func TestStreamingServiceConstructor(t *testing.T) {
_, err := NewServiceConstructor("unexpectedName")
_, err := streaming.NewServiceConstructor("unexpectedName")
require.NotNil(t, err)

constructor, err := NewServiceConstructor("file")
constructor, err := streaming.NewServiceConstructor("file")
require.Nil(t, err)
var expectedType ServiceConstructor
var expectedType streaming.ServiceConstructor
require.IsType(t, expectedType, constructor)

serv, err := constructor(mockOptions, mockKeys, testMarshaller)
Expand All @@ -41,3 +47,54 @@ func TestStreamingServiceConstructor(t *testing.T) {
require.True(t, ok)
}
}

func TestLoadStreamingServices(t *testing.T) {
db := dbm.NewMemDB()
encCdc := simapp.MakeTestEncodingConfig()
keys := sdk.NewKVStoreKeys("mockKey1", "mockKey2")
bApp := baseapp.NewBaseApp("appName", log.NewNopLogger(), db)

testCases := map[string]struct {
appOpts serverTypes.AppOptions
activeStreamersLen int
}{
"empty app options": {
appOpts: simapp.EmptyAppOptions{},
},
"all StoreKeys exposed": {
appOpts: streamingAppOptions{keys: []string{"*"}},
activeStreamersLen: 1,
},
"some StoreKey exposed": {
appOpts: streamingAppOptions{keys: []string{"mockKey1"}},
activeStreamersLen: 1,
},
"not exposing anything": {
appOpts: streamingAppOptions{keys: []string{"mockKey3"}},
},
}

for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
activeStreamers, _, err := streaming.LoadStreamingServices(bApp, tc.appOpts, encCdc.Codec, keys)
require.NoError(t, err)
require.Equal(t, tc.activeStreamersLen, len(activeStreamers))
})
}

}

type streamingAppOptions struct {
keys []string
}

func (ao streamingAppOptions) Get(o string) interface{} {
switch o {
case "store.streamers":
return []string{"file"}
case "streamers.file.keys":
return ao.keys
default:
return nil
}
}
4 changes: 2 additions & 2 deletions store/streaming/file/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type IntermediateWriter struct {
outChan chan<- []byte
}

// NewIntermediateWriter create an instance of an intermediateWriter that sends to the provided channel
// NewIntermediateWriter create an instance of an IntermediateWriter that sends to the provided channel
func NewIntermediateWriter(outChan chan<- []byte) *IntermediateWriter {
return &IntermediateWriter{
outChan: outChan,
Expand All @@ -62,7 +62,7 @@ func NewStreamingService(writeDir, filePrefix string, storeKeys []types.StoreKey
for _, key := range storeKeys {
listeners[key] = append(listeners[key], listener)
}
// check that the writeDir exists and is writeable so that we can catch the error here at initialization if it is not
// check that the writeDir exists and is writable so that we can catch the error here at initialization if it is not
// we don't open a dstFile until we receive our first ABCI message
if err := isDirWriteable(writeDir); err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions store/streaming/file/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func readInFile(name string) ([]byte, error) {
return ioutil.ReadFile(path)
}

// Returns all of the protobuf messages contained in the byte array as an array of byte arrays
// segmentBytes returns all of the protobuf messages contained in the byte array as an array of byte arrays
// The messages have their length prefix removed
func segmentBytes(bz []byte) ([][]byte, error) {
var err error
Expand All @@ -388,7 +388,7 @@ func segmentBytes(bz []byte) ([][]byte, error) {
return segments, nil
}

// Returns the bytes for the leading protobuf object in the byte array (removing the length prefix) and returns the remainder of the byte array
// getHeadSegment returns the bytes for the leading protobuf object in the byte array (removing the length prefix) and returns the remainder of the byte array
func getHeadSegment(bz []byte) ([]byte, []byte, error) {
size, prefixSize := binary.Uvarint(bz)
if prefixSize < 0 {
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
Loading

0 comments on commit ebec0a8

Please sign in to comment.