From 4520e66622534ed26d7f1304105b35cd7cbacc67 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 08:06:58 +0300 Subject: [PATCH 01/22] update types/ --- types/context.go | 4 ++-- types/store.go | 42 +++++++----------------------------- types/store_internal_test.go | 3 ++- types/store_test.go | 6 +++--- 4 files changed, 15 insertions(+), 40 deletions(-) diff --git a/types/context.go b/types/context.go index 35030dad9a9..9e9edbf2e24 100644 --- a/types/context.go +++ b/types/context.go @@ -243,12 +243,12 @@ func (c Context) Value(key interface{}) interface{} { // ---------------------------------------------------------------------------- // KVStore fetches a KVStore from the MultiStore. -func (c Context) KVStore(key StoreKey) KVStore { +func (c Context) KVStore(key stypes.StoreKey) KVStore { return gaskv.NewStore(c.MultiStore().GetKVStore(key), c.GasMeter(), stypes.KVGasConfig()) } // TransientStore fetches a TransientStore from the MultiStore. -func (c Context) TransientStore(key StoreKey) KVStore { +func (c Context) TransientStore(key stypes.StoreKey) KVStore { return gaskv.NewStore(c.MultiStore().GetKVStore(key), c.GasMeter(), stypes.TransientGasConfig()) } diff --git a/types/store.go b/types/store.go index 5fb34b5fae5..b50f95d02a7 100644 --- a/types/store.go +++ b/types/store.go @@ -58,32 +58,6 @@ func DiffKVStores(a KVStore, b KVStore, prefixesToSkip [][]byte) (kvAs, kvBs []k return types.DiffKVStores(a, b, prefixesToSkip) } -type ( - CacheKVStore = types.CacheKVStore - CommitKVStore = types.CommitKVStore - CacheWrap = types.CacheWrap - CacheWrapper = types.CacheWrapper - CommitID = types.CommitID -) - -type StoreType = types.StoreType - -const ( - StoreTypeMulti = types.StoreTypeMulti - StoreTypeDB = types.StoreTypeDB - StoreTypeIAVL = types.StoreTypeIAVL - StoreTypeTransient = types.StoreTypeTransient - StoreTypeMemory = types.StoreTypeMemory -) - -type ( - StoreKey = types.StoreKey - CapabilityKey = types.CapabilityKey - KVStoreKey = types.KVStoreKey - TransientStoreKey = types.TransientStoreKey - MemoryStoreKey = types.MemoryStoreKey -) - // assertNoCommonPrefix will panic if there are two keys: k1 and k2 in keys, such that // k1 is a prefix of k2 func assertNoPrefix(keys []string) { @@ -98,16 +72,16 @@ func assertNoPrefix(keys []string) { } // NewKVStoreKey returns a new pointer to a KVStoreKey. -func NewKVStoreKey(name string) *KVStoreKey { +func NewKVStoreKey(name string) *types.KVStoreKey { return types.NewKVStoreKey(name) } // NewKVStoreKeys returns a map of new pointers to KVStoreKey's. // The function will panic if there is a potential conflict in names (see `assertNoPrefix` // function for more details). -func NewKVStoreKeys(names ...string) map[string]*KVStoreKey { +func NewKVStoreKeys(names ...string) map[string]*types.KVStoreKey { assertNoPrefix(names) - keys := make(map[string]*KVStoreKey, len(names)) + keys := make(map[string]*types.KVStoreKey, len(names)) for _, n := range names { keys[n] = NewKVStoreKey(n) } @@ -117,7 +91,7 @@ func NewKVStoreKeys(names ...string) map[string]*KVStoreKey { // Constructs new TransientStoreKey // Must return a pointer according to the ocap principle -func NewTransientStoreKey(name string) *TransientStoreKey { +func NewTransientStoreKey(name string) *types.TransientStoreKey { return types.NewTransientStoreKey(name) } @@ -125,9 +99,9 @@ func NewTransientStoreKey(name string) *TransientStoreKey { // Must return pointers according to the ocap principle // The function will panic if there is a potential conflict in names (see `assertNoPrefix` // function for more details). -func NewTransientStoreKeys(names ...string) map[string]*TransientStoreKey { +func NewTransientStoreKeys(names ...string) map[string]*types.TransientStoreKey { assertNoPrefix(names) - keys := make(map[string]*TransientStoreKey) + keys := make(map[string]*types.TransientStoreKey) for _, n := range names { keys[n] = NewTransientStoreKey(n) } @@ -139,9 +113,9 @@ func NewTransientStoreKeys(names ...string) map[string]*TransientStoreKey { // respective MemoryStoreKey references. // The function will panic if there is a potential conflict in names (see `assertNoPrefix` // function for more details). -func NewMemoryStoreKeys(names ...string) map[string]*MemoryStoreKey { +func NewMemoryStoreKeys(names ...string) map[string]*types.MemoryStoreKey { assertNoPrefix(names) - keys := make(map[string]*MemoryStoreKey) + keys := make(map[string]*types.MemoryStoreKey) for _, n := range names { keys[n] = types.NewMemoryStoreKey(n) } diff --git a/types/store_internal_test.go b/types/store_internal_test.go index 0ed4db3ae48..e55ae175dbd 100644 --- a/types/store_internal_test.go +++ b/types/store_internal_test.go @@ -3,6 +3,7 @@ package types import ( "testing" + "github.com/cosmos/cosmos-sdk/store/types" "github.com/stretchr/testify/suite" ) @@ -47,7 +48,7 @@ func (s *storeIntSuite) TestNewKVStoreKeys() { require := s.Require() require.Panics(func() { NewKVStoreKeys("a1", "a") }, "should fail one key is a prefix of another one") - require.Equal(map[string]*KVStoreKey{}, NewKVStoreKeys()) + require.Equal(map[string]*types.KVStoreKey{}, NewKVStoreKeys()) require.Equal(1, len(NewKVStoreKeys("one"))) key := "baca" diff --git a/types/store_test.go b/types/store_test.go index 9c3ef2f79dd..d2039f8cb89 100644 --- a/types/store_test.go +++ b/types/store_test.go @@ -44,10 +44,10 @@ func (s *storeTestSuite) TestPrefixEndBytes() { } func (s *storeTestSuite) TestCommitID() { - var empty sdk.CommitID + var empty types.CommitID s.Require().True(empty.IsZero()) - var nonempty = sdk.CommitID{ + var nonempty = types.CommitID{ Version: 1, Hash: []byte("testhash"), } @@ -55,7 +55,7 @@ func (s *storeTestSuite) TestCommitID() { } func (s *storeTestSuite) TestNewTransientStoreKeys() { - s.Require().Equal(map[string]*sdk.TransientStoreKey{}, sdk.NewTransientStoreKeys()) + s.Require().Equal(map[string]*types.TransientStoreKey{}, sdk.NewTransientStoreKeys()) s.Require().Equal(1, len(sdk.NewTransientStoreKeys("one"))) } From 84334df52b9e365ada1ee4ad8fbf179c7a55c565 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 08:07:14 +0300 Subject: [PATCH 02/22] update baseapp/ --- baseapp/baseapp.go | 31 ++++++++++++++++--------------- baseapp/baseapp_test.go | 21 +++++++++++---------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 6044b9518d1..32073cc8827 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -15,6 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/snapshots" "github.com/cosmos/cosmos-sdk/store" "github.com/cosmos/cosmos-sdk/store/rootmulti" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" ) @@ -185,20 +186,20 @@ func (app *BaseApp) Trace() bool { // MountStores mounts all IAVL or DB stores to the provided keys in the BaseApp // multistore. -func (app *BaseApp) MountStores(keys ...sdk.StoreKey) { +func (app *BaseApp) MountStores(keys ...storetypes.StoreKey) { for _, key := range keys { switch key.(type) { - case *sdk.KVStoreKey: + case *storetypes.KVStoreKey: if !app.fauxMerkleMode { - app.MountStore(key, sdk.StoreTypeIAVL) + app.MountStore(key, storetypes.StoreTypeIAVL) } else { // StoreTypeDB doesn't do anything upon commit, and it doesn't // retain history, but it's useful for faster simulation. - app.MountStore(key, sdk.StoreTypeDB) + app.MountStore(key, storetypes.StoreTypeDB) } - case *sdk.TransientStoreKey: - app.MountStore(key, sdk.StoreTypeTransient) + case *storetypes.TransientStoreKey: + app.MountStore(key, storetypes.StoreTypeTransient) default: panic("Unrecognized store key type " + reflect.TypeOf(key).Name()) @@ -208,37 +209,37 @@ func (app *BaseApp) MountStores(keys ...sdk.StoreKey) { // MountKVStores mounts all IAVL or DB stores to the provided keys in the // BaseApp multistore. -func (app *BaseApp) MountKVStores(keys map[string]*sdk.KVStoreKey) { +func (app *BaseApp) MountKVStores(keys map[string]*storetypes.KVStoreKey) { for _, key := range keys { if !app.fauxMerkleMode { - app.MountStore(key, sdk.StoreTypeIAVL) + app.MountStore(key, storetypes.StoreTypeIAVL) } else { // StoreTypeDB doesn't do anything upon commit, and it doesn't // retain history, but it's useful for faster simulation. - app.MountStore(key, sdk.StoreTypeDB) + app.MountStore(key, storetypes.StoreTypeDB) } } } // MountTransientStores mounts all transient stores to the provided keys in // the BaseApp multistore. -func (app *BaseApp) MountTransientStores(keys map[string]*sdk.TransientStoreKey) { +func (app *BaseApp) MountTransientStores(keys map[string]*storetypes.TransientStoreKey) { for _, key := range keys { - app.MountStore(key, sdk.StoreTypeTransient) + app.MountStore(key, storetypes.StoreTypeTransient) } } // MountMemoryStores mounts all in-memory KVStores with the BaseApp's internal // commit multi-store. -func (app *BaseApp) MountMemoryStores(keys map[string]*sdk.MemoryStoreKey) { +func (app *BaseApp) MountMemoryStores(keys map[string]*storetypes.MemoryStoreKey) { for _, memKey := range keys { - app.MountStore(memKey, sdk.StoreTypeMemory) + app.MountStore(memKey, storetypes.StoreTypeMemory) } } // MountStore mounts a store to the provided key in the BaseApp multistore, // using the default DB. -func (app *BaseApp) MountStore(key sdk.StoreKey, typ sdk.StoreType) { +func (app *BaseApp) MountStore(key storetypes.StoreKey, typ storetypes.StoreType) { app.cms.MountStoreWithDB(key, typ, nil) } @@ -270,7 +271,7 @@ func (app *BaseApp) LoadVersion(version int64) error { } // LastCommitID returns the last CommitID of the multistore. -func (app *BaseApp) LastCommitID() sdk.CommitID { +func (app *BaseApp) LastCommitID() storetypes.CommitID { return app.cms.LastCommitID() } diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index 63abd71b563..1242ad4034e 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -28,6 +28,7 @@ import ( snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" "github.com/cosmos/cosmos-sdk/store/rootmulti" store "github.com/cosmos/cosmos-sdk/store/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -243,7 +244,7 @@ func TestLoadVersion(t *testing.T) { err := app.LoadLatestVersion() // needed to make stores non-nil require.Nil(t, err) - emptyCommitID := sdk.CommitID{} + emptyCommitID := storetypes.CommitID{} // fresh store has zero/empty last commit lastHeight := app.LastBlockHeight() @@ -255,13 +256,13 @@ func TestLoadVersion(t *testing.T) { header := tmproto.Header{Height: 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) res := app.Commit() - commitID1 := sdk.CommitID{Version: 1, Hash: res.Data} + commitID1 := storetypes.CommitID{Version: 1, Hash: res.Data} // execute a block, collect commit ID header = tmproto.Header{Height: 2} app.BeginBlock(abci.RequestBeginBlock{Header: header}) res = app.Commit() - commitID2 := sdk.CommitID{Version: 2, Hash: res.Data} + commitID2 := storetypes.CommitID{Version: 2, Hash: res.Data} // reload with LoadLatestVersion app = baseapp.NewBaseApp(name, logger, db, nil, pruningOpt) @@ -405,7 +406,7 @@ func TestLoadVersionInvalid(t *testing.T) { header := tmproto.Header{Height: 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) res := app.Commit() - commitID1 := sdk.CommitID{Version: 1, Hash: res.Data} + commitID1 := storetypes.CommitID{Version: 1, Hash: res.Data} // create a new app with the stores mounted under the same cap key app = baseapp.NewBaseApp(name, logger, db, nil, pruningOpt) @@ -439,7 +440,7 @@ func TestLoadVersionPruning(t *testing.T) { err := app.LoadLatestVersion() // needed to make stores non-nil require.Nil(t, err) - emptyCommitID := sdk.CommitID{} + emptyCommitID := storetypes.CommitID{} // fresh store has zero/empty last commit lastHeight := app.LastBlockHeight() @@ -447,14 +448,14 @@ func TestLoadVersionPruning(t *testing.T) { require.Equal(t, int64(0), lastHeight) require.Equal(t, emptyCommitID, lastID) - var lastCommitID sdk.CommitID + var lastCommitID storetypes.CommitID // Commit seven blocks, of which 7 (latest) is kept in addition to 6, 5 // (keep recent) and 3 (keep every). for i := int64(1); i <= 7; i++ { app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: i}}) res := app.Commit() - lastCommitID = sdk.CommitID{Version: i, Hash: res.Data} + lastCommitID = storetypes.CommitID{Version: i, Hash: res.Data} } for _, v := range []int64{1, 2, 4} { @@ -476,7 +477,7 @@ func TestLoadVersionPruning(t *testing.T) { testLoadVersionHelper(t, app, int64(7), lastCommitID) } -func testLoadVersionHelper(t *testing.T, app *baseapp.BaseApp, expectedHeight int64, expectedID sdk.CommitID) { +func testLoadVersionHelper(t *testing.T, app *baseapp.BaseApp, expectedHeight int64, expectedID storetypes.CommitID) { lastHeight := app.LastBlockHeight() lastID := app.LastCommitID() require.Equal(t, expectedHeight, lastHeight) @@ -845,7 +846,7 @@ func testTxDecoder(cdc *codec.LegacyAmino) sdk.TxDecoder { } } -func customHandlerTxTest(t *testing.T, capKey sdk.StoreKey, storeKey []byte) handlerFun { +func customHandlerTxTest(t *testing.T, capKey storetypes.StoreKey, storeKey []byte) handlerFun { return func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) { store := ctx.KVStore(capKey) txTest := tx.(txTest) @@ -876,7 +877,7 @@ func counterEvent(evType string, msgCount int64) sdk.Events { } } -func handlerMsgCounter(t *testing.T, capKey sdk.StoreKey, deliverKey []byte) sdk.Handler { +func handlerMsgCounter(t *testing.T, capKey storetypes.StoreKey, deliverKey []byte) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) store := ctx.KVStore(capKey) From 83aab05dde3f970a40f20d796375157c24cb0ed0 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 08:07:25 +0300 Subject: [PATCH 03/22] update server/ --- server/mock/app.go | 10 +++++----- server/mock/store.go | 30 +++++++++++++++--------------- server/mock/store_test.go | 6 +++--- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/server/mock/app.go b/server/mock/app.go index d5f7c911c25..84475a4fc11 100644 --- a/server/mock/app.go +++ b/server/mock/app.go @@ -8,15 +8,15 @@ import ( "github.com/tendermint/tendermint/types" - abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/libs/log" - bam "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/x/auth/middleware" + abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/libs/log" ) func testTxHandler(options middleware.TxHandlerOptions) tx.Handler { @@ -72,7 +72,7 @@ func NewApp(rootDir string, logger log.Logger) (abci.Application, error) { // KVStoreHandler is a simple handler that takes kvstoreTx and writes // them to the db -func KVStoreHandler(storeKey sdk.StoreKey) sdk.Handler { +func KVStoreHandler(storeKey storetypes.StoreKey) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { dTx, ok := msg.(kvstoreTx) if !ok { @@ -105,7 +105,7 @@ type GenesisJSON struct { // InitChainer returns a function that can initialize the chain // with key/value pairs -func InitChainer(key sdk.StoreKey) func(sdk.Context, abci.RequestInitChain) abci.ResponseInitChain { +func InitChainer(key storetypes.StoreKey) func(sdk.Context, abci.RequestInitChain) abci.ResponseInitChain { return func(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { stateJSON := req.AppStateBytes diff --git a/server/mock/store.go b/server/mock/store.go index 33f573518c1..7829ca58c68 100644 --- a/server/mock/store.go +++ b/server/mock/store.go @@ -12,7 +12,7 @@ import ( var _ sdk.MultiStore = multiStore{} type multiStore struct { - kv map[sdk.StoreKey]kvStore + kv map[store.StoreKey]kvStore } func (ms multiStore) CacheMultiStore() sdk.CacheMultiStore { @@ -23,11 +23,11 @@ func (ms multiStore) CacheMultiStoreWithVersion(_ int64) (sdk.CacheMultiStore, e panic("not implemented") } -func (ms multiStore) CacheWrap() sdk.CacheWrap { +func (ms multiStore) CacheWrap() store.CacheWrap { panic("not implemented") } -func (ms multiStore) CacheWrapWithTrace(_ io.Writer, _ sdk.TraceContext) sdk.CacheWrap { +func (ms multiStore) CacheWrapWithTrace(_ io.Writer, _ sdk.TraceContext) store.CacheWrap { panic("not implemented") } @@ -55,11 +55,11 @@ func (ms multiStore) ListeningEnabled(key store.StoreKey) bool { panic("not implemented") } -func (ms multiStore) Commit() sdk.CommitID { +func (ms multiStore) Commit() store.CommitID { panic("not implemented") } -func (ms multiStore) LastCommitID() sdk.CommitID { +func (ms multiStore) LastCommitID() store.CommitID { panic("not implemented") } @@ -71,15 +71,15 @@ func (ms multiStore) GetPruning() sdk.PruningOptions { panic("not implemented") } -func (ms multiStore) GetCommitKVStore(key sdk.StoreKey) sdk.CommitKVStore { +func (ms multiStore) GetCommitKVStore(key store.StoreKey) store.CommitKVStore { panic("not implemented") } -func (ms multiStore) GetCommitStore(key sdk.StoreKey) sdk.CommitStore { +func (ms multiStore) GetCommitStore(key store.StoreKey) store.CommitStore { panic("not implemented") } -func (ms multiStore) MountStoreWithDB(key sdk.StoreKey, typ sdk.StoreType, db dbm.DB) { +func (ms multiStore) MountStoreWithDB(key store.StoreKey, typ store.StoreType, db dbm.DB) { ms.kv[key] = kvStore{store: make(map[string][]byte)} } @@ -99,15 +99,15 @@ func (ms multiStore) LoadVersion(ver int64) error { panic("not implemented") } -func (ms multiStore) GetKVStore(key sdk.StoreKey) sdk.KVStore { +func (ms multiStore) GetKVStore(key store.StoreKey) sdk.KVStore { return ms.kv[key] } -func (ms multiStore) GetStore(key sdk.StoreKey) sdk.Store { +func (ms multiStore) GetStore(key store.StoreKey) sdk.Store { panic("not implemented") } -func (ms multiStore) GetStoreType() sdk.StoreType { +func (ms multiStore) GetStoreType() store.StoreType { panic("not implemented") } @@ -135,11 +135,11 @@ type kvStore struct { store map[string][]byte } -func (kv kvStore) CacheWrap() sdk.CacheWrap { +func (kv kvStore) CacheWrap() store.CacheWrap { panic("not implemented") } -func (kv kvStore) CacheWrapWithTrace(w io.Writer, tc sdk.TraceContext) sdk.CacheWrap { +func (kv kvStore) CacheWrapWithTrace(w io.Writer, tc sdk.TraceContext) store.CacheWrap { panic("not implemented") } @@ -147,7 +147,7 @@ func (kv kvStore) CacheWrapWithListeners(_ store.StoreKey, _ []store.WriteListen panic("not implemented") } -func (kv kvStore) GetStoreType() sdk.StoreType { +func (kv kvStore) GetStoreType() store.StoreType { panic("not implemented") } @@ -198,5 +198,5 @@ func (kv kvStore) ReverseSubspaceIterator(prefix []byte) sdk.Iterator { } func NewCommitMultiStore() sdk.CommitMultiStore { - return multiStore{kv: make(map[sdk.StoreKey]kvStore)} + return multiStore{kv: make(map[store.StoreKey]kvStore)} } diff --git a/server/mock/store_test.go b/server/mock/store_test.go index b945cd30599..cfa61c1c6cf 100644 --- a/server/mock/store_test.go +++ b/server/mock/store_test.go @@ -5,9 +5,9 @@ import ( "github.com/stretchr/testify/require" - dbm "github.com/tendermint/tm-db" - + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + dbm "github.com/tendermint/tm-db" ) func TestStore(t *testing.T) { @@ -15,7 +15,7 @@ func TestStore(t *testing.T) { cms := NewCommitMultiStore() key := sdk.NewKVStoreKey("test") - cms.MountStoreWithDB(key, sdk.StoreTypeIAVL, db) + cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db) err := cms.LoadLatestVersion() require.Nil(t, err) From d4c58c7e0b1addf75bb6216f174ef77fae12a76e Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 08:07:38 +0300 Subject: [PATCH 04/22] update simapp --- simapp/app.go | 15 ++++++++------- simapp/sim_test.go | 5 +++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index b3323ec076f..ebddd0b6204 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -42,6 +42,7 @@ import ( capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" authmiddleware "github.com/cosmos/cosmos-sdk/x/auth/middleware" "github.com/cosmos/cosmos-sdk/x/authz" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" @@ -147,9 +148,9 @@ type SimApp struct { invCheckPeriod uint // keys to access the substores - keys map[string]*sdk.KVStoreKey - tkeys map[string]*sdk.TransientStoreKey - memKeys map[string]*sdk.MemoryStoreKey + keys map[string]*storetypes.KVStoreKey + tkeys map[string]*storetypes.TransientStoreKey + memKeys map[string]*storetypes.MemoryStoreKey // keepers AccountKeeper authkeeper.AccountKeeper @@ -484,21 +485,21 @@ func (app *SimApp) InterfaceRegistry() types.InterfaceRegistry { // GetKey returns the KVStoreKey for the provided store key. // // NOTE: This is solely to be used for testing purposes. -func (app *SimApp) GetKey(storeKey string) *sdk.KVStoreKey { +func (app *SimApp) GetKey(storeKey string) *storetypes.KVStoreKey { return app.keys[storeKey] } // GetTKey returns the TransientStoreKey for the provided store key. // // NOTE: This is solely to be used for testing purposes. -func (app *SimApp) GetTKey(storeKey string) *sdk.TransientStoreKey { +func (app *SimApp) GetTKey(storeKey string) *storetypes.TransientStoreKey { return app.tkeys[storeKey] } // GetMemKey returns the MemStoreKey for the provided mem key. // // NOTE: This is solely used for testing purposes. -func (app *SimApp) GetMemKey(storeKey string) *sdk.MemoryStoreKey { +func (app *SimApp) GetMemKey(storeKey string) *storetypes.MemoryStoreKey { return app.memKeys[storeKey] } @@ -565,7 +566,7 @@ func GetMaccPerms() map[string][]string { } // initParamsKeeper init params keeper and its subspaces -func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper { +func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper { paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) paramsKeeper.Subspace(authtypes.ModuleName) diff --git a/simapp/sim_test.go b/simapp/sim_test.go index b31efd8aa53..377c9379014 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -7,6 +7,7 @@ import ( "os" "testing" + storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" @@ -38,8 +39,8 @@ func init() { } type StoreKeysPrefixes struct { - A sdk.StoreKey - B sdk.StoreKey + A storetypes.StoreKey + B storetypes.StoreKey Prefixes [][]byte } From 540cab93278a8612dab5c8295186eb8009db73d8 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 08:08:03 +0300 Subject: [PATCH 05/22] update auth/ --- testutil/context.go | 7 ++++--- x/auth/keeper/keeper.go | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/testutil/context.go b/testutil/context.go index 2fb9865a269..1addf17c287 100644 --- a/testutil/context.go +++ b/testutil/context.go @@ -6,15 +6,16 @@ import ( dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" ) // DefaultContext creates a sdk.Context with a fresh MemDB that can be used in tests. -func DefaultContext(key sdk.StoreKey, tkey sdk.StoreKey) sdk.Context { +func DefaultContext(key storetypes.StoreKey, tkey storetypes.StoreKey) sdk.Context { db := dbm.NewMemDB() cms := store.NewCommitMultiStore(db) - cms.MountStoreWithDB(key, sdk.StoreTypeIAVL, db) - cms.MountStoreWithDB(tkey, sdk.StoreTypeTransient, db) + cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db) + cms.MountStoreWithDB(tkey, storetypes.StoreTypeTransient, db) err := cms.LoadLatestVersion() if err != nil { panic(err) diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index 10ce4f0be2a..25592115a3e 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -12,6 +12,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -53,7 +54,7 @@ type AccountKeeperI interface { // AccountKeeper encodes/decodes accounts using the go-amino (binary) // encoding/decoding library. type AccountKeeper struct { - key sdk.StoreKey + key storetypes.StoreKey cdc codec.BinaryCodec paramSubspace paramtypes.Subspace permAddrs map[string]types.PermissionsForAddress @@ -72,7 +73,7 @@ var _ AccountKeeperI = &AccountKeeper{} // and don't have to fit into any predefined structure. This auth module does not use account permissions internally, though other modules // may use auth.Keeper to access the accounts permissions map. func NewAccountKeeper( - cdc codec.BinaryCodec, key sdk.StoreKey, paramstore paramtypes.Subspace, proto func() types.AccountI, + cdc codec.BinaryCodec, key storetypes.StoreKey, paramstore paramtypes.Subspace, proto func() types.AccountI, maccPerms map[string][]string, bech32Prefix string, ) AccountKeeper { From 0d2e02b204345735de311157b34751f736839ab0 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 08:08:32 +0300 Subject: [PATCH 06/22] update authz/ --- x/authz/keeper/keeper.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index b884d41bc4f..43c3ccc15d4 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -10,6 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/middleware" @@ -17,13 +18,13 @@ import ( ) type Keeper struct { - storeKey sdk.StoreKey + storeKey storetypes.StoreKey cdc codec.BinaryCodec router *middleware.MsgServiceRouter } // NewKeeper constructs a message authorization Keeper -func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec, router *middleware.MsgServiceRouter) Keeper { +func NewKeeper(storeKey storetypes.StoreKey, cdc codec.BinaryCodec, router *middleware.MsgServiceRouter) Keeper { return Keeper{ storeKey: storeKey, cdc: cdc, From f4cde8e0243841cb9bab0d56f950017a0abe49d3 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 08:08:43 +0300 Subject: [PATCH 07/22] update bank/ --- x/bank/keeper/keeper.go | 5 +++-- x/bank/keeper/send.go | 5 +++-- x/bank/keeper/view.go | 5 +++-- x/bank/migrations/v043/store.go | 3 ++- x/bank/migrations/v045/store.go | 3 ++- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index ca014d4eca0..50aec230dda 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -5,6 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" @@ -52,7 +53,7 @@ type BaseKeeper struct { ak types.AccountKeeper cdc codec.BinaryCodec - storeKey sdk.StoreKey + storeKey storetypes.StoreKey paramSpace paramtypes.Subspace } @@ -89,7 +90,7 @@ func (k BaseKeeper) GetPaginatedTotalSupply(ctx sdk.Context, pagination *query.P // by using a SendCoinsFromModuleToAccount execution. func NewBaseKeeper( cdc codec.BinaryCodec, - storeKey sdk.StoreKey, + storeKey storetypes.StoreKey, ak types.AccountKeeper, paramSpace paramtypes.Subspace, blockedAddrs map[string]bool, diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go index b0c38a320e0..fa77baa5e69 100644 --- a/x/bank/keeper/send.go +++ b/x/bank/keeper/send.go @@ -3,6 +3,7 @@ package keeper import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" @@ -37,7 +38,7 @@ type BaseSendKeeper struct { cdc codec.BinaryCodec ak types.AccountKeeper - storeKey sdk.StoreKey + storeKey storetypes.StoreKey paramSpace paramtypes.Subspace // list of addresses that are restricted from receiving transactions @@ -45,7 +46,7 @@ type BaseSendKeeper struct { } func NewBaseSendKeeper( - cdc codec.BinaryCodec, storeKey sdk.StoreKey, ak types.AccountKeeper, paramSpace paramtypes.Subspace, blockedAddrs map[string]bool, + cdc codec.BinaryCodec, storeKey storetypes.StoreKey, ak types.AccountKeeper, paramSpace paramtypes.Subspace, blockedAddrs map[string]bool, ) BaseSendKeeper { return BaseSendKeeper{ diff --git a/x/bank/keeper/view.go b/x/bank/keeper/view.go index 62fed93c874..6f178bb7f7e 100644 --- a/x/bank/keeper/view.go +++ b/x/bank/keeper/view.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" vestexported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" @@ -34,12 +35,12 @@ type ViewKeeper interface { // BaseViewKeeper implements a read only keeper implementation of ViewKeeper. type BaseViewKeeper struct { cdc codec.BinaryCodec - storeKey sdk.StoreKey + storeKey storetypes.StoreKey ak types.AccountKeeper } // NewBaseViewKeeper returns a new BaseViewKeeper. -func NewBaseViewKeeper(cdc codec.BinaryCodec, storeKey sdk.StoreKey, ak types.AccountKeeper) BaseViewKeeper { +func NewBaseViewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, ak types.AccountKeeper) BaseViewKeeper { return BaseViewKeeper{ cdc: cdc, storeKey: storeKey, diff --git a/x/bank/migrations/v043/store.go b/x/bank/migrations/v043/store.go index 2b3a084d0bf..4c6b56e2b3e 100644 --- a/x/bank/migrations/v043/store.go +++ b/x/bank/migrations/v043/store.go @@ -3,6 +3,7 @@ package v043 import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" v040auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v040" v040bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v040" @@ -76,7 +77,7 @@ func migrateBalanceKeys(store sdk.KVStore) { // - Change balances prefix to 1 byte // - Change supply to be indexed by denom // - Prune balances & supply with zero coins (ref: https://github.com/cosmos/cosmos-sdk/pull/9229) -func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) error { +func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { store := ctx.KVStore(storeKey) migrateBalanceKeys(store) diff --git a/x/bank/migrations/v045/store.go b/x/bank/migrations/v045/store.go index 35a3545b114..6a6ee8aa034 100644 --- a/x/bank/migrations/v045/store.go +++ b/x/bank/migrations/v045/store.go @@ -3,6 +3,7 @@ package v045 import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" v043 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v043" @@ -15,7 +16,7 @@ import ( // - Migrate coin storage to save only amount. // - Add an additional reverse index from denomination to address. // - Remove duplicate denom from denom metadata store key. -func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) error { +func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { store := ctx.KVStore(storeKey) err := addDenomReverseIndex(store, cdc) if err != nil { From 9ce943483f1e515b763ce33f0d78010d1fa2d8c6 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 08:09:01 +0300 Subject: [PATCH 08/22] update capability/ --- x/capability/keeper/keeper.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/x/capability/keeper/keeper.go b/x/capability/keeper/keeper.go index 61df229af9f..cea52456349 100644 --- a/x/capability/keeper/keeper.go +++ b/x/capability/keeper/keeper.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/capability/types" @@ -28,8 +29,8 @@ type ( // a single specific module. Keeper struct { cdc codec.BinaryCodec - storeKey sdk.StoreKey - memKey sdk.StoreKey + storeKey storetypes.StoreKey + memKey storetypes.StoreKey capMap map[uint64]*types.Capability scopedModules map[string]struct{} sealed bool @@ -43,8 +44,8 @@ type ( // passed by other modules. ScopedKeeper struct { cdc codec.BinaryCodec - storeKey sdk.StoreKey - memKey sdk.StoreKey + storeKey storetypes.StoreKey + memKey storetypes.StoreKey capMap map[uint64]*types.Capability module string } @@ -52,7 +53,7 @@ type ( // NewKeeper constructs a new CapabilityKeeper instance and initializes maps // for capability map and scopedModules map. -func NewKeeper(cdc codec.BinaryCodec, storeKey, memKey sdk.StoreKey) *Keeper { +func NewKeeper(cdc codec.BinaryCodec, storeKey, memKey storetypes.StoreKey) *Keeper { return &Keeper{ cdc: cdc, storeKey: storeKey, @@ -108,8 +109,8 @@ func (k *Keeper) InitMemStore(ctx sdk.Context) { memStore := ctx.KVStore(k.memKey) memStoreType := memStore.GetStoreType() - if memStoreType != sdk.StoreTypeMemory { - panic(fmt.Sprintf("invalid memory store type; got %s, expected: %s", memStoreType, sdk.StoreTypeMemory)) + if memStoreType != storetypes.StoreTypeMemory { + panic(fmt.Sprintf("invalid memory store type; got %s, expected: %s", memStoreType, storetypes.StoreTypeMemory)) } // create context with no block gas meter to ensure we do not consume gas during local initialization logic. From 06b58ab8e87bdf729fb94cb9d0c03b264f5ae4f5 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 08:09:48 +0300 Subject: [PATCH 09/22] update epoching/ --- x/distribution/keeper/keeper.go | 5 +++-- x/distribution/migrations/v043/store.go | 3 ++- x/epoching/keeper/keeper.go | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/x/distribution/keeper/keeper.go b/x/distribution/keeper/keeper.go index 97669cae23a..9bd8285c31e 100644 --- a/x/distribution/keeper/keeper.go +++ b/x/distribution/keeper/keeper.go @@ -6,6 +6,7 @@ import ( "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/distribution/types" @@ -14,7 +15,7 @@ import ( // Keeper of the distribution store type Keeper struct { - storeKey sdk.StoreKey + storeKey storetypes.StoreKey cdc codec.BinaryCodec paramSpace paramtypes.Subspace authKeeper types.AccountKeeper @@ -28,7 +29,7 @@ type Keeper struct { // NewKeeper creates a new distribution Keeper instance func NewKeeper( - cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace, + cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace, ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper, feeCollectorName string, blockedAddrs map[string]bool, ) Keeper { diff --git a/x/distribution/migrations/v043/store.go b/x/distribution/migrations/v043/store.go index 3ec85d3a42e..b757c7f2ac1 100644 --- a/x/distribution/migrations/v043/store.go +++ b/x/distribution/migrations/v043/store.go @@ -1,6 +1,7 @@ package v043 import ( + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" v040distribution "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v040" ) @@ -9,7 +10,7 @@ import ( // migration includes: // // - Change addresses to be length-prefixed. -func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey) error { +func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey) error { store := ctx.KVStore(storeKey) MigratePrefixAddress(store, v040distribution.ValidatorOutstandingRewardsPrefix) MigratePrefixAddress(store, v040distribution.DelegatorWithdrawAddrPrefix) diff --git a/x/epoching/keeper/keeper.go b/x/epoching/keeper/keeper.go index 3047375233b..f39d324bdf0 100644 --- a/x/epoching/keeper/keeper.go +++ b/x/epoching/keeper/keeper.go @@ -5,6 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" db "github.com/tendermint/tm-db" ) @@ -22,7 +23,7 @@ var ( // Keeper of the store type Keeper struct { - storeKey sdk.StoreKey + storeKey storetypes.StoreKey cdc codec.BinaryCodec // Used to calculate the estimated next epoch time. // This is local to every node @@ -31,7 +32,7 @@ type Keeper struct { } // NewKeeper creates a epoch queue manager -func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, commitTimeout time.Duration) Keeper { +func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, commitTimeout time.Duration) Keeper { return Keeper{ storeKey: key, cdc: cdc, From 8ec7ffea8360cb270924996f0e1a650c5b95cf56 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 08:09:59 +0300 Subject: [PATCH 10/22] update gov/ --- x/gov/keeper/keeper.go | 5 +++-- x/gov/migrations/v043/store.go | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/x/gov/keeper/keeper.go b/x/gov/keeper/keeper.go index 9e639fe5d0f..dc2a2e6bfa2 100644 --- a/x/gov/keeper/keeper.go +++ b/x/gov/keeper/keeper.go @@ -7,6 +7,7 @@ import ( "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -27,7 +28,7 @@ type Keeper struct { hooks types.GovHooks // The (unexposed) keys used to access the stores from the Context. - storeKey sdk.StoreKey + storeKey storetypes.StoreKey // The codec codec for binary encoding/decoding. cdc codec.BinaryCodec @@ -44,7 +45,7 @@ type Keeper struct { // // CONTRACT: the parameter Subspace must have the param key table already initialized func NewKeeper( - cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace types.ParamSubspace, + cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace types.ParamSubspace, authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, sk types.StakingKeeper, rtr types.Router, ) Keeper { diff --git a/x/gov/migrations/v043/store.go b/x/gov/migrations/v043/store.go index 2de980dbab3..b71c6b8d743 100644 --- a/x/gov/migrations/v043/store.go +++ b/x/gov/migrations/v043/store.go @@ -5,6 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -73,7 +74,7 @@ func migrateStoreWeightedVotes(store sdk.KVStore, cdc codec.BinaryCodec) error { // migration includes: // // - Change addresses to be length-prefixed. -func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) error { +func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { store := ctx.KVStore(storeKey) migratePrefixProposalAddress(store, types.DepositsKeyPrefix) migratePrefixProposalAddress(store, types.VotesKeyPrefix) From e56671a535d47be33a4a4f42b78e12633e94a805 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 08:10:12 +0300 Subject: [PATCH 11/22] update params/ --- x/params/keeper/common_test.go | 3 ++- x/params/keeper/keeper.go | 10 +++++----- x/params/types/subspace.go | 7 ++++--- x/params/types/subspace_test.go | 5 +++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/x/params/keeper/common_test.go b/x/params/keeper/common_test.go index e5bebaf09b0..20bba1944d6 100644 --- a/x/params/keeper/common_test.go +++ b/x/params/keeper/common_test.go @@ -3,12 +3,13 @@ package keeper_test import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" + storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" ) -func testComponents() (*codec.LegacyAmino, sdk.Context, sdk.StoreKey, sdk.StoreKey, paramskeeper.Keeper) { +func testComponents() (*codec.LegacyAmino, sdk.Context, storetypes.StoreKey, storetypes.StoreKey, paramskeeper.Keeper) { marshaler := simapp.MakeTestEncodingConfig().Codec legacyAmino := createTestCodec() mkey := sdk.NewKVStoreKey("test") diff --git a/x/params/keeper/keeper.go b/x/params/keeper/keeper.go index 8a0e708aeb3..362231a56ad 100644 --- a/x/params/keeper/keeper.go +++ b/x/params/keeper/keeper.go @@ -1,25 +1,25 @@ package keeper import ( - "github.com/tendermint/tendermint/libs/log" - "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/cosmos/cosmos-sdk/x/params/types/proposal" + "github.com/tendermint/tendermint/libs/log" ) // Keeper of the global paramstore type Keeper struct { cdc codec.BinaryCodec legacyAmino *codec.LegacyAmino - key sdk.StoreKey - tkey sdk.StoreKey + key storetypes.StoreKey + tkey storetypes.StoreKey spaces map[string]*types.Subspace } // NewKeeper constructs a params keeper -func NewKeeper(cdc codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) Keeper { +func NewKeeper(cdc codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) Keeper { return Keeper{ cdc: cdc, legacyAmino: legacyAmino, diff --git a/x/params/types/subspace.go b/x/params/types/subspace.go index 541277dcf61..dd316cbd42e 100644 --- a/x/params/types/subspace.go +++ b/x/params/types/subspace.go @@ -6,6 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -23,14 +24,14 @@ const ( type Subspace struct { cdc codec.BinaryCodec legacyAmino *codec.LegacyAmino - key sdk.StoreKey // []byte -> []byte, stores parameter - tkey sdk.StoreKey // []byte -> bool, stores parameter change + key storetypes.StoreKey // []byte -> []byte, stores parameter + tkey storetypes.StoreKey // []byte -> bool, stores parameter change name []byte table KeyTable } // NewSubspace constructs a store with namestore -func NewSubspace(cdc codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key sdk.StoreKey, tkey sdk.StoreKey, name string) Subspace { +func NewSubspace(cdc codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key storetypes.StoreKey, tkey storetypes.StoreKey, name string) Subspace { return Subspace{ cdc: cdc, legacyAmino: legacyAmino, diff --git a/x/params/types/subspace_test.go b/x/params/types/subspace_test.go index d09e9c26b53..fa1d1a36ecb 100644 --- a/x/params/types/subspace_test.go +++ b/x/params/types/subspace_test.go @@ -6,6 +6,7 @@ import ( "testing" "time" + storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/stretchr/testify/suite" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -31,8 +32,8 @@ func (suite *SubspaceTestSuite) SetupTest() { db := dbm.NewMemDB() ms := store.NewCommitMultiStore(db) - ms.MountStoreWithDB(key, sdk.StoreTypeIAVL, db) - ms.MountStoreWithDB(tkey, sdk.StoreTypeTransient, db) + ms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db) + ms.MountStoreWithDB(tkey, storetypes.StoreTypeTransient, db) suite.NoError(ms.LoadLatestVersion()) encCfg := simapp.MakeTestEncodingConfig() From 8656ed63e7cee7afc065c6d99df7b524b25f35fb Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 08:10:24 +0300 Subject: [PATCH 12/22] update slashing/ --- x/slashing/keeper/keeper.go | 5 +++-- x/slashing/migrations/v043/store.go | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/x/slashing/keeper/keeper.go b/x/slashing/keeper/keeper.go index 179bc860dd1..dbec306bfda 100644 --- a/x/slashing/keeper/keeper.go +++ b/x/slashing/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" @@ -13,14 +14,14 @@ import ( // Keeper of the slashing store type Keeper struct { - storeKey sdk.StoreKey + storeKey storetypes.StoreKey cdc codec.BinaryCodec sk types.StakingKeeper paramspace types.ParamSubspace } // NewKeeper creates a slashing keeper -func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, sk types.StakingKeeper, paramspace types.ParamSubspace) Keeper { +func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, sk types.StakingKeeper, paramspace types.ParamSubspace) Keeper { // set KeyTable if it has not already been set if !paramspace.HasKeyTable() { paramspace = paramspace.WithKeyTable(types.ParamKeyTable()) diff --git a/x/slashing/migrations/v043/store.go b/x/slashing/migrations/v043/store.go index 20878352a69..15da0982e27 100644 --- a/x/slashing/migrations/v043/store.go +++ b/x/slashing/migrations/v043/store.go @@ -1,6 +1,7 @@ package v043 import ( + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" v043distribution "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v043" v040slashing "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v040" @@ -10,7 +11,7 @@ import ( // migration includes: // // - Change addresses to be length-prefixed. -func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey) error { +func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey) error { store := ctx.KVStore(storeKey) v043distribution.MigratePrefixAddress(store, v040slashing.ValidatorSigningInfoKeyPrefix) v043distribution.MigratePrefixAddressBytes(store, v040slashing.ValidatorMissedBlockBitArrayKeyPrefix) From 5da4d72391908b26a6905cc9627193c5cd20df40 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 08:10:42 +0300 Subject: [PATCH 13/22] update evidence/ --- x/evidence/keeper/keeper.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x/evidence/keeper/keeper.go b/x/evidence/keeper/keeper.go index e913e7ab55e..366f46b8318 100644 --- a/x/evidence/keeper/keeper.go +++ b/x/evidence/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + storetypes "github.com/cosmos/cosmos-sdk/store/types" tmbytes "github.com/tendermint/tendermint/libs/bytes" "github.com/tendermint/tendermint/libs/log" @@ -19,14 +20,14 @@ import ( // module. type Keeper struct { cdc codec.BinaryCodec - storeKey sdk.StoreKey + storeKey storetypes.StoreKey router types.Router stakingKeeper types.StakingKeeper slashingKeeper types.SlashingKeeper } func NewKeeper( - cdc codec.BinaryCodec, storeKey sdk.StoreKey, stakingKeeper types.StakingKeeper, + cdc codec.BinaryCodec, storeKey storetypes.StoreKey, stakingKeeper types.StakingKeeper, slashingKeeper types.SlashingKeeper, ) *Keeper { From 649a3453acd5d9d18cc62331c19e25be68b64caa Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 08:10:54 +0300 Subject: [PATCH 14/22] update feegrant/ --- x/feegrant/keeper/keeper.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x/feegrant/keeper/keeper.go b/x/feegrant/keeper/keeper.go index 8e675046321..5d4d79fabc4 100644 --- a/x/feegrant/keeper/keeper.go +++ b/x/feegrant/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" @@ -16,14 +17,14 @@ import ( // It must have a codec with all available allowances registered. type Keeper struct { cdc codec.BinaryCodec - storeKey sdk.StoreKey + storeKey storetypes.StoreKey authKeeper feegrant.AccountKeeper } var _ middleware.FeegrantKeeper = &Keeper{} // NewKeeper creates a fee grant Keeper -func NewKeeper(cdc codec.BinaryCodec, storeKey sdk.StoreKey, ak feegrant.AccountKeeper) Keeper { +func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, ak feegrant.AccountKeeper) Keeper { return Keeper{ cdc: cdc, storeKey: storeKey, From 7f7da24bf4752cbe319837098dac206bcda9cdb6 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 08:11:05 +0300 Subject: [PATCH 15/22] update mint/ --- x/mint/keeper/keeper.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x/mint/keeper/keeper.go b/x/mint/keeper/keeper.go index b010204e8a1..fd064ff7b4d 100644 --- a/x/mint/keeper/keeper.go +++ b/x/mint/keeper/keeper.go @@ -4,6 +4,7 @@ import ( "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/mint/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -12,7 +13,7 @@ import ( // Keeper of the mint store type Keeper struct { cdc codec.BinaryCodec - storeKey sdk.StoreKey + storeKey storetypes.StoreKey paramSpace paramtypes.Subspace stakingKeeper types.StakingKeeper bankKeeper types.BankKeeper @@ -21,7 +22,7 @@ type Keeper struct { // NewKeeper creates a new mint Keeper instance func NewKeeper( - cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace, + cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace, sk types.StakingKeeper, ak types.AccountKeeper, bk types.BankKeeper, feeCollectorName string, ) Keeper { From ff077324f1832a0fa0fa48ab9a8f51357f0ca524 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 08:11:23 +0300 Subject: [PATCH 16/22] update staking/ --- x/staking/keeper/keeper.go | 5 +++-- x/staking/migrations/v043/store.go | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/x/staking/keeper/keeper.go b/x/staking/keeper/keeper.go index 6211dcf6ad9..5dde8f1bb92 100644 --- a/x/staking/keeper/keeper.go +++ b/x/staking/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" @@ -19,7 +20,7 @@ var _ types.DelegationSet = Keeper{} // keeper of the staking store type Keeper struct { - storeKey sdk.StoreKey + storeKey storetypes.StoreKey cdc codec.BinaryCodec authKeeper types.AccountKeeper bankKeeper types.BankKeeper @@ -29,7 +30,7 @@ type Keeper struct { // NewKeeper creates a new staking Keeper instance func NewKeeper( - cdc codec.BinaryCodec, key sdk.StoreKey, ak types.AccountKeeper, bk types.BankKeeper, + cdc codec.BinaryCodec, key storetypes.StoreKey, ak types.AccountKeeper, bk types.BankKeeper, ps paramtypes.Subspace, ) Keeper { // set KeyTable if it has not already been set diff --git a/x/staking/migrations/v043/store.go b/x/staking/migrations/v043/store.go index 4ebba9b600f..2ebcbb8686d 100644 --- a/x/staking/migrations/v043/store.go +++ b/x/staking/migrations/v043/store.go @@ -2,6 +2,7 @@ package v043 import ( "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" v040auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v040" @@ -58,7 +59,7 @@ func migrateValidatorsByPowerIndexKey(store sdk.KVStore) { // migration includes: // // - Setting the Power Reduction param in the paramstore -func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey) error { +func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey) error { store := ctx.KVStore(storeKey) v043distribution.MigratePrefixAddress(store, v040staking.LastValidatorPowerKey) From 8d521ed002b31d1a3d42f739410d0e9ff0d074e2 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 08:11:35 +0300 Subject: [PATCH 17/22] update upgrade/ --- x/upgrade/keeper/keeper.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go index a6a5ee9552e..21ab2b2a517 100644 --- a/x/upgrade/keeper/keeper.go +++ b/x/upgrade/keeper/keeper.go @@ -9,6 +9,7 @@ import ( "path/filepath" "sort" + storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/tendermint/tendermint/libs/log" tmos "github.com/tendermint/tendermint/libs/os" @@ -28,7 +29,7 @@ const UpgradeInfoFileName string = "upgrade-info.json" type Keeper struct { homePath string // root directory of app config skipUpgradeHeights map[int64]bool // map of heights to skip for an upgrade - storeKey sdk.StoreKey // key to access x/upgrade store + storeKey storetypes.StoreKey // key to access x/upgrade store cdc codec.BinaryCodec // App-wide binary codec upgradeHandlers map[string]types.UpgradeHandler // map of plan name to upgrade handler versionSetter xp.ProtocolVersionSetter // implements setting the protocol version field on BaseApp @@ -40,7 +41,7 @@ type Keeper struct { // cdc - the app-wide binary codec // homePath - root directory of the application's config // vs - the interface implemented by baseapp which allows setting baseapp's protocol version field -func NewKeeper(skipUpgradeHeights map[int64]bool, storeKey sdk.StoreKey, cdc codec.BinaryCodec, homePath string, vs xp.ProtocolVersionSetter) Keeper { +func NewKeeper(skipUpgradeHeights map[int64]bool, storeKey storetypes.StoreKey, cdc codec.BinaryCodec, homePath string, vs xp.ProtocolVersionSetter) Keeper { return Keeper{ homePath: homePath, skipUpgradeHeights: skipUpgradeHeights, From c3af1f396ff0ef4e11d83bbb1f06f079028c3b62 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 09:06:54 +0300 Subject: [PATCH 18/22] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c01a3a52aa8..46e25c0a12b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (bank) [\#9618](https://github.com/cosmos/cosmos-sdk/pull/9618) Update bank.Metadata: add URI and URIHash attributes. * [\#9837](https://github.com/cosmos/cosmos-sdk/issues/9837) `--generate-only` flag will accept the keyname now. * [\#10045](https://github.com/cosmos/cosmos-sdk/pull/10045) Revert [#8549](https://github.com/cosmos/cosmos-sdk/pull/8549). Do not route grpc queries through Tendermint. +* [\#10295](https://github.com/cosmos/cosmos-sdk/pull/10295) Remove store type aliases in /types ### API Breaking Changes From 9fc7fd8ee7c61ebf2a3307c8bf2c9b77fe36c171 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 3 Oct 2021 09:14:14 +0300 Subject: [PATCH 19/22] standardize storetypes imports --- baseapp/baseapp_test.go | 23 +++++++-------- server/mock/store.go | 46 ++++++++++++++--------------- types/context.go | 12 ++++---- x/gov/keeper/msg_server.go | 4 +-- x/upgrade/types/storeloader.go | 4 +-- x/upgrade/types/storeloader_test.go | 22 +++++++------- 6 files changed, 55 insertions(+), 56 deletions(-) diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index 1242ad4034e..5d77a16469c 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -27,7 +27,6 @@ import ( "github.com/cosmos/cosmos-sdk/snapshots" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" "github.com/cosmos/cosmos-sdk/store/rootmulti" - store "github.com/cosmos/cosmos-sdk/store/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -235,7 +234,7 @@ func TestMountStores(t *testing.T) { // Test that LoadLatestVersion actually does. func TestLoadVersion(t *testing.T) { logger := defaultLogger() - pruningOpt := baseapp.SetPruning(store.PruneNothing) + pruningOpt := baseapp.SetPruning(storetypes.PruneNothing) db := dbm.NewMemDB() name := t.Name() app := baseapp.NewBaseApp(name, logger, db, nil, pruningOpt) @@ -288,15 +287,15 @@ func useDefaultLoader(app *baseapp.BaseApp) { func initStore(t *testing.T, db dbm.DB, storeKey string, k, v []byte) { rs := rootmulti.NewStore(db) - rs.SetPruning(store.PruneNothing) + rs.SetPruning(storetypes.PruneNothing) key := sdk.NewKVStoreKey(storeKey) - rs.MountStoreWithDB(key, store.StoreTypeIAVL, nil) + rs.MountStoreWithDB(key, storetypes.StoreTypeIAVL, nil) err := rs.LoadLatestVersion() require.Nil(t, err) require.Equal(t, int64(0), rs.LastCommitID().Version) // write some data in substore - kv, _ := rs.GetStore(key).(store.KVStore) + kv, _ := rs.GetStore(key).(storetypes.KVStore) require.NotNil(t, kv) kv.Set(k, v) commitID := rs.Commit() @@ -305,15 +304,15 @@ func initStore(t *testing.T, db dbm.DB, storeKey string, k, v []byte) { func checkStore(t *testing.T, db dbm.DB, ver int64, storeKey string, k, v []byte) { rs := rootmulti.NewStore(db) - rs.SetPruning(store.PruneDefault) + rs.SetPruning(storetypes.PruneDefault) key := sdk.NewKVStoreKey(storeKey) - rs.MountStoreWithDB(key, store.StoreTypeIAVL, nil) + rs.MountStoreWithDB(key, storetypes.StoreTypeIAVL, nil) err := rs.LoadLatestVersion() require.Nil(t, err) require.Equal(t, ver, rs.LastCommitID().Version) // query data in substore - kv, _ := rs.GetStore(key).(store.KVStore) + kv, _ := rs.GetStore(key).(storetypes.KVStore) require.NotNil(t, kv) require.Equal(t, v, kv.Get(k)) } @@ -348,7 +347,7 @@ func TestSetLoader(t *testing.T) { initStore(t, db, tc.origStoreKey, k, v) // load the app with the existing db - opts := []func(*baseapp.BaseApp){baseapp.SetPruning(store.PruneNothing)} + opts := []func(*baseapp.BaseApp){baseapp.SetPruning(storetypes.PruneNothing)} if tc.setLoader != nil { opts = append(opts, tc.setLoader) } @@ -371,7 +370,7 @@ func TestSetLoader(t *testing.T) { func TestVersionSetterGetter(t *testing.T) { logger := defaultLogger() - pruningOpt := baseapp.SetPruning(store.PruneDefault) + pruningOpt := baseapp.SetPruning(storetypes.PruneDefault) db := dbm.NewMemDB() name := t.Name() app := baseapp.NewBaseApp(name, logger, db, nil, pruningOpt) @@ -391,7 +390,7 @@ func TestVersionSetterGetter(t *testing.T) { func TestLoadVersionInvalid(t *testing.T) { logger := log.NewNopLogger() - pruningOpt := baseapp.SetPruning(store.PruneNothing) + pruningOpt := baseapp.SetPruning(storetypes.PruneNothing) db := dbm.NewMemDB() name := t.Name() app := baseapp.NewBaseApp(name, logger, db, nil, pruningOpt) @@ -423,7 +422,7 @@ func TestLoadVersionInvalid(t *testing.T) { func TestLoadVersionPruning(t *testing.T) { logger := log.NewNopLogger() - pruningOptions := store.PruningOptions{ + pruningOptions := storetypes.PruningOptions{ KeepRecent: 2, KeepEvery: 3, Interval: 1, diff --git a/server/mock/store.go b/server/mock/store.go index 7829ca58c68..91596337f96 100644 --- a/server/mock/store.go +++ b/server/mock/store.go @@ -5,14 +5,14 @@ import ( dbm "github.com/tendermint/tm-db" - store "github.com/cosmos/cosmos-sdk/store/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" ) var _ sdk.MultiStore = multiStore{} type multiStore struct { - kv map[store.StoreKey]kvStore + kv map[storetypes.StoreKey]kvStore } func (ms multiStore) CacheMultiStore() sdk.CacheMultiStore { @@ -23,15 +23,15 @@ func (ms multiStore) CacheMultiStoreWithVersion(_ int64) (sdk.CacheMultiStore, e panic("not implemented") } -func (ms multiStore) CacheWrap() store.CacheWrap { +func (ms multiStore) CacheWrap() storetypes.CacheWrap { panic("not implemented") } -func (ms multiStore) CacheWrapWithTrace(_ io.Writer, _ sdk.TraceContext) store.CacheWrap { +func (ms multiStore) CacheWrapWithTrace(_ io.Writer, _ sdk.TraceContext) storetypes.CacheWrap { panic("not implemented") } -func (ms multiStore) CacheWrapWithListeners(_ store.StoreKey, _ []store.WriteListener) store.CacheWrap { +func (ms multiStore) CacheWrapWithListeners(_ storetypes.StoreKey, _ []storetypes.WriteListener) storetypes.CacheWrap { panic("not implemented") } @@ -47,19 +47,19 @@ func (ms multiStore) SetTracer(w io.Writer) sdk.MultiStore { panic("not implemented") } -func (ms multiStore) AddListeners(key store.StoreKey, listeners []store.WriteListener) { +func (ms multiStore) AddListeners(key storetypes.StoreKey, listeners []storetypes.WriteListener) { panic("not implemented") } -func (ms multiStore) ListeningEnabled(key store.StoreKey) bool { +func (ms multiStore) ListeningEnabled(key storetypes.StoreKey) bool { panic("not implemented") } -func (ms multiStore) Commit() store.CommitID { +func (ms multiStore) Commit() storetypes.CommitID { panic("not implemented") } -func (ms multiStore) LastCommitID() store.CommitID { +func (ms multiStore) LastCommitID() storetypes.CommitID { panic("not implemented") } @@ -71,15 +71,15 @@ func (ms multiStore) GetPruning() sdk.PruningOptions { panic("not implemented") } -func (ms multiStore) GetCommitKVStore(key store.StoreKey) store.CommitKVStore { +func (ms multiStore) GetCommitKVStore(key storetypes.StoreKey) storetypes.CommitKVStore { panic("not implemented") } -func (ms multiStore) GetCommitStore(key store.StoreKey) store.CommitStore { +func (ms multiStore) GetCommitStore(key storetypes.StoreKey) storetypes.CommitStore { panic("not implemented") } -func (ms multiStore) MountStoreWithDB(key store.StoreKey, typ store.StoreType, db dbm.DB) { +func (ms multiStore) MountStoreWithDB(key storetypes.StoreKey, typ storetypes.StoreType, db dbm.DB) { ms.kv[key] = kvStore{store: make(map[string][]byte)} } @@ -87,11 +87,11 @@ func (ms multiStore) LoadLatestVersion() error { return nil } -func (ms multiStore) LoadLatestVersionAndUpgrade(upgrades *store.StoreUpgrades) error { +func (ms multiStore) LoadLatestVersionAndUpgrade(upgrades *storetypes.StoreUpgrades) error { return nil } -func (ms multiStore) LoadVersionAndUpgrade(ver int64, upgrades *store.StoreUpgrades) error { +func (ms multiStore) LoadVersionAndUpgrade(ver int64, upgrades *storetypes.StoreUpgrades) error { panic("not implemented") } @@ -99,15 +99,15 @@ func (ms multiStore) LoadVersion(ver int64) error { panic("not implemented") } -func (ms multiStore) GetKVStore(key store.StoreKey) sdk.KVStore { +func (ms multiStore) GetKVStore(key storetypes.StoreKey) sdk.KVStore { return ms.kv[key] } -func (ms multiStore) GetStore(key store.StoreKey) sdk.Store { +func (ms multiStore) GetStore(key storetypes.StoreKey) sdk.Store { panic("not implemented") } -func (ms multiStore) GetStoreType() store.StoreType { +func (ms multiStore) GetStoreType() storetypes.StoreType { panic("not implemented") } @@ -135,19 +135,19 @@ type kvStore struct { store map[string][]byte } -func (kv kvStore) CacheWrap() store.CacheWrap { +func (kv kvStore) CacheWrap() storetypes.CacheWrap { panic("not implemented") } -func (kv kvStore) CacheWrapWithTrace(w io.Writer, tc sdk.TraceContext) store.CacheWrap { +func (kv kvStore) CacheWrapWithTrace(w io.Writer, tc sdk.TraceContext) storetypes.CacheWrap { panic("not implemented") } -func (kv kvStore) CacheWrapWithListeners(_ store.StoreKey, _ []store.WriteListener) store.CacheWrap { +func (kv kvStore) CacheWrapWithListeners(_ storetypes.StoreKey, _ []storetypes.WriteListener) storetypes.CacheWrap { panic("not implemented") } -func (kv kvStore) GetStoreType() store.StoreType { +func (kv kvStore) GetStoreType() storetypes.StoreType { panic("not implemented") } @@ -165,7 +165,7 @@ func (kv kvStore) Has(key []byte) bool { } func (kv kvStore) Set(key, value []byte) { - store.AssertValidKey(key) + storetypes.AssertValidKey(key) kv.store[string(key)] = value } @@ -198,5 +198,5 @@ func (kv kvStore) ReverseSubspaceIterator(prefix []byte) sdk.Iterator { } func NewCommitMultiStore() sdk.CommitMultiStore { - return multiStore{kv: make(map[store.StoreKey]kvStore)} + return multiStore{kv: make(map[storetypes.StoreKey]kvStore)} } diff --git a/types/context.go b/types/context.go index 9e9edbf2e24..b802070a3b8 100644 --- a/types/context.go +++ b/types/context.go @@ -11,7 +11,7 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/store/gaskv" - stypes "github.com/cosmos/cosmos-sdk/store/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" ) /* @@ -87,7 +87,7 @@ func NewContext(ms MultiStore, header tmproto.Header, isCheckTx bool, logger log chainID: header.ChainID, checkTx: isCheckTx, logger: logger, - gasMeter: stypes.NewInfiniteGasMeter(), + gasMeter: storetypes.NewInfiniteGasMeter(), minGasPrice: DecCoins{}, eventManager: NewEventManager(), } @@ -243,13 +243,13 @@ func (c Context) Value(key interface{}) interface{} { // ---------------------------------------------------------------------------- // KVStore fetches a KVStore from the MultiStore. -func (c Context) KVStore(key stypes.StoreKey) KVStore { - return gaskv.NewStore(c.MultiStore().GetKVStore(key), c.GasMeter(), stypes.KVGasConfig()) +func (c Context) KVStore(key storetypes.StoreKey) KVStore { + return gaskv.NewStore(c.MultiStore().GetKVStore(key), c.GasMeter(), storetypes.KVGasConfig()) } // TransientStore fetches a TransientStore from the MultiStore. -func (c Context) TransientStore(key stypes.StoreKey) KVStore { - return gaskv.NewStore(c.MultiStore().GetKVStore(key), c.GasMeter(), stypes.TransientGasConfig()) +func (c Context) TransientStore(key storetypes.StoreKey) KVStore { + return gaskv.NewStore(c.MultiStore().GetKVStore(key), c.GasMeter(), storetypes.TransientGasConfig()) } // CacheContext returns a new Context with the multi-store cached and a new diff --git a/x/gov/keeper/msg_server.go b/x/gov/keeper/msg_server.go index 89876271336..a3b42b9b3a3 100644 --- a/x/gov/keeper/msg_server.go +++ b/x/gov/keeper/msg_server.go @@ -7,7 +7,7 @@ import ( "github.com/armon/go-metrics" - store "github.com/cosmos/cosmos-sdk/store/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -39,7 +39,7 @@ func (k msgServer) SubmitProposal(goCtx context.Context, msg *types.MsgSubmitPro // ref: https://github.com/cosmos/cosmos-sdk/issues/9683 ctx.GasMeter().ConsumeGas( - 3*store.KVGasConfig().WriteCostPerByte*uint64(len(bytes)), + 3*storetypes.KVGasConfig().WriteCostPerByte*uint64(len(bytes)), "submit proposal", ) diff --git a/x/upgrade/types/storeloader.go b/x/upgrade/types/storeloader.go index 00538e07152..3911effbed3 100644 --- a/x/upgrade/types/storeloader.go +++ b/x/upgrade/types/storeloader.go @@ -2,13 +2,13 @@ package types import ( "github.com/cosmos/cosmos-sdk/baseapp" - store "github.com/cosmos/cosmos-sdk/store/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" ) // UpgradeStoreLoader is used to prepare baseapp with a fixed StoreLoader // pattern. This is useful for custom upgrade loading logic. -func UpgradeStoreLoader(upgradeHeight int64, storeUpgrades *store.StoreUpgrades) baseapp.StoreLoader { +func UpgradeStoreLoader(upgradeHeight int64, storeUpgrades *storetypes.StoreUpgrades) baseapp.StoreLoader { return func(ms sdk.CommitMultiStore) error { if upgradeHeight == ms.LastCommitID().Version+1 { // Check if the current commit version and upgrade height matches diff --git a/x/upgrade/types/storeloader_test.go b/x/upgrade/types/storeloader_test.go index b06678fc2a5..20e28888ed3 100644 --- a/x/upgrade/types/storeloader_test.go +++ b/x/upgrade/types/storeloader_test.go @@ -15,11 +15,11 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/store/rootmulti" - store "github.com/cosmos/cosmos-sdk/store/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" ) -func useUpgradeLoader(height int64, upgrades *store.StoreUpgrades) func(*baseapp.BaseApp) { +func useUpgradeLoader(height int64, upgrades *storetypes.StoreUpgrades) func(*baseapp.BaseApp) { return func(app *baseapp.BaseApp) { app.SetStoreLoader(UpgradeStoreLoader(height, upgrades)) } @@ -31,15 +31,15 @@ func defaultLogger() log.Logger { func initStore(t *testing.T, db dbm.DB, storeKey string, k, v []byte) { rs := rootmulti.NewStore(db) - rs.SetPruning(store.PruneNothing) + rs.SetPruning(storetypes.PruneNothing) key := sdk.NewKVStoreKey(storeKey) - rs.MountStoreWithDB(key, store.StoreTypeIAVL, nil) + rs.MountStoreWithDB(key, storetypes.StoreTypeIAVL, nil) err := rs.LoadLatestVersion() require.Nil(t, err) require.Equal(t, int64(0), rs.LastCommitID().Version) // write some data in substore - kv, _ := rs.GetStore(key).(store.KVStore) + kv, _ := rs.GetStore(key).(storetypes.KVStore) require.NotNil(t, kv) kv.Set(k, v) commitID := rs.Commit() @@ -48,15 +48,15 @@ func initStore(t *testing.T, db dbm.DB, storeKey string, k, v []byte) { func checkStore(t *testing.T, db dbm.DB, ver int64, storeKey string, k, v []byte) { rs := rootmulti.NewStore(db) - rs.SetPruning(store.PruneNothing) + rs.SetPruning(storetypes.PruneNothing) key := sdk.NewKVStoreKey(storeKey) - rs.MountStoreWithDB(key, store.StoreTypeIAVL, nil) + rs.MountStoreWithDB(key, storetypes.StoreTypeIAVL, nil) err := rs.LoadLatestVersion() require.Nil(t, err) require.Equal(t, ver, rs.LastCommitID().Version) // query data in substore - kv, _ := rs.GetStore(key).(store.KVStore) + kv, _ := rs.GetStore(key).(storetypes.KVStore) require.NotNil(t, kv) require.Equal(t, v, kv.Get(k)) @@ -95,8 +95,8 @@ func TestSetLoader(t *testing.T) { loadStoreKey: "foo", }, "rename with inline opts": { - setLoader: useUpgradeLoader(upgradeHeight, &store.StoreUpgrades{ - Renamed: []store.StoreRename{{ + setLoader: useUpgradeLoader(upgradeHeight, &storetypes.StoreUpgrades{ + Renamed: []storetypes.StoreRename{{ OldKey: "foo", NewKey: "bar", }}, @@ -118,7 +118,7 @@ func TestSetLoader(t *testing.T) { initStore(t, db, tc.origStoreKey, k, v) // load the app with the existing db - opts := []func(*baseapp.BaseApp){baseapp.SetPruning(store.PruneNothing)} + opts := []func(*baseapp.BaseApp){baseapp.SetPruning(storetypes.PruneNothing)} origapp := baseapp.NewBaseApp(t.Name(), defaultLogger(), db, nil, opts...) origapp.MountStores(sdk.NewKVStoreKey(tc.origStoreKey)) From 583385358d028a12da49341ce48ced3e711b8b07 Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 4 Oct 2021 19:02:24 +0300 Subject: [PATCH 20/22] fix imports order in server/mock/app.go --- server/mock/app.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/mock/app.go b/server/mock/app.go index 84475a4fc11..779b9c5c320 100644 --- a/server/mock/app.go +++ b/server/mock/app.go @@ -6,6 +6,8 @@ import ( "fmt" "path/filepath" + abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/types" bam "github.com/cosmos/cosmos-sdk/baseapp" @@ -15,8 +17,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/x/auth/middleware" - abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/libs/log" ) func testTxHandler(options middleware.TxHandlerOptions) tx.Handler { From c98803e73e632f8bd3a7cce2a026dd7569e2bc22 Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 4 Oct 2021 19:03:06 +0300 Subject: [PATCH 21/22] fix imports order in server/mock/store_test.go --- server/mock/store_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/mock/store_test.go b/server/mock/store_test.go index cfa61c1c6cf..fc5cd12e097 100644 --- a/server/mock/store_test.go +++ b/server/mock/store_test.go @@ -4,10 +4,10 @@ import ( "testing" "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - dbm "github.com/tendermint/tm-db" ) func TestStore(t *testing.T) { From fbb9e9ee007e68f27bd1c2a8591c5cb63f68d789 Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 4 Oct 2021 19:04:38 +0300 Subject: [PATCH 22/22] move changelog record to API-breaking changes section --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e67f86c7588..ef4a2424e1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,10 +47,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (bank) [\#9618](https://github.com/cosmos/cosmos-sdk/pull/9618) Update bank.Metadata: add URI and URIHash attributes. * [\#9837](https://github.com/cosmos/cosmos-sdk/issues/9837) `--generate-only` flag will accept the keyname now. * [\#10045](https://github.com/cosmos/cosmos-sdk/pull/10045) Revert [#8549](https://github.com/cosmos/cosmos-sdk/pull/8549). Do not route grpc queries through Tendermint. -* [\#10295](https://github.com/cosmos/cosmos-sdk/pull/10295) Remove store type aliases in /types ### API Breaking Changes +* [\#10295](https://github.com/cosmos/cosmos-sdk/pull/10295) Remove store type aliases from /types * [\#9695](https://github.com/cosmos/cosmos-sdk/pull/9695) Migrate keys from `Info` -> `Record` * Add new `codec.Codec` argument in: * `keyring.NewInMemory`