From 01b4a4237973698e174d1de48d82cc496b89c97c Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Thu, 14 Jul 2022 08:37:58 -0400 Subject: [PATCH 1/3] refactor: remove cosmos/keyring (#12576) --- CHANGELOG.md | 1 + go.mod | 9 ++++----- go.sum | 19 +++++++++---------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c19539f91d2e..923490f64ea7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +* [#12576](https://github.com/cosmos/cosmos-sdk/pull/12576) Remove dependency on cosmos/keyring and upgrade to 99designs/keyring v1.2.1 * [#12089](https://github.com/cosmos/cosmos-sdk/pull/12089) Mark the `TipDecorator` as beta, don't include it in simapp by default. * [#12153](https://github.com/cosmos/cosmos-sdk/pull/12153) Add a new `NewSimulationManagerFromAppModules` constructor, to simplify simulation wiring. * [#12187](https://github.com/cosmos/cosmos-sdk/pull/12187) Add batch operation for x/nft module. diff --git a/go.mod b/go.mod index 33c2ab7416c9..d6302f6b50d6 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( cosmossdk.io/depinject v1.0.0-alpha.4 cosmossdk.io/errors v1.0.0-beta.7 cosmossdk.io/math v1.0.0-beta.2 - github.com/99designs/keyring v1.1.6 + github.com/99designs/keyring v1.2.1 github.com/armon/go-metrics v0.4.0 github.com/bgentry/speakeasy v0.1.0 github.com/btcsuite/btcd v0.22.1 @@ -73,6 +73,7 @@ require ( cloud.google.com/go/iam v0.3.0 // indirect cloud.google.com/go/storage v1.14.0 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect + github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/Antonboom/errname v0.1.6 // indirect github.com/Antonboom/nilnil v0.1.1 // indirect github.com/BurntSushi/toml v1.1.0 // indirect @@ -102,14 +103,14 @@ require ( github.com/cosmos/ledger-go v0.9.2 // indirect github.com/creachadair/taskgroup v0.3.2 // indirect github.com/daixiang0/gci v0.3.3 // indirect - github.com/danieljoos/wincred v1.0.2 // indirect + github.com/danieljoos/wincred v1.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/denis-tingaikin/go-header v0.4.3 // indirect github.com/dgraph-io/badger/v2 v2.2007.4 // indirect github.com/dgraph-io/ristretto v0.1.0 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dustin/go-humanize v1.0.0 // indirect - github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect + github.com/dvsekhvalnov/jose2go v1.5.0 // indirect github.com/esimonov/ifshort v1.0.4 // indirect github.com/ettle/strcase v0.1.1 // indirect github.com/fatih/color v1.13.0 // indirect @@ -170,7 +171,6 @@ require ( github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect github.com/julz/importas v0.1.0 // indirect - github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect github.com/kisielk/errcheck v1.6.0 // indirect github.com/kisielk/gotool v1.0.0 // indirect github.com/klauspost/compress v1.13.6 // indirect @@ -277,7 +277,6 @@ replace ( cosmossdk.io/api => ./api cosmossdk.io/core => ./core cosmossdk.io/depinject => ./depinject - github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 github.com/cosmos/cosmos-sdk/db => ./db // Fix upstream GHSA-h395-qcrw-5vmq vulnerability. diff --git a/go.sum b/go.sum index 6d2050b79006..640ccf502eb0 100644 --- a/go.sum +++ b/go.sum @@ -74,6 +74,10 @@ cosmossdk.io/math v1.0.0-beta.2/go.mod h1:u/MXvf8wbUbCsAEyQSSYXXMsczAsFX48e2D6JI dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= +github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs= +github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4= +github.com/99designs/keyring v1.2.1 h1:tYLp1ULvO7i3fI5vE21ReQuj99QFSs7lGm0xWyJo87o= +github.com/99designs/keyring v1.2.1/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= github.com/Antonboom/errname v0.1.6 h1:LzIJZlyLOCSu51o3/t2n9Ck7PcoP9wdbrdaW6J8fX24= github.com/Antonboom/errname v0.1.6/go.mod h1:7lz79JAnuoMNDAWE9MeeIr1/c/VpSUWatBv2FH9NYpI= github.com/Antonboom/nilnil v0.1.1 h1:PHhrh5ANKFWRBh7TdYmyyq2gyT2lotnvFvvFbylF81Q= @@ -278,8 +282,6 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4 github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cosmos/iavl v0.18.0 h1:02ur4vnalMR2GuWCFNkuseUcl/BCVmg9tOeHOGiZOkE= github.com/cosmos/iavl v0.18.0/go.mod h1:L0VZHfq0tqMNJvXlslGExaaiZM7eSm+90Vh9QUbp6j4= -github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU= -github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76/go.mod h1:0mkLWIoZuQ7uBoospo5Q9zIpqq6rYCPJDSUdeCJvPM8= github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI= @@ -301,8 +303,8 @@ github.com/cucumber/common/messages/go/v17 v17.1.1 h1:RNqopvIFyLWnKv0LfATh34SWBh github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= github.com/daixiang0/gci v0.3.3 h1:55xJKH7Gl9Vk6oQ1cMkwrDWjAkT1D+D1G9kNmRcAIY4= github.com/daixiang0/gci v0.3.3/go.mod h1:1Xr2bxnQbDxCqqulUOv8qpGqkgRw9RSCGGjEC2LjF8o= -github.com/danieljoos/wincred v1.0.2 h1:zf4bhty2iLuwgjgpraD2E9UbvO+fe54XXGJbOwe23fU= -github.com/danieljoos/wincred v1.0.2/go.mod h1:SnuYRW9lp1oJrZX/dXJqr0cPK5gYXqx3EJbmjhLdK9U= +github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= +github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -333,8 +335,8 @@ github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b h1:HBah4D48ypg3J7Np4N+HY/ZR76fx3HEUGxDU6Uk39oQ= -github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM= +github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM= +github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= @@ -780,8 +782,6 @@ github.com/julz/importas v0.1.0 h1:F78HnrsjY3cR7j0etXy5+TU1Zuy7Xt08X/1aJnH5xXY= github.com/julz/importas v0.1.0/go.mod h1:oSFU2R4XK/P7kNBrnL/FEQlDGN1/6WoxXEjSSXO0DV0= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= -github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM= -github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/errcheck v1.6.0 h1:YTDO4pNy7AUN/021p+JGHycQyYNIyMoenM1YDVK6RlY= github.com/kisielk/errcheck v1.6.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -1237,7 +1237,6 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/streadway/handy v0.0.0-20200128134331-0f66f006fb2e/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v0.0.0-20170130113145-4d4bfba8f1d1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -1598,7 +1597,6 @@ golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1668,6 +1666,7 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= From 934b2b8ede333d51f5bdbdf189a3777bc8437116 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 14 Jul 2022 10:32:06 -0400 Subject: [PATCH 2/3] chore: fix migration paths (#12579) --- x/auth/keeper/migrations.go | 10 ++++------ x/auth/migrations/v043/store_test.go | 9 ++++----- x/auth/migrations/v046/store_test.go | 18 +++++++++--------- x/auth/migrations/{v2 => v4}/migrate.go | 2 +- x/auth/migrations/{v2 => v4}/migrator_test.go | 11 +++++------ x/auth/module.go | 11 ++++------- x/crisis/keeper/migrator.go | 4 ++-- x/crisis/migrations/{v046 => v2}/migrate.go | 2 +- .../migrations/{v046 => v2}/migrate_test.go | 13 +++++++------ x/crisis/module.go | 4 ++-- x/distribution/keeper/migrations.go | 4 ++-- .../migrations/{v046 => v3}/migrate.go | 2 +- .../migrations/{v046 => v3}/migrate_test.go | 13 +++++++------ x/distribution/module.go | 6 +++--- x/slashing/keeper/migrations.go | 4 ++-- x/slashing/migrations/{v2 => v3}/migrate.go | 2 +- .../migrations/{v2 => v3}/migrator_test.go | 11 +++++------ x/slashing/module.go | 8 +++----- 18 files changed, 63 insertions(+), 71 deletions(-) rename x/auth/migrations/{v2 => v4}/migrate.go (98%) rename x/auth/migrations/{v2 => v4}/migrator_test.go (82%) rename x/crisis/migrations/{v046 => v2}/migrate.go (98%) rename x/crisis/migrations/{v046 => v2}/migrate_test.go (81%) rename x/distribution/migrations/{v046 => v3}/migrate.go (98%) rename x/distribution/migrations/{v046 => v3}/migrate_test.go (81%) rename x/slashing/migrations/{v2 => v3}/migrate.go (98%) rename x/slashing/migrations/{v2 => v3}/migrator_test.go (82%) diff --git a/x/auth/keeper/migrations.go b/x/auth/keeper/migrations.go index 5826a6bb1688..2b52771dd39f 100644 --- a/x/auth/keeper/migrations.go +++ b/x/auth/keeper/migrations.go @@ -3,14 +3,12 @@ package keeper import ( "github.com/gogo/protobuf/grpc" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/exported" v043 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v043" v046 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v046" - - "github.com/cosmos/cosmos-sdk/x/auth/exported" + v4 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v4" "github.com/cosmos/cosmos-sdk/x/auth/types" - - sdk "github.com/cosmos/cosmos-sdk/types" - v2 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v2" ) // Migrator is a struct for handling in-place store migrations. @@ -58,7 +56,7 @@ func (m Migrator) Migrate2to3(ctx sdk.Context) error { // and managed by the x/params modules and stores them directly into the x/auth // module state. func (m Migrator) Migrate3to4(ctx sdk.Context) error { - return v2.Migrate(ctx, ctx.KVStore(m.keeper.storeKey), m.legacySubspace, m.keeper.cdc) + return v4.Migrate(ctx, ctx.KVStore(m.keeper.storeKey), m.legacySubspace, m.keeper.cdc) } // V45_SetAccount implements V45_SetAccount diff --git a/x/auth/migrations/v043/store_test.go b/x/auth/migrations/v043/store_test.go index afb89bbe2910..498f33972673 100644 --- a/x/auth/migrations/v043/store_test.go +++ b/x/auth/migrations/v043/store_test.go @@ -8,8 +8,6 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - "github.com/cosmos/cosmos-sdk/testutil" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" @@ -17,11 +15,12 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth" authexported "github.com/cosmos/cosmos-sdk/x/auth/exported" "github.com/cosmos/cosmos-sdk/x/auth/keeper" - v2 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v2" + v4 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v4" authtestutil "github.com/cosmos/cosmos-sdk/x/auth/testutil" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/staking" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -43,7 +42,7 @@ func TestMigrateVestingAccounts(t *testing.T) { encCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{}) cdc := encCfg.Codec - storeKey := sdk.NewKVStoreKey(v2.ModuleName) + storeKey := sdk.NewKVStoreKey(v4.ModuleName) tKey := sdk.NewTransientStoreKey("transient_test") ctx := testutil.DefaultContext(storeKey, tKey) store := ctx.KVStore(storeKey) @@ -62,7 +61,7 @@ func TestMigrateVestingAccounts(t *testing.T) { require.NoError(t, err) legacySubspace := newMockSubspace(authtypes.DefaultParams()) - require.NoError(t, v2.Migrate(ctx, store, legacySubspace, cdc)) + require.NoError(t, v4.Migrate(ctx, store, legacySubspace, cdc)) ctx = app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) stakingKeeper.SetParams(ctx, stakingtypes.DefaultParams()) diff --git a/x/auth/migrations/v046/store_test.go b/x/auth/migrations/v046/store_test.go index e063fac55653..f8fe4dc0cf28 100644 --- a/x/auth/migrations/v046/store_test.go +++ b/x/auth/migrations/v046/store_test.go @@ -5,20 +5,20 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/testutil" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cosmos/cosmos-sdk/x/auth" + authexported "github.com/cosmos/cosmos-sdk/x/auth/exported" "github.com/cosmos/cosmos-sdk/x/auth/keeper" - v2 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v2" + v4 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v4" authtestutil "github.com/cosmos/cosmos-sdk/x/auth/testutil" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - - sdk "github.com/cosmos/cosmos-sdk/types" - moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" - authexported "github.com/cosmos/cosmos-sdk/x/auth/exported" - "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) type mockSubspace struct { @@ -38,7 +38,7 @@ func TestMigrateMapAccAddressToAccNumberKey(t *testing.T) { encCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{}) cdc := encCfg.Codec - storeKey := sdk.NewKVStoreKey(v2.ModuleName) + storeKey := sdk.NewKVStoreKey(v4.ModuleName) tKey := sdk.NewTransientStoreKey("transient_test") ctx := testutil.DefaultContext(storeKey, tKey) store := ctx.KVStore(storeKey) @@ -54,7 +54,7 @@ func TestMigrateMapAccAddressToAccNumberKey(t *testing.T) { require.NoError(t, err) legacySubspace := newMockSubspace(authtypes.DefaultParams()) - require.NoError(t, v2.Migrate(ctx, store, legacySubspace, cdc)) + require.NoError(t, v4.Migrate(ctx, store, legacySubspace, cdc)) // new base account senderPrivKey := secp256k1.GenPrivKey() diff --git a/x/auth/migrations/v2/migrate.go b/x/auth/migrations/v4/migrate.go similarity index 98% rename from x/auth/migrations/v2/migrate.go rename to x/auth/migrations/v4/migrate.go index 7c5a2b2f38d0..65e72a732a7f 100644 --- a/x/auth/migrations/v2/migrate.go +++ b/x/auth/migrations/v4/migrate.go @@ -1,4 +1,4 @@ -package v2 +package v4 import ( "github.com/cosmos/cosmos-sdk/codec" diff --git a/x/auth/migrations/v2/migrator_test.go b/x/auth/migrations/v4/migrator_test.go similarity index 82% rename from x/auth/migrations/v2/migrator_test.go rename to x/auth/migrations/v4/migrator_test.go index 76a5389e7e95..57a9245a819a 100644 --- a/x/auth/migrations/v2/migrator_test.go +++ b/x/auth/migrations/v4/migrator_test.go @@ -1,4 +1,4 @@ -package v2_test +package v4_test import ( "testing" @@ -7,11 +7,10 @@ import ( "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" - moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/exported" - v2 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v2" + v4 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v4" "github.com/cosmos/cosmos-sdk/x/auth/types" ) @@ -31,16 +30,16 @@ func TestMigrate(t *testing.T) { encCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{}) cdc := encCfg.Codec - storeKey := sdk.NewKVStoreKey(v2.ModuleName) + storeKey := sdk.NewKVStoreKey(v4.ModuleName) tKey := sdk.NewTransientStoreKey("transient_test") ctx := testutil.DefaultContext(storeKey, tKey) store := ctx.KVStore(storeKey) legacySubspace := newMockSubspace(types.DefaultParams()) - require.NoError(t, v2.Migrate(ctx, store, legacySubspace, cdc)) + require.NoError(t, v4.Migrate(ctx, store, legacySubspace, cdc)) var res types.Params - bz := store.Get(v2.ParamsKey) + bz := store.Get(v4.ParamsKey) require.NoError(t, cdc.Unmarshal(bz, &res)) require.Equal(t, legacySubspace.ps, res) } diff --git a/x/auth/module.go b/x/auth/module.go index c72e76848ea2..5eb6b0f9e308 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -6,21 +6,18 @@ import ( "fmt" "math/rand" + modulev1 "cosmossdk.io/api/cosmos/auth/module/v1" + "cosmossdk.io/core/appmodule" "cosmossdk.io/depinject" - gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" - modulev1 "cosmossdk.io/api/cosmos/auth/module/v1" - "cosmossdk.io/core/appmodule" - "github.com/cosmos/cosmos-sdk/runtime" - store "github.com/cosmos/cosmos-sdk/store/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/runtime" + store "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" diff --git a/x/crisis/keeper/migrator.go b/x/crisis/keeper/migrator.go index 6094e0dbb3d8..53b68fb17f5e 100644 --- a/x/crisis/keeper/migrator.go +++ b/x/crisis/keeper/migrator.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/crisis/exported" - v046 "github.com/cosmos/cosmos-sdk/x/crisis/migrations/v046" + v2 "github.com/cosmos/cosmos-sdk/x/crisis/migrations/v2" ) // Migrator is a struct for handling in-place state migrations. @@ -24,5 +24,5 @@ func NewMigrator(k *Keeper, ss exported.Subspace) Migrator { // and managed by the x/params modules and stores them directly into the x/mint // module state. func (m Migrator) Migrate1to2(ctx sdk.Context) error { - return v046.MigrateStore(ctx, m.keeper.storeKey, m.legacySubspace, m.keeper.cdc) + return v2.MigrateStore(ctx, m.keeper.storeKey, m.legacySubspace, m.keeper.cdc) } diff --git a/x/crisis/migrations/v046/migrate.go b/x/crisis/migrations/v2/migrate.go similarity index 98% rename from x/crisis/migrations/v046/migrate.go rename to x/crisis/migrations/v2/migrate.go index 333b4be89403..e019e1eb4dca 100644 --- a/x/crisis/migrations/v046/migrate.go +++ b/x/crisis/migrations/v2/migrate.go @@ -1,4 +1,4 @@ -package v046 +package v2 import ( "github.com/cosmos/cosmos-sdk/codec" diff --git a/x/crisis/migrations/v046/migrate_test.go b/x/crisis/migrations/v2/migrate_test.go similarity index 81% rename from x/crisis/migrations/v046/migrate_test.go rename to x/crisis/migrations/v2/migrate_test.go index ae283a688f85..4239b675d0ae 100644 --- a/x/crisis/migrations/v046/migrate_test.go +++ b/x/crisis/migrations/v2/migrate_test.go @@ -1,15 +1,16 @@ -package v046_test +package v2_test import ( "testing" + "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" - v046 "github.com/cosmos/cosmos-sdk/x/crisis/migrations/v046" + v2 "github.com/cosmos/cosmos-sdk/x/crisis/migrations/v2" "github.com/cosmos/cosmos-sdk/x/crisis/types" "github.com/cosmos/cosmos-sdk/x/distribution" - "github.com/stretchr/testify/require" ) type mockSubspace struct { @@ -28,16 +29,16 @@ func TestMigrate(t *testing.T) { encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{}) cdc := encCfg.Codec - storeKey := sdk.NewKVStoreKey(v046.ModuleName) + storeKey := sdk.NewKVStoreKey(v2.ModuleName) tKey := sdk.NewTransientStoreKey("transient_test") ctx := testutil.DefaultContext(storeKey, tKey) store := ctx.KVStore(storeKey) legacySubspace := newMockSubspace(types.DefaultGenesisState().ConstantFee) - require.NoError(t, v046.MigrateStore(ctx, storeKey, legacySubspace, cdc)) + require.NoError(t, v2.MigrateStore(ctx, storeKey, legacySubspace, cdc)) var res sdk.Coin - bz := store.Get(v046.ConstantFeeKey) + bz := store.Get(v2.ConstantFeeKey) require.NoError(t, cdc.Unmarshal(bz, &res)) require.NotNil(t, res) require.Equal(t, legacySubspace.constantFee, res) diff --git a/x/crisis/module.go b/x/crisis/module.go index 424fcaec3790..ca66890b9c5f 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -5,14 +5,14 @@ import ( "fmt" "time" + modulev1 "cosmossdk.io/api/cosmos/crisis/module/v1" "cosmossdk.io/core/appmodule" + "cosmossdk.io/depinject" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cast" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" - modulev1 "cosmossdk.io/api/cosmos/crisis/module/v1" - "cosmossdk.io/depinject" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/x/distribution/keeper/migrations.go b/x/distribution/keeper/migrations.go index cc928e3f79b6..1ea8c0f16088 100644 --- a/x/distribution/keeper/migrations.go +++ b/x/distribution/keeper/migrations.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/distribution/exported" v043 "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v043" - v046 "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v046" + v3 "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v3" ) // Migrator is a struct for handling in-place store migrations. @@ -28,5 +28,5 @@ func (m Migrator) Migrate1to2(ctx sdk.Context) error { // and managed by the x/params module and stores them directly into the x/distribution // module state. func (m Migrator) Migrate2to3(ctx sdk.Context) error { - return v046.MigrateStore(ctx, m.keeper.storeKey, m.legacySubspace, m.keeper.cdc) + return v3.MigrateStore(ctx, m.keeper.storeKey, m.legacySubspace, m.keeper.cdc) } diff --git a/x/distribution/migrations/v046/migrate.go b/x/distribution/migrations/v3/migrate.go similarity index 98% rename from x/distribution/migrations/v046/migrate.go rename to x/distribution/migrations/v3/migrate.go index 0a4c99a111f1..f5226688bedd 100644 --- a/x/distribution/migrations/v046/migrate.go +++ b/x/distribution/migrations/v3/migrate.go @@ -1,4 +1,4 @@ -package v046 +package v3 import ( "github.com/cosmos/cosmos-sdk/codec" diff --git a/x/distribution/migrations/v046/migrate_test.go b/x/distribution/migrations/v3/migrate_test.go similarity index 81% rename from x/distribution/migrations/v046/migrate_test.go rename to x/distribution/migrations/v3/migrate_test.go index 56bf5df0447b..b0de4b46051a 100644 --- a/x/distribution/migrations/v046/migrate_test.go +++ b/x/distribution/migrations/v3/migrate_test.go @@ -1,16 +1,17 @@ -package v046_test +package v3_test import ( "testing" + "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cosmos/cosmos-sdk/x/distribution" "github.com/cosmos/cosmos-sdk/x/distribution/exported" - v046 "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v046" + v3 "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v3" "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/stretchr/testify/require" ) type mockSubspace struct { @@ -29,16 +30,16 @@ func TestMigrate(t *testing.T) { encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{}) cdc := encCfg.Codec - storeKey := sdk.NewKVStoreKey(v046.ModuleName) + storeKey := sdk.NewKVStoreKey(v3.ModuleName) tKey := sdk.NewTransientStoreKey("transient_test") ctx := testutil.DefaultContext(storeKey, tKey) store := ctx.KVStore(storeKey) legacySubspace := newMockSubspace(types.DefaultParams()) - require.NoError(t, v046.MigrateStore(ctx, storeKey, legacySubspace, cdc)) + require.NoError(t, v3.MigrateStore(ctx, storeKey, legacySubspace, cdc)) var res types.Params - bz := store.Get(v046.ParamsKey) + bz := store.Get(v3.ParamsKey) require.NoError(t, cdc.Unmarshal(bz, &res)) require.Equal(t, legacySubspace.ps, res) } diff --git a/x/distribution/module.go b/x/distribution/module.go index 7366ce1d1adb..2d1f16c0a31b 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -6,13 +6,13 @@ import ( "fmt" "math/rand" + modulev1 "cosmossdk.io/api/cosmos/distribution/module/v1" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/depinject" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" - modulev1 "cosmossdk.io/api/cosmos/distribution/module/v1" - "cosmossdk.io/core/appmodule" - "cosmossdk.io/depinject" sdkclient "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/x/slashing/keeper/migrations.go b/x/slashing/keeper/migrations.go index d06a372262ad..07ded76095d5 100644 --- a/x/slashing/keeper/migrations.go +++ b/x/slashing/keeper/migrations.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/slashing/exported" v043 "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v043" - v2 "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v2" + v3 "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v3" ) // Migrator is a struct for handling in-place store migrations. @@ -28,5 +28,5 @@ func (m Migrator) Migrate1to2(ctx sdk.Context) error { // and managed by the x/params modules and stores them directly into the x/slashing // module state. func (m Migrator) Migrate2to3(ctx sdk.Context) error { - return v2.Migrate(ctx, ctx.KVStore(m.keeper.storeKey), m.legacySubspace, m.keeper.cdc) + return v3.Migrate(ctx, ctx.KVStore(m.keeper.storeKey), m.legacySubspace, m.keeper.cdc) } diff --git a/x/slashing/migrations/v2/migrate.go b/x/slashing/migrations/v3/migrate.go similarity index 98% rename from x/slashing/migrations/v2/migrate.go rename to x/slashing/migrations/v3/migrate.go index cd411b4c0929..a0d79308df18 100644 --- a/x/slashing/migrations/v2/migrate.go +++ b/x/slashing/migrations/v3/migrate.go @@ -1,4 +1,4 @@ -package v2 +package v3 import ( "github.com/cosmos/cosmos-sdk/codec" diff --git a/x/slashing/migrations/v2/migrator_test.go b/x/slashing/migrations/v3/migrator_test.go similarity index 82% rename from x/slashing/migrations/v2/migrator_test.go rename to x/slashing/migrations/v3/migrator_test.go index de0979b4036d..4030a2360df0 100644 --- a/x/slashing/migrations/v2/migrator_test.go +++ b/x/slashing/migrations/v3/migrator_test.go @@ -1,4 +1,4 @@ -package v2_test +package v3_test import ( "testing" @@ -7,11 +7,10 @@ import ( "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" - moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cosmos/cosmos-sdk/x/slashing" "github.com/cosmos/cosmos-sdk/x/slashing/exported" - v2 "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v2" + v3 "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v3" "github.com/cosmos/cosmos-sdk/x/slashing/types" ) @@ -31,16 +30,16 @@ func TestMigrate(t *testing.T) { encCfg := moduletestutil.MakeTestEncodingConfig(slashing.AppModuleBasic{}) cdc := encCfg.Codec - storeKey := sdk.NewKVStoreKey(v2.ModuleName) + storeKey := sdk.NewKVStoreKey(v3.ModuleName) tKey := sdk.NewTransientStoreKey("transient_test") ctx := testutil.DefaultContext(storeKey, tKey) store := ctx.KVStore(storeKey) legacySubspace := newMockSubspace(types.DefaultParams()) - require.NoError(t, v2.Migrate(ctx, store, legacySubspace, cdc)) + require.NoError(t, v3.Migrate(ctx, store, legacySubspace, cdc)) var res types.Params - bz := store.Get(v2.ParamsKey) + bz := store.Get(v3.ParamsKey) require.NoError(t, cdc.Unmarshal(bz, &res)) require.Equal(t, legacySubspace.ps, res) } diff --git a/x/slashing/module.go b/x/slashing/module.go index a9d30d85afab..9b82d0fbb80f 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -8,29 +8,27 @@ import ( modulev1 "cosmossdk.io/api/cosmos/slashing/module/v1" "cosmossdk.io/core/appmodule" - staking "github.com/cosmos/cosmos-sdk/x/staking/types" - + "cosmossdk.io/depinject" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" - "cosmossdk.io/depinject" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" store "github.com/cosmos/cosmos-sdk/store/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/slashing/client/cli" "github.com/cosmos/cosmos-sdk/x/slashing/exported" "github.com/cosmos/cosmos-sdk/x/slashing/keeper" "github.com/cosmos/cosmos-sdk/x/slashing/simulation" "github.com/cosmos/cosmos-sdk/x/slashing/types" + staking "github.com/cosmos/cosmos-sdk/x/staking/types" ) // ConsensusVersion defines the current x/slashing module consensus version. From 63d484a1b8d9e0e88833dc197e7965307cfb5a4c Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 14 Jul 2022 11:10:06 -0400 Subject: [PATCH 3/3] chore!: remove x/slashing legacy querier (#12581) --- CHANGELOG.md | 1 + x/slashing/keeper/querier.go | 92 ------------------------------- x/slashing/keeper/querier_test.go | 72 ------------------------ x/slashing/module.go | 4 +- 4 files changed, 4 insertions(+), 165 deletions(-) delete mode 100644 x/slashing/keeper/querier.go delete mode 100644 x/slashing/keeper/querier_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 923490f64ea7..51f69fed435f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,6 +62,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### API Breaking Changes +* (x/slashing) [#12581](https://github.com/cosmos/cosmos-sdk/pull/12581) Remove `x/slashing` legacy querier. * (types) [\#12355](https://github.com/cosmos/cosmos-sdk/pull/12355) Remove the compile-time `types.DBbackend` variable. Removes usage of the same in server/util.go * (x/gov) [#12368](https://github.com/cosmos/cosmos-sdk/pull/12369) Gov keeper is now passed by reference instead of copy to make post-construction mutation of Hooks and Proposal Handlers possible at a framework level. * (simapp) [#12270](https://github.com/cosmos/cosmos-sdk/pull/12270) Remove `invCheckPeriod uint` attribute from `SimApp` struct as per migration of `x/crisis` to app wiring diff --git a/x/slashing/keeper/querier.go b/x/slashing/keeper/querier.go deleted file mode 100644 index 036f3a16dde3..000000000000 --- a/x/slashing/keeper/querier.go +++ /dev/null @@ -1,92 +0,0 @@ -package keeper - -import ( - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/slashing/types" -) - -// NewQuerier creates a new querier for slashing clients. -func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { - switch path[0] { - case types.QueryParameters: - return queryParams(ctx, k, legacyQuerierCdc) - - case types.QuerySigningInfo: - return querySigningInfo(ctx, req, k, legacyQuerierCdc) - - case types.QuerySigningInfos: - return querySigningInfos(ctx, req, k, legacyQuerierCdc) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown %s query endpoint: %s", types.ModuleName, path[0]) - } - } -} - -func queryParams(ctx sdk.Context, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - params := k.GetParams(ctx) - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, params) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func querySigningInfo(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QuerySigningInfoRequest - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - signingInfo, found := k.GetValidatorSigningInfo(ctx, sdk.ConsAddress(params.ConsAddress)) - if !found { - return nil, sdkerrors.Wrap(types.ErrNoSigningInfoFound, params.ConsAddress) - } - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, signingInfo) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func querySigningInfos(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QuerySigningInfosParams - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - var signingInfos []types.ValidatorSigningInfo - - k.IterateValidatorSigningInfos(ctx, func(consAddr sdk.ConsAddress, info types.ValidatorSigningInfo) (stop bool) { - signingInfos = append(signingInfos, info) - return false - }) - - start, end := client.Paginate(len(signingInfos), params.Page, params.Limit, int(k.sk.MaxValidators(ctx))) - if start < 0 || end < 0 { - signingInfos = []types.ValidatorSigningInfo{} - } else { - signingInfos = signingInfos[start:end] - } - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, signingInfos) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} diff --git a/x/slashing/keeper/querier_test.go b/x/slashing/keeper/querier_test.go deleted file mode 100644 index c34965f62f21..000000000000 --- a/x/slashing/keeper/querier_test.go +++ /dev/null @@ -1,72 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - abci "github.com/tendermint/tendermint/abci/types" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - - "github.com/cosmos/cosmos-sdk/codec" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - "github.com/cosmos/cosmos-sdk/x/slashing/keeper" - slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" - "github.com/cosmos/cosmos-sdk/x/slashing/testslashing" - "github.com/cosmos/cosmos-sdk/x/slashing/testutil" - "github.com/cosmos/cosmos-sdk/x/slashing/types" -) - -func TestNewQuerier(t *testing.T) { - var slashingKeeper slashingkeeper.Keeper - var legacyAmino *codec.LegacyAmino - app, err := simtestutil.Setup( - testutil.AppConfig, - &legacyAmino, - &slashingKeeper, - ) - require.NoError(t, err) - - ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - slashingKeeper.SetParams(ctx, testslashing.TestParams()) - legacyQuerierCdc := codec.NewAminoCodec(legacyAmino) - querier := keeper.NewQuerier(slashingKeeper, legacyQuerierCdc.LegacyAmino) - - query := abci.RequestQuery{ - Path: "", - Data: []byte{}, - } - - _, err = querier(ctx, []string{types.QueryParameters}, query) - require.NoError(t, err) -} - -func TestQueryParams(t *testing.T) { - var slashingKeeper slashingkeeper.Keeper - app, err := simtestutil.Setup( - testutil.AppConfig, - &slashingKeeper, - ) - require.NoError(t, err) - - cdc := codec.NewLegacyAmino() - legacyQuerierCdc := codec.NewAminoCodec(cdc) - ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - slashingKeeper.SetParams(ctx, testslashing.TestParams()) - - querier := keeper.NewQuerier(slashingKeeper, legacyQuerierCdc.LegacyAmino) - - query := abci.RequestQuery{ - Path: "", - Data: []byte{}, - } - - var params types.Params - - res, err := querier(ctx, []string{types.QueryParameters}, query) - require.NoError(t, err) - - err = cdc.UnmarshalJSON(res, ¶ms) - require.NoError(t, err) - require.Equal(t, slashingKeeper.GetParams(ctx), params) -} diff --git a/x/slashing/module.go b/x/slashing/module.go index 9b82d0fbb80f..239465983b1b 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -140,7 +140,9 @@ func (AppModule) QuerierRoute() string { // LegacyQuerierHandler returns the slashing module sdk.Querier. func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return keeper.NewQuerier(am.keeper, legacyQuerierCdc) + return func(sdk.Context, []string, abci.RequestQuery) ([]byte, error) { + return nil, fmt.Errorf("legacy querier not supported for the x/%s module", types.ModuleName) + } } // RegisterServices registers module services.