From c87cc30ec1e289857de15dd96bfc6061962b8981 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 11 Aug 2023 12:55:27 +0200 Subject: [PATCH 1/3] refactor: remove collections.ErrInvalidIterator when unecessary --- go.mod | 4 ++-- go.sum | 8 ++++---- simapp/go.mod | 4 ++-- simapp/go.sum | 8 ++++---- tests/go.mod | 4 ++-- tests/go.sum | 8 ++++---- x/bank/keeper/keeper.go | 6 ++---- x/bank/keeper/send.go | 2 +- x/bank/keeper/view.go | 6 ++---- x/circuit/go.mod | 8 ++++---- x/circuit/go.sum | 16 ++++++++-------- x/circuit/keeper/genesis.go | 6 ++---- x/circuit/keeper/query.go | 4 +--- x/evidence/genesis.go | 4 +--- x/evidence/genesis_test.go | 3 +-- x/evidence/go.mod | 8 ++++---- x/evidence/go.sum | 16 ++++++++-------- x/gov/abci.go | 5 ++--- x/gov/genesis.go | 7 +++---- x/gov/keeper/deposit.go | 2 +- x/gov/keeper/invariants.go | 3 +-- x/gov/keeper/tally.go | 2 +- x/gov/simulation/operations.go | 2 +- 23 files changed, 61 insertions(+), 75 deletions(-) diff --git a/go.mod b/go.mod index 6aa629faf74..5585b36edef 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.9.0 cosmossdk.io/depinject v1.0.0-alpha.4 cosmossdk.io/errors v1.0.0 @@ -60,7 +60,7 @@ require ( google.golang.org/grpc v1.57.0 google.golang.org/protobuf v1.31.0 gotest.tools/v3 v3.5.0 - pgregory.net/rapid v1.0.0 + pgregory.net/rapid v1.0.1 sigs.k8s.io/yaml v1.3.0 ) diff --git a/go.sum b/go.sum index e0ade6632e5..159f42e80fe 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.9.0 h1:30ScAOHDIUOCg1DKAwqkho9wuQJnu7GUrMcg0XLioic= cosmossdk.io/core v0.9.0/go.mod h1:NFgl5r41Q36+RixTvyrfsS6qQ65agCbZ1FTpnN7/G1Y= cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= @@ -1276,8 +1276,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/simapp/go.mod b/simapp/go.mod index 188a1f25bc3..6a4badcdc6b 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 @@ -187,7 +187,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/simapp/go.sum b/simapp/go.sum index 066d3e87f54..42286561d8c 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-20230725211428-f28adc7c9e83 h1:dsBUY9zfxl0qtiXZzdiQ+S7KuLERKCDsX4a/329+zlc= cosmossdk.io/client/v2 v2.0.0-20230725211428-f28adc7c9e83/go.mod h1:mrwVTC+6n90zDpvn4N12YJVl67QUCDQ3yEqIR4Ovp14= -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.9.0 h1:30ScAOHDIUOCg1DKAwqkho9wuQJnu7GUrMcg0XLioic= cosmossdk.io/core v0.9.0/go.mod h1:NFgl5r41Q36+RixTvyrfsS6qQ65agCbZ1FTpnN7/G1Y= cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= @@ -1692,8 +1692,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/tests/go.mod b/tests/go.mod index ac89355839b..4f65afaf8e3 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( cosmossdk.io/api v0.7.0 - cosmossdk.io/collections v0.3.0 // indirect + cosmossdk.io/collections v0.3.1-0.20230808102719-f04fefdc7a68 // indirect cosmossdk.io/core v0.9.0 cosmossdk.io/depinject v1.0.0-alpha.4 cosmossdk.io/errors v1.0.0 @@ -29,7 +29,7 @@ require ( google.golang.org/grpc v1.57.0 google.golang.org/protobuf v1.31.0 gotest.tools/v3 v3.5.0 - pgregory.net/rapid v1.0.0 + pgregory.net/rapid v1.0.1 ) require ( diff --git a/tests/go.sum b/tests/go.sum index c744fe347e6..7e5de1cc4f9 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-20230725211428-f28adc7c9e83 h1:dsBUY9zfxl0qtiXZzdiQ+S7KuLERKCDsX4a/329+zlc= cosmossdk.io/client/v2 v2.0.0-20230725211428-f28adc7c9e83/go.mod h1:mrwVTC+6n90zDpvn4N12YJVl67QUCDQ3yEqIR4Ovp14= -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.9.0 h1:30ScAOHDIUOCg1DKAwqkho9wuQJnu7GUrMcg0XLioic= cosmossdk.io/core v0.9.0/go.mod h1:NFgl5r41Q36+RixTvyrfsS6qQ65agCbZ1FTpnN7/G1Y= cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= @@ -1694,8 +1694,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/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 459d7ac33dc..279d372587e 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.9.0 cosmossdk.io/depinject v1.0.0-alpha.4 cosmossdk.io/errors v1.0.0 @@ -19,7 +19,7 @@ require ( github.com/spf13/cobra v1.7.0 github.com/stretchr/testify v1.8.4 google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 - google.golang.org/grpc v1.56.2 + google.golang.org/grpc v1.57.0 ) require ( @@ -142,13 +142,13 @@ require ( golang.org/x/term v0.10.0 // indirect golang.org/x/text v0.12.0 // indirect google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect 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 f8ca3a94fea..8da80fc8dff 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.9.0 h1:30ScAOHDIUOCg1DKAwqkho9wuQJnu7GUrMcg0XLioic= cosmossdk.io/core v0.9.0/go.mod h1:NFgl5r41Q36+RixTvyrfsS6qQ65agCbZ1FTpnN7/G1Y= cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= @@ -1143,8 +1143,8 @@ google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 h1:Au6te5hbKUV8pIY google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:O9kGHb51iE/nOGvQaDUuadVYqovW56s5emA88lQnj6Y= google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 h1:s5YSX+ZH5b5vS9rnpGymvIyMpLRJizowqDlOuyjXnTk= google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e h1:S83+ibolgyZ0bqz7KEsUOPErxcv4VzlszxY+31OfB/E= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -1171,8 +1171,8 @@ google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.56.2 h1:fVRFRnXvU+x6C4IlHZewvJOVHoOv1TUuQyoRsYnB4bI= -google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= +google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= 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= @@ -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 8c6ff24d9ec..b84b9baa6c2 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.9.0 cosmossdk.io/depinject v1.0.0-alpha.4 cosmossdk.io/errors v1.0.0 @@ -21,7 +21,7 @@ require ( github.com/spf13/cobra v1.7.0 github.com/stretchr/testify v1.8.4 google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 - google.golang.org/grpc v1.56.2 + google.golang.org/grpc v1.57.0 google.golang.org/protobuf v1.31.0 ) @@ -144,13 +144,13 @@ require ( golang.org/x/term v0.10.0 // indirect golang.org/x/text v0.12.0 // indirect google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect 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 366466b0210..3269fa092b5 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.9.0 h1:30ScAOHDIUOCg1DKAwqkho9wuQJnu7GUrMcg0XLioic= cosmossdk.io/core v0.9.0/go.mod h1:NFgl5r41Q36+RixTvyrfsS6qQ65agCbZ1FTpnN7/G1Y= cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= @@ -1188,8 +1188,8 @@ google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 h1:Au6te5hbKUV8pIY google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:O9kGHb51iE/nOGvQaDUuadVYqovW56s5emA88lQnj6Y= google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 h1:s5YSX+ZH5b5vS9rnpGymvIyMpLRJizowqDlOuyjXnTk= google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e h1:S83+ibolgyZ0bqz7KEsUOPErxcv4VzlszxY+31OfB/E= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -1216,8 +1216,8 @@ google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.56.2 h1:fVRFRnXvU+x6C4IlHZewvJOVHoOv1TUuQyoRsYnB4bI= -google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= +google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= 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= @@ -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/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 2486c056b41..7d8fccbb124 100644 --- a/x/gov/keeper/tally.go +++ b/x/gov/keeper/tally.go @@ -93,7 +93,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..c448ad9b9c4 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -602,7 +602,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 { From 6b899e9d1ec1141224dcdb336d5ec8e366270c61 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 11 Aug 2023 13:03:11 +0200 Subject: [PATCH 2/3] updates --- x/gov/keeper/tally.go | 3 +-- x/gov/simulation/operations.go | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/x/gov/keeper/tally.go b/x/gov/keeper/tally.go index 7d8fccbb124..6497c64c4ab 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 && { + if err != nil { return false, false, tallyResults, err } diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index c448ad9b9c4..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 && { + if err != nil { panic(err) } if len(proposals) == 0 { From c8c1ce6543ab128aa6e132097cd0690fb73676dd Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 11 Aug 2023 13:09:50 +0200 Subject: [PATCH 3/3] fixes --- x/gov/abci_test.go | 78 +++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 42 deletions(-) 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) }