From 9546267da3f791431a1fa0a4cc96f9eac8964195 Mon Sep 17 00:00:00 2001 From: Woosang Son Date: Mon, 24 May 2021 15:58:00 +0900 Subject: [PATCH] chore: remove transient store that is not used now (#203) --- baseapp/baseapp.go | 11 ------- simapp/app.go | 17 ++-------- store/rootmulti/store.go | 18 +---------- store/rootmulti/store_test.go | 12 +------ store/transient/store.go | 44 -------------------------- store/transient/store_test.go | 35 -------------------- store/types/gas.go | 6 ---- store/types/store.go | 27 ---------------- store/types/store_test.go | 8 ----- types/context.go | 5 --- types/store.go | 35 +++++--------------- types/store_test.go | 5 --- x/params/keeper/common_test.go | 12 +++---- x/params/keeper/keeper.go | 6 ++-- x/params/keeper/keeper_test.go | 6 ++-- x/params/proposal_handler_test.go | 4 +-- x/params/types/common_test.go | 1 - x/params/types/subspace.go | 9 +----- x/params/types/subspace_test.go | 5 ++- x/wasm/internal/keeper/genesis_test.go | 4 +-- x/wasm/internal/keeper/options_test.go | 2 +- x/wasm/internal/keeper/test_common.go | 4 +-- 22 files changed, 30 insertions(+), 246 deletions(-) delete mode 100644 store/transient/store.go delete mode 100644 store/transient/store_test.go diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 344bdd5ded..c8746733d7 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -197,9 +197,6 @@ func (app *BaseApp) MountStores(keys ...sdk.StoreKey) { app.MountStore(key, sdk.StoreTypeDB) } - case *sdk.TransientStoreKey: - app.MountStore(key, sdk.StoreTypeTransient) - default: panic("Unrecognized store key type " + reflect.TypeOf(key).Name()) } @@ -220,14 +217,6 @@ func (app *BaseApp) MountKVStores(keys map[string]*sdk.KVStoreKey) { } } -// MountTransientStores mounts all transient stores to the provided keys in -// the BaseApp multistore. -func (app *BaseApp) MountTransientStores(keys map[string]*sdk.TransientStoreKey) { - for _, key := range keys { - app.MountStore(key, sdk.StoreTypeTransient) - } -} - // MountMemoryStores mounts all in-memory KVStores with the BaseApp's internal // commit multi-store. func (app *BaseApp) MountMemoryStores(keys map[string]*sdk.MemoryStoreKey) { diff --git a/simapp/app.go b/simapp/app.go index 4dd78ed0e8..73f3982c65 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -151,7 +151,6 @@ type SimApp struct { // keys to access the substores keys map[string]*sdk.KVStoreKey - tkeys map[string]*sdk.TransientStoreKey memKeys map[string]*sdk.MemoryStoreKey // keepers @@ -214,7 +213,6 @@ func NewSimApp( govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, ) - tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) app := &SimApp{ @@ -224,11 +222,10 @@ func NewSimApp( interfaceRegistry: interfaceRegistry, invCheckPeriod: invCheckPeriod, keys: keys, - tkeys: tkeys, memKeys: memKeys, } - app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) + app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey]) // set the BaseApp's parameter store bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable())) @@ -396,7 +393,6 @@ func NewSimApp( // initialize stores app.MountKVStores(keys) - app.MountTransientStores(tkeys) app.MountMemoryStores(memKeys) // initialize BaseApp @@ -509,13 +505,6 @@ func (app *SimApp) GetKey(storeKey string) *sdk.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 { - return app.tkeys[storeKey] -} - // GetMemKey returns the MemStoreKey for the provided mem key. // // NOTE: This is solely used for testing purposes. @@ -589,8 +578,8 @@ func GetMaccPerms() map[string][]string { } // initParamsKeeper init params keeper and its subspaces -func initParamsKeeper(appCodec codec.BinaryMarshaler, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper { - paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) +func initParamsKeeper(appCodec codec.BinaryMarshaler, legacyAmino *codec.LegacyAmino, key sdk.StoreKey) paramskeeper.Keeper { + paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key) paramsKeeper.Subspace(authtypes.ModuleName) paramsKeeper.Subspace(banktypes.ModuleName) diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 2cdc49c334..7da4d97405 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -25,7 +25,6 @@ import ( "github.com/line/lbm-sdk/v2/store/iavl" "github.com/line/lbm-sdk/v2/store/mem" "github.com/line/lbm-sdk/v2/store/tracekv" - "github.com/line/lbm-sdk/v2/store/transient" "github.com/line/lbm-sdk/v2/store/types" sdkerrors "github.com/line/lbm-sdk/v2/types/errors" ) @@ -612,7 +611,7 @@ func (rs *Store) Snapshot(height uint64, format uint32) (<-chan io.ReadCloser, e switch store := rs.GetCommitKVStore(key).(type) { case *iavl.Store: stores = append(stores, namedStore{name: key.Name(), Store: store}) - case *transient.Store, *mem.Store: + case *mem.Store: // Non-persisted stores shouldn't be snapshotted continue default: @@ -857,14 +856,6 @@ func (rs *Store) loadCommitStoreFromParams(key types.StoreKey, id types.CommitID case types.StoreTypeDB: return commitDBStoreAdapter{Store: dbadapter.Store{DB: db}}, nil - case types.StoreTypeTransient: - _, ok := key.(*types.TransientStoreKey) - if !ok { - return nil, fmt.Errorf("invalid StoreKey for StoreTypeTransient: %s", key.String()) - } - - return transient.NewStore(), nil - case types.StoreTypeMemory: if _, ok := key.(*types.MemoryStoreKey); !ok { return nil, fmt.Errorf("unexpected key type for a MemoryStoreKey; got: %s", key.String()) @@ -880,9 +871,6 @@ func (rs *Store) loadCommitStoreFromParams(key types.StoreKey, id types.CommitID func (rs *Store) buildCommitInfo(version int64) *types.CommitInfo { storeInfos := []types.StoreInfo{} for key, store := range rs.stores { - if store.GetStoreType() == types.StoreTypeTransient { - continue - } storeInfos = append(storeInfos, types.StoreInfo{ Name: key.Name(), CommitId: store.LastCommitID(), @@ -925,10 +913,6 @@ func commitStores(version int64, storeMap map[types.StoreKey]types.CommitKVStore for key, store := range storeMap { commitID := store.Commit() - if store.GetStoreType() == types.StoreTypeTransient { - continue - } - si := types.StoreInfo{} si.Name = key.Name() si.CommitId = commitID diff --git a/store/rootmulti/store_test.go b/store/rootmulti/store_test.go index f4d2460949..71e6179cb4 100644 --- a/store/rootmulti/store_test.go +++ b/store/rootmulti/store_test.go @@ -646,13 +646,7 @@ func TestMultistoreSnapshotRestore(t *testing.T) { assert.Equal(t, source.LastCommitID(), target.LastCommitID()) for key, sourceStore := range source.stores { targetStore := target.getStoreByName(key.Name()).(types.CommitKVStore) - switch sourceStore.GetStoreType() { - case types.StoreTypeTransient: - assert.False(t, targetStore.Iterator(nil, nil).Valid(), - "transient store %v not empty", key.Name()) - default: - assertStoresEqual(t, sourceStore, targetStore, "store %q not equal", key.Name()) - } + assertStoresEqual(t, sourceStore, targetStore, "store %q not equal", key.Name()) } } @@ -760,7 +754,6 @@ func newMultiStoreWithMixedMounts(db tmdb.DB) *Store { store.MountStoreWithDB(types.NewKVStoreKey("iavl1"), types.StoreTypeIAVL, nil) store.MountStoreWithDB(types.NewKVStoreKey("iavl2"), types.StoreTypeIAVL, nil) store.MountStoreWithDB(types.NewKVStoreKey("iavl3"), types.StoreTypeIAVL, nil) - store.MountStoreWithDB(types.NewTransientStoreKey("trans1"), types.StoreTypeTransient, nil) store.LoadLatestVersion() return store @@ -770,13 +763,11 @@ func newMultiStoreWithMixedMountsAndBasicData(db tmdb.DB) *Store { store := newMultiStoreWithMixedMounts(db) store1 := store.getStoreByName("iavl1").(types.CommitKVStore) store2 := store.getStoreByName("iavl2").(types.CommitKVStore) - trans1 := store.getStoreByName("trans1").(types.KVStore) store1.Set([]byte("a"), []byte{1}) store1.Set([]byte("b"), []byte{1}) store2.Set([]byte("X"), []byte{255}) store2.Set([]byte("A"), []byte{101}) - trans1.Set([]byte("x1"), []byte{91}) store.Commit() store1.Set([]byte("b"), []byte{2}) @@ -786,7 +777,6 @@ func newMultiStoreWithMixedMountsAndBasicData(db tmdb.DB) *Store { store2.Set([]byte("C"), []byte{103}) store2.Delete([]byte("X")) - trans1.Set([]byte("x2"), []byte{92}) store.Commit() return store diff --git a/store/transient/store.go b/store/transient/store.go deleted file mode 100644 index f8583fc1c5..0000000000 --- a/store/transient/store.go +++ /dev/null @@ -1,44 +0,0 @@ -package transient - -import ( - "github.com/line/tm-db/v2/memdb" - - "github.com/line/lbm-sdk/v2/store/dbadapter" - "github.com/line/lbm-sdk/v2/store/types" -) - -var _ types.Committer = (*Store)(nil) -var _ types.KVStore = (*Store)(nil) - -// Store is a wrapper for a MemDB with Commiter implementation -type Store struct { - dbadapter.Store -} - -// Constructs new MemDB adapter -func NewStore() *Store { - return &Store{Store: dbadapter.Store{DB: memdb.NewDB()}} -} - -// Implements CommitStore -// Commit cleans up Store. -func (ts *Store) Commit() (id types.CommitID) { - ts.Store = dbadapter.Store{DB: memdb.NewDB()} - return -} - -func (ts *Store) SetPruning(_ types.PruningOptions) {} - -// GetPruning is a no-op as pruning options cannot be directly set on this store. -// They must be set on the root commit multi-store. -func (ts *Store) GetPruning() types.PruningOptions { return types.PruningOptions{} } - -// Implements CommitStore -func (ts *Store) LastCommitID() (id types.CommitID) { - return -} - -// Implements Store. -func (ts *Store) GetStoreType() types.StoreType { - return types.StoreTypeTransient -} diff --git a/store/transient/store_test.go b/store/transient/store_test.go deleted file mode 100644 index 6b4ce9b47b..0000000000 --- a/store/transient/store_test.go +++ /dev/null @@ -1,35 +0,0 @@ -package transient_test - -import ( - "bytes" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/line/lbm-sdk/v2/store/transient" - "github.com/line/lbm-sdk/v2/store/types" -) - -var k, v = []byte("hello"), []byte("world") - -func TestTransientStore(t *testing.T) { - tstore := transient.NewStore() - - require.Nil(t, tstore.Get(k)) - - tstore.Set(k, v) - - require.Equal(t, v, tstore.Get(k)) - - tstore.Commit() - - require.Nil(t, tstore.Get(k)) - - // no-op - tstore.SetPruning(types.PruningOptions{}) - - emptyCommitID := tstore.LastCommitID() - require.Equal(t, emptyCommitID.Version, int64(0)) - require.True(t, bytes.Equal(emptyCommitID.Hash, nil)) - require.Equal(t, types.StoreTypeTransient, tstore.GetStoreType()) -} diff --git a/store/types/gas.go b/store/types/gas.go index c6c94f859e..96eb5de58d 100644 --- a/store/types/gas.go +++ b/store/types/gas.go @@ -173,9 +173,3 @@ func KVGasConfig() GasConfig { IterNextCostFlat: 30, } } - -// TransientGasConfig returns a default gas config for TransientStores. -func TransientGasConfig() GasConfig { - // TODO: define gasconfig for transient stores - return KVGasConfig() -} diff --git a/store/types/store.go b/store/types/store.go index f31bd5d782..8444ceeceb 100644 --- a/store/types/store.go +++ b/store/types/store.go @@ -290,7 +290,6 @@ const ( StoreTypeMulti StoreType = iota StoreTypeDB StoreTypeIAVL - StoreTypeTransient StoreTypeMemory ) @@ -305,9 +304,6 @@ func (st StoreType) String() string { case StoreTypeIAVL: return "StoreTypeIAVL" - case StoreTypeTransient: - return "StoreTypeTransient" - case StoreTypeMemory: return "StoreTypeMemory" } @@ -353,29 +349,6 @@ func (key *KVStoreKey) String() string { return fmt.Sprintf("KVStoreKey{%p, %s}", key, key.name) } -// TransientStoreKey is used for indexing transient stores in a MultiStore -type TransientStoreKey struct { - name string -} - -// Constructs new TransientStoreKey -// Must return a pointer according to the ocap principle -func NewTransientStoreKey(name string) *TransientStoreKey { - return &TransientStoreKey{ - name: name, - } -} - -// Implements StoreKey -func (key *TransientStoreKey) Name() string { - return key.name -} - -// Implements StoreKey -func (key *TransientStoreKey) String() string { - return fmt.Sprintf("TransientStoreKey{%p, %s}", key, key.name) -} - // MemoryStoreKey defines a typed key to be used with an in-memory KVStore. type MemoryStoreKey struct { name string diff --git a/store/types/store_test.go b/store/types/store_test.go index f86144af7f..8dac7f5394 100644 --- a/store/types/store_test.go +++ b/store/types/store_test.go @@ -82,11 +82,3 @@ func TestNilKVStoreKey(t *testing.T) { _ = NewKVStoreKey("") }, "setting an empty key should panic") } - -func TestTransientStoreKey(t *testing.T) { - t.Parallel() - key := NewTransientStoreKey("test") - require.Equal(t, "test", key.name) - require.Equal(t, key.name, key.Name()) - require.Equal(t, fmt.Sprintf("TransientStoreKey{%p, test}", key), key.String()) -} diff --git a/types/context.go b/types/context.go index f8eec3d793..8e1d949500 100644 --- a/types/context.go +++ b/types/context.go @@ -229,11 +229,6 @@ func (c Context) KVStore(key 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 { - return gaskv.NewStore(c.MultiStore().GetKVStore(key), c.GasMeter(), stypes.TransientGasConfig()) -} - // CacheContext returns a new Context with the multi-store cached and a new // EventManager. The cached context is written to the context when writeCache // is called. diff --git a/types/store.go b/types/store.go index 8e3f71c94f..6657747bca 100644 --- a/types/store.go +++ b/types/store.go @@ -65,19 +65,17 @@ type ( type StoreType = types.StoreType const ( - StoreTypeMulti = types.StoreTypeMulti - StoreTypeDB = types.StoreTypeDB - StoreTypeIAVL = types.StoreTypeIAVL - StoreTypeTransient = types.StoreTypeTransient - StoreTypeMemory = types.StoreTypeMemory + StoreTypeMulti = types.StoreTypeMulti + StoreTypeDB = types.StoreTypeDB + StoreTypeIAVL = types.StoreTypeIAVL + StoreTypeMemory = types.StoreTypeMemory ) type ( - StoreKey = types.StoreKey - CapabilityKey = types.CapabilityKey - KVStoreKey = types.KVStoreKey - TransientStoreKey = types.TransientStoreKey - MemoryStoreKey = types.MemoryStoreKey + StoreKey = types.StoreKey + CapabilityKey = types.CapabilityKey + KVStoreKey = types.KVStoreKey + MemoryStoreKey = types.MemoryStoreKey ) // NewKVStoreKey returns a new pointer to a KVStoreKey. @@ -97,23 +95,6 @@ func NewKVStoreKeys(names ...string) map[string]*KVStoreKey { return keys } -// Constructs new TransientStoreKey -// Must return a pointer according to the ocap principle -func NewTransientStoreKey(name string) *TransientStoreKey { - return types.NewTransientStoreKey(name) -} - -// NewTransientStoreKeys constructs a new map of TransientStoreKey's -// Must return pointers according to the ocap principle -func NewTransientStoreKeys(names ...string) map[string]*TransientStoreKey { - keys := make(map[string]*TransientStoreKey) - for _, name := range names { - keys[name] = NewTransientStoreKey(name) - } - - return keys -} - // NewMemoryStoreKeys constructs a new map matching store key names to their // respective MemoryStoreKey references. func NewMemoryStoreKeys(names ...string) map[string]*MemoryStoreKey { diff --git a/types/store_test.go b/types/store_test.go index 970ba64a77..901f86c193 100644 --- a/types/store_test.go +++ b/types/store_test.go @@ -60,11 +60,6 @@ func (s *storeTestSuite) TestNewKVStoreKeys() { s.Require().Equal(1, len(sdk.NewKVStoreKeys("one"))) } -func (s *storeTestSuite) TestNewTransientStoreKeys() { - s.Require().Equal(map[string]*sdk.TransientStoreKey{}, sdk.NewTransientStoreKeys()) - s.Require().Equal(1, len(sdk.NewTransientStoreKeys("one"))) -} - func (s *storeTestSuite) TestNewInfiniteGasMeter() { gm := sdk.NewInfiniteGasMeter() s.Require().NotNil(gm) diff --git a/x/params/keeper/common_test.go b/x/params/keeper/common_test.go index cb45cd6269..7427102658 100644 --- a/x/params/keeper/common_test.go +++ b/x/params/keeper/common_test.go @@ -13,15 +13,14 @@ import ( paramskeeper "github.com/line/lbm-sdk/v2/x/params/keeper" ) -func testComponents() (*codec.LegacyAmino, sdk.Context, sdk.StoreKey, sdk.StoreKey, paramskeeper.Keeper) { +func testComponents() (*codec.LegacyAmino, sdk.Context, sdk.StoreKey, paramskeeper.Keeper) { marshaler := simapp.MakeTestEncodingConfig().Marshaler legacyAmino := createTestCodec() mkey := sdk.NewKVStoreKey("test") - tkey := sdk.NewTransientStoreKey("transient_test") - ctx := defaultContext(mkey, tkey) - keeper := paramskeeper.NewKeeper(marshaler, legacyAmino, mkey, tkey) + ctx := defaultContext(mkey) + keeper := paramskeeper.NewKeeper(marshaler, legacyAmino, mkey) - return legacyAmino, ctx, mkey, tkey, keeper + return legacyAmino, ctx, mkey, keeper } type invalid struct{} @@ -38,11 +37,10 @@ func createTestCodec() *codec.LegacyAmino { return cdc } -func defaultContext(key sdk.StoreKey, tkey sdk.StoreKey) sdk.Context { +func defaultContext(key sdk.StoreKey) sdk.Context { db := memdb.NewDB() cms := store.NewCommitMultiStore(db) cms.MountStoreWithDB(key, sdk.StoreTypeIAVL, db) - cms.MountStoreWithDB(tkey, sdk.StoreTypeTransient, db) err := cms.LoadLatestVersion() if err != nil { panic(err) diff --git a/x/params/keeper/keeper.go b/x/params/keeper/keeper.go index 33b7dae579..8fcc888199 100644 --- a/x/params/keeper/keeper.go +++ b/x/params/keeper/keeper.go @@ -14,17 +14,15 @@ type Keeper struct { cdc codec.BinaryMarshaler legacyAmino *codec.LegacyAmino key sdk.StoreKey - tkey sdk.StoreKey spaces map[string]*types.Subspace } // NewKeeper constructs a params keeper -func NewKeeper(cdc codec.BinaryMarshaler, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) Keeper { +func NewKeeper(cdc codec.BinaryMarshaler, legacyAmino *codec.LegacyAmino, key sdk.StoreKey) Keeper { return Keeper{ cdc: cdc, legacyAmino: legacyAmino, key: key, - tkey: tkey, spaces: make(map[string]*types.Subspace), } } @@ -45,7 +43,7 @@ func (k Keeper) Subspace(s string) *types.Subspace { panic("cannot use empty string for subspace") } - space := types.NewSubspace(k.cdc, k.legacyAmino, k.key, k.tkey, s) + space := types.NewSubspace(k.cdc, k.legacyAmino, k.key, s) k.spaces[s] = space return space diff --git a/x/params/keeper/keeper_test.go b/x/params/keeper/keeper_test.go index 6f9e4da50b..99a6c85719 100644 --- a/x/params/keeper/keeper_test.go +++ b/x/params/keeper/keeper_test.go @@ -73,7 +73,7 @@ func TestKeeper(t *testing.T) { types.NewParamSetPair([]byte("extra2"), string(""), validateNoOp), ) - cdc, ctx, skey, _, keeper := testComponents() + cdc, ctx, skey, keeper := testComponents() store := prefix.NewStore(ctx.KVStore(skey), []byte("test/")) space := keeper.Subspace("test") @@ -149,7 +149,7 @@ func indirect(ptr interface{}) interface{} { } func TestSubspace(t *testing.T) { - cdc, ctx, key, _, keeper := testComponents() + cdc, ctx, key, keeper := testComponents() kvs := []struct { key string @@ -231,7 +231,7 @@ type paramJSON struct { } func TestJSONUpdate(t *testing.T) { - _, ctx, _, _, keeper := testComponents() + _, ctx, _, keeper := testComponents() key := []byte("key") diff --git a/x/params/proposal_handler_test.go b/x/params/proposal_handler_test.go index a84c9b8dcb..aeee1c9428 100644 --- a/x/params/proposal_handler_test.go +++ b/x/params/proposal_handler_test.go @@ -68,16 +68,14 @@ func newTestInput(t *testing.T) testInput { cms := store.NewCommitMultiStore(db) keyParams := sdk.NewKVStoreKey("params") - tKeyParams := sdk.NewTransientStoreKey("transient_params") cms.MountStoreWithDB(keyParams, sdk.StoreTypeIAVL, db) - cms.MountStoreWithDB(tKeyParams, sdk.StoreTypeTransient, db) err := cms.LoadLatestVersion() require.Nil(t, err) encCfg := simapp.MakeTestEncodingConfig() - keeper := keeper.NewKeeper(encCfg.Marshaler, encCfg.Amino, keyParams, tKeyParams) + keeper := keeper.NewKeeper(encCfg.Marshaler, encCfg.Amino, keyParams) ctx := sdk.NewContext(cms, ostproto.Header{}, false, log.NewNopLogger()) return testInput{ctx, cdc, keeper} diff --git a/x/params/types/common_test.go b/x/params/types/common_test.go index 9eff4a2d43..d405c20bcc 100644 --- a/x/params/types/common_test.go +++ b/x/params/types/common_test.go @@ -15,7 +15,6 @@ var ( keyBondDenom = []byte("BondDenom") key = sdk.NewKVStoreKey("storekey") - tkey = sdk.NewTransientStoreKey("transientstorekey") ) type params struct { diff --git a/x/params/types/subspace.go b/x/params/types/subspace.go index 5322e656f5..bc35840f8d 100644 --- a/x/params/types/subspace.go +++ b/x/params/types/subspace.go @@ -14,30 +14,23 @@ import ( const ( // StoreKey is the string store key for the param store StoreKey = "params" - - // TStoreKey is the string store key for the param transient store - TStoreKey = "transient_params" ) // Individual parameter store for each keeper -// Transient store persists for a block, so we use it for -// recording whether the parameter has been changed or not type Subspace struct { cdc codec.BinaryMarshaler legacyAmino *codec.LegacyAmino key sdk.StoreKey // []byte -> []byte, stores parameter - tkey sdk.StoreKey // []byte -> bool, stores parameter change name []byte table KeyTable } // NewSubspace constructs a store with namestore -func NewSubspace(cdc codec.BinaryMarshaler, legacyAmino *codec.LegacyAmino, key sdk.StoreKey, tkey sdk.StoreKey, name string) *Subspace { +func NewSubspace(cdc codec.BinaryMarshaler, legacyAmino *codec.LegacyAmino, key sdk.StoreKey, name string) *Subspace { return &Subspace{ cdc: cdc, legacyAmino: legacyAmino, key: key, - tkey: tkey, name: []byte(name), table: NewKeyTable(), } diff --git a/x/params/types/subspace_test.go b/x/params/types/subspace_test.go index baef4df61b..815121ea47 100644 --- a/x/params/types/subspace_test.go +++ b/x/params/types/subspace_test.go @@ -31,11 +31,10 @@ func (suite *SubspaceTestSuite) SetupTest() { ms := store.NewCommitMultiStore(db) ms.MountStoreWithDB(key, sdk.StoreTypeIAVL, db) - ms.MountStoreWithDB(tkey, sdk.StoreTypeTransient, db) suite.NoError(ms.LoadLatestVersion()) encCfg := simapp.MakeTestEncodingConfig() - ss := types.NewSubspace(encCfg.Marshaler, encCfg.Amino, key, tkey, "testsubspace") + ss := types.NewSubspace(encCfg.Marshaler, encCfg.Amino, key, "testsubspace") suite.cdc = encCfg.Marshaler suite.amino = encCfg.Amino @@ -49,7 +48,7 @@ func (suite *SubspaceTestSuite) TestKeyTable() { suite.ss.WithKeyTable(paramKeyTable()) }) suite.Require().NotPanics(func() { - ss := types.NewSubspace(suite.cdc, suite.amino, key, tkey, "testsubspace2") + ss := types.NewSubspace(suite.cdc, suite.amino, key, "testsubspace2") ss = ss.WithKeyTable(paramKeyTable()) }) } diff --git a/x/wasm/internal/keeper/genesis_test.go b/x/wasm/internal/keeper/genesis_test.go index 74022254bd..dddb0354a4 100644 --- a/x/wasm/internal/keeper/genesis_test.go +++ b/x/wasm/internal/keeper/genesis_test.go @@ -631,7 +631,6 @@ func setupKeeper(t *testing.T) (*Keeper, sdk.Context, []sdk.StoreKey) { t.Cleanup(func() { os.RemoveAll(tempDir) }) var ( keyParams = sdk.NewKVStoreKey(paramtypes.StoreKey) - tkeyParams = sdk.NewTransientStoreKey(paramtypes.TStoreKey) keyWasm = sdk.NewKVStoreKey(wasmTypes.StoreKey) ) @@ -639,7 +638,6 @@ func setupKeeper(t *testing.T) (*Keeper, sdk.Context, []sdk.StoreKey) { ms := store.NewCommitMultiStore(db) ms.MountStoreWithDB(keyWasm, sdk.StoreTypeIAVL, db) ms.MountStoreWithDB(keyParams, sdk.StoreTypeIAVL, db) - ms.MountStoreWithDB(tkeyParams, sdk.StoreTypeTransient, db) require.NoError(t, ms.LoadLatestVersion()) ctx := sdk.NewContext(ms, tmproto.Header{ @@ -649,7 +647,7 @@ func setupKeeper(t *testing.T) (*Keeper, sdk.Context, []sdk.StoreKey) { encodingConfig := MakeEncodingConfig(t) wasmConfig := wasmTypes.DefaultWasmConfig() - pk := paramskeeper.NewKeeper(encodingConfig.Marshaler, encodingConfig.Amino, keyParams, tkeyParams) + pk := paramskeeper.NewKeeper(encodingConfig.Marshaler, encodingConfig.Amino, keyParams) srcKeeper := NewKeeper(encodingConfig.Marshaler, keyWasm, pk.Subspace(wasmTypes.DefaultParamspace), authkeeper.AccountKeeper{}, nil, stakingkeeper.Keeper{}, distributionkeeper.Keeper{}, nil, nil, nil, nil, nil, nil, tempDir, wasmConfig, SupportedFeatures, nil, nil) return &srcKeeper, ctx, []sdk.StoreKey{keyWasm, keyParams} diff --git a/x/wasm/internal/keeper/options_test.go b/x/wasm/internal/keeper/options_test.go index ef50e8258a..18d4d101e7 100644 --- a/x/wasm/internal/keeper/options_test.go +++ b/x/wasm/internal/keeper/options_test.go @@ -40,7 +40,7 @@ func TestConstructorOptions(t *testing.T) { k := NewKeeper( nil, nil, - paramtypes.NewSubspace(nil, nil, nil, nil, ""), + paramtypes.NewSubspace(nil, nil, nil, ""), authkeeper.AccountKeeper{}, nil, stakingkeeper.Keeper{}, diff --git a/x/wasm/internal/keeper/test_common.go b/x/wasm/internal/keeper/test_common.go index 5b571ce1be..1f7e837969 100644 --- a/x/wasm/internal/keeper/test_common.go +++ b/x/wasm/internal/keeper/test_common.go @@ -168,7 +168,6 @@ func createTestInput( keyStaking := sdk.NewKVStoreKey(stakingtypes.StoreKey) keyDistro := sdk.NewKVStoreKey(distributiontypes.StoreKey) keyParams := sdk.NewKVStoreKey(paramstypes.StoreKey) - tkeyParams := sdk.NewTransientStoreKey(paramstypes.TStoreKey) keyGov := sdk.NewKVStoreKey(govtypes.StoreKey) keyIBC := sdk.NewKVStoreKey(ibchost.StoreKey) keyCapability := sdk.NewKVStoreKey(capabilitytypes.StoreKey) @@ -181,7 +180,6 @@ func createTestInput( ms.MountStoreWithDB(keyParams, sdk.StoreTypeIAVL, db) ms.MountStoreWithDB(keyStaking, sdk.StoreTypeIAVL, db) ms.MountStoreWithDB(keyDistro, sdk.StoreTypeIAVL, db) - ms.MountStoreWithDB(tkeyParams, sdk.StoreTypeTransient, db) ms.MountStoreWithDB(keyGov, sdk.StoreTypeIAVL, db) ms.MountStoreWithDB(keyIBC, sdk.StoreTypeIAVL, db) ms.MountStoreWithDB(keyCapability, sdk.StoreTypeIAVL, db) @@ -195,7 +193,7 @@ func createTestInput( encodingConfig := MakeEncodingConfig(t) appCodec, legacyAmino := encodingConfig.Marshaler, encodingConfig.Amino - paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, keyParams, tkeyParams) + paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, keyParams) paramsKeeper.Subspace(authtypes.ModuleName) paramsKeeper.Subspace(banktypes.ModuleName) paramsKeeper.Subspace(stakingtypes.ModuleName)