Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove transient store that is not used now #203

Merged
merged 1 commit into from
May 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand All @@ -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) {
Expand Down
17 changes: 3 additions & 14 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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{
Expand All @@ -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()))
Expand Down Expand Up @@ -396,7 +393,6 @@ func NewSimApp(

// initialize stores
app.MountKVStores(keys)
app.MountTransientStores(tkeys)
app.MountMemoryStores(memKeys)

// initialize BaseApp
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
18 changes: 1 addition & 17 deletions store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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())
Expand All @@ -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(),
Expand Down Expand Up @@ -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
Expand Down
12 changes: 1 addition & 11 deletions store/rootmulti/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}

Expand Down Expand Up @@ -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
Expand All @@ -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})
Expand All @@ -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
Expand Down
44 changes: 0 additions & 44 deletions store/transient/store.go

This file was deleted.

35 changes: 0 additions & 35 deletions store/transient/store_test.go

This file was deleted.

6 changes: 0 additions & 6 deletions store/types/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
27 changes: 0 additions & 27 deletions store/types/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ const (
StoreTypeMulti StoreType = iota
StoreTypeDB
StoreTypeIAVL
StoreTypeTransient
StoreTypeMemory
)

Expand All @@ -305,9 +304,6 @@ func (st StoreType) String() string {
case StoreTypeIAVL:
return "StoreTypeIAVL"

case StoreTypeTransient:
return "StoreTypeTransient"

case StoreTypeMemory:
return "StoreTypeMemory"
}
Expand Down Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions store/types/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
5 changes: 0 additions & 5 deletions types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
35 changes: 8 additions & 27 deletions types/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 {
Expand Down
Loading