Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/cosmos/cosmos-sdk into likh…
Browse files Browse the repository at this point in the history
…ita/fix-evidence-cli-query
  • Loading branch information
likhita-809 committed Nov 2, 2022
2 parents fb3c98c + 3e25045 commit 6ddbf13
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 165 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

* (deps) Bump IAVL version to [v0.19.4](https://github.com/cosmos/iavl/releases/tag/v0.19.4).

## Bug Fixes
### Bug Fixes

* (x/auth/tx) [#12474](https://github.com/cosmos/cosmos-sdk/pull/12474) Remove condition in GetTxsEvent that disallowed multiple equal signs, which would break event queries with base64 strings (i.e. query by signature).
* (store) [#13530](https://github.com/cosmos/cosmos-sdk/pull/13530) Fix app-hash mismatch if upgrade migration commit is interrupted.
Expand All @@ -202,7 +202,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

* [#13656](https://github.com/cosmos/cosmos-sdk/pull/13659) Rename `server.FlagIAVLFastNode` to `server.FlagDisableIAVLFastNode` for clarity.

## API Breaking Changes
### API Breaking Changes

* (context) [#13063](https://github.com/cosmos/cosmos-sdk/pull/13063) Update `Context#CacheContext` to automatically emit all events on the parent context's `EventManager`.

Expand Down
6 changes: 3 additions & 3 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ const config = {
additionalLanguages: ["protobuf", "go-module"], // https://prismjs.com/#supported-languages
},
algolia: {
appId: "BH4D9OD16A",
apiKey: "ac317234e6a42074175369b2f42e9754",
indexName: "cosmos-sdk",
appId: "QLS2QSP47E",
apiKey: "067b84458bfa80c295e1d4f12c461911",
indexName: "cosmos_network",
contextualSearch: false,
},
}),
Expand Down
4 changes: 0 additions & 4 deletions runtime/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ import (
// App can be used to create a hybrid app.go setup where some configuration is
// done declaratively with an app config and the rest of it is done the old way.
// See simapp/app.go for an example of this setup.
//
//nolint:unused
type App struct {
*baseapp.BaseApp

Expand All @@ -49,8 +47,6 @@ type App struct {
cdc codec.Codec
amino *codec.LegacyAmino
basicManager module.BasicManager
beginBlockers []func(sdk.Context, abci.RequestBeginBlock)
endBlockers []func(sdk.Context, abci.RequestEndBlock) []abci.ValidatorUpdate
baseAppOptions []BaseAppOption
msgServiceRouter *baseapp.MsgServiceRouter
appConfig *appv1alpha1.Config
Expand Down
25 changes: 0 additions & 25 deletions store/iavl/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,28 +410,3 @@ func getProofFromTree(tree *iavl.MutableTree, key []byte, exists bool) *tmcrypto
op := types.NewIavlCommitmentOp(key, commitmentProof)
return &tmcrypto.ProofOps{Ops: []tmcrypto.ProofOp{op.ProofOp()}}
}

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

// iavlIterator implements types.Iterator.
type iavlIterator struct {
dbm.Iterator
}

var _ types.Iterator = (*iavlIterator)(nil)

// newIAVLIterator will create a new iavlIterator.
// CONTRACT: Caller must release the iavlIterator, as each one creates a new
// goroutine.
//
//nolint:deadcode,unused
func newIAVLIterator(tree *iavl.ImmutableTree, start, end []byte, ascending bool) *iavlIterator {
iterator, err := tree.Iterator(start, end, ascending)
if err != nil {
panic(err)
}
iter := &iavlIterator{
Iterator: iterator,
}
return iter
}
1 change: 1 addition & 0 deletions store/iavl/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func TestGetImmutable(t *testing.T) {
store := UnsafeNewStore(tree)

updated, err := tree.Set([]byte("hello"), []byte("adios"))
require.NoError(t, err)
require.True(t, updated)
hash, ver, err := tree.SaveVersion()
cID = types.CommitID{Version: ver, Hash: hash}
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/bank/keeper/deterministic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ func (suite *DeterministicTestSuite) TestGRPCQueryTotalSupply() {
initialSupply := res.GetSupply()

rapid.Check(suite.T(), func(t *rapid.T) {

numCoins := rapid.IntRange(1, 3).Draw(t, "num-count")
coins := make(sdk.Coins, 0, numCoins)

Expand Down Expand Up @@ -233,7 +232,6 @@ func (suite *DeterministicTestSuite) TestGRPCQueryTotalSupplyOf() {

req := &banktypes.QuerySupplyOfRequest{Denom: coin.GetDenom()}
testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.SupplyOf, 0, true)

})

coin := sdk.NewCoin("bar", sdk.NewInt(100))
Expand Down
8 changes: 3 additions & 5 deletions testutil/testdata/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

var (
// iterCount defines the number of iterations to run on each query to test
// determinism.
iterCount = 1000
)
// iterCount defines the number of iterations to run on each query to test
// determinism.
var iterCount = 1000

type QueryImpl struct{}

Expand Down
3 changes: 1 addition & 2 deletions tx/textual/valuerenderer/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import (
"google.golang.org/protobuf/reflect/protoreflect"
)

type stringValueRenderer struct {
}
type stringValueRenderer struct{}

// NewStringValueRenderer returns a ValueRenderer for protocol buffer string values.
// It renders the string as-is without quotation.
Expand Down
6 changes: 0 additions & 6 deletions types/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@ func (s *contextTestSuite) TestLogContext() {
ctx.Logger().Error("error")
}

type dummy int64 //nolint:unused

func (d dummy) Clone() interface{} {
return d
}

// Testing saving/loading sdk type values to/from the context
func (s *contextTestSuite) TestContextWithCustom() {
var ctx types.Context
Expand Down
3 changes: 2 additions & 1 deletion types/mempool/mempool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ func (tx testTx) GetSignaturesV2() (res []txsigning.SignatureV2, err error) {
res = append(res, txsigning.SignatureV2{
PubKey: testPubKey{address: tx.address},
Data: nil,
Sequence: tx.nonce})
Sequence: tx.nonce,
})

return res, nil
}
Expand Down
55 changes: 50 additions & 5 deletions x/auth/keeper/deterministic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ type DeterministicTestSuite struct {
}

var (
addr = sdk.MustAccAddressFromBech32("cosmos1j364pjm8jkxxmujj0vp2xjg0y7w8tyveuamfm6")
pub, _ = hex.DecodeString("01090C02812F010C25200ED40E004105160196E801F70005070EA21603FF06001E")
addr = sdk.MustAccAddressFromBech32("cosmos1j364pjm8jkxxmujj0vp2xjg0y7w8tyveuamfm6")
pub, _ = hex.DecodeString("01090C02812F010C25200ED40E004105160196E801F70005070EA21603FF06001E")
permissions = []string{"burner", "minter", "staking", "random"}
)

func TestDeterministicTestSuite(t *testing.T) {
Expand Down Expand Up @@ -252,8 +253,6 @@ func (suite *DeterministicTestSuite) setModuleAccounts(
}

func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccounts() {
permissions := []string{"burner", "minter", "staking", "random"}

rapid.Check(suite.T(), func(t *rapid.T) {
maccsCount := rapid.IntRange(1, 10).Draw(t, "accounts")
maccs := make([]string, maccsCount)
Expand Down Expand Up @@ -303,5 +302,51 @@ func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccounts() {

queryClient := suite.createAndReturnQueryClient(suite.accountKeeper)
req := &types.QueryModuleAccountsRequest{}
testdata.DeterministicIterations(suite.ctx, suite.Require(), req, queryClient.ModuleAccounts, 0x2175, false)
testdata.DeterministicIterations(suite.ctx, suite.Require(), req, queryClient.ModuleAccounts, 8565, false)
}

func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccountByName() {
rapid.Check(suite.T(), func(t *rapid.T) {
mName := rapid.StringMatching(`[a-z]{5,}`).Draw(t, "module-name")

maccPerms := make(map[string][]string)
mPerms := make([]string, 0, 4)
for _, permission := range permissions {
if rapid.Bool().Draw(t, "permissions") {
mPerms = append(mPerms, permission)
}
}

if len(mPerms) == 0 {
num := rapid.IntRange(0, 3).Draw(t, "num")
mPerms = append(mPerms, permissions[num])
}

maccPerms[mName] = mPerms

ak := keeper.NewAccountKeeper(
suite.encCfg.Codec,
suite.key,
types.ProtoBaseAccount,
maccPerms,
"cosmos",
types.NewModuleAddress("gov").String(),
)
suite.setModuleAccounts(suite.ctx, ak, []string{mName})

queryClient := suite.createAndReturnQueryClient(ak)
req := &types.QueryModuleAccountByNameRequest{Name: mName}
testdata.DeterministicIterations(suite.ctx, suite.Require(), req, queryClient.ModuleAccountByName, 0, true)
})

maccs := make([]string, 0, len(suite.maccPerms))
for k := range suite.maccPerms {
maccs = append(maccs, k)
}

suite.setModuleAccounts(suite.ctx, suite.accountKeeper, maccs)

queryClient := suite.createAndReturnQueryClient(suite.accountKeeper)
req := &types.QueryModuleAccountByNameRequest{Name: "mint"}
testdata.DeterministicIterations(suite.ctx, suite.Require(), req, queryClient.ModuleAccountByName, 1372, false)
}
33 changes: 0 additions & 33 deletions x/bank/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,6 @@ func (se SendEnabled) Validate() error {
return sdk.ValidateDenom(se.Denom)
}

// validateSendEnabledParams is used by the x/params module to validate the params for the bank module.
//
//nolint:deadcode,unused
func validateSendEnabledParams(i interface{}) error {
params, ok := i.([]*SendEnabled)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
// ensure each denom is only registered one time.
registered := make(map[string]bool)
for _, p := range params {
if _, exists := registered[p.Denom]; exists {
return fmt.Errorf("duplicate send enabled parameter found: '%s'", p.Denom)
}
if err := validateSendEnabled(*p); err != nil {
return err
}
registered[p.Denom] = true
}
return nil
}

// NewSendEnabled creates a new SendEnabled object
// The denom may be left empty to control the global default setting of send_enabled
func NewSendEnabled(denom string, sendEnabled bool) *SendEnabled {
Expand All @@ -87,17 +65,6 @@ func (se SendEnabled) String() string {
return fmt.Sprintf("denom: %s\nenabled: %t\n", se.Denom, se.Enabled)
}

// validateSendEnabled is used by the x/params module to validate a single SendEnabled entry.
//
//nolint:unused
func validateSendEnabled(i interface{}) error {
param, ok := i.(SendEnabled)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
return param.Validate()
}

// validateIsBool is used by the x/params module to validate that a thing is a bool.
func validateIsBool(i interface{}) error {
_, ok := i.(bool)
Expand Down
73 changes: 0 additions & 73 deletions x/bank/types/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,12 @@ package types
import (
"testing"

"cosmossdk.io/math"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

sdk "github.com/cosmos/cosmos-sdk/types"
)

func Test_validateSendEnabledParam(t *testing.T) {
type args struct {
i interface{}
}
tests := []struct {
name string
args args
wantErr bool
}{
{"invalid type", args{sdk.NewCoin(sdk.DefaultBondDenom, math.OneInt())}, true},

{"invalid empty denom send enabled", args{*NewSendEnabled("", true)}, true},
{"invalid empty denom send disabled", args{*NewSendEnabled("", false)}, true},

{"valid denom send enabled", args{*NewSendEnabled(sdk.DefaultBondDenom, true)}, false},
{"valid denom send disabled", args{*NewSendEnabled(sdk.DefaultBondDenom, false)}, false},

{"invalid denom send enabled", args{*NewSendEnabled("0FOO", true)}, true},
{"invalid denom send disabled", args{*NewSendEnabled("0FOO", false)}, true},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.wantErr, validateSendEnabled(tt.args.i) != nil)
})
}
}

func Test_sendParamEqual(t *testing.T) {
paramsA := NewSendEnabled(sdk.DefaultBondDenom, true)
paramsB := NewSendEnabled(sdk.DefaultBondDenom, true)
Expand Down Expand Up @@ -100,47 +71,3 @@ func Test_validateParams(t *testing.T) {
assert.NoError(t, NewParams(false).Validate(), "false")
assert.Error(t, Params{[]*SendEnabled{{"foocoing", false}}, true}.Validate(), "with SendEnabled entry")
}

func Test_validateSendEnabledParams(t *testing.T) {
tests := []struct {
name string
arg interface{}
exp string
}{
{
name: "ok",
arg: []*SendEnabled{},
exp: "",
},
{
name: "has entry",
arg: []*SendEnabled{{"foocoin", false}},
exp: "",
},
{
name: "not a slice",
arg: &SendEnabled{},
exp: "invalid parameter type: *types.SendEnabled",
},
{
name: "not a slice of refs",
arg: []SendEnabled{},
exp: "invalid parameter type: []types.SendEnabled",
},
{
name: "not a slice of send enabled",
arg: []*Params{},
exp: "invalid parameter type: []*types.Params",
},
}
for _, tc := range tests {
t.Run(tc.name, func(tt *testing.T) {
actual := validateSendEnabledParams(tc.arg)
if len(tc.exp) == 0 {
assert.NoError(tt, actual)
} else {
assert.EqualError(tt, actual, tc.exp)
}
})
}
}
3 changes: 0 additions & 3 deletions x/gov/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ import (

// Keeper defines the governance module Keeper
type Keeper struct {
// The reference to the Paramstore to get and set gov specific params
paramSpace types.ParamSubspace //nolint:unused

authKeeper types.AccountKeeper
bankKeeper types.BankKeeper

Expand Down
1 change: 0 additions & 1 deletion x/gov/migrations/v4/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ func TestMigrateStore(t *testing.T) {
// Check if proposal 2 is in the new store but not proposal 1
require.Nil(t, store.Get(v4.VotingPeriodProposalKey(proposal1.Id)))
require.Equal(t, []byte{0x1}, store.Get(v4.VotingPeriodProposalKey(proposal2.Id)))

}

func getTestProposal() []sdk.Msg {
Expand Down

0 comments on commit 6ddbf13

Please sign in to comment.