diff --git a/go.mod b/go.mod index ee7977a475d..636819e0ef4 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ module github.com/cosmos/cosmos-sdk require ( cosmossdk.io/api v0.7.0 - cosmossdk.io/collections v0.3.0 + cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68 cosmossdk.io/core v0.10.0 cosmossdk.io/depinject v1.0.0-alpha.4 cosmossdk.io/errors v1.0.0 diff --git a/go.sum b/go.sum index c914d9c8c22..8806f7d6399 100644 --- a/go.sum +++ b/go.sum @@ -37,8 +37,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= cosmossdk.io/api v0.7.0 h1:QsEMIWuv9xWDbF2HZnW4Lpu1/SejCztPu0LQx7t6MN4= cosmossdk.io/api v0.7.0/go.mod h1:kJFAEMLN57y0viszHDPLMmieF0471o5QAwwApa+270M= -cosmossdk.io/collections v0.3.0 h1:v0eEqLBxebAV+t+Ahwf9tSJOu95HVLINwROXx2TTZ08= -cosmossdk.io/collections v0.3.0/go.mod h1:CHE1+niUElL9ikCpevRZcp0yqQ4TU0TrEEGirN0mvIg= +cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68 h1:aFHpJtJgdqBH8kRvD86Rl92rvd1+JFpaUpj+5NZNodg= +cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68/go.mod h1:OK08xZu8fxXLoQcFIfkBDayo2aRokLfC3vVcXX0MB8E= cosmossdk.io/core v0.10.0 h1:NP28Ol9YyRODmZLJg2ko/mUl40hMegeMzhJnG+XPkcY= cosmossdk.io/core v0.10.0/go.mod h1:MygXNld9DvMgYY4yE76DM/mdZpgfeyRjy6FPjEEehlY= cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= diff --git a/simapp/go.mod b/simapp/go.mod index fcf6ca27823..6818fc3de92 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -37,7 +37,7 @@ require ( cloud.google.com/go/compute/metadata v0.2.3 // indirect cloud.google.com/go/iam v1.1.0 // indirect cloud.google.com/go/storage v1.30.1 // indirect - cosmossdk.io/collections v0.3.0 // indirect + cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68 // indirect cosmossdk.io/errors v1.0.0 // indirect filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect diff --git a/simapp/go.sum b/simapp/go.sum index 840dd5bcdba..21a76392d26 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -191,8 +191,8 @@ cosmossdk.io/api v0.7.0 h1:QsEMIWuv9xWDbF2HZnW4Lpu1/SejCztPu0LQx7t6MN4= cosmossdk.io/api v0.7.0/go.mod h1:kJFAEMLN57y0viszHDPLMmieF0471o5QAwwApa+270M= cosmossdk.io/client/v2 v2.0.0-20230816141149-e3a3df2a824b h1:0d6jT9oqH4ms7Ak1mFjB+FFu1UtzGMPWVjvSguPCpn4= cosmossdk.io/client/v2 v2.0.0-20230816141149-e3a3df2a824b/go.mod h1:TbVT7QkpMHo+nwmztzYCfCCzO8w776VDe97ME3yjW0I= -cosmossdk.io/collections v0.3.0 h1:v0eEqLBxebAV+t+Ahwf9tSJOu95HVLINwROXx2TTZ08= -cosmossdk.io/collections v0.3.0/go.mod h1:CHE1+niUElL9ikCpevRZcp0yqQ4TU0TrEEGirN0mvIg= +cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68 h1:aFHpJtJgdqBH8kRvD86Rl92rvd1+JFpaUpj+5NZNodg= +cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68/go.mod h1:OK08xZu8fxXLoQcFIfkBDayo2aRokLfC3vVcXX0MB8E= cosmossdk.io/core v0.10.0 h1:NP28Ol9YyRODmZLJg2ko/mUl40hMegeMzhJnG+XPkcY= cosmossdk.io/core v0.10.0/go.mod h1:MygXNld9DvMgYY4yE76DM/mdZpgfeyRjy6FPjEEehlY= cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= diff --git a/tests/go.mod b/tests/go.mod index f204b2f3db6..1d743a3272d 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -4,7 +4,6 @@ go 1.20 require ( cosmossdk.io/api v0.7.0 - cosmossdk.io/collections v0.3.0 // indirect cosmossdk.io/core v0.10.0 cosmossdk.io/depinject v1.0.0-alpha.4 cosmossdk.io/errors v1.0.0 @@ -39,6 +38,7 @@ require ( cloud.google.com/go/iam v1.1.0 // indirect cloud.google.com/go/storage v1.30.1 // indirect cosmossdk.io/client/v2 v2.0.0-20230816141149-e3a3df2a824b // indirect + cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68 // indirect cosmossdk.io/x/circuit v0.0.0-20230719143845-dff6b0e26aa4 // indirect filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect diff --git a/tests/go.sum b/tests/go.sum index 1a54a5826e0..fa771149a2f 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -191,8 +191,8 @@ cosmossdk.io/api v0.7.0 h1:QsEMIWuv9xWDbF2HZnW4Lpu1/SejCztPu0LQx7t6MN4= cosmossdk.io/api v0.7.0/go.mod h1:kJFAEMLN57y0viszHDPLMmieF0471o5QAwwApa+270M= cosmossdk.io/client/v2 v2.0.0-20230816141149-e3a3df2a824b h1:0d6jT9oqH4ms7Ak1mFjB+FFu1UtzGMPWVjvSguPCpn4= cosmossdk.io/client/v2 v2.0.0-20230816141149-e3a3df2a824b/go.mod h1:TbVT7QkpMHo+nwmztzYCfCCzO8w776VDe97ME3yjW0I= -cosmossdk.io/collections v0.3.0 h1:v0eEqLBxebAV+t+Ahwf9tSJOu95HVLINwROXx2TTZ08= -cosmossdk.io/collections v0.3.0/go.mod h1:CHE1+niUElL9ikCpevRZcp0yqQ4TU0TrEEGirN0mvIg= +cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68 h1:aFHpJtJgdqBH8kRvD86Rl92rvd1+JFpaUpj+5NZNodg= +cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68/go.mod h1:OK08xZu8fxXLoQcFIfkBDayo2aRokLfC3vVcXX0MB8E= cosmossdk.io/core v0.10.0 h1:NP28Ol9YyRODmZLJg2ko/mUl40hMegeMzhJnG+XPkcY= cosmossdk.io/core v0.10.0/go.mod h1:MygXNld9DvMgYY4yE76DM/mdZpgfeyRjy6FPjEEehlY= cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index cb0787a5add..da2937372c6 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -2,10 +2,8 @@ package keeper import ( "context" - "errors" "fmt" - "cosmossdk.io/collections" "cosmossdk.io/core/store" errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" @@ -258,7 +256,7 @@ func (k BaseKeeper) IterateAllDenomMetaData(ctx context.Context, cb func(types.M err := k.BaseViewKeeper.DenomMetadata.Walk(ctx, nil, func(_ string, metadata types.Metadata) (stop bool, err error) { return cb(metadata), nil }) - if err != nil && !errors.Is(err, collections.ErrInvalidIterator) { + if err != nil { panic(err) } } @@ -479,7 +477,7 @@ func (k BaseViewKeeper) IterateTotalSupply(ctx context.Context, cb func(sdk.Coin err := k.Supply.Walk(ctx, nil, func(s string, m math.Int) (bool, error) { return cb(sdk.NewCoin(s, m)), nil }) - if err != nil && !errors.Is(err, collections.ErrInvalidIterator) { + if err != nil { panic(err) } } diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go index 5ba51deb58d..1371d4e4e63 100644 --- a/x/bank/keeper/send.go +++ b/x/bank/keeper/send.go @@ -382,7 +382,7 @@ func (k BaseSendKeeper) IterateSendEnabledEntries(ctx context.Context, cb func(d err := k.SendEnabled.Walk(ctx, nil, func(key string, value bool) (stop bool, err error) { return cb(key, value), nil }) - if err != nil && !errorsmod.IsOf(err, collections.ErrInvalidIterator) { + if err != nil { panic(err) } } diff --git a/x/bank/keeper/view.go b/x/bank/keeper/view.go index 9132032f774..d4e2544bc79 100644 --- a/x/bank/keeper/view.go +++ b/x/bank/keeper/view.go @@ -4,8 +4,6 @@ import ( "context" "fmt" - "github.com/cockroachdb/errors" - "cosmossdk.io/collections" "cosmossdk.io/collections/indexes" "cosmossdk.io/core/store" @@ -158,7 +156,7 @@ func (k BaseViewKeeper) IterateAccountBalances(ctx context.Context, addr sdk.Acc err := k.Balances.Walk(ctx, collections.NewPrefixedPairRange[sdk.AccAddress, string](addr), func(key collections.Pair[sdk.AccAddress, string], value math.Int) (stop bool, err error) { return cb(sdk.NewCoin(key.K2(), value)), nil }) - if err != nil && !errors.Is(err, collections.ErrInvalidIterator) { + if err != nil { panic(err) } } @@ -170,7 +168,7 @@ func (k BaseViewKeeper) IterateAllBalances(ctx context.Context, cb func(sdk.AccA err := k.Balances.Walk(ctx, nil, func(key collections.Pair[sdk.AccAddress, string], value math.Int) (stop bool, err error) { return cb(key.K1(), sdk.NewCoin(key.K2(), value)), nil }) - if err != nil && !errors.Is(err, collections.ErrInvalidIterator) { + if err != nil { panic(err) } } diff --git a/x/circuit/go.mod b/x/circuit/go.mod index 6548013f4e9..e1bb8d8a97b 100644 --- a/x/circuit/go.mod +++ b/x/circuit/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( cosmossdk.io/api v0.7.0 - cosmossdk.io/collections v0.3.0 + cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68 cosmossdk.io/core v0.10.0 cosmossdk.io/depinject v1.0.0-alpha.4 cosmossdk.io/errors v1.0.0 @@ -149,6 +149,6 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.0 // indirect nhooyr.io/websocket v1.8.6 // indirect - pgregory.net/rapid v1.0.0 // indirect + pgregory.net/rapid v1.0.1 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/x/circuit/go.sum b/x/circuit/go.sum index b23b6629537..6d153abe9a6 100644 --- a/x/circuit/go.sum +++ b/x/circuit/go.sum @@ -37,8 +37,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= cosmossdk.io/api v0.7.0 h1:QsEMIWuv9xWDbF2HZnW4Lpu1/SejCztPu0LQx7t6MN4= cosmossdk.io/api v0.7.0/go.mod h1:kJFAEMLN57y0viszHDPLMmieF0471o5QAwwApa+270M= -cosmossdk.io/collections v0.3.0 h1:v0eEqLBxebAV+t+Ahwf9tSJOu95HVLINwROXx2TTZ08= -cosmossdk.io/collections v0.3.0/go.mod h1:CHE1+niUElL9ikCpevRZcp0yqQ4TU0TrEEGirN0mvIg= +cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68 h1:aFHpJtJgdqBH8kRvD86Rl92rvd1+JFpaUpj+5NZNodg= +cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68/go.mod h1:OK08xZu8fxXLoQcFIfkBDayo2aRokLfC3vVcXX0MB8E= cosmossdk.io/core v0.10.0 h1:NP28Ol9YyRODmZLJg2ko/mUl40hMegeMzhJnG+XPkcY= cosmossdk.io/core v0.10.0/go.mod h1:MygXNld9DvMgYY4yE76DM/mdZpgfeyRjy6FPjEEehlY= cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= @@ -1231,8 +1231,8 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= -pgregory.net/rapid v1.0.0 h1:iQaM2w5PZ6xvt6x7hbd7tiDS+nk7YPp5uCaEba+T/F4= -pgregory.net/rapid v1.0.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= +pgregory.net/rapid v1.0.1 h1:4bhVd38cZJzEMeIzypWN2egQKA6t1BoqAPWZwiral0U= +pgregory.net/rapid v1.0.1/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/x/circuit/keeper/genesis.go b/x/circuit/keeper/genesis.go index 50fd6af67c5..d6747d44290 100644 --- a/x/circuit/keeper/genesis.go +++ b/x/circuit/keeper/genesis.go @@ -3,8 +3,6 @@ package keeper import ( context "context" - "cosmossdk.io/collections" - errorsmod "cosmossdk.io/errors" "cosmossdk.io/x/circuit/types" ) @@ -27,7 +25,7 @@ func (k *Keeper) ExportGenesis(ctx context.Context) (data *types.GenesisState) { }) return false, nil }) - if err != nil && !errorsmod.IsOf(err, collections.ErrInvalidIterator) { + if err != nil { panic(err) } @@ -35,7 +33,7 @@ func (k *Keeper) ExportGenesis(ctx context.Context) (data *types.GenesisState) { disabledMsgs = append(disabledMsgs, msgUrl) return false, nil }) - if err != nil && !errorsmod.IsOf(err, collections.ErrInvalidIterator) { + if err != nil { panic(err) } diff --git a/x/circuit/keeper/query.go b/x/circuit/keeper/query.go index 931fe828d23..8ab7b4214ae 100644 --- a/x/circuit/keeper/query.go +++ b/x/circuit/keeper/query.go @@ -3,8 +3,6 @@ package keeper import ( "context" - "cosmossdk.io/collections" - errorsmod "cosmossdk.io/errors" "cosmossdk.io/x/circuit/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -72,7 +70,7 @@ func (qs QueryServer) DisabledList(ctx context.Context, req *types.QueryDisabled msgs = append(msgs, msgUrl) return false, nil }) - if err != nil && !errorsmod.IsOf(err, collections.ErrInvalidIterator) { + if err != nil { return nil, err } diff --git a/x/evidence/genesis.go b/x/evidence/genesis.go index 4cd4d063618..1c756941554 100644 --- a/x/evidence/genesis.go +++ b/x/evidence/genesis.go @@ -1,10 +1,8 @@ package evidence import ( - "errors" "fmt" - "cosmossdk.io/collections" "cosmossdk.io/x/evidence/exported" "cosmossdk.io/x/evidence/keeper" "cosmossdk.io/x/evidence/types" @@ -46,7 +44,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { gs.Evidence = append(gs.Evidence, anyEvi) return false, nil }) - if err != nil && !errors.Is(err, collections.ErrInvalidIterator) { + if err != nil { panic(err) } return gs diff --git a/x/evidence/genesis_test.go b/x/evidence/genesis_test.go index 2b5dea52ae6..600f61cad7d 100644 --- a/x/evidence/genesis_test.go +++ b/x/evidence/genesis_test.go @@ -9,7 +9,6 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "cosmossdk.io/collections" "cosmossdk.io/depinject" "cosmossdk.io/log" "cosmossdk.io/x/evidence" @@ -96,7 +95,7 @@ func (suite *GenesisTestSuite) TestInitGenesis() { false, func() { _, err := suite.keeper.Evidences.Iterate(suite.ctx, nil) - suite.Require().ErrorIs(err, collections.ErrInvalidIterator) + suite.Require().NoError(err) }, }, } diff --git a/x/evidence/go.mod b/x/evidence/go.mod index 06bca25fd5b..7f55441e5c0 100644 --- a/x/evidence/go.mod +++ b/x/evidence/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( cosmossdk.io/api v0.7.0 - cosmossdk.io/collections v0.3.0 + cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68 cosmossdk.io/core v0.10.0 cosmossdk.io/depinject v1.0.0-alpha.4 cosmossdk.io/errors v1.0.0 @@ -150,7 +150,7 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.0 // indirect nhooyr.io/websocket v1.8.6 // indirect - pgregory.net/rapid v1.0.0 // indirect + pgregory.net/rapid v1.0.1 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/x/evidence/go.sum b/x/evidence/go.sum index e68d8d5914d..1eafe9deaca 100644 --- a/x/evidence/go.sum +++ b/x/evidence/go.sum @@ -37,8 +37,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= cosmossdk.io/api v0.7.0 h1:QsEMIWuv9xWDbF2HZnW4Lpu1/SejCztPu0LQx7t6MN4= cosmossdk.io/api v0.7.0/go.mod h1:kJFAEMLN57y0viszHDPLMmieF0471o5QAwwApa+270M= -cosmossdk.io/collections v0.3.0 h1:v0eEqLBxebAV+t+Ahwf9tSJOu95HVLINwROXx2TTZ08= -cosmossdk.io/collections v0.3.0/go.mod h1:CHE1+niUElL9ikCpevRZcp0yqQ4TU0TrEEGirN0mvIg= +cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68 h1:aFHpJtJgdqBH8kRvD86Rl92rvd1+JFpaUpj+5NZNodg= +cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68/go.mod h1:OK08xZu8fxXLoQcFIfkBDayo2aRokLfC3vVcXX0MB8E= cosmossdk.io/core v0.10.0 h1:NP28Ol9YyRODmZLJg2ko/mUl40hMegeMzhJnG+XPkcY= cosmossdk.io/core v0.10.0/go.mod h1:MygXNld9DvMgYY4yE76DM/mdZpgfeyRjy6FPjEEehlY= cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= @@ -1277,8 +1277,8 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= -pgregory.net/rapid v1.0.0 h1:iQaM2w5PZ6xvt6x7hbd7tiDS+nk7YPp5uCaEba+T/F4= -pgregory.net/rapid v1.0.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= +pgregory.net/rapid v1.0.1 h1:4bhVd38cZJzEMeIzypWN2egQKA6t1BoqAPWZwiral0U= +pgregory.net/rapid v1.0.1/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= diff --git a/x/gov/abci.go b/x/gov/abci.go index 43e9cde2592..0be4c0f5d38 100644 --- a/x/gov/abci.go +++ b/x/gov/abci.go @@ -1,7 +1,6 @@ package gov import ( - "errors" "fmt" "time" @@ -68,7 +67,7 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) error { return false, nil }) - if err != nil && !errors.Is(err, collections.ErrInvalidIterator) { + if err != nil { return err } @@ -219,7 +218,7 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) error { return false, nil }) - if err != nil && !errors.Is(err, collections.ErrInvalidIterator) { + if err != nil { return err } return nil diff --git a/x/gov/abci_test.go b/x/gov/abci_test.go index a8be3bb1ee7..b30fecb6ed1 100644 --- a/x/gov/abci_test.go +++ b/x/gov/abci_test.go @@ -35,7 +35,7 @@ func TestTickExpiredDepositPeriod(t *testing.T) { govMsgSvr := keeper.NewMsgServerImpl(suite.GovKeeper) - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, true) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) newProposalMsg, err := v1.NewMsgSubmitProposal( []sdk.Msg{mkTestLegacyContent(t)}, @@ -52,25 +52,25 @@ func TestTickExpiredDepositPeriod(t *testing.T) { require.NoError(t, err) require.NotNil(t, res) - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, true) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) newHeader := ctx.BlockHeader() newHeader.Time = ctx.BlockHeader().Time.Add(time.Duration(1) * time.Second) ctx = ctx.WithBlockHeader(newHeader) - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, true) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) params, _ := suite.GovKeeper.Params.Get(ctx) newHeader = ctx.BlockHeader() newHeader.Time = ctx.BlockHeader().Time.Add(*params.MaxDepositPeriod) ctx = ctx.WithBlockHeader(newHeader) - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, false) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) err = gov.EndBlocker(ctx, suite.GovKeeper) require.NoError(t, err) - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, true) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) } func TestTickMultipleExpiredDepositPeriod(t *testing.T) { @@ -86,7 +86,7 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) { govMsgSvr := keeper.NewMsgServerImpl(suite.GovKeeper) - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, true) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) newProposalMsg, err := v1.NewMsgSubmitProposal( []sdk.Msg{mkTestLegacyContent(t)}, @@ -103,13 +103,13 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) { require.NoError(t, err) require.NotNil(t, res) - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, true) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) newHeader := ctx.BlockHeader() newHeader.Time = ctx.BlockHeader().Time.Add(time.Duration(2) * time.Second) ctx = ctx.WithBlockHeader(newHeader) - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, true) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) newProposalMsg2, err := v1.NewMsgSubmitProposal( []sdk.Msg{mkTestLegacyContent(t)}, @@ -131,17 +131,17 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) { newHeader.Time = ctx.BlockHeader().Time.Add(*params.MaxDepositPeriod).Add(time.Duration(-1) * time.Second) ctx = ctx.WithBlockHeader(newHeader) - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, false) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) require.NoError(t, gov.EndBlocker(ctx, suite.GovKeeper)) - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, true) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) newHeader = ctx.BlockHeader() newHeader.Time = ctx.BlockHeader().Time.Add(time.Duration(5) * time.Second) ctx = ctx.WithBlockHeader(newHeader) - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, false) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) require.NoError(t, gov.EndBlocker(ctx, suite.GovKeeper)) - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, true) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) } func TestTickPassedDepositPeriod(t *testing.T) { @@ -174,13 +174,13 @@ func TestTickPassedDepositPeriod(t *testing.T) { proposalID := res.ProposalId - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, true) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) newHeader := ctx.BlockHeader() newHeader.Time = ctx.BlockHeader().Time.Add(time.Duration(1) * time.Second) ctx = ctx.WithBlockHeader(newHeader) - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, true) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) newDepositMsg := v1.NewMsgDeposit(addrs[1], proposalID, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)}) @@ -188,7 +188,7 @@ func TestTickPassedDepositPeriod(t *testing.T) { require.NoError(t, err) require.NotNil(t, res1) - checkActiveProposalsQueue(t, ctx, suite.GovKeeper, true) + checkActiveProposalsQueue(t, ctx, suite.GovKeeper) } func TestTickPassedVotingPeriod(t *testing.T) { @@ -222,8 +222,8 @@ func TestTickPassedVotingPeriod(t *testing.T) { govMsgSvr := keeper.NewMsgServerImpl(suite.GovKeeper) - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, true) - checkActiveProposalsQueue(t, ctx, suite.GovKeeper, true) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) + checkActiveProposalsQueue(t, ctx, suite.GovKeeper) proposalCoins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, suite.StakingKeeper.TokensFromConsensusPower(ctx, 5*depositMultiplier))} newProposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{mkTestLegacyContent(t)}, proposalCoins, addrs[0].String(), "", "Proposal", "description of proposal", tc.expedited) @@ -255,8 +255,8 @@ func TestTickPassedVotingPeriod(t *testing.T) { newHeader.Time = ctx.BlockHeader().Time.Add(*params.MaxDepositPeriod).Add(*votingPeriod) ctx = ctx.WithBlockHeader(newHeader) - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, true) - checkActiveProposalsQueue(t, ctx, suite.GovKeeper, false) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) + checkActiveProposalsQueue(t, ctx, suite.GovKeeper) proposal, err := suite.GovKeeper.Proposals.Get(ctx, res.ProposalId) require.NoError(t, err) @@ -266,12 +266,12 @@ func TestTickPassedVotingPeriod(t *testing.T) { require.NoError(t, err) if !tc.expedited { - checkActiveProposalsQueue(t, ctx, suite.GovKeeper, true) + checkActiveProposalsQueue(t, ctx, suite.GovKeeper) return } // If expedited, it should be converted to a regular proposal instead. - checkActiveProposalsQueue(t, ctx, suite.GovKeeper, false) + checkActiveProposalsQueue(t, ctx, suite.GovKeeper) proposal, err = suite.GovKeeper.Proposals.Get(ctx, res.ProposalId) require.Nil(t, err) @@ -464,8 +464,8 @@ func TestExpeditedProposal_PassAndConversionToRegular(t *testing.T) { createValidators(t, stakingMsgSvr, ctx, []sdk.ValAddress{valAddr}, []int64{10}) suite.StakingKeeper.EndBlocker(ctx) - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, true) - checkActiveProposalsQueue(t, ctx, suite.GovKeeper, true) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) + checkActiveProposalsQueue(t, ctx, suite.GovKeeper) macc := suite.GovKeeper.GetGovernanceAccount(ctx) require.NotNil(t, macc) @@ -498,8 +498,8 @@ func TestExpeditedProposal_PassAndConversionToRegular(t *testing.T) { newHeader.Time = ctx.BlockHeader().Time.Add(*params.MaxDepositPeriod).Add(*params.ExpeditedVotingPeriod) ctx = ctx.WithBlockHeader(newHeader) - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, true) - checkActiveProposalsQueue(t, ctx, suite.GovKeeper, false) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) + checkActiveProposalsQueue(t, ctx, suite.GovKeeper) proposal, err := suite.GovKeeper.Proposals.Get(ctx, res.ProposalId) require.Nil(t, err) @@ -515,7 +515,7 @@ func TestExpeditedProposal_PassAndConversionToRegular(t *testing.T) { gov.EndBlocker(ctx, suite.GovKeeper) if tc.expeditedPasses { - checkActiveProposalsQueue(t, ctx, suite.GovKeeper, true) + checkActiveProposalsQueue(t, ctx, suite.GovKeeper) proposal, err = suite.GovKeeper.Proposals.Get(ctx, res.ProposalId) require.Nil(t, err) @@ -536,7 +536,7 @@ func TestExpeditedProposal_PassAndConversionToRegular(t *testing.T) { } // Expedited proposal should be converted to a regular proposal instead. - checkActiveProposalsQueue(t, ctx, suite.GovKeeper, false) + checkActiveProposalsQueue(t, ctx, suite.GovKeeper) proposal, err = suite.GovKeeper.Proposals.Get(ctx, res.ProposalId) require.Nil(t, err) require.Equal(t, v1.StatusVotingPeriod, proposal.Status) @@ -557,8 +557,8 @@ func TestExpeditedProposal_PassAndConversionToRegular(t *testing.T) { newHeader.Time = ctx.BlockHeader().Time.Add(*params.MaxDepositPeriod).Add(*params.VotingPeriod) ctx = ctx.WithBlockHeader(newHeader) - checkInactiveProposalsQueue(t, ctx, suite.GovKeeper, true) - checkActiveProposalsQueue(t, ctx, suite.GovKeeper, false) + checkInactiveProposalsQueue(t, ctx, suite.GovKeeper) + checkActiveProposalsQueue(t, ctx, suite.GovKeeper) if tc.regularEventuallyPassing { // Validator votes YES, letting the converted regular proposal pass. @@ -576,7 +576,7 @@ func TestExpeditedProposal_PassAndConversionToRegular(t *testing.T) { submitterEventualBalance := suite.BankKeeper.GetAllBalances(ctx, addrs[0]) depositorEventualBalance := suite.BankKeeper.GetAllBalances(ctx, addrs[1]) - checkActiveProposalsQueue(t, ctx, suite.GovKeeper, true) + checkActiveProposalsQueue(t, ctx, suite.GovKeeper) proposal, err = suite.GovKeeper.Proposals.Get(ctx, res.ProposalId) require.Nil(t, err) @@ -628,24 +628,18 @@ func getDepositMultiplier(expedited bool) int64 { return 1 } -func checkActiveProposalsQueue(t *testing.T, ctx sdk.Context, k *keeper.Keeper, invalid bool) { +func checkActiveProposalsQueue(t *testing.T, ctx sdk.Context, k *keeper.Keeper) { err := k.ActiveProposalsQueue.Walk(ctx, collections.NewPrefixUntilPairRange[time.Time, uint64](ctx.BlockTime()), func(key collections.Pair[time.Time, uint64], value uint64) (stop bool, err error) { return false, err }) - if invalid { - require.ErrorIs(t, err, collections.ErrInvalidIterator) - } else { - require.NoError(t, err) - } + + require.NoError(t, err) } -func checkInactiveProposalsQueue(t *testing.T, ctx sdk.Context, k *keeper.Keeper, invalid bool) { +func checkInactiveProposalsQueue(t *testing.T, ctx sdk.Context, k *keeper.Keeper) { err := k.InactiveProposalsQueue.Walk(ctx, collections.NewPrefixUntilPairRange[time.Time, uint64](ctx.BlockTime()), func(key collections.Pair[time.Time, uint64], value uint64) (stop bool, err error) { return false, err }) - if invalid { - require.ErrorIs(t, err, collections.ErrInvalidIterator) - } else { - require.NoError(t, err) - } + + require.NoError(t, err) } diff --git a/x/gov/genesis.go b/x/gov/genesis.go index 8877324d654..0eeebcd72e2 100644 --- a/x/gov/genesis.go +++ b/x/gov/genesis.go @@ -1,7 +1,6 @@ package gov import ( - "errors" "fmt" "cosmossdk.io/collections" @@ -98,7 +97,7 @@ func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) (*v1.GenesisState, error) proposals = append(proposals, &value) return false, nil }) - if err != nil && !errors.Is(err, collections.ErrInvalidIterator) { + if err != nil { return nil, err } @@ -117,7 +116,7 @@ func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) (*v1.GenesisState, error) proposalsDeposits = append(proposalsDeposits, &value) return false, nil }) - if err != nil && !errors.Is(err, collections.ErrInvalidIterator) { + if err != nil { panic(err) } @@ -127,7 +126,7 @@ func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) (*v1.GenesisState, error) proposalsVotes = append(proposalsVotes, &value) return false, nil }) - if err != nil && !errors.Is(err, collections.ErrInvalidIterator) { + if err != nil { panic(err) } diff --git a/x/gov/keeper/deposit.go b/x/gov/keeper/deposit.go index f72a025d150..56bcd5ea3b8 100644 --- a/x/gov/keeper/deposit.go +++ b/x/gov/keeper/deposit.go @@ -50,7 +50,7 @@ func (keeper Keeper) DeleteAndBurnDeposits(ctx context.Context, proposalID uint6 func (keeper Keeper) IterateDeposits(ctx context.Context, proposalID uint64, cb func(key collections.Pair[uint64, sdk.AccAddress], value v1.Deposit) (bool, error)) error { rng := collections.NewPrefixedPairRange[uint64, sdk.AccAddress](proposalID) err := keeper.Deposits.Walk(ctx, rng, cb) - if err != nil && !errors.IsOf(err, collections.ErrInvalidIterator) { + if err != nil { return err } return nil diff --git a/x/gov/keeper/invariants.go b/x/gov/keeper/invariants.go index e8cd15d5737..f5374c28dfd 100644 --- a/x/gov/keeper/invariants.go +++ b/x/gov/keeper/invariants.go @@ -1,7 +1,6 @@ package keeper import ( - "errors" "fmt" "cosmossdk.io/collections" @@ -26,7 +25,7 @@ func ModuleAccountInvariant(keeper *Keeper, bk types.BankKeeper) sdk.Invariant { expectedDeposits = expectedDeposits.Add(value.Amount...) return false, nil }) - if err != nil && !errors.Is(err, collections.ErrInvalidIterator) { + if err != nil { panic(err) } diff --git a/x/gov/keeper/tally.go b/x/gov/keeper/tally.go index fbb76632c72..fa69ca381f9 100644 --- a/x/gov/keeper/tally.go +++ b/x/gov/keeper/tally.go @@ -2,7 +2,6 @@ package keeper import ( "context" - "errors" "cosmossdk.io/collections" "cosmossdk.io/math" @@ -93,7 +92,7 @@ func (keeper Keeper) Tally(ctx context.Context, proposal v1.Proposal) (passes, b return false, keeper.Votes.Remove(ctx, collections.Join(vote.ProposalId, sdk.AccAddress(voter))) }) - if err != nil && !errors.Is(err, collections.ErrInvalidIterator) { + if err != nil { return false, false, tallyResults, err } diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index f0425e6de3f..1b4784752ed 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -1,12 +1,10 @@ package simulation import ( - "errors" "math" "math/rand" "time" - "cosmossdk.io/collections" sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/baseapp" @@ -602,7 +600,7 @@ func randomProposal(r *rand.Rand, k *keeper.Keeper, ctx sdk.Context) *v1.Proposa proposals = append(proposals, &value) return false, nil }) - if err != nil && !errors.Is(err, collections.ErrInvalidIterator) { + if err != nil { panic(err) } if len(proposals) == 0 {