refactor: migrate calls from alias file to appropriate store/types (#14455)

Co-authored-by: Marko <marbar3778@yahoo.com>
Closes https://github.com/cosmos/cosmos-sdk/issues/14406
This commit is contained in:
Noel Ukwa 2023-01-10 16:31:06 +01:00 committed by GitHub
parent a4d4d30d01
commit c822836501
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
193 changed files with 893 additions and 1035 deletions

View File

@ -122,7 +122,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Store pacakge no longer has a dependency on baseapp.
* (store) [#14438](https://github.com/cosmos/cosmos-sdk/pull/14438) Pass logger from baseapp to store.
* (store) [#14439](https://github.com/cosmos/cosmos-sdk/pull/14439) Remove global metric gatherer from store.
* By default store has a no op metric gatherer, the application developer must set another metric gatherer or us the provided one in `store/metrics`.
* By default store has a no op metric gatherer, the application developer must set another metric gatherer or us the provided one in `store/metrics`.
* [#14406](https://github.com/cosmos/cosmos-sdk/issues/14406) Migrate usage of types/store.go to store/types/..
### State Machine Breaking

View File

@ -19,6 +19,12 @@ The SDK is in the process of removing all `gogoproto` annotations.
The `gogoproto.goproto_stringer = false` annotation has been removed from most proto files. This means that the `String()` method is being generated for types that previously had this annotation. The generated `String()` method uses `proto.CompactTextString` for _stringifying_ structs.
[Verify](https://github.com/cosmos/cosmos-sdk/pull/13850#issuecomment-1328889651) the usage of the modified `String()` methods and double-check that they are not used in state-machine code.
### Types
#### Store
References to `types/store.go` which contained aliases for store types have been remapped to point to appropriate store/types, hence the `types/store.go` file is no longer needed and has been removed.
### SimApp
#### Module Assertions

View File

@ -18,6 +18,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
snapshottypes "github.com/cosmos/cosmos-sdk/store/snapshots/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
@ -69,7 +70,7 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC
}
// add block gas meter for any genesis transactions (allow infinite gas)
app.deliverState.ctx = app.deliverState.ctx.WithBlockGasMeter(sdk.NewInfiniteGasMeter())
app.deliverState.ctx = app.deliverState.ctx.WithBlockGasMeter(storetypes.NewInfiniteGasMeter())
res = app.initChainer(app.deliverState.ctx, req)
@ -149,7 +150,7 @@ func (app *BaseApp) FilterPeerByID(info string) abci.ResponseQuery {
// BeginBlock implements the ABCI application interface.
func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeginBlock) {
if app.cms.TracingEnabled() {
app.cms.SetTracingContext(sdk.TraceContext(
app.cms.SetTracingContext(storetypes.TraceContext(
map[string]interface{}{"blockHeight": req.Header.Height},
))
}
@ -172,11 +173,11 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg
}
// add block gas meter
var gasMeter sdk.GasMeter
var gasMeter storetypes.GasMeter
if maxGas := app.GetMaximumBlockGas(app.deliverState.ctx); maxGas > 0 {
gasMeter = sdk.NewGasMeter(maxGas)
gasMeter = storetypes.NewGasMeter(maxGas)
} else {
gasMeter = sdk.NewInfiniteGasMeter()
gasMeter = storetypes.NewInfiniteGasMeter()
}
// NOTE: header hash is not set in NewContext, so we manually set it here
@ -212,7 +213,7 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg
// EndBlock implements the ABCI interface.
func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBlock) {
if app.deliverState.ms.TracingEnabled() {
app.deliverState.ms = app.deliverState.ms.SetTracingContext(nil).(sdk.CacheMultiStore)
app.deliverState.ms = app.deliverState.ms.SetTracingContext(nil).(storetypes.CacheMultiStore)
}
if app.endBlocker != nil {
@ -717,7 +718,7 @@ func (app *BaseApp) CreateQueryContext(height int64, prove bool) (sdk.Context, e
// use custom query multistore if provided
qms := app.qms
if qms == nil {
qms = app.cms.(sdk.MultiStore)
qms = app.cms.(storetypes.MultiStore)
}
lastBlockHeight := qms.LatestVersion()
@ -880,7 +881,7 @@ func handleQueryApp(app *BaseApp, path []string, req abci.RequestQuery) abci.Res
func handleQueryStore(app *BaseApp, path []string, req abci.RequestQuery) abci.ResponseQuery {
// "/store" prefix for store queries
queryable, ok := app.cms.(sdk.Queryable)
queryable, ok := app.cms.(storetypes.Queryable)
if !ok {
return sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "multistore doesn't support queries"), app.trace)
}

View File

@ -8,6 +8,7 @@ import (
"testing"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/gogoproto/jsonpb"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
@ -18,6 +19,7 @@ import (
pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types"
"github.com/cosmos/cosmos-sdk/store/snapshots"
snapshottypes "github.com/cosmos/cosmos-sdk/store/snapshots/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -45,8 +47,8 @@ func TestABCI_InitChain(t *testing.T) {
logger := defaultLogger()
app := baseapp.NewBaseApp(name, logger, db, nil)
capKey := sdk.NewKVStoreKey("main")
capKey2 := sdk.NewKVStoreKey("key2")
capKey := storetypes.NewKVStoreKey("main")
capKey2 := storetypes.NewKVStoreKey("key2")
app.MountStores(capKey, capKey2)
// set a value in the store on init chain
@ -745,7 +747,7 @@ func TestABCI_Query_SimulateTx(t *testing.T) {
gasConsumed := uint64(5)
anteOpt := func(bapp *baseapp.BaseApp) {
bapp.SetAnteHandler(func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) {
newCtx = ctx.WithGasMeter(sdk.NewGasMeter(gasConsumed))
newCtx = ctx.WithGasMeter(storetypes.NewGasMeter(gasConsumed))
return
})
}
@ -910,7 +912,7 @@ func TestABCI_TxGasLimits(t *testing.T) {
gasGranted := uint64(10)
anteOpt := func(bapp *baseapp.BaseApp) {
bapp.SetAnteHandler(func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) {
newCtx = ctx.WithGasMeter(sdk.NewGasMeter(gasGranted))
newCtx = ctx.WithGasMeter(storetypes.NewGasMeter(gasGranted))
// AnteHandlers must have their own defer/recover in order for the BaseApp
// to know how much gas was used! This is because the GasMeter is created in
@ -919,7 +921,7 @@ func TestABCI_TxGasLimits(t *testing.T) {
defer func() {
if r := recover(); r != nil {
switch rType := r.(type) {
case sdk.ErrorOutOfGas:
case storetypes.ErrorOutOfGas:
err = sdkerrors.Wrapf(sdkerrors.ErrOutOfGas, "out of gas in location: %v", rType.Descriptor)
default:
panic(r)
@ -993,12 +995,12 @@ func TestABCI_MaxBlockGasLimits(t *testing.T) {
gasGranted := uint64(10)
anteOpt := func(bapp *baseapp.BaseApp) {
bapp.SetAnteHandler(func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) {
newCtx = ctx.WithGasMeter(sdk.NewGasMeter(gasGranted))
newCtx = ctx.WithGasMeter(storetypes.NewGasMeter(gasGranted))
defer func() {
if r := recover(); r != nil {
switch rType := r.(type) {
case sdk.ErrorOutOfGas:
case storetypes.ErrorOutOfGas:
err = sdkerrors.Wrapf(sdkerrors.ErrOutOfGas, "out of gas in location: %v", rType.Descriptor)
default:
panic(r)
@ -1088,12 +1090,12 @@ func TestABCI_GasConsumptionBadTx(t *testing.T) {
gasWanted := uint64(5)
anteOpt := func(bapp *baseapp.BaseApp) {
bapp.SetAnteHandler(func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) {
newCtx = ctx.WithGasMeter(sdk.NewGasMeter(gasWanted))
newCtx = ctx.WithGasMeter(storetypes.NewGasMeter(gasWanted))
defer func() {
if r := recover(); r != nil {
switch rType := r.(type) {
case sdk.ErrorOutOfGas:
case storetypes.ErrorOutOfGas:
log := fmt.Sprintf("out of gas in location: %v", rType.Descriptor)
err = sdkerrors.Wrap(sdkerrors.ErrOutOfGas, log)
default:

View File

@ -43,20 +43,20 @@ type (
// from disk. This is useful for state migration, when loading a datastore written with
// an older version of the software. In particular, if a module changed the substore key name
// (or removed a substore) between two versions of the software.
StoreLoader func(ms sdk.CommitMultiStore) error
StoreLoader func(ms storetypes.CommitMultiStore) error
)
// BaseApp reflects the ABCI application implementation.
type BaseApp struct { //nolint: maligned
// initialized on creation
logger log.Logger
name string // application name from abci.Info
db dbm.DB // common DB backend
cms sdk.CommitMultiStore // Main (uncached) state
qms sdk.MultiStore // Optional alternative multistore for querying only.
storeLoader StoreLoader // function to handle store loading, may be overridden with SetStoreLoader()
grpcQueryRouter *GRPCQueryRouter // router for redirecting gRPC query calls
msgServiceRouter *MsgServiceRouter // router for redirecting Msg service messages
name string // application name from abci.Info
db dbm.DB // common DB backend
cms storetypes.CommitMultiStore // Main (uncached) state
qms storetypes.MultiStore // Optional alternative multistore for querying only.
storeLoader StoreLoader // function to handle store loading, may be overridden with SetStoreLoader()
grpcQueryRouter *GRPCQueryRouter // router for redirecting gRPC query calls
msgServiceRouter *MsgServiceRouter // router for redirecting Msg service messages
interfaceRegistry codectypes.InterfaceRegistry
txDecoder sdk.TxDecoder // unmarshal []byte into sdk.Tx
txEncoder sdk.TxEncoder // marshal sdk.Tx into []byte
@ -86,7 +86,7 @@ type BaseApp struct { //nolint: maligned
prepareProposalState *state // for PrepareProposal
// an inter-block write-through cache provided to the context during deliverState
interBlockCache sdk.MultiStorePersistentCache
interBlockCache storetypes.MultiStorePersistentCache
// absent validators from begin block
voteInfos []abci.VoteInfo
@ -300,14 +300,14 @@ func (app *BaseApp) LoadLatestVersion() error {
}
// DefaultStoreLoader will be used by default and loads the latest version
func DefaultStoreLoader(ms sdk.CommitMultiStore) error {
func DefaultStoreLoader(ms storetypes.CommitMultiStore) error {
return ms.LoadLatestVersion()
}
// CommitMultiStore returns the root multi-store.
// App constructor can use this to access the `cms`.
// UNSAFE: must not be used during the abci life cycle.
func (app *BaseApp) CommitMultiStore() sdk.CommitMultiStore {
func (app *BaseApp) CommitMultiStore() storetypes.CommitMultiStore {
return app.cms
}
@ -381,7 +381,7 @@ func (app *BaseApp) setMinRetainBlocks(minRetainBlocks uint64) {
app.minRetainBlocks = minRetainBlocks
}
func (app *BaseApp) setInterBlockCache(cache sdk.MultiStorePersistentCache) {
func (app *BaseApp) setInterBlockCache(cache storetypes.MultiStorePersistentCache) {
app.interBlockCache = cache
}
@ -576,18 +576,18 @@ func (app *BaseApp) getContextForTx(mode runTxMode, txBytes []byte) sdk.Context
// cacheTxContext returns a new context based off of the provided context with
// a branched multi-store.
func (app *BaseApp) cacheTxContext(ctx sdk.Context, txBytes []byte) (sdk.Context, sdk.CacheMultiStore) {
func (app *BaseApp) cacheTxContext(ctx sdk.Context, txBytes []byte) (sdk.Context, storetypes.CacheMultiStore) {
ms := ctx.MultiStore()
// TODO: https://github.com/cosmos/cosmos-sdk/issues/2824
msCache := ms.CacheMultiStore()
if msCache.TracingEnabled() {
msCache = msCache.SetTracingContext(
sdk.TraceContext(
storetypes.TraceContext(
map[string]interface{}{
"txHash": fmt.Sprintf("%X", tmhash.Sum(txBytes)),
},
),
).(sdk.CacheMultiStore)
).(storetypes.CacheMultiStore)
}
return ctx.WithMultiStore(msCache), msCache
@ -657,7 +657,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re
if app.anteHandler != nil {
var (
anteCtx sdk.Context
msCache sdk.CacheMultiStore
msCache storetypes.CacheMultiStore
)
// Branch context before AnteHandler call in case it aborts.

View File

@ -30,8 +30,8 @@ import (
)
var (
capKey1 = sdk.NewKVStoreKey("key1")
capKey2 = sdk.NewKVStoreKey("key2")
capKey1 = storetypes.NewKVStoreKey("key1")
capKey2 = storetypes.NewKVStoreKey("key2")
// testTxPriority is the CheckTx priority that we set in the test
// AnteHandler.
@ -221,7 +221,7 @@ func TestSetLoader(t *testing.T) {
rs := rootmulti.NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics())
rs.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningNothing))
key := sdk.NewKVStoreKey(storeKey)
key := storetypes.NewKVStoreKey(storeKey)
rs.MountStoreWithDB(key, storetypes.StoreTypeIAVL, nil)
err := rs.LoadLatestVersion()
@ -241,7 +241,7 @@ func TestSetLoader(t *testing.T) {
rs := rootmulti.NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics())
rs.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningDefault))
key := sdk.NewKVStoreKey(storeKey)
key := storetypes.NewKVStoreKey(storeKey)
rs.MountStoreWithDB(key, storetypes.StoreTypeIAVL, nil)
err := rs.LoadLatestVersion()
@ -285,7 +285,7 @@ func TestSetLoader(t *testing.T) {
opts = append(opts, tc.setLoader)
}
app := baseapp.NewBaseApp(t.Name(), defaultLogger(), db, nil, opts...)
app.MountStores(sdk.NewKVStoreKey(tc.loadStoreKey))
app.MountStores(storetypes.NewKVStoreKey(tc.loadStoreKey))
err := app.LoadLatestVersion()
require.Nil(t, err)
@ -613,7 +613,7 @@ func TestLoadVersionPruning(t *testing.T) {
app := baseapp.NewBaseApp(name, logger, db, nil, pruningOpt)
// make a cap key and mount the store
capKey := sdk.NewKVStoreKey("key1")
capKey := storetypes.NewKVStoreKey("key1")
app.MountStores(capKey)
err := app.LoadLatestVersion() // needed to make stores non-nil

View File

@ -5,10 +5,8 @@ import (
"io"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/codec/types"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/store"
"github.com/cosmos/cosmos-sdk/store/metrics"
pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types"
"github.com/cosmos/cosmos-sdk/store/snapshots"
@ -76,7 +74,7 @@ func SetIAVLDisableFastNode(disable bool) func(*BaseApp) {
// SetInterBlockCache provides a BaseApp option function that sets the
// inter-block cache.
func SetInterBlockCache(cache sdk.MultiStorePersistentCache) func(*BaseApp) {
func SetInterBlockCache(cache storetypes.MultiStorePersistentCache) func(*BaseApp) {
return func(app *BaseApp) { app.setInterBlockCache(cache) }
}
@ -128,7 +126,7 @@ func (app *BaseApp) SetDB(db dbm.DB) {
app.db = db
}
func (app *BaseApp) SetCMS(cms store.CommitMultiStore) {
func (app *BaseApp) SetCMS(cms storetypes.CommitMultiStore) {
if app.sealed {
panic("SetEndBlocker() on sealed BaseApp")
}
@ -270,7 +268,7 @@ func (app *BaseApp) SetTxEncoder(txEncoder sdk.TxEncoder) {
// SetQueryMultiStore set a alternative MultiStore implementation to support grpc query service.
//
// Ref: https://github.com/cosmos/cosmos-sdk/issues/13317
func (app *BaseApp) SetQueryMultiStore(ms sdk.MultiStore) {
func (app *BaseApp) SetQueryMultiStore(ms storetypes.MultiStore) {
app.qms = ms
}

View File

@ -4,6 +4,7 @@ import (
"fmt"
"runtime/debug"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
@ -47,7 +48,7 @@ func newRecoveryMiddleware(handler RecoveryHandler, next recoveryMiddleware) rec
// newOutOfGasRecoveryMiddleware creates a standard OutOfGas recovery middleware for app.runTx method.
func newOutOfGasRecoveryMiddleware(gasWanted uint64, ctx sdk.Context, next recoveryMiddleware) recoveryMiddleware {
handler := func(recoveryObj interface{}) error {
err, ok := recoveryObj.(sdk.ErrorOutOfGas)
err, ok := recoveryObj.(storetypes.ErrorOutOfGas)
if !ok {
return nil
}

View File

@ -1,17 +1,18 @@
package baseapp
import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
type state struct {
ms sdk.CacheMultiStore
ms storetypes.CacheMultiStore
ctx sdk.Context
}
// CacheMultiStore calls and returns a CacheMultiStore on the state's underling
// CacheMultiStore.
func (st *state) CacheMultiStore() sdk.CacheMultiStore {
func (st *state) CacheMultiStore() storetypes.CacheMultiStore {
return st.ms.CacheMultiStore()
}

View File

@ -230,14 +230,14 @@ func anteHandlerTxTest(t *testing.T, capKey storetypes.StoreKey, storeKey []byte
}
}
func incrementingCounter(t *testing.T, store sdk.KVStore, counterKey []byte, counter int64) (*sdk.Result, error) {
func incrementingCounter(t *testing.T, store storetypes.KVStore, counterKey []byte, counter int64) (*sdk.Result, error) {
storedCounter := getIntFromStore(t, store, counterKey)
require.Equal(t, storedCounter, counter)
setIntOnStore(store, counterKey, counter+1)
return &sdk.Result{}, nil
}
func setIntOnStore(store sdk.KVStore, key []byte, i int64) {
func setIntOnStore(store storetypes.KVStore, key []byte, i int64) {
bz := make([]byte, 8)
n := binary.PutVarint(bz, i)
store.Set(key, bz[:n])
@ -347,7 +347,7 @@ func newTxCounter(t *testing.T, cfg client.TxConfig, counter int64, msgCounters
return builder.GetTx()
}
func getIntFromStore(t *testing.T, store sdk.KVStore, key []byte) int64 {
func getIntFromStore(t *testing.T, store storetypes.KVStore, key []byte) int64 {
bz := store.Get(key)
if len(bz) == 0 {
return 0

View File

@ -222,9 +222,9 @@ func prefixStartEndBytes[K, V any](m Map[K, V], prefix K) (startBytes, endBytes
return startBytes, prefixEndBytes(startBytes), nil
}
// Iterator defines a generic wrapper around an sdk.Iterator.
// Iterator defines a generic wrapper around an storetypes.Iterator.
// This iterator provides automatic key and value encoding,
// it assumes all the keys and values contained within the sdk.Iterator
// it assumes all the keys and values contained within the storetypes.Iterator
// range are the same.
type Iterator[K, V any] struct {
kc KeyCodec[K]
@ -240,7 +240,7 @@ func (i Iterator[K, V]) Value() (V, error) {
return i.vc.Decode(i.iter.Value())
}
// Key returns the current sdk.Iterator decoded key.
// Key returns the current storetypes.Iterator decoded key.
func (i Iterator[K, V]) Key() (K, error) {
bytesKey := i.iter.Key()[i.prefixLength:] // strip prefix namespace

1
go.mod
View File

@ -60,6 +60,7 @@ require (
google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef
google.golang.org/grpc v1.51.0
google.golang.org/protobuf v1.28.1
gotest.tools/v3 v3.4.0
pgregory.net/rapid v0.5.5
sigs.k8s.io/yaml v1.3.0
)

1
go.sum
View File

@ -1358,6 +1358,7 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o=
gotest.tools/v3 v3.4.0/go.mod h1:CtbdzLSsqVhDgMtKsx03ird5YTGB3ar27v0u/yKBW5g=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

View File

@ -29,7 +29,7 @@ func NewApp(rootDir string, logger log.Logger) (abci.Application, error) {
return nil, err
}
capKeyMainStore := sdk.NewKVStoreKey("main")
capKeyMainStore := storetypes.NewKVStoreKey("main")
baseApp := bam.NewBaseApp("kvstore", logger, db, decodeTx)
baseApp.MountStores(capKeyMainStore)

View File

@ -10,20 +10,19 @@ import (
pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types"
snapshottypes "github.com/cosmos/cosmos-sdk/store/snapshots/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
var _ sdk.MultiStore = multiStore{}
var _ storetypes.MultiStore = multiStore{}
type multiStore struct {
kv map[storetypes.StoreKey]kvStore
}
func (ms multiStore) CacheMultiStore() sdk.CacheMultiStore {
func (ms multiStore) CacheMultiStore() storetypes.CacheMultiStore {
panic("not implemented")
}
func (ms multiStore) CacheMultiStoreWithVersion(_ int64) (sdk.CacheMultiStore, error) {
func (ms multiStore) CacheMultiStoreWithVersion(_ int64) (storetypes.CacheMultiStore, error) {
panic("not implemented")
}
@ -31,7 +30,7 @@ func (ms multiStore) CacheWrap() storetypes.CacheWrap {
panic("not implemented")
}
func (ms multiStore) CacheWrapWithTrace(_ io.Writer, _ sdk.TraceContext) storetypes.CacheWrap {
func (ms multiStore) CacheWrapWithTrace(_ io.Writer, _ storetypes.TraceContext) storetypes.CacheWrap {
panic("not implemented")
}
@ -43,11 +42,11 @@ func (ms multiStore) TracingEnabled() bool {
panic("not implemented")
}
func (ms multiStore) SetTracingContext(tc sdk.TraceContext) sdk.MultiStore {
func (ms multiStore) SetTracingContext(tc storetypes.TraceContext) storetypes.MultiStore {
panic("not implemented")
}
func (ms multiStore) SetTracer(w io.Writer) sdk.MultiStore {
func (ms multiStore) SetTracer(w io.Writer) storetypes.MultiStore {
panic("not implemented")
}
@ -107,11 +106,11 @@ func (ms multiStore) LoadVersion(ver int64) error {
panic("not implemented")
}
func (ms multiStore) GetKVStore(key storetypes.StoreKey) sdk.KVStore {
func (ms multiStore) GetKVStore(key storetypes.StoreKey) storetypes.KVStore {
return ms.kv[key]
}
func (ms multiStore) GetStore(key storetypes.StoreKey) sdk.Store {
func (ms multiStore) GetStore(key storetypes.StoreKey) storetypes.Store {
panic("not implemented")
}
@ -127,7 +126,7 @@ func (ms multiStore) SetSnapshotInterval(snapshotInterval uint64) {
panic("not implemented")
}
func (ms multiStore) SetInterBlockCache(_ sdk.MultiStorePersistentCache) {
func (ms multiStore) SetInterBlockCache(_ storetypes.MultiStorePersistentCache) {
panic("not implemented")
}
@ -161,7 +160,7 @@ func (ms multiStore) LatestVersion() int64 {
panic("not implemented")
}
var _ sdk.KVStore = kvStore{}
var _ storetypes.KVStore = kvStore{}
type kvStore struct {
store map[string][]byte
@ -171,7 +170,7 @@ func (kv kvStore) CacheWrap() storetypes.CacheWrap {
panic("not implemented")
}
func (kv kvStore) CacheWrapWithTrace(w io.Writer, tc sdk.TraceContext) storetypes.CacheWrap {
func (kv kvStore) CacheWrapWithTrace(w io.Writer, tc storetypes.TraceContext) storetypes.CacheWrap {
panic("not implemented")
}
@ -205,30 +204,30 @@ func (kv kvStore) Delete(key []byte) {
delete(kv.store, string(key))
}
func (kv kvStore) Prefix(prefix []byte) sdk.KVStore {
func (kv kvStore) Prefix(prefix []byte) storetypes.KVStore {
panic("not implemented")
}
func (kv kvStore) Gas(meter sdk.GasMeter, config sdk.GasConfig) sdk.KVStore {
func (kv kvStore) Gas(meter storetypes.GasMeter, config storetypes.GasConfig) storetypes.KVStore {
panic("not implmeneted")
}
func (kv kvStore) Iterator(start, end []byte) sdk.Iterator {
func (kv kvStore) Iterator(start, end []byte) storetypes.Iterator {
panic("not implemented")
}
func (kv kvStore) ReverseIterator(start, end []byte) sdk.Iterator {
func (kv kvStore) ReverseIterator(start, end []byte) storetypes.Iterator {
panic("not implemented")
}
func (kv kvStore) SubspaceIterator(prefix []byte) sdk.Iterator {
func (kv kvStore) SubspaceIterator(prefix []byte) storetypes.Iterator {
panic("not implemented")
}
func (kv kvStore) ReverseSubspaceIterator(prefix []byte) sdk.Iterator {
func (kv kvStore) ReverseSubspaceIterator(prefix []byte) storetypes.Iterator {
panic("not implemented")
}
func NewCommitMultiStore() sdk.CommitMultiStore {
func NewCommitMultiStore() storetypes.CommitMultiStore {
return multiStore{kv: make(map[storetypes.StoreKey]kvStore)}
}

View File

@ -7,7 +7,6 @@ import (
"github.com/stretchr/testify/require"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
func TestStore(t *testing.T) {
@ -15,7 +14,7 @@ func TestStore(t *testing.T) {
cms := NewCommitMultiStore()
key := sdk.NewKVStoreKey("test")
key := storetypes.NewKVStoreKey("test")
cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db)
err := cms.LoadLatestVersion()
require.Nil(t, err)

View File

@ -6,6 +6,7 @@ import (
"time"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/gogoproto/grpc"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"
@ -16,7 +17,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
sdk "github.com/cosmos/cosmos-sdk/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
)
// ServerStartTime defines the time duration that the server need to stay running after startup
@ -58,7 +59,7 @@ type (
RegisterNodeService(client.Context)
// CommitMultiStore return the multistore instance
CommitMultiStore() sdk.CommitMultiStore
CommitMultiStore() storetypes.CommitMultiStore
}
// AppCreator is a function that allows us to lazily initialize an

View File

@ -15,6 +15,7 @@ import (
"time"
dbm "github.com/cosmos/cosmos-db"
"github.com/spf13/cast"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
@ -32,6 +33,7 @@ import (
"github.com/cosmos/cosmos-sdk/store"
"github.com/cosmos/cosmos-sdk/store/snapshots"
snapshottypes "github.com/cosmos/cosmos-sdk/store/snapshots/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/mempool"
"github.com/cosmos/cosmos-sdk/version"
@ -428,7 +430,7 @@ func openTraceWriter(traceWriterFile string) (w io.WriteCloser, err error) {
// DefaultBaseappOptions returns the default baseapp options provided by the Cosmos SDK
func DefaultBaseappOptions(appOpts types.AppOptions) []func(*baseapp.BaseApp) {
var cache sdk.MultiStorePersistentCache
var cache storetypes.MultiStorePersistentCache
if cast.ToBool(appOpts.Get(FlagInterBlockCache)) {
cache = store.NewCommitKVStoreCacheManager()

View File

@ -250,7 +250,7 @@ func NewSimApp(
bApp.SetInterfaceRegistry(interfaceRegistry)
bApp.SetTxEncoder(txConfig.TxEncoder())
keys := sdk.NewKVStoreKeys(
keys := storetypes.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, consensusparamtypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
@ -258,10 +258,10 @@ func NewSimApp(
authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
// NOTE: The testingkey is just mounted for testing purposes. Actual applications should
// not include this key.
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, "testingkey")
memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, "testingkey")
// register the streaming service with the BaseApp
if err := bApp.SetStreamingService(appOpts, appCodec, keys); err != nil {

View File

@ -8,6 +8,7 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"github.com/cosmos/cosmos-sdk/x/staking"
@ -158,7 +159,7 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
// Iterate through validators by power descending, reset bond heights, and
// update bond intra-tx counters.
store := ctx.KVStore(app.GetKey(stakingtypes.StoreKey))
iter := sdk.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey)
iter := storetypes.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey)
counter := int16(0)
for ; iter.Valid(); iter.Next() {

View File

@ -189,6 +189,7 @@ replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
// Simapp always use the latest version of the cosmos-sdk
github.com/cosmos/cosmos-sdk => ../.
github.com/cosmos/cosmos-sdk/x/nft => .././x/nft
// Fix upstream GHSA-h395-qcrw-5vmq vulnerability.
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.8.1

View File

@ -22,7 +22,6 @@ import (
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
@ -218,7 +217,7 @@ func TestAppImportExport(t *testing.T) {
storeA := ctxA.KVStore(skp.A)
storeB := ctxB.KVStore(skp.B)
failedKVAs, failedKVBs := sdk.DiffKVStores(storeA, storeB, skp.Prefixes)
failedKVAs, failedKVBs := simtestutil.DiffKVStores(storeA, storeB, skp.Prefixes)
require.Equal(t, len(failedKVAs), len(failedKVBs), "unequal sets of key-values to compare")
fmt.Printf("compared %d different key/value pairs between %s and %s\n", len(failedKVAs), skp.A, skp.B)

View File

@ -7,10 +7,10 @@ import (
dbm "github.com/cosmos/cosmos-db"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/cosmos/cosmos-sdk/store/internal/kv"
"github.com/cosmos/cosmos-sdk/store/metrics"
pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types"
snapshottypes "github.com/cosmos/cosmos-sdk/store/snapshots/types"
"github.com/cosmos/cosmos-sdk/types/kv"
)
type Store interface {
@ -486,3 +486,35 @@ type StoreWithInitialVersion interface {
// starting a new chain at an arbitrary height.
SetInitialVersion(version int64)
}
// NewTransientStoreKeys constructs a new map of TransientStoreKey's
// Must return pointers according to the ocap principle
// The function will panic if there is a potential conflict in names
// see `assertNoCommonPrefix` function for more details.
func NewTransientStoreKeys(names ...string) map[string]*TransientStoreKey {
assertNoCommonPrefix(names)
keys := make(map[string]*TransientStoreKey)
for _, n := range names {
keys[n] = NewTransientStoreKey(n)
}
return keys
}
// NewMemoryStoreKeys constructs a new map matching store key names to their
// 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 {
assertNoCommonPrefix(names)
keys := make(map[string]*MemoryStoreKey)
for _, n := range names {
keys[n] = NewMemoryStoreKey(n)
}
return keys
}
// StoreDecoderRegistry defines each of the modules store decoders. Used for ImportExport
// simulation.
type StoreDecoderRegistry map[string]func(kvA, kvB kv.Pair) string

View File

@ -4,8 +4,8 @@ import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gotest.tools/v3/assert"
)
func TestStoreUpgrades(t *testing.T) {
@ -224,3 +224,19 @@ func TestTraceContext_Merge(t *testing.T) {
})
}
}
func TestNewTransientStoreKeys(t *testing.T) {
assert.DeepEqual(t, map[string]*TransientStoreKey{}, NewTransientStoreKeys())
assert.DeepEqual(t, 1, len(NewTransientStoreKeys("one")))
}
func TestNewInfiniteGasMeter(t *testing.T) {
gm := NewInfiniteGasMeter()
require.NotNil(t, gm)
_, ok := gm.(GasMeter) //nolint:gosimple
require.True(t, ok)
}
func TestStoreTypes(t *testing.T) {
assert.DeepEqual(t, InclusiveEndBytes([]byte("endbytes")), InclusiveEndBytes([]byte("endbytes")))
}

View File

@ -1,27 +1,37 @@
package types_test
import (
"bytes"
"testing"
"github.com/stretchr/testify/require"
"gotest.tools/v3/assert"
"github.com/cosmos/cosmos-sdk/store/types"
)
func TestPrefixEndBytes(t *testing.T) {
t.Parallel()
bs1 := []byte{0x23, 0xA5, 0x06}
require.True(t, bytes.Equal([]byte{0x23, 0xA5, 0x07}, types.PrefixEndBytes(bs1)))
bs2 := []byte{0x23, 0xA5, 0xFF}
require.True(t, bytes.Equal([]byte{0x23, 0xA6}, types.PrefixEndBytes(bs2)))
require.Nil(t, types.PrefixEndBytes([]byte{0xFF}))
require.Nil(t, types.PrefixEndBytes(nil))
testCases := []struct {
prefix []byte
expected []byte
}{
{[]byte{byte(55), byte(255), byte(255), byte(0)}, []byte{byte(55), byte(255), byte(255), byte(1)}},
{[]byte{byte(55), byte(255), byte(255), byte(15)}, []byte{byte(55), byte(255), byte(255), byte(16)}},
{[]byte{byte(55), byte(200), byte(255)}, []byte{byte(55), byte(201)}},
{[]byte{byte(55), byte(255), byte(255)}, []byte{byte(56)}},
{[]byte{byte(255), byte(255), byte(255)}, nil},
{[]byte{byte(255)}, nil},
{nil, nil},
}
for _, test := range testCases {
end := types.PrefixEndBytes(test.prefix)
assert.DeepEqual(t, test.expected, end)
}
}
func TestInclusiveEndBytes(t *testing.T) {
t.Parallel()
require.True(t, bytes.Equal([]byte{0x00}, types.InclusiveEndBytes(nil)))
assert.DeepEqual(t, []byte{0x00}, types.InclusiveEndBytes(nil))
bs := []byte("test")
require.True(t, bytes.Equal(append(bs, byte(0x00)), types.InclusiveEndBytes(bs)))
assert.DeepEqual(t, append(bs, byte(0x00)), types.InclusiveEndBytes(bs))
}

View File

@ -187,4 +187,5 @@ replace (
// Fix upstream GHSA-h395-qcrw-5vmq vulnerability.
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.8.1
github.com/cosmos/cosmos-sdk/x/nft => .././x/nft // todo remove after pr merged
)

View File

@ -60,7 +60,7 @@ func (s *DeterministicTestSuite) SetupTest() {
)
s.Require().NoError(err)
// s.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1, Time: time.Now()}).WithGasMeter(sdk.NewInfiniteGasMeter())
// s.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1, Time: time.Now()}).WithGasMeter(storetypes.NewInfiniteGasMeter())
s.ctx = app.BaseApp.NewContext(false, tmproto.Header{})
queryHelper := baseapp.NewQueryServerTestHelper(s.ctx, interfaceRegistry)

View File

@ -1,18 +1,21 @@
package sims
import (
"bytes"
"encoding/json"
"fmt"
"os"
dbm "github.com/cosmos/cosmos-db"
"github.com/tendermint/tendermint/libs/log"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/runtime"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/tendermint/tendermint/libs/log"
)
// SetupSimulation creates the config, db (levelDB), temporary directory and logger for the simulation tests.
@ -106,7 +109,7 @@ func PrintStats(db dbm.DB) {
// GetSimulationLog unmarshals the KVPair's Value to the corresponding type based on the
// each's module store key and the prefix bytes of the KVPair's key.
func GetSimulationLog(storeName string, sdr sdk.StoreDecoderRegistry, kvAs, kvBs []kv.Pair) (log string) {
func GetSimulationLog(storeName string, sdr storetypes.StoreDecoderRegistry, kvAs, kvBs []kv.Pair) (log string) {
for i := 0; i < len(kvAs); i++ {
if len(kvAs[i].Value) == 0 && len(kvBs[i].Value) == 0 {
// skip if the value doesn't have any bytes
@ -123,3 +126,59 @@ func GetSimulationLog(storeName string, sdr sdk.StoreDecoderRegistry, kvAs, kvBs
return log
}
// DiffKVStores compares two KVstores and returns all the key/value pairs
// that differ from one another. It also skips value comparison for a set of provided prefixes.
func DiffKVStores(a storetypes.KVStore, b storetypes.KVStore, prefixesToSkip [][]byte) (kvAs, kvBs []kv.Pair) {
iterA := a.Iterator(nil, nil)
defer iterA.Close()
iterB := b.Iterator(nil, nil)
defer iterB.Close()
for {
if !iterA.Valid() && !iterB.Valid() {
return kvAs, kvBs
}
var kvA, kvB kv.Pair
if iterA.Valid() {
kvA = kv.Pair{Key: iterA.Key(), Value: iterA.Value()}
iterA.Next()
}
if iterB.Valid() {
kvB = kv.Pair{Key: iterB.Key(), Value: iterB.Value()}
}
compareValue := true
for _, prefix := range prefixesToSkip {
// Skip value comparison if we matched a prefix
if bytes.HasPrefix(kvA.Key, prefix) {
compareValue = false
break
}
}
if !compareValue {
// We're skipping this key due to an exclusion prefix. If it's present in B, iterate past it. If it's
// absent don't iterate.
if bytes.Equal(kvA.Key, kvB.Key) {
iterB.Next()
}
continue
}
// always iterate B when comparing
iterB.Next()
if !bytes.Equal(kvA.Key, kvB.Key) || !bytes.Equal(kvA.Value, kvB.Value) {
kvAs = append(kvAs, kvA)
kvBs = append(kvBs, kvB)
}
}
}

View File

@ -5,16 +5,22 @@ import (
"testing"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
"gotest.tools/v3/assert"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/store/metrics"
"github.com/cosmos/cosmos-sdk/store/rootmulti"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/types/kv"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)
func TestGetSimulationLog(t *testing.T) {
legacyAmino := codec.NewLegacyAmino()
decoders := make(sdk.StoreDecoderRegistry)
decoders := make(storetypes.StoreDecoderRegistry)
decoders[authtypes.StoreKey] = func(kvAs, kvBs kv.Pair) string { return "10" }
tests := []struct {
@ -46,3 +52,58 @@ func TestGetSimulationLog(t *testing.T) {
})
}
}
func TestDiffKVStores(t *testing.T) {
store1, store2 := initTestStores(t)
// Two equal stores
k1, v1 := []byte("k1"), []byte("v1")
store1.Set(k1, v1)
store2.Set(k1, v1)
checkDiffResults(t, store1, store2)
// delete k1 from store2, which is now empty
store2.Delete(k1)
checkDiffResults(t, store1, store2)
// set k1 in store2, different value than what store1 holds for k1
v2 := []byte("v2")
store2.Set(k1, v2)
checkDiffResults(t, store1, store2)
// add k2 to store2
k2 := []byte("k2")
store2.Set(k2, v2)
checkDiffResults(t, store1, store2)
// Reset stores
store1.Delete(k1)
store2.Delete(k1)
store2.Delete(k2)
// Same keys, different value. Comparisons will be nil as prefixes are skipped.
prefix := []byte("prefix:")
k1Prefixed := append(prefix, k1...) //nolint:gocritic // append is fine here
store1.Set(k1Prefixed, v1)
store2.Set(k1Prefixed, v2)
checkDiffResults(t, store1, store2)
}
func checkDiffResults(t *testing.T, store1, store2 storetypes.KVStore) {
kvAs1, kvBs1 := DiffKVStores(store1, store2, nil)
kvAs2, kvBs2 := DiffKVStores(store1, store2, nil)
assert.DeepEqual(t, kvAs1, kvAs2)
assert.DeepEqual(t, kvBs1, kvBs2)
}
func initTestStores(t *testing.T) (storetypes.KVStore, storetypes.KVStore) {
db := dbm.NewMemDB()
ms := rootmulti.NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics())
key1 := storetypes.NewKVStoreKey("store1")
key2 := storetypes.NewKVStoreKey("store2")
require.NotPanics(t, func() { ms.MountStoreWithDB(key1, storetypes.StoreTypeIAVL, db) })
require.NotPanics(t, func() { ms.MountStoreWithDB(key2, storetypes.StoreTypeIAVL, db) })
require.NotPanics(t, func() { ms.LoadLatestVersion() })
return ms.GetKVStore(key1), ms.GetKVStore(key2)
}

View File

@ -24,15 +24,15 @@ and standard additions here would be better just to add to the Context struct
*/
type Context struct {
baseCtx context.Context
ms MultiStore
ms storetypes.MultiStore
header tmproto.Header
headerHash tmbytes.HexBytes
chainID string
txBytes []byte
logger log.Logger
voteInfo []abci.VoteInfo
gasMeter GasMeter
blockGasMeter GasMeter
gasMeter storetypes.GasMeter
blockGasMeter storetypes.GasMeter
checkTx bool
recheckTx bool // if recheckTx == true, then checkTx must also be true
minGasPrice DecCoins
@ -48,15 +48,15 @@ type Request = Context
// Read-only accessors
func (c Context) Context() context.Context { return c.baseCtx }
func (c Context) MultiStore() MultiStore { return c.ms }
func (c Context) MultiStore() storetypes.MultiStore { return c.ms }
func (c Context) BlockHeight() int64 { return c.header.Height }
func (c Context) BlockTime() time.Time { return c.header.Time }
func (c Context) ChainID() string { return c.chainID }
func (c Context) TxBytes() []byte { return c.txBytes }
func (c Context) Logger() log.Logger { return c.logger }
func (c Context) VoteInfos() []abci.VoteInfo { return c.voteInfo }
func (c Context) GasMeter() GasMeter { return c.gasMeter }
func (c Context) BlockGasMeter() GasMeter { return c.blockGasMeter }
func (c Context) GasMeter() storetypes.GasMeter { return c.gasMeter }
func (c Context) BlockGasMeter() storetypes.GasMeter { return c.blockGasMeter }
func (c Context) IsCheckTx() bool { return c.checkTx }
func (c Context) IsReCheckTx() bool { return c.recheckTx }
func (c Context) MinGasPrices() DecCoins { return c.minGasPrice }
@ -95,7 +95,7 @@ func (c Context) Err() error {
}
// create a new context
func NewContext(ms MultiStore, header tmproto.Header, isCheckTx bool, logger log.Logger) Context {
func NewContext(ms storetypes.MultiStore, header tmproto.Header, isCheckTx bool, logger log.Logger) Context {
// https://github.com/gogo/protobuf/issues/519
header.Time = header.Time.UTC()
return Context{
@ -120,7 +120,7 @@ func (c Context) WithContext(ctx context.Context) Context {
}
// WithMultiStore returns a Context with an updated MultiStore.
func (c Context) WithMultiStore(ms MultiStore) Context {
func (c Context) WithMultiStore(ms storetypes.MultiStore) Context {
c.ms = ms
return c
}
@ -189,13 +189,13 @@ func (c Context) WithVoteInfos(voteInfo []abci.VoteInfo) Context {
}
// WithGasMeter returns a Context with an updated transaction GasMeter.
func (c Context) WithGasMeter(meter GasMeter) Context {
func (c Context) WithGasMeter(meter storetypes.GasMeter) Context {
c.gasMeter = meter
return c
}
// WithBlockGasMeter returns a Context with an updated block GasMeter
func (c Context) WithBlockGasMeter(meter GasMeter) Context {
func (c Context) WithBlockGasMeter(meter storetypes.GasMeter) Context {
c.blockGasMeter = meter
return c
}
@ -277,12 +277,12 @@ func (c Context) Value(key interface{}) interface{} {
// ----------------------------------------------------------------------------
// KVStore fetches a KVStore from the MultiStore.
func (c Context) KVStore(key storetypes.StoreKey) KVStore {
func (c Context) KVStore(key storetypes.StoreKey) storetypes.KVStore {
return gaskv.NewStore(c.ms.GetKVStore(key), c.gasMeter, c.kvGasConfig)
}
// TransientStore fetches a TransientStore from the MultiStore.
func (c Context) TransientStore(key storetypes.StoreKey) KVStore {
func (c Context) TransientStore(key storetypes.StoreKey) storetypes.KVStore {
return gaskv.NewStore(c.ms.GetKVStore(key), c.gasMeter, c.transientKVGasConfig)
}

View File

@ -26,13 +26,13 @@ func TestContextTestSuite(t *testing.T) {
}
func (s *contextTestSuite) TestCacheContext() {
key := types.NewKVStoreKey(s.T().Name() + "_TestCacheContext")
key := storetypes.NewKVStoreKey(s.T().Name() + "_TestCacheContext")
k1 := []byte("hello")
v1 := []byte("world")
k2 := []byte("key")
v2 := []byte("value")
ctx := testutil.DefaultContext(key, types.NewTransientStoreKey("transient_"+s.T().Name()))
ctx := testutil.DefaultContext(key, storetypes.NewTransientStoreKey("transient_"+s.T().Name()))
store := ctx.KVStore(key)
store.Set(k1, v1)
s.Require().Equal(v1, store.Get(k1))
@ -58,8 +58,8 @@ func (s *contextTestSuite) TestCacheContext() {
}
func (s *contextTestSuite) TestLogContext() {
key := types.NewKVStoreKey(s.T().Name())
ctx := testutil.DefaultContext(key, types.NewTransientStoreKey("transient_"+s.T().Name()))
key := storetypes.NewKVStoreKey(s.T().Name())
ctx := testutil.DefaultContext(key, storetypes.NewTransientStoreKey("transient_"+s.T().Name()))
ctrl := gomock.NewController(s.T())
s.T().Cleanup(ctrl.Finish)
@ -89,8 +89,8 @@ func (s *contextTestSuite) TestContextWithCustom() {
txbytes := []byte("txbytes")
logger := mock.NewMockLogger(ctrl)
voteinfos := []abci.VoteInfo{{}}
meter := types.NewGasMeter(10000)
blockGasMeter := types.NewGasMeter(20000)
meter := storetypes.NewGasMeter(10000)
blockGasMeter := storetypes.NewGasMeter(20000)
minGasPrices := types.DecCoins{types.NewInt64DecCoin("feetoken", 1)}
headerHash := []byte("headerHash")
zeroGasCfg := storetypes.GasConfig{}

View File

@ -42,6 +42,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"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"
)
@ -416,7 +417,8 @@ func (m *Manager) ExportGenesisForModules(ctx sdk.Context, cdc codec.JSONCodec,
if module, ok := m.Modules[moduleName].(HasGenesis); ok {
channels[moduleName] = make(chan json.RawMessage)
go func(module HasGenesis, ch chan json.RawMessage) {
ctx := ctx.WithGasMeter(sdk.NewInfiniteGasMeter()) // avoid race conditions
ctx := ctx.WithGasMeter(storetypes.NewInfiniteGasMeter()) // avoid race conditions
ch <- module.ExportGenesis(ctx, cdc)
}(module, channels[moduleName])
}

View File

@ -7,9 +7,8 @@ import (
"time"
sdkmath "cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/types/simulation"
)
@ -23,7 +22,7 @@ type AppModuleSimulation interface {
ProposalContents(simState SimulationState) []simulation.WeightedProposalContent
// register a func to decode the each module's defined types from their corresponding store key
RegisterStoreDecoder(sdk.StoreDecoderRegistry)
RegisterStoreDecoder(storetypes.StoreDecoderRegistry)
// simulation operations (i.e msgs) with their respective weight
WeightedOperations(simState SimulationState) []simulation.WeightedOperation
@ -32,8 +31,8 @@ type AppModuleSimulation interface {
// SimulationManager defines a simulation manager that provides the high level utility
// for managing and executing simulation functionalities for a group of modules
type SimulationManager struct {
Modules []AppModuleSimulation // array of app modules; we use an array for deterministic simulation tests
StoreDecoders sdk.StoreDecoderRegistry // functions to decode the key-value pairs from each module's store
Modules []AppModuleSimulation // array of app modules; we use an array for deterministic simulation tests
StoreDecoders storetypes.StoreDecoderRegistry // functions to decode the key-value pairs from each module's store
}
// NewSimulationManager creates a new SimulationManager object
@ -42,7 +41,7 @@ type SimulationManager struct {
func NewSimulationManager(modules ...AppModuleSimulation) *SimulationManager {
return &SimulationManager{
Modules: modules,
StoreDecoders: make(sdk.StoreDecoderRegistry),
StoreDecoders: make(storetypes.StoreDecoderRegistry),
}
}

View File

@ -6,6 +6,7 @@ import (
"cosmossdk.io/math"
"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/types/query"
@ -219,7 +220,7 @@ func (s *paginationTestSuite) TestFilteredPaginate() {
// balances:<denom:"test0denom" amount:"250" > pagination:<next_key:"test1denom" total:5 >
}
func execFilterPaginate(store sdk.KVStore, pageReq *query.PageRequest, appCodec codec.Codec) (balances sdk.Coins, res *query.PageResponse, err error) {
func execFilterPaginate(store storetypes.KVStore, pageReq *query.PageRequest, appCodec codec.Codec) (balances sdk.Coins, res *query.PageResponse, err error) {
balancesStore := prefix.NewStore(store, types.BalancesPrefix)
accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1))
@ -261,7 +262,7 @@ func (s *paginationTestSuite) TestFilteredPaginationsNextKey() {
s.Require().NoError(testutil.FundAccount(s.bankKeeper, s.ctx, addr1, balances))
store := s.ctx.KVStore(s.app.UnsafeFindStoreKey(types.StoreKey))
execFilterPaginate := func(store sdk.KVStore, pageReq *query.PageRequest, appCodec codec.Codec) (balances sdk.Coins, res *query.PageResponse, err error) {
execFilterPaginate := func(store storetypes.KVStore, pageReq *query.PageRequest, appCodec codec.Codec) (balances sdk.Coins, res *query.PageResponse, err error) {
balancesStore := prefix.NewStore(store, types.BalancesPrefix)
accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1))

View File

@ -1,216 +0,0 @@
package types
import (
"bytes"
fmt "fmt"
"sort"
"strings"
"github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/types/kv"
)
type (
Store = types.Store
Committer = types.Committer
CommitStore = types.CommitStore
Queryable = types.Queryable
MultiStore = types.MultiStore
CacheMultiStore = types.CacheMultiStore
CommitMultiStore = types.CommitMultiStore
MultiStorePersistentCache = types.MultiStorePersistentCache
KVStore = types.KVStore
Iterator = types.Iterator
)
// StoreDecoderRegistry defines each of the modules store decoders. Used for ImportExport
// simulation.
type StoreDecoderRegistry map[string]func(kvA, kvB kv.Pair) string
// Iterator over all the keys with a certain prefix in ascending order
func KVStorePrefixIterator(kvs KVStore, prefix []byte) Iterator {
return types.KVStorePrefixIterator(kvs, prefix)
}
// Iterator over all the keys with a certain prefix in descending order.
func KVStoreReversePrefixIterator(kvs KVStore, prefix []byte) Iterator {
return types.KVStoreReversePrefixIterator(kvs, prefix)
}
// KVStorePrefixIteratorPaginated returns iterator over items in the selected page.
// Items iterated and skipped in ascending order.
func KVStorePrefixIteratorPaginated(kvs KVStore, prefix []byte, page, limit uint) Iterator {
return types.KVStorePrefixIteratorPaginated(kvs, prefix, page, limit)
}
// KVStoreReversePrefixIteratorPaginated returns iterator over items in the selected page.
// Items iterated and skipped in descending order.
func KVStoreReversePrefixIteratorPaginated(kvs KVStore, prefix []byte, page, limit uint) Iterator {
return types.KVStoreReversePrefixIteratorPaginated(kvs, prefix, page, limit)
}
// DiffKVStores compares two KVstores and returns all the key/value pairs
// that differ from one another. It also skips value comparison for a set of provided prefixes.
func DiffKVStores(a KVStore, b KVStore, prefixesToSkip [][]byte) (kvAs, kvBs []kv.Pair) {
iterA := a.Iterator(nil, nil)
defer iterA.Close()
iterB := b.Iterator(nil, nil)
defer iterB.Close()
for {
if !iterA.Valid() && !iterB.Valid() {
return kvAs, kvBs
}
var kvA, kvB kv.Pair
if iterA.Valid() {
kvA = kv.Pair{Key: iterA.Key(), Value: iterA.Value()}
iterA.Next()
}
if iterB.Valid() {
kvB = kv.Pair{Key: iterB.Key(), Value: iterB.Value()}
}
compareValue := true
for _, prefix := range prefixesToSkip {
// Skip value comparison if we matched a prefix
if bytes.HasPrefix(kvA.Key, prefix) {
compareValue = false
break
}
}
if !compareValue {
// We're skipping this key due to an exclusion prefix. If it's present in B, iterate past it. If it's
// absent don't iterate.
if bytes.Equal(kvA.Key, kvB.Key) {
iterB.Next()
}
continue
}
// always iterate B when comparing
iterB.Next()
if !bytes.Equal(kvA.Key, kvB.Key) || !bytes.Equal(kvA.Value, kvB.Value) {
kvAs = append(kvAs, kvA)
kvBs = append(kvBs, kvB)
}
}
}
// 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) {
sorted := make([]string, len(keys))
copy(sorted, keys)
sort.Strings(sorted)
for i := 1; i < len(sorted); i++ {
if strings.HasPrefix(sorted[i], sorted[i-1]) {
panic(fmt.Sprint("Potential key collision between KVStores:", sorted[i], " - ", sorted[i-1]))
}
}
}
// NewKVStoreKey returns a new pointer to a 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]*types.KVStoreKey {
assertNoPrefix(names)
keys := make(map[string]*types.KVStoreKey, len(names))
for _, n := range names {
keys[n] = NewKVStoreKey(n)
}
return keys
}
// Constructs new TransientStoreKey
// Must return a pointer according to the ocap principle
func NewTransientStoreKey(name string) *types.TransientStoreKey {
return types.NewTransientStoreKey(name)
}
// NewTransientStoreKeys constructs a new map of TransientStoreKey's
// 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]*types.TransientStoreKey {
assertNoPrefix(names)
keys := make(map[string]*types.TransientStoreKey)
for _, n := range names {
keys[n] = NewTransientStoreKey(n)
}
return keys
}
// NewMemoryStoreKeys constructs a new map matching store key names to their
// 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]*types.MemoryStoreKey {
assertNoPrefix(names)
keys := make(map[string]*types.MemoryStoreKey)
for _, n := range names {
keys[n] = types.NewMemoryStoreKey(n)
}
return keys
}
// PrefixEndBytes returns the []byte that would end a
// range query for all []byte with a certain prefix
// Deals with last byte of prefix being FF without overflowing
func PrefixEndBytes(prefix []byte) []byte {
return types.PrefixEndBytes(prefix)
}
// InclusiveEndBytes returns the []byte that would end a
// range query such that the input would be included
func InclusiveEndBytes(inclusiveBytes []byte) (exclusiveBytes []byte) {
return types.InclusiveEndBytes(inclusiveBytes)
}
//----------------------------------------
// key-value result for iterator queries
type KVPair = types.KVPair
//----------------------------------------
// TraceContext contains TraceKVStore context data. It will be written with
// every trace operation.
type TraceContext = types.TraceContext
// --------------------------------------
type (
Gas = types.Gas
GasMeter = types.GasMeter
GasConfig = types.GasConfig
)
type (
ErrorOutOfGas = types.ErrorOutOfGas
ErrorGasOverflow = types.ErrorGasOverflow
)
func NewGasMeter(limit Gas) GasMeter {
return types.NewGasMeter(limit)
}
func NewInfiniteGasMeter() GasMeter {
return types.NewInfiniteGasMeter()
}

View File

@ -1,58 +0,0 @@
package types
import (
"testing"
"github.com/cosmos/cosmos-sdk/store/types"
"github.com/stretchr/testify/suite"
)
type storeIntSuite struct {
suite.Suite
}
func TestStoreIntSuite(t *testing.T) {
suite.Run(t, new(storeIntSuite))
}
func (s *storeIntSuite) TestAssertNoPrefix() {
testCases := []struct {
keys []string
expectPanic bool
}{
{[]string{""}, false},
{[]string{"a"}, false},
{[]string{"a", "b"}, false},
{[]string{"a", "b1"}, false},
{[]string{"b2", "b1"}, false},
{[]string{"b1", "bb", "b2"}, false},
{[]string{"a", ""}, true},
{[]string{"a", "b", "a"}, true},
{[]string{"a", "b", "aa"}, true},
{[]string{"a", "b", "ab"}, true},
{[]string{"a", "b1", "bb", "b12"}, true},
}
require := s.Require()
for _, tc := range testCases {
if tc.expectPanic {
require.Panics(func() { assertNoPrefix(tc.keys) })
} else {
assertNoPrefix(tc.keys)
}
}
}
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]*types.KVStoreKey{}, NewKVStoreKeys())
require.Equal(1, len(NewKVStoreKeys("one")))
key := "baca"
stores := NewKVStoreKeys(key, "a")
require.Len(stores, 2)
require.Equal(key, stores[key].Name())
}

View File

@ -1,128 +0,0 @@
package types_test
import (
"testing"
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/suite"
"github.com/tendermint/tendermint/libs/log"
"github.com/cosmos/cosmos-sdk/store/metrics"
"github.com/cosmos/cosmos-sdk/store/rootmulti"
"github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
type storeTestSuite struct {
suite.Suite
}
func TestStoreTestSuite(t *testing.T) {
suite.Run(t, new(storeTestSuite))
}
func (s *storeTestSuite) SetupSuite() {
s.T().Parallel()
}
func (s *storeTestSuite) TestPrefixEndBytes() {
testCases := []struct {
prefix []byte
expected []byte
}{
{[]byte{byte(55), byte(255), byte(255), byte(0)}, []byte{byte(55), byte(255), byte(255), byte(1)}},
{[]byte{byte(55), byte(255), byte(255), byte(15)}, []byte{byte(55), byte(255), byte(255), byte(16)}},
{[]byte{byte(55), byte(200), byte(255)}, []byte{byte(55), byte(201)}},
{[]byte{byte(55), byte(255), byte(255)}, []byte{byte(56)}},
{[]byte{byte(255), byte(255), byte(255)}, nil},
{[]byte{byte(255)}, nil},
{nil, nil},
}
for _, test := range testCases {
end := types.PrefixEndBytes(test.prefix)
s.Require().Equal(test.expected, end)
}
}
func (s *storeTestSuite) TestCommitID() {
var empty types.CommitID
s.Require().True(empty.IsZero())
nonempty := types.CommitID{
Version: 1,
Hash: []byte("testhash"),
}
s.Require().False(nonempty.IsZero())
}
func (s *storeTestSuite) TestNewTransientStoreKeys() {
s.Require().Equal(map[string]*types.TransientStoreKey{}, sdk.NewTransientStoreKeys())
s.Require().Equal(1, len(sdk.NewTransientStoreKeys("one")))
}
func (s *storeTestSuite) TestNewInfiniteGasMeter() {
gm := sdk.NewInfiniteGasMeter()
s.Require().NotNil(gm)
_, ok := gm.(types.GasMeter) //nolint:gosimple
s.Require().True(ok)
}
func (s *storeTestSuite) TestStoreTypes() {
s.Require().Equal(sdk.InclusiveEndBytes([]byte("endbytes")), types.InclusiveEndBytes([]byte("endbytes")))
}
func (s *storeTestSuite) TestDiffKVStores() {
store1, store2 := s.initTestStores()
// Two equal stores
k1, v1 := []byte("k1"), []byte("v1")
store1.Set(k1, v1)
store2.Set(k1, v1)
s.checkDiffResults(store1, store2)
// delete k1 from store2, which is now empty
store2.Delete(k1)
s.checkDiffResults(store1, store2)
// set k1 in store2, different value than what store1 holds for k1
v2 := []byte("v2")
store2.Set(k1, v2)
s.checkDiffResults(store1, store2)
// add k2 to store2
k2 := []byte("k2")
store2.Set(k2, v2)
s.checkDiffResults(store1, store2)
// Reset stores
store1.Delete(k1)
store2.Delete(k1)
store2.Delete(k2)
// Same keys, different value. Comparisons will be nil as prefixes are skipped.
prefix := []byte("prefix:")
k1Prefixed := append(prefix, k1...) //nolint:gocritic // append is fine here
store1.Set(k1Prefixed, v1)
store2.Set(k1Prefixed, v2)
s.checkDiffResults(store1, store2)
}
func (s *storeTestSuite) initTestStores() (types.KVStore, types.KVStore) {
db := dbm.NewMemDB()
ms := rootmulti.NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics())
key1 := types.NewKVStoreKey("store1")
key2 := types.NewKVStoreKey("store2")
s.Require().NotPanics(func() { ms.MountStoreWithDB(key1, types.StoreTypeIAVL, db) })
s.Require().NotPanics(func() { ms.MountStoreWithDB(key2, types.StoreTypeIAVL, db) })
s.Require().NoError(ms.LoadLatestVersion())
return ms.GetKVStore(key1), ms.GetKVStore(key2)
}
func (s *storeTestSuite) checkDiffResults(store1, store2 types.KVStore) {
kvAs1, kvBs1 := sdk.DiffKVStores(store1, store2, nil)
kvAs2, kvBs2 := sdk.DiffKVStores(store1, store2, nil)
s.Require().Equal(kvAs1, kvAs2)
s.Require().Equal(kvBs1, kvBs2)
}

View File

@ -1,6 +1,7 @@
package ante
import (
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/tx/signing"
@ -15,7 +16,7 @@ type HandlerOptions struct {
ExtensionOptionChecker ExtensionOptionChecker
FeegrantKeeper FeegrantKeeper
SignModeHandler authsigning.SignModeHandler
SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params types.Params) error
SigGasConsumer func(meter storetypes.GasMeter, sig signing.SignatureV2, params types.Params) error
TxFeeChecker TxFeeChecker
}

View File

@ -15,6 +15,7 @@ import (
kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/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"
@ -1368,7 +1369,7 @@ func TestCustomSignatureVerificationGasConsumer(t *testing.T) {
BankKeeper: suite.bankKeeper,
FeegrantKeeper: suite.feeGrantKeeper,
SignModeHandler: suite.clientCtx.TxConfig.SignModeHandler(),
SigGasConsumer: func(meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.Params) error {
SigGasConsumer: func(meter storetypes.GasMeter, sig signing.SignatureV2, params authtypes.Params) error {
switch pubkey := sig.PubKey.(type) {
case *ed25519.PubKey:
meter.ConsumeGas(params.SigVerifyCostED25519, "ante verify: ed25519")

View File

@ -4,6 +4,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/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/types/tx/signing"
@ -93,7 +94,7 @@ func (cgts ConsumeTxSizeGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim
}
params := cgts.ak.GetParams(ctx)
ctx.GasMeter().ConsumeGas(params.TxSizeCostPerByte*sdk.Gas(len(ctx.TxBytes())), "txSize")
ctx.GasMeter().ConsumeGas(params.TxSizeCostPerByte*storetypes.Gas(len(ctx.TxBytes())), "txSize")
// simulate gas cost for signatures in simulate mode
if simulate {
@ -128,7 +129,7 @@ func (cgts ConsumeTxSizeGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim
}
sigBz := legacy.Cdc.MustMarshal(simSig)
cost := sdk.Gas(len(sigBz) + 6)
cost := storetypes.Gas(len(sigBz) + 6)
// If the pubkey is a multi-signature pubkey, then we estimate for the maximum
// number of signers.

View File

@ -6,6 +6,7 @@ import (
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/crypto/types/multisig"
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"
@ -129,7 +130,7 @@ func TestConsumeGasForTxSize(t *testing.T) {
require.Nil(t, err, "Cannot marshal tx: %v", err)
params := suite.accountKeeper.GetParams(suite.ctx)
expectedGas := sdk.Gas(len(txBytes)) * params.TxSizeCostPerByte
expectedGas := storetypes.Gas(len(txBytes)) * params.TxSizeCostPerByte
// Set suite.ctx with TxBytes manually
suite.ctx = suite.ctx.WithTxBytes(txBytes)

View File

@ -12,8 +12,8 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/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"
"github.com/cosmos/cosmos-sdk/types/simulation"
@ -183,7 +183,7 @@ func TestDeductFeesNoDelegation(t *testing.T) {
}
// don't consume any gas
func SigGasNoConsumer(meter sdk.GasMeter, sig []byte, pubkey crypto.PubKey, params authtypes.Params) error {
func SigGasNoConsumer(meter storetypes.GasMeter, sig []byte, pubkey crypto.PubKey, params authtypes.Params) error {
return nil
}

View File

@ -3,6 +3,7 @@ package ante
import (
"fmt"
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/migrations/legacytx"
@ -47,7 +48,7 @@ func (sud SetUpContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
defer func() {
if r := recover(); r != nil {
switch rType := r.(type) {
case sdk.ErrorOutOfGas:
case storetypes.ErrorOutOfGas:
log := fmt.Sprintf(
"out of gas in location: %v; gasWanted: %d, gasUsed: %d",
rType.Descriptor, gasTx.GetGas(), newCtx.GasMeter().GasConsumed())
@ -67,8 +68,8 @@ func SetGasMeter(simulate bool, ctx sdk.Context, gasLimit uint64) sdk.Context {
// In various cases such as simulation and during the genesis block, we do not
// meter any gas utilization.
if simulate || ctx.BlockHeight() == 0 {
return ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
return ctx.WithGasMeter(storetypes.NewInfiniteGasMeter())
}
return ctx.WithGasMeter(sdk.NewGasMeter(gasLimit))
return ctx.WithGasMeter(storetypes.NewGasMeter(gasLimit))
}

View File

@ -4,6 +4,7 @@ import (
"testing"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/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"
@ -34,7 +35,7 @@ func TestSetup(t *testing.T) {
antehandler := sdk.ChainAnteDecorators(sud)
// Set height to non-zero value for GasMeter to be set
suite.ctx = suite.ctx.WithBlockHeight(1).WithGasMeter(sdk.NewGasMeter(0))
suite.ctx = suite.ctx.WithBlockHeight(1).WithGasMeter(storetypes.NewGasMeter(0))
// Context GasMeter Limit not set
require.Equal(t, uint64(0), suite.ctx.GasMeter().Limit(), "GasMeter set with limit before setup")

View File

@ -12,6 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256r1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/crypto/types/multisig"
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/tx/signing"
@ -39,7 +40,7 @@ func init() {
// SignatureVerificationGasConsumer is the type of function that is used to both
// consume gas when verifying signatures and also to accept or reject different types of pubkeys
// This is where apps can define their own PubKey
type SignatureVerificationGasConsumer = func(meter sdk.GasMeter, sig signing.SignatureV2, params types.Params) error
type SignatureVerificationGasConsumer = func(meter storetypes.GasMeter, sig signing.SignatureV2, params types.Params) error
// SetPubKeyDecorator sets PubKeys in context for any signer which does not already have pubkey set
// PubKeys must be set in context for all signers before any other sigverify decorators run
@ -388,7 +389,7 @@ func (vscd ValidateSigCountDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim
// for signature verification based upon the public key type. The cost is fetched from the given params and is matched
// by the concrete type.
func DefaultSigVerificationGasConsumer(
meter sdk.GasMeter, sig signing.SignatureV2, params types.Params,
meter storetypes.GasMeter, sig signing.SignatureV2, params types.Params,
) error {
pubkey := sig.PubKey
switch pubkey := pubkey.(type) {
@ -422,7 +423,7 @@ func DefaultSigVerificationGasConsumer(
// ConsumeMultisignatureVerificationGas consumes gas from a GasMeter for verifying a multisig pubkey signature
func ConsumeMultisignatureVerificationGas(
meter sdk.GasMeter, sig *signing.MultiSignatureData, pubkey multisig.PubKey,
meter storetypes.GasMeter, sig *signing.MultiSignatureData, pubkey multisig.PubKey,
params types.Params, accSeq uint64,
) error {
size := sig.BitArray.Count()

View File

@ -12,6 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256r1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/crypto/types/multisig"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
@ -84,7 +85,7 @@ func TestConsumeSignatureVerificationGas(t *testing.T) {
}
type args struct {
meter sdk.GasMeter
meter storetypes.GasMeter
sig signing.SignatureData
pubkey cryptotypes.PubKey
params types.Params
@ -95,11 +96,11 @@ func TestConsumeSignatureVerificationGas(t *testing.T) {
gasConsumed uint64
shouldErr bool
}{
{"PubKeyEd25519", args{sdk.NewInfiniteGasMeter(), nil, ed25519.GenPrivKey().PubKey(), params}, p.SigVerifyCostED25519, true},
{"PubKeySecp256k1", args{sdk.NewInfiniteGasMeter(), nil, secp256k1.GenPrivKey().PubKey(), params}, p.SigVerifyCostSecp256k1, false},
{"PubKeySecp256r1", args{sdk.NewInfiniteGasMeter(), nil, skR1.PubKey(), params}, p.SigVerifyCostSecp256r1(), false},
{"Multisig", args{sdk.NewInfiniteGasMeter(), multisignature1, multisigKey1, params}, expectedCost1, false},
{"unknown key", args{sdk.NewInfiniteGasMeter(), nil, nil, params}, 0, true},
{"PubKeyEd25519", args{storetypes.NewInfiniteGasMeter(), nil, ed25519.GenPrivKey().PubKey(), params}, p.SigVerifyCostED25519, true},
{"PubKeySecp256k1", args{storetypes.NewInfiniteGasMeter(), nil, secp256k1.GenPrivKey().PubKey(), params}, p.SigVerifyCostSecp256k1, false},
{"PubKeySecp256r1", args{storetypes.NewInfiniteGasMeter(), nil, skR1.PubKey(), params}, p.SigVerifyCostSecp256r1(), false},
{"Multisig", args{storetypes.NewInfiniteGasMeter(), multisignature1, multisigKey1, params}, expectedCost1, false},
{"unknown key", args{storetypes.NewInfiniteGasMeter(), nil, nil, params}, 0, true},
}
for _, tt := range tests {
sigV2 := signing.SignatureV2{
@ -315,7 +316,7 @@ func TestSigIntegration(t *testing.T) {
require.Equal(t, initialSigCost*uint64(len(privs)), doubleCost-initialCost)
}
func runSigDecorators(t *testing.T, params types.Params, _ bool, privs ...cryptotypes.PrivKey) (sdk.Gas, error) {
func runSigDecorators(t *testing.T, params types.Params, _ bool, privs ...cryptotypes.PrivKey) (storetypes.Gas, error) {
suite := SetupTestSuite(t, true)
suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder()

View File

@ -9,16 +9,16 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/auth/keeper"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
antetestutil "github.com/cosmos/cosmos-sdk/x/auth/ante/testutil"
"github.com/cosmos/cosmos-sdk/x/auth/keeper"
xauthsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
authtestutil "github.com/cosmos/cosmos-sdk/x/auth/testutil"
"github.com/cosmos/cosmos-sdk/x/auth/types"
@ -50,8 +50,8 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite {
suite.feeGrantKeeper = antetestutil.NewMockFeegrantKeeper(ctrl)
key := sdk.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
suite.ctx = testCtx.Ctx.WithIsCheckTx(isCheckTx).WithBlockHeight(1) // app.BaseApp.NewContext(isCheckTx, tmproto.Header{}).WithBlockHeight(1)
suite.encCfg = moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{})

View File

@ -1,6 +1,7 @@
package keeper
import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/types"
)
@ -95,7 +96,7 @@ func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc sdk.AccountI) {
// Stops iteration when callback returns true.
func (ak AccountKeeper) IterateAccounts(ctx sdk.Context, cb func(account sdk.AccountI) (stop bool)) {
store := ctx.KVStore(ak.storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.AddressStoreKeyPrefix)
iterator := storetypes.KVStorePrefixIterator(store, types.AddressStoreKeyPrefix)
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {

View File

@ -46,8 +46,8 @@ func (suite *DeterministicTestSuite) SetupTest() {
suite.encCfg = moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{})
suite.Require()
key := sdk.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(suite.T(), key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test"))
suite.ctx = testCtx.Ctx.WithBlockHeader(tmproto.Header{})
maccPerms := map[string][]string{

View File

@ -10,6 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -43,8 +44,8 @@ type KeeperTestSuite struct {
func (suite *KeeperTestSuite) SetupTest() {
suite.encCfg = moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{})
key := sdk.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(suite.T(), key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test"))
suite.ctx = testCtx.Ctx.WithBlockHeader(tmproto.Header{})
maccPerms := map[string][]string{

View File

@ -8,6 +8,7 @@ import (
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -43,8 +44,8 @@ func TestMigrateVestingAccounts(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{})
cdc := encCfg.Codec
storeKey := sdk.NewKVStoreKey(v1.ModuleName)
tKey := sdk.NewTransientStoreKey("transient_test")
storeKey := storetypes.NewKVStoreKey(v1.ModuleName)
tKey := storetypes.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(storeKey, tKey)
store := ctx.KVStore(storeKey)

View File

@ -9,7 +9,7 @@ import (
func mapAccountAddressToAccountID(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error {
store := ctx.KVStore(storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.AddressStoreKeyPrefix)
iterator := storetypes.KVStorePrefixIterator(store, types.AddressStoreKeyPrefix)
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {

View File

@ -9,6 +9,7 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -39,8 +40,8 @@ func TestMigrateMapAccAddressToAccNumberKey(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{})
cdc := encCfg.Codec
storeKey := sdk.NewKVStoreKey(v1.ModuleName)
tKey := sdk.NewTransientStoreKey("transient_test")
storeKey := storetypes.NewKVStoreKey(v1.ModuleName)
tKey := storetypes.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(storeKey, tKey)
store := ctx.KVStore(storeKey)

View File

@ -2,6 +2,7 @@ package v4
import (
"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/auth/exported"
"github.com/cosmos/cosmos-sdk/x/auth/types"
@ -13,7 +14,7 @@ var ParamsKey = []byte{0x01}
// version 4. Specifically, it takes the parameters that are currently stored
// and managed by the x/params modules and stores them directly into the x/auth
// module state.
func Migrate(ctx sdk.Context, store sdk.KVStore, legacySubspace exported.Subspace, cdc codec.BinaryCodec) error {
func Migrate(ctx sdk.Context, store storetypes.KVStore, legacySubspace exported.Subspace, cdc codec.BinaryCodec) error {
var currParams types.Params
legacySubspace.GetParamSet(ctx, &currParams)

View File

@ -5,6 +5,7 @@ import (
"github.com/stretchr/testify/require"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -31,8 +32,8 @@ func TestMigrate(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{})
cdc := encCfg.Codec
storeKey := sdk.NewKVStoreKey(v1.ModuleName)
tKey := sdk.NewTransientStoreKey("transient_test")
storeKey := storetypes.NewKVStoreKey(v1.ModuleName)
tKey := storetypes.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(storeKey, tKey)
store := ctx.KVStore(storeKey)

View File

@ -184,7 +184,7 @@ func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.We
}
// RegisterStoreDecoder registers a decoder for auth module's types
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
func (am AppModule) RegisterStoreDecoder(sdr store.StoreDecoderRegistry) {
sdr[types.StoreKey] = simulation.NewDecodeStore(am.accountKeeper)
}

View File

@ -8,13 +8,13 @@ import (
kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/crypto/types/multisig"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/testutil"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/auth/keeper"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
@ -32,7 +32,7 @@ func TestVerifySignature(t *testing.T) {
)
encCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{})
key := sdk.NewKVStoreKey(types.StoreKey)
key := storetypes.NewKVStoreKey(types.StoreKey)
maccPerms := map[string][]string{
"fee_collector": nil,
@ -52,7 +52,7 @@ func TestVerifySignature(t *testing.T) {
types.NewModuleAddress("gov").String(),
)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{})
encCfg.Amino.RegisterConcrete(testdata.TestMsg{}, "cosmos-sdk/Test", nil)

View File

@ -9,6 +9,7 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtime "github.com/tendermint/tendermint/types/time"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -38,8 +39,8 @@ type VestingTestSuite struct {
}
func (s *VestingTestSuite) SetupTest() {
key := sdk.NewKVStoreKey(authtypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(authtypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
s.ctx = testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: tmtime.Now()})
encCfg := moduletestutil.MakeTestEncodingConfig()

View File

@ -10,6 +10,7 @@ import (
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -35,8 +36,8 @@ type VestingAccountTestSuite struct {
func (s *VestingAccountTestSuite) SetupTest() {
encCfg := moduletestutil.MakeTestEncodingConfig(vesting.AppModuleBasic{})
key := sdk.NewKVStoreKey(authtypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(authtypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
s.ctx = testCtx.Ctx.WithBlockHeader(tmproto.Header{})
maccPerms := map[string][]string{

View File

@ -10,6 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -31,8 +32,8 @@ type GenesisTestSuite struct {
}
func (suite *GenesisTestSuite) SetupTest() {
key := sdk.NewKVStoreKey(keeper.StoreKey)
testCtx := testutil.DefaultContextWithDB(suite.T(), key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(keeper.StoreKey)
testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test"))
suite.ctx = testCtx.Ctx.WithBlockHeader(tmproto.Header{Height: 1})
suite.encCfg = moduletestutil.MakeTestEncodingConfig(authzmodule.AppModuleBasic{})

View File

@ -231,7 +231,7 @@ func (k Keeper) DeleteGrant(ctx sdk.Context, grantee sdk.AccAddress, granter sdk
func (k Keeper) GetAuthorizations(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccAddress) ([]authz.Authorization, error) {
store := ctx.KVStore(k.storeKey)
key := grantStoreKey(grantee, granter, "")
iter := sdk.KVStorePrefixIterator(store, key)
iter := storetypes.KVStorePrefixIterator(store, key)
defer iter.Close()
var authorization authz.Grant
@ -279,7 +279,7 @@ func (k Keeper) IterateGrants(ctx sdk.Context,
handler func(granterAddr sdk.AccAddress, granteeAddr sdk.AccAddress, grant authz.Grant) bool,
) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, GrantKey)
iter := storetypes.KVStorePrefixIterator(store, GrantKey)
defer iter.Close()
for ; iter.Valid(); iter.Next() {
var grant authz.Grant
@ -378,7 +378,7 @@ func (k Keeper) removeFromGrantQueue(ctx sdk.Context, grantKey []byte, granter,
func (k Keeper) DequeueAndDeleteExpiredGrants(ctx sdk.Context) error {
store := ctx.KVStore(k.storeKey)
iterator := store.Iterator(GrantQueuePrefix, sdk.InclusiveEndBytes(GrantQueueTimePrefix(ctx.BlockTime())))
iterator := store.Iterator(GrantQueuePrefix, storetypes.InclusiveEndBytes(GrantQueueTimePrefix(ctx.BlockTime())))
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {

View File

@ -10,6 +10,7 @@ import (
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/cosmos/cosmos-sdk/baseapp"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -44,8 +45,8 @@ type TestSuite struct {
}
func (s *TestSuite) SetupTest() {
key := sdk.NewKVStoreKey(authzkeeper.StoreKey)
testCtx := testutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(authzkeeper.StoreKey)
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
s.ctx = testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: tmtime.Now()})
s.encCfg = moduletestutil.MakeTestEncodingConfig(authzmodule.AppModuleBasic{})

View File

@ -8,6 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/authz"
@ -22,8 +23,8 @@ func TestMigration(t *testing.T) {
var cdc codec.Codec
depinject.Inject(authztestutil.AppConfig, &cdc)
authzKey := sdk.NewKVStoreKey("authz")
ctx := testutil.DefaultContext(authzKey, sdk.NewTransientStoreKey("transient_test"))
authzKey := storetypes.NewKVStoreKey("authz")
ctx := testutil.DefaultContext(authzKey, storetypes.NewTransientStoreKey("transient_test"))
granter1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address())
grantee1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address())
granter2 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address())

View File

@ -5,6 +5,7 @@ import (
"time"
"github.com/cosmos/cosmos-sdk/baseapp"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -15,16 +16,17 @@ import (
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
authztestutil "github.com/cosmos/cosmos-sdk/x/authz/testutil"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/proto/tendermint/types"
)
func TestExpiredGrantsQueue(t *testing.T) {
key := sdk.NewKVStoreKey(keeper.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(keeper.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(authzmodule.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(types.Header{})

View File

@ -213,7 +213,7 @@ func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes
}
// RegisterStoreDecoder registers a decoder for authz module's types
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
func (am AppModule) RegisterStoreDecoder(sdr store.StoreDecoderRegistry) {
sdr[keeper.StoreKey] = simulation.NewDecodeStore(am.cdc)
}

View File

@ -14,6 +14,7 @@ import (
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/cosmos/cosmos-sdk/baseapp"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -85,8 +86,8 @@ func TestKeeperTestSuite(t *testing.T) {
}
func (suite *KeeperTestSuite) SetupTest() {
key := sdk.NewKVStoreKey(banktypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(suite.T(), key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(banktypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test"))
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: tmtime.Now()})
encCfg := moduletestutil.MakeTestEncodingConfig()
@ -199,7 +200,7 @@ func (suite *KeeperTestSuite) TestGetAuthority() {
NewKeeperWithAuthority := func(authority string) keeper.BaseKeeper {
return keeper.NewBaseKeeper(
moduletestutil.MakeTestEncodingConfig().Codec,
sdk.NewKVStoreKey(banktypes.StoreKey),
storetypes.NewKVStoreKey(banktypes.StoreKey),
nil,
nil,
authority,

View File

@ -431,7 +431,7 @@ func (k BaseSendKeeper) SetAllSendEnabled(ctx sdk.Context, entries []*types.Send
}
// setSendEnabledEntry sets SendEnabled for the given denom to the give value in the provided store.
func (k BaseSendKeeper) setSendEnabledEntry(store sdk.KVStore, denom string, value bool) {
func (k BaseSendKeeper) setSendEnabledEntry(store storetypes.KVStore, denom string, value bool) {
key := types.CreateSendEnabledKey(denom)
bz := k.cdc.MustMarshal(&gogotypes.BoolValue{Value: value})
@ -448,7 +448,7 @@ func (k BaseSendKeeper) DeleteSendEnabled(ctx sdk.Context, denoms ...string) {
}
// getSendEnabledPrefixStore gets a prefix store for the SendEnabled entries.
func (k BaseSendKeeper) getSendEnabledPrefixStore(ctx sdk.Context) sdk.KVStore {
func (k BaseSendKeeper) getSendEnabledPrefixStore(ctx sdk.Context) storetypes.KVStore {
return prefix.NewStore(ctx.KVStore(k.storeKey), types.SendEnabledPrefix)
}
@ -493,7 +493,7 @@ func (k BaseSendKeeper) GetAllSendEnabledEntries(ctx sdk.Context) []types.SendEn
// if !found {
// sendEnabled = DefaultSendEnabled
// }
func (k BaseSendKeeper) getSendEnabled(store sdk.KVStore, denom string) (bool, bool) {
func (k BaseSendKeeper) getSendEnabled(store storetypes.KVStore, denom string) (bool, bool) {
key := types.CreateSendEnabledKey(denom)
if !store.Has(key) {
return false, false
@ -512,7 +512,7 @@ func (k BaseSendKeeper) getSendEnabled(store sdk.KVStore, denom string) (bool, b
// getSendEnabledOrDefault gets the SendEnabled value for a denom. If it's not
// in the store, this will return defaultVal.
func (k BaseSendKeeper) getSendEnabledOrDefault(store sdk.KVStore, denom string, defaultVal bool) bool {
func (k BaseSendKeeper) getSendEnabledOrDefault(store storetypes.KVStore, denom string, defaultVal bool) bool {
sendEnabled, found := k.getSendEnabled(store, denom)
if found {
return sendEnabled

View File

@ -15,7 +15,7 @@ import (
// migrateSupply migrates the supply to be stored by denom key instead in a
// single blob.
// ref: https://github.com/cosmos/cosmos-sdk/issues/7092
func migrateSupply(store sdk.KVStore, cdc codec.BinaryCodec) error {
func migrateSupply(store storetypes.KVStore, cdc codec.BinaryCodec) error {
// Old supply was stored as a single blob under the SupplyKey.
var oldSupplyI v1.SupplyI
err := cdc.UnmarshalInterface(store.Get(v1.SupplyKey), &oldSupplyI)
@ -51,7 +51,7 @@ func migrateSupply(store sdk.KVStore, cdc codec.BinaryCodec) error {
// migrateBalanceKeys migrate the balances keys to cater for variable-length
// addresses.
func migrateBalanceKeys(store sdk.KVStore, logger log.Logger) {
func migrateBalanceKeys(store storetypes.KVStore, logger log.Logger) {
// old key is of format:
// prefix ("balances") || addrBytes (20 bytes) || denomBytes
// new key is of format
@ -95,7 +95,7 @@ func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Binar
}
// pruneZeroBalances removes the zero balance addresses from balances store.
func pruneZeroBalances(store sdk.KVStore, cdc codec.BinaryCodec) error {
func pruneZeroBalances(store storetypes.KVStore, cdc codec.BinaryCodec) error {
balancesStore := prefix.NewStore(store, BalancesPrefix)
iterator := balancesStore.Iterator(nil, nil)
defer iterator.Close()
@ -114,7 +114,7 @@ func pruneZeroBalances(store sdk.KVStore, cdc codec.BinaryCodec) error {
}
// pruneZeroSupply removes zero balance denom from supply store.
func pruneZeroSupply(store sdk.KVStore) error {
func pruneZeroSupply(store storetypes.KVStore) error {
supplyStore := prefix.NewStore(store, SupplyKey)
iterator := supplyStore.Iterator(nil, nil)
defer iterator.Close()

View File

@ -7,6 +7,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/store/prefix"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -18,8 +19,8 @@ import (
func TestSupplyMigration(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig()
bankKey := sdk.NewKVStoreKey("bank")
ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test"))
bankKey := storetypes.NewKVStoreKey("bank")
ctx := testutil.DefaultContext(bankKey, storetypes.NewTransientStoreKey("transient_test"))
store := ctx.KVStore(bankKey)
v1bank.RegisterInterfaces(encCfg.InterfaceRegistry)
@ -68,8 +69,8 @@ func TestSupplyMigration(t *testing.T) {
func TestBalanceKeysMigration(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig()
bankKey := sdk.NewKVStoreKey("bank")
ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test"))
bankKey := storetypes.NewKVStoreKey("bank")
ctx := testutil.DefaultContext(bankKey, storetypes.NewTransientStoreKey("transient_test"))
store := ctx.KVStore(bankKey)
_, _, addr := testdata.KeyTestPubAddr()

View File

@ -27,7 +27,7 @@ func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Binar
return migrateDenomMetadata(store, ctx.Logger())
}
func addDenomReverseIndex(store sdk.KVStore, cdc codec.BinaryCodec, logger log.Logger) error {
func addDenomReverseIndex(store storetypes.KVStore, cdc codec.BinaryCodec, logger log.Logger) error {
oldBalancesStore := prefix.NewStore(store, v2.BalancesPrefix)
oldBalancesIter := oldBalancesStore.Iterator(nil, nil)
@ -73,7 +73,7 @@ func addDenomReverseIndex(store sdk.KVStore, cdc codec.BinaryCodec, logger log.L
return nil
}
func migrateDenomMetadata(store sdk.KVStore, logger log.Logger) error {
func migrateDenomMetadata(store storetypes.KVStore, logger log.Logger) error {
oldDenomMetaDataStore := prefix.NewStore(store, v2.DenomMetadataPrefix)
oldDenomMetaDataIter := oldDenomMetaDataStore.Iterator(nil, nil)

View File

@ -3,11 +3,11 @@ package v3_test
import (
"testing"
"cosmossdk.io/math"
"github.com/stretchr/testify/require"
"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/store/prefix"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
@ -19,8 +19,8 @@ import (
func TestMigrateStore(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig()
bankKey := sdk.NewKVStoreKey("bank")
ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test"))
bankKey := storetypes.NewKVStoreKey("bank")
ctx := testutil.DefaultContext(bankKey, storetypes.NewTransientStoreKey("transient_test"))
store := ctx.KVStore(bankKey)
addr := sdk.AccAddress([]byte("addr________________"))
@ -57,8 +57,8 @@ func TestMigrateStore(t *testing.T) {
func TestMigrateDenomMetaData(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig()
bankKey := sdk.NewKVStoreKey("bank")
ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test"))
bankKey := storetypes.NewKVStoreKey("bank")
ctx := testutil.DefaultContext(bankKey, storetypes.NewTransientStoreKey("transient_test"))
store := ctx.KVStore(bankKey)
metaData := []types.Metadata{
{

View File

@ -3,6 +3,7 @@ package v4_test
import (
"testing"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -29,8 +30,8 @@ func TestMigrate(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig(bank.AppModuleBasic{})
cdc := encCfg.Codec
storeKey := sdk.NewKVStoreKey(v4.ModuleName)
tKey := sdk.NewTransientStoreKey("transient_test")
storeKey := storetypes.NewKVStoreKey(v4.ModuleName)
tKey := storetypes.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(storeKey, tKey)
store := ctx.KVStore(storeKey)

View File

@ -188,7 +188,7 @@ func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedP
}
// RegisterStoreDecoder registers a decoder for supply module's types
func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {}
func (am AppModule) RegisterStoreDecoder(_ store.StoreDecoderRegistry) {}
// WeightedOperations returns the all the gov module operations with their respective weights.
func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {

View File

@ -7,6 +7,7 @@ import (
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank/types"
@ -21,7 +22,7 @@ var (
)
func TestSendAuthorization(t *testing.T) {
ctx := testutil.DefaultContextWithDB(t, sdk.NewKVStoreKey(types.StoreKey), sdk.NewTransientStoreKey("transient_test")).Ctx.WithBlockHeader(tmproto.Header{})
ctx := testutil.DefaultContextWithDB(t, storetypes.NewKVStoreKey(types.StoreKey), storetypes.NewTransientStoreKey("transient_test")).Ctx.WithBlockHeader(tmproto.Header{})
allowList := make([]sdk.AccAddress, 1)
allowList[0] = toAddr
authorization := types.NewSendAuthorization(coins1000, nil)

View File

@ -68,7 +68,7 @@ func (suite *CapabilityTestSuite) TestInitializeMemStore() {
suite.Require().False(newKeeper.IsInitialized(ctx), "memstore initialized flag set before BeginBlock")
// Mock app beginblock and ensure that no gas has been consumed and memstore is initialized
ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{}).WithBlockGasMeter(sdk.NewGasMeter(50))
ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{}).WithBlockGasMeter(storetypes.NewGasMeter(50))
prevGas := ctx.BlockGasMeter().GasConsumed()
restartedModule := capability.NewAppModule(suite.cdc, *newKeeper, true)
restartedModule.BeginBlock(ctx, abci.RequestBeginBlock{})

View File

@ -3,8 +3,8 @@ package capability_test
import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/capability"
"github.com/cosmos/cosmos-sdk/x/capability/keeper"
@ -37,7 +37,7 @@ func (suite *CapabilityTestSuite) TestGenesis() {
newSk1 := newKeeper.ScopeToModule(banktypes.ModuleName)
newSk2 := newKeeper.ScopeToModule(stakingtypes.ModuleName)
deliverCtx, _ := newApp.BaseApp.NewUncachedContext(false, tmproto.Header{}).WithBlockGasMeter(sdk.NewInfiniteGasMeter()).CacheContext()
deliverCtx, _ := newApp.BaseApp.NewUncachedContext(false, tmproto.Header{}).WithBlockGasMeter(storetypes.NewInfiniteGasMeter()).CacheContext()
capability.InitGenesis(deliverCtx, *newKeeper, *genState)

View File

@ -119,12 +119,12 @@ func (k *Keeper) InitMemStore(ctx sdk.Context) {
}
// create context with no block gas meter to ensure we do not consume gas during local initialization logic.
noGasCtx := ctx.WithBlockGasMeter(sdk.NewInfiniteGasMeter())
noGasCtx := ctx.WithBlockGasMeter(storetypes.NewInfiniteGasMeter())
// check if memory store has not been initialized yet by checking if initialized flag is nil.
if !k.IsInitialized(noGasCtx) {
prefixStore := prefix.NewStore(noGasCtx.KVStore(k.storeKey), types.KeyPrefixIndexCapability)
iterator := sdk.KVStorePrefixIterator(prefixStore, nil)
iterator := storetypes.KVStorePrefixIterator(prefixStore, nil)
// initialize the in-memory store for all persisted capabilities
defer iterator.Close()

View File

@ -6,6 +6,7 @@ import (
"github.com/stretchr/testify/suite"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -27,8 +28,8 @@ type KeeperTestSuite struct {
}
func (suite *KeeperTestSuite) SetupTest() {
key := sdk.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(suite.T(), key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test"))
suite.ctx = testCtx.Ctx
encCfg := moduletestutil.MakeTestEncodingConfig(capability.AppModuleBasic{})
suite.keeper = keeper.NewKeeper(encCfg.Codec, key, key)

View File

@ -168,7 +168,7 @@ func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes
}
// RegisterStoreDecoder registers a decoder for capability module's types
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
func (am AppModule) RegisterStoreDecoder(sdr store.StoreDecoderRegistry) {
sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc)
}

View File

@ -7,6 +7,7 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/baseapp"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -26,8 +27,8 @@ type KeeperTestSuite struct {
}
func (s *KeeperTestSuite) SetupTest() {
key := sdk.NewKVStoreKey(consensusparamtypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(consensusparamtypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{})
encCfg := moduletestutil.MakeTestEncodingConfig()

View File

@ -7,6 +7,7 @@ import (
"github.com/stretchr/testify/suite"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -29,8 +30,8 @@ func TestGenesisTestSuite(t *testing.T) {
}
func (s *GenesisTestSuite) SetupTest() {
key := sdk.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(crisis.AppModuleBasic{})
// gomock initializations

View File

@ -6,6 +6,7 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -19,8 +20,8 @@ func TestLogger(t *testing.T) {
ctrl := gomock.NewController(t)
supplyKeeper := crisistestutil.NewMockSupplyKeeper(ctrl)
key := sdk.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(crisis.AppModuleBasic{})
keeper := keeper.NewKeeper(encCfg.Codec, key, 5, supplyKeeper, "", "")
@ -33,7 +34,7 @@ func TestInvariants(t *testing.T) {
ctrl := gomock.NewController(t)
supplyKeeper := crisistestutil.NewMockSupplyKeeper(ctrl)
key := sdk.NewKVStoreKey(types.StoreKey)
key := storetypes.NewKVStoreKey(types.StoreKey)
encCfg := moduletestutil.MakeTestEncodingConfig(crisis.AppModuleBasic{})
keeper := keeper.NewKeeper(encCfg.Codec, key, 5, supplyKeeper, "", "")
require.Equal(t, keeper.InvCheckPeriod(), uint(5))
@ -48,8 +49,8 @@ func TestAssertInvariants(t *testing.T) {
ctrl := gomock.NewController(t)
supplyKeeper := crisistestutil.NewMockSupplyKeeper(ctrl)
key := sdk.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(crisis.AppModuleBasic{})
keeper := keeper.NewKeeper(encCfg.Codec, key, 5, supplyKeeper, "", "")

View File

@ -6,6 +6,7 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/suite"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -28,8 +29,8 @@ func (s *KeeperTestSuite) SetupTest() {
ctrl := gomock.NewController(s.T())
supplyKeeper := crisistestutil.NewMockSupplyKeeper(ctrl)
key := sdk.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(crisis.AppModuleBasic{})
keeper := keeper.NewKeeper(encCfg.Codec, key, 5, supplyKeeper, "", "")

View File

@ -5,6 +5,7 @@ import (
"github.com/stretchr/testify/require"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -27,8 +28,8 @@ func (ms mockSubspace) Get(ctx sdk.Context, key []byte, ptr interface{}) {
func TestMigrate(t *testing.T) {
cdc := moduletestutil.MakeTestEncodingConfig(crisis.AppModuleBasic{}).Codec
storeKey := sdk.NewKVStoreKey(v2.ModuleName)
tKey := sdk.NewTransientStoreKey("transient_test")
storeKey := storetypes.NewKVStoreKey(v2.ModuleName)
tKey := storetypes.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(storeKey, tKey)
store := ctx.KVStore(storeKey)

View File

@ -10,6 +10,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -23,8 +24,8 @@ import (
func TestAllocateTokensToValidatorWithCommission(t *testing.T) {
ctrl := gomock.NewController(t)
key := sdk.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: time.Now()})
@ -68,8 +69,8 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) {
func TestAllocateTokensToManyValidators(t *testing.T) {
ctrl := gomock.NewController(t)
key := sdk.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: time.Now()})
@ -166,8 +167,8 @@ func TestAllocateTokensToManyValidators(t *testing.T) {
func TestAllocateTokensTruncation(t *testing.T) {
ctrl := gomock.NewController(t)
key := sdk.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: time.Now()})

View File

@ -8,7 +8,7 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"cosmossdk.io/math"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -22,8 +22,8 @@ import (
func TestCalculateRewardsBasic(t *testing.T) {
ctrl := gomock.NewController(t)
key := sdk.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Height: 1})
@ -100,8 +100,8 @@ func TestCalculateRewardsBasic(t *testing.T) {
func TestCalculateRewardsAfterSlash(t *testing.T) {
ctrl := gomock.NewController(t)
key := sdk.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Height: 1})
@ -195,8 +195,8 @@ func TestCalculateRewardsAfterSlash(t *testing.T) {
func TestCalculateRewardsAfterManySlashes(t *testing.T) {
ctrl := gomock.NewController(t)
key := sdk.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Height: 1})
@ -310,8 +310,8 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) {
func TestCalculateRewardsMultiDelegator(t *testing.T) {
ctrl := gomock.NewController(t)
key := sdk.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Height: 1})
@ -400,8 +400,8 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) {
func TestWithdrawDelegationRewardsBasic(t *testing.T) {
ctrl := gomock.NewController(t)
key := sdk.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Height: 1})
@ -472,8 +472,8 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) {
func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) {
ctrl := gomock.NewController(t)
key := sdk.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Height: 1})
@ -579,8 +579,8 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) {
func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {
ctrl := gomock.NewController(t)
key := sdk.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Height: 1})
@ -706,8 +706,8 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {
func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) {
ctrl := gomock.NewController(t)
key := sdk.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Height: 1})
@ -889,8 +889,8 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) {
func Test100PercentCommissionReward(t *testing.T) {
ctrl := gomock.NewController(t)
key := sdk.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(disttypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Height: 1})

View File

@ -9,6 +9,7 @@ import (
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -22,8 +23,8 @@ import (
func TestSetWithdrawAddr(t *testing.T) {
ctrl := gomock.NewController(t)
key := sdk.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: time.Now()})
addrs := simtestutil.CreateIncrementalAccounts(2)
@ -68,8 +69,8 @@ func TestSetWithdrawAddr(t *testing.T) {
func TestWithdrawValidatorCommission(t *testing.T) {
ctrl := gomock.NewController(t)
key := sdk.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: time.Now()})
addrs := simtestutil.CreateIncrementalAccounts(1)
@ -123,8 +124,8 @@ func TestWithdrawValidatorCommission(t *testing.T) {
func TestGetTotalRewards(t *testing.T) {
ctrl := gomock.NewController(t)
key := sdk.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: time.Now()})
addrs := simtestutil.CreateIncrementalAccounts(2)
@ -164,8 +165,8 @@ func TestGetTotalRewards(t *testing.T) {
func TestFundCommunityPool(t *testing.T) {
ctrl := gomock.NewController(t)
key := sdk.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: time.Now()})
addrs := simtestutil.CreateIncrementalAccounts(1)

View File

@ -3,6 +3,7 @@ package keeper_test
import (
"testing"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -18,8 +19,8 @@ import (
func TestParams(t *testing.T) {
ctrl := gomock.NewController(t)
key := sdk.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Height: 1})

View File

@ -3,6 +3,7 @@ package keeper
import (
gogotypes "github.com/cosmos/gogoproto/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
)
@ -32,7 +33,7 @@ func (k Keeper) DeleteDelegatorWithdrawAddr(ctx sdk.Context, delAddr, withdrawAd
// iterate over delegator withdraw addrs
func (k Keeper) IterateDelegatorWithdrawAddrs(ctx sdk.Context, handler func(del sdk.AccAddress, addr sdk.AccAddress) (stop bool)) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.DelegatorWithdrawAddrPrefix)
iter := storetypes.KVStorePrefixIterator(store, types.DelegatorWithdrawAddrPrefix)
defer iter.Close()
for ; iter.Valid(); iter.Next() {
addr := sdk.AccAddress(iter.Value())
@ -112,7 +113,7 @@ func (k Keeper) DeleteDelegatorStartingInfo(ctx sdk.Context, val sdk.ValAddress,
// iterate over delegator starting infos
func (k Keeper) IterateDelegatorStartingInfos(ctx sdk.Context, handler func(val sdk.ValAddress, del sdk.AccAddress, info types.DelegatorStartingInfo) (stop bool)) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.DelegatorStartingInfoPrefix)
iter := storetypes.KVStorePrefixIterator(store, types.DelegatorStartingInfoPrefix)
defer iter.Close()
for ; iter.Valid(); iter.Next() {
var info types.DelegatorStartingInfo
@ -142,7 +143,7 @@ func (k Keeper) SetValidatorHistoricalRewards(ctx sdk.Context, val sdk.ValAddres
// iterate over historical rewards
func (k Keeper) IterateValidatorHistoricalRewards(ctx sdk.Context, handler func(val sdk.ValAddress, period uint64, rewards types.ValidatorHistoricalRewards) (stop bool)) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.ValidatorHistoricalRewardsPrefix)
iter := storetypes.KVStorePrefixIterator(store, types.ValidatorHistoricalRewardsPrefix)
defer iter.Close()
for ; iter.Valid(); iter.Next() {
var rewards types.ValidatorHistoricalRewards
@ -163,7 +164,7 @@ func (k Keeper) DeleteValidatorHistoricalReward(ctx sdk.Context, val sdk.ValAddr
// delete historical rewards for a validator
func (k Keeper) DeleteValidatorHistoricalRewards(ctx sdk.Context, val sdk.ValAddress) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.GetValidatorHistoricalRewardsPrefix(val))
iter := storetypes.KVStorePrefixIterator(store, types.GetValidatorHistoricalRewardsPrefix(val))
defer iter.Close()
for ; iter.Valid(); iter.Next() {
store.Delete(iter.Key())
@ -173,7 +174,7 @@ func (k Keeper) DeleteValidatorHistoricalRewards(ctx sdk.Context, val sdk.ValAdd
// delete all historical rewards
func (k Keeper) DeleteAllValidatorHistoricalRewards(ctx sdk.Context) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.ValidatorHistoricalRewardsPrefix)
iter := storetypes.KVStorePrefixIterator(store, types.ValidatorHistoricalRewardsPrefix)
defer iter.Close()
for ; iter.Valid(); iter.Next() {
store.Delete(iter.Key())
@ -183,7 +184,7 @@ func (k Keeper) DeleteAllValidatorHistoricalRewards(ctx sdk.Context) {
// historical reference count (used for testcases)
func (k Keeper) GetValidatorHistoricalReferenceCount(ctx sdk.Context) (count uint64) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.ValidatorHistoricalRewardsPrefix)
iter := storetypes.KVStorePrefixIterator(store, types.ValidatorHistoricalRewardsPrefix)
defer iter.Close()
for ; iter.Valid(); iter.Next() {
var rewards types.ValidatorHistoricalRewards
@ -217,7 +218,7 @@ func (k Keeper) DeleteValidatorCurrentRewards(ctx sdk.Context, val sdk.ValAddres
// iterate over current rewards
func (k Keeper) IterateValidatorCurrentRewards(ctx sdk.Context, handler func(val sdk.ValAddress, rewards types.ValidatorCurrentRewards) (stop bool)) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.ValidatorCurrentRewardsPrefix)
iter := storetypes.KVStorePrefixIterator(store, types.ValidatorCurrentRewardsPrefix)
defer iter.Close()
for ; iter.Valid(); iter.Next() {
var rewards types.ValidatorCurrentRewards
@ -263,7 +264,7 @@ func (k Keeper) DeleteValidatorAccumulatedCommission(ctx sdk.Context, val sdk.Va
// iterate over accumulated commissions
func (k Keeper) IterateValidatorAccumulatedCommissions(ctx sdk.Context, handler func(val sdk.ValAddress, commission types.ValidatorAccumulatedCommission) (stop bool)) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.ValidatorAccumulatedCommissionPrefix)
iter := storetypes.KVStorePrefixIterator(store, types.ValidatorAccumulatedCommissionPrefix)
defer iter.Close()
for ; iter.Valid(); iter.Next() {
var commission types.ValidatorAccumulatedCommission
@ -299,7 +300,7 @@ func (k Keeper) DeleteValidatorOutstandingRewards(ctx sdk.Context, val sdk.ValAd
// iterate validator outstanding rewards
func (k Keeper) IterateValidatorOutstandingRewards(ctx sdk.Context, handler func(val sdk.ValAddress, rewards types.ValidatorOutstandingRewards) (stop bool)) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.ValidatorOutstandingRewardsPrefix)
iter := storetypes.KVStorePrefixIterator(store, types.ValidatorOutstandingRewardsPrefix)
defer iter.Close()
for ; iter.Valid(); iter.Next() {
rewards := types.ValidatorOutstandingRewards{}
@ -352,7 +353,7 @@ func (k Keeper) IterateValidatorSlashEventsBetween(ctx sdk.Context, val sdk.ValA
// iterate over all slash events
func (k Keeper) IterateValidatorSlashEvents(ctx sdk.Context, handler func(val sdk.ValAddress, height uint64, event types.ValidatorSlashEvent) (stop bool)) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.ValidatorSlashEventPrefix)
iter := storetypes.KVStorePrefixIterator(store, types.ValidatorSlashEventPrefix)
defer iter.Close()
for ; iter.Valid(); iter.Next() {
var event types.ValidatorSlashEvent
@ -367,7 +368,7 @@ func (k Keeper) IterateValidatorSlashEvents(ctx sdk.Context, handler func(val sd
// delete slash events for a particular validator
func (k Keeper) DeleteValidatorSlashEvents(ctx sdk.Context, val sdk.ValAddress) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.GetValidatorSlashEventPrefix(val))
iter := storetypes.KVStorePrefixIterator(store, types.GetValidatorSlashEventPrefix(val))
defer iter.Close()
for ; iter.Valid(); iter.Next() {
store.Delete(iter.Key())
@ -377,7 +378,7 @@ func (k Keeper) DeleteValidatorSlashEvents(ctx sdk.Context, val sdk.ValAddress)
// delete all slash events
func (k Keeper) DeleteAllValidatorSlashEvents(ctx sdk.Context) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.ValidatorSlashEventPrefix)
iter := storetypes.KVStorePrefixIterator(store, types.ValidatorSlashEventPrefix)
defer iter.Close()
for ; iter.Valid(); iter.Next() {
store.Delete(iter.Key())

View File

@ -2,7 +2,7 @@ package v2
import (
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/types/address"
v1auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v1"
)
@ -11,7 +11,7 @@ import (
// prefix_bytes | address_bytes
// into format:
// prefix_bytes | address_len (1 byte) | address_bytes
func MigratePrefixAddress(store sdk.KVStore, prefixBz []byte) {
func MigratePrefixAddress(store storetypes.KVStore, prefixBz []byte) {
oldStore := prefix.NewStore(store, prefixBz)
oldStoreIter := oldStore.Iterator(nil, nil)
@ -32,7 +32,7 @@ func MigratePrefixAddress(store sdk.KVStore, prefixBz []byte) {
// prefix_bytes | address_bytes | arbitrary_bytes
// into format:
// prefix_bytes | address_len (1 byte) | address_bytes | arbitrary_bytes
func MigratePrefixAddressBytes(store sdk.KVStore, prefixBz []byte) {
func MigratePrefixAddressBytes(store storetypes.KVStore, prefixBz []byte) {
oldStore := prefix.NewStore(store, prefixBz)
oldStoreIter := oldStore.Iterator(nil, nil)
@ -53,7 +53,7 @@ func MigratePrefixAddressBytes(store sdk.KVStore, prefixBz []byte) {
// prefix_bytes | address_1_bytes | address_2_bytes
// into format:
// prefix_bytes | address_1_len (1 byte) | address_1_bytes | address_2_len (1 byte) | address_2_bytes
func MigratePrefixAddressAddress(store sdk.KVStore, prefixBz []byte) {
func MigratePrefixAddressAddress(store storetypes.KVStore, prefixBz []byte) {
oldStore := prefix.NewStore(store, prefixBz)
oldStoreIter := oldStore.Iterator(nil, nil)

View File

@ -6,6 +6,7 @@ import (
"github.com/stretchr/testify/require"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -15,8 +16,8 @@ import (
)
func TestStoreMigration(t *testing.T) {
distributionKey := sdk.NewKVStoreKey("distribution")
ctx := testutil.DefaultContext(distributionKey, sdk.NewTransientStoreKey("transient_test"))
distributionKey := storetypes.NewKVStoreKey("distribution")
ctx := testutil.DefaultContext(distributionKey, storetypes.NewTransientStoreKey("transient_test"))
store := ctx.KVStore(distributionKey)
_, _, addr1 := testdata.KeyTestPubAddr()

View File

@ -5,6 +5,7 @@ import (
"github.com/stretchr/testify/require"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -28,8 +29,8 @@ func (ms mockSubspace) GetParamSet(ctx sdk.Context, ps exported.ParamSet) {
func TestMigrate(t *testing.T) {
cdc := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{}).Codec
storeKey := sdk.NewKVStoreKey(v3.ModuleName)
tKey := sdk.NewTransientStoreKey("transient_test")
storeKey := storetypes.NewKVStoreKey(v3.ModuleName)
tKey := storetypes.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(storeKey, tKey)
store := ctx.KVStore(storeKey)

View File

@ -191,7 +191,7 @@ func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes
}
// RegisterStoreDecoder registers a decoder for distribution module's types
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
func (am AppModule) RegisterStoreDecoder(sdr store.StoreDecoderRegistry) {
sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc)
}

View File

@ -124,7 +124,7 @@ func (k Keeper) GetEvidence(ctx sdk.Context, hash tmbytes.HexBytes) (exported.Ev
// will close and stop.
func (k Keeper) IterateEvidence(ctx sdk.Context, cb func(exported.Evidence) bool) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixEvidence)
iterator := sdk.KVStorePrefixIterator(store, nil)
iterator := storetypes.KVStorePrefixIterator(store, nil)
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {

View File

@ -12,6 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -82,8 +83,8 @@ type KeeperTestSuite struct {
func (suite *KeeperTestSuite) SetupTest() {
encCfg := moduletestutil.MakeTestEncodingConfig(evidence.AppModuleBasic{})
key := sdk.NewKVStoreKey(types.StoreKey)
tkey := sdk.NewTransientStoreKey("evidence_transient_store")
key := storetypes.NewKVStoreKey(types.StoreKey)
tkey := storetypes.NewTransientStoreKey("evidence_transient_store")
testCtx := testutil.DefaultContextWithDB(suite.T(), key, tkey)
suite.ctx = testCtx.Ctx

View File

@ -183,7 +183,7 @@ func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes
}
// RegisterStoreDecoder registers a decoder for evidence module's types
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
func (am AppModule) RegisterStoreDecoder(sdr store.StoreDecoderRegistry) {
sdr[types.StoreKey] = simulation.NewDecodeStore(am.keeper)
}

View File

@ -8,14 +8,15 @@ import (
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
)
func TestBasicFeeValidAllow(t *testing.T) {
key := sdk.NewKVStoreKey(feegrant.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(feegrant.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Height: 1})

View File

@ -8,6 +8,7 @@ import (
"github.com/stretchr/testify/require"
ocproto "github.com/tendermint/tendermint/proto/tendermint/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -17,8 +18,8 @@ import (
)
func TestFilteredFeeValidAllow(t *testing.T) {
key := sdk.NewKVStoreKey(feegrant.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(feegrant.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(ocproto.Header{Time: time.Now()})

View File

@ -7,6 +7,7 @@ import (
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -15,8 +16,8 @@ import (
)
func TestGrant(t *testing.T) {
key := sdk.NewKVStoreKey(feegrant.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(feegrant.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: time.Now()})

View File

@ -8,6 +8,7 @@ import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -26,8 +27,8 @@ type GenesisTestSuite struct {
}
func (suite *GenesisTestSuite) SetupTest() {
key := sdk.NewKVStoreKey(feegrant.StoreKey)
testCtx := testutil.DefaultContextWithDB(suite.T(), key, sdk.NewTransientStoreKey("transient_test"))
key := storetypes.NewKVStoreKey(feegrant.StoreKey)
testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModuleBasic{})
ctrl := gomock.NewController(suite.T())

Some files were not shown because too many files have changed in this diff Show More