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 unused store keys #2881

Merged
merged 2 commits into from
Nov 30, 2023
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
3 changes: 0 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ func New(
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, capabilitytypes.StoreKey,
blobmoduletypes.StoreKey,
bsmoduletypes.StoreKey,
ibctransfertypes.StoreKey,
ibchost.StoreKey,
Expand Down Expand Up @@ -402,8 +401,6 @@ func New(

app.BlobKeeper = *blobmodulekeeper.NewKeeper(
appCodec,
keys[blobmoduletypes.StoreKey],
keys[blobmoduletypes.MemStoreKey],
app.GetSubspace(blobmoduletypes.ModuleName),
)
blobmod := blobmodule.NewAppModule(appCodec, app.BlobKeeper)
Expand Down
53 changes: 0 additions & 53 deletions test/util/keeper/blob.go

This file was deleted.

44 changes: 3 additions & 41 deletions x/blob/keeper/gas_test.go
Original file line number Diff line number Diff line change
@@ -1,53 +1,15 @@
package keeper
package keeper_test

import (
"testing"

"github.com/celestiaorg/celestia-app/pkg/appconsts"
"github.com/celestiaorg/celestia-app/x/blob/types"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
typesparams "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmdb "github.com/tendermint/tm-db"
)

func keeper(t *testing.T) (*Keeper, store.CommitMultiStore) {
storeKey := sdk.NewKVStoreKey(types.StoreKey)
memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey)

db := tmdb.NewMemDB()
stateStore := store.NewCommitMultiStore(db)
stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db)
stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil)
require.NoError(t, stateStore.LoadLatestVersion())

registry := codectypes.NewInterfaceRegistry()
cdc := codec.NewProtoCodec(registry)
tempCtx := sdk.NewContext(stateStore, tmproto.Header{}, false, nil)

aminoCdc := codec.NewLegacyAmino()
paramsSubspace := typesparams.NewSubspace(cdc,
aminoCdc,
storeKey,
memStoreKey,
"Blob",
)
k := NewKeeper(
cdc,
storeKey,
memStoreKey,
paramsSubspace,
)
k.SetParams(tempCtx, types.DefaultParams())

return k, stateStore
}

func TestPayForBlobGas(t *testing.T) {
type testCase struct {
name string
Expand Down Expand Up @@ -87,7 +49,7 @@ func TestPayForBlobGas(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
k, stateStore := keeper(t)
k, stateStore, _ := CreateKeeper(t)
ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, nil)
rootulp marked this conversation as resolved.
Show resolved Hide resolved
_, err := k.PayForBlobs(sdk.WrapSDKContext(ctx), &tc.msg)
require.NoError(t, err)
Expand All @@ -100,7 +62,7 @@ func TestPayForBlobGas(t *testing.T) {

func TestChangingGasParam(t *testing.T) {
msg := types.MsgPayForBlobs{BlobSizes: []uint32{1024}}
k, stateStore := keeper(t)
k, stateStore, _ := CreateKeeper(t)
tempCtx := sdk.NewContext(stateStore, tmproto.Header{}, false, nil)

ctx1 := sdk.NewContext(stateStore, tmproto.Header{}, false, nil)
Expand Down
5 changes: 2 additions & 3 deletions x/blob/genesis_test.go → x/blob/keeper/genesis_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package blob_test
package keeper_test

import (
"testing"

keepertest "github.com/celestiaorg/celestia-app/test/util/keeper"
"github.com/celestiaorg/celestia-app/x/blob"
"github.com/celestiaorg/celestia-app/x/blob/types"
"github.com/stretchr/testify/require"
Expand All @@ -14,7 +13,7 @@ func TestGenesis(t *testing.T) {
Params: types.DefaultParams(),
}

k, ctx := keepertest.BlobKeeper(t)
k, _, ctx := CreateKeeper(t)
blob.InitGenesis(ctx, *k, genesisState)
got := blob.ExportGenesis(ctx, *k)
require.NotNil(t, got)
Expand Down
3 changes: 1 addition & 2 deletions x/blob/keeper/grpc_query_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package keeper_test
import (
"testing"

testkeeper "github.com/celestiaorg/celestia-app/test/util/keeper"
"github.com/celestiaorg/celestia-app/x/blob/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"
)

func TestParamsQuery(t *testing.T) {
keeper, ctx := testkeeper.BlobKeeper(t)
keeper, _, ctx := CreateKeeper(t)
wctx := sdk.WrapSDKContext(ctx)
params := types.DefaultParams()
keeper.SetParams(ctx, params)
Expand Down
7 changes: 0 additions & 7 deletions x/blob/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/celestiaorg/celestia-app/x/blob/types"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/tendermint/tendermint/libs/log"
Expand All @@ -19,15 +18,11 @@ const (
// Keeper handles all the state changes for the blob module.
type Keeper struct {
cdc codec.BinaryCodec
storeKey storetypes.StoreKey
memKey storetypes.StoreKey
paramStore paramtypes.Subspace
}

func NewKeeper(
cdc codec.BinaryCodec,
storeKey,
memKey storetypes.StoreKey,
ps paramtypes.Subspace,
) *Keeper {
if !ps.HasKeyTable() {
Expand All @@ -36,8 +31,6 @@ func NewKeeper(

return &Keeper{
cdc: cdc,
storeKey: storeKey,
memKey: memKey,
paramStore: ps,
}
}
Expand Down
49 changes: 46 additions & 3 deletions x/blob/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package keeper
package keeper_test

import (
"bytes"
Expand All @@ -8,18 +8,27 @@ import (
"github.com/celestiaorg/celestia-app/pkg/appconsts"
"github.com/celestiaorg/celestia-app/pkg/blob"
appns "github.com/celestiaorg/celestia-app/pkg/namespace"
testutil "github.com/celestiaorg/celestia-app/test/util"
"github.com/celestiaorg/celestia-app/x/blob/keeper"
"github.com/celestiaorg/celestia-app/x/blob/types"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
proto "github.com/gogo/protobuf/proto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
tmversion "github.com/tendermint/tendermint/proto/tendermint/version"
tmdb "github.com/tendermint/tm-db"
)

// TestPayForBlobs verifies the attributes on the emitted event.
func TestPayForBlobs(t *testing.T) {
k, stateStore := keeper(t)
ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, nil)
k, _, ctx := CreateKeeper(t)
signer := "celestia15drmhzw5kwgenvemy30rqqqgq52axf5wwrruf7"
namespace := appns.MustNewV0(bytes.Repeat([]byte{1}, appns.NamespaceVersionZeroIDSize))
namespaces := [][]byte{namespace.Bytes()}
Expand Down Expand Up @@ -62,3 +71,37 @@ func createMsgPayForBlob(t *testing.T, signer string, namespace appns.Namespace,
require.NoError(t, err)
return msg
}

func CreateKeeper(t *testing.T) (*keeper.Keeper, store.CommitMultiStore, sdk.Context) {
storeKey := sdk.NewKVStoreKey(paramtypes.StoreKey)
tStoreKey := storetypes.NewTransientStoreKey(paramtypes.TStoreKey)

db := tmdb.NewMemDB()
stateStore := store.NewCommitMultiStore(db)
stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db)
stateStore.MountStoreWithDB(tStoreKey, storetypes.StoreTypeTransient, nil)
require.NoError(t, stateStore.LoadLatestVersion())

registry := codectypes.NewInterfaceRegistry()
cdc := codec.NewProtoCodec(registry)
ctx := sdk.NewContext(stateStore, tmproto.Header{
Version: tmversion.Consensus{
Block: 1,
App: 1,
},
}, false, nil)

paramsSubspace := paramtypes.NewSubspace(cdc,
testutil.MakeTestCodec(),
storeKey,
tStoreKey,
types.ModuleName,
)
k := keeper.NewKeeper(
cdc,
paramsSubspace,
)
k.SetParams(ctx, types.DefaultParams())

return k, stateStore, ctx
}
3 changes: 1 addition & 2 deletions x/blob/keeper/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package keeper_test
import (
"testing"

testkeeper "github.com/celestiaorg/celestia-app/test/util/keeper"
"github.com/celestiaorg/celestia-app/x/blob/types"
"github.com/stretchr/testify/require"
)

func TestGetParams(t *testing.T) {
k, ctx := testkeeper.BlobKeeper(t)
k, _, ctx := CreateKeeper(t)
params := types.DefaultParams()

k.SetParams(ctx, params)
Expand Down
Loading