diff --git a/Makefile b/Makefile index cefb603..c95d3a8 100644 --- a/Makefile +++ b/Makefile @@ -35,8 +35,8 @@ install: go.sum @echo "DONE" -OS := $(shell go env | grep GOOS | sed -E 's:.*="(.*)":\1:') -ARCH := $(shell go env | grep GOARCH | sed -E 's:.*="(.*)":\1:') +OS := $(shell go env | grep GOOS | sed -E "s:.*='(.*)':\1:") +ARCH := $(shell go env | grep GOARCH | sed -E "s:.*='(.*)':\1:") .PHONY: build build: @@ -161,7 +161,7 @@ local-init: $(V)rm -rf test @echo initalizing test chain - $(V)$(SCORUMD) init --staking-bond-denom nsp local-network + $(V)$(SCORUMD) init --default-denom nsp local-network @echo adding key 'test' $(V)$(SCORUMD) keys add test --keyring-backend test --keyring-dir test diff --git a/app/app.go b/app/app.go index 6f1b89a..8788212 100644 --- a/app/app.go +++ b/app/app.go @@ -7,8 +7,6 @@ import ( "os" "path/filepath" - "github.com/cosmos/cosmos-sdk/x/auth/posthandler" - autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" @@ -153,8 +151,8 @@ var ( // and genesis verification. ModuleBasics = module.NewBasicManager( auth.AppModuleBasic{}, + genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), authzmodule.AppModuleBasic{}, - genutil.AppModuleBasic{}, bank.AppModuleBasic{}, capability.AppModuleBasic{}, staking.AppModuleBasic{}, @@ -311,7 +309,7 @@ func New( authtypes.StoreKey, authz.ModuleName, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, - capabilitytypes.StoreKey, group.StoreKey, nft.StoreKey, + capabilitytypes.StoreKey, group.StoreKey, nft.StoreKey, consensusparamtypes.StoreKey, // ibc ibcexported.StoreKey, ibcfeetypes.StoreKey, icahosttypes.StoreKey, icacontrollertypes.StoreKey, @@ -338,6 +336,13 @@ func New( memKeys: memKeys, } + app.ParamsKeeper = initParamsKeeper( + appCodec, + legacyAmino, + app.keys[paramstypes.StoreKey], + app.tkeys[paramstypes.TStoreKey], + ) + // set the BaseApp's parameter store app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper( appCodec, keys[consensusparamtypes.StoreKey], @@ -500,7 +505,8 @@ func New( ) app.ICAHostKeeper = icahostkeeper.NewKeeper( - appCodec, keys[icahosttypes.StoreKey], + appCodec, + keys[icahosttypes.StoreKey], app.GetSubspace(icahosttypes.SubModuleName), app.IBCFeeKeeper, app.IBCKeeper.ChannelKeeper, @@ -578,11 +584,8 @@ func New( govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - app.GovKeeper = *govKeeper.SetHooks( - govtypes.NewMultiGovHooks( - // register the governance hooks - ), - ) + govKeeper.SetLegacyRouter(govRouter) + app.GovKeeper = *govKeeper /**** IBC Routing ****/ @@ -830,8 +833,6 @@ func New( app.ScopedICAHostKeeper = scopedICAHostKeeper app.ScopedICAControllerKeeper = scopedICAControllerKeeper - app.setPostHandler() - // create the simulation manager and define the order of the modules for deterministic simulations app.sm = module.NewSimulationManager( auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), @@ -860,17 +861,6 @@ func New( return app } -func (app *App) setPostHandler() { - postHandler, err := posthandler.NewPostHandler( - posthandler.HandlerOptions{}, - ) - if err != nil { - panic(err) - } - - app.SetPostHandler(postHandler) -} - // Name returns the name of the App func (app *App) Name() string { return app.BaseApp.Name() } diff --git a/app/sim/config.go b/app/sim/config.go new file mode 100644 index 0000000..43c1503 --- /dev/null +++ b/app/sim/config.go @@ -0,0 +1,75 @@ +package sim + +import ( + "flag" + + "github.com/cosmos/cosmos-sdk/types/simulation" +) + +// List of available flags for the simulator +var ( + FlagGenesisFileValue string + FlagParamsFileValue string + FlagExportParamsPathValue string + FlagExportParamsHeightValue int + FlagExportStatePathValue string + FlagExportStatsPathValue string + FlagSeedValue int64 + FlagInitialBlockHeightValue int + FlagNumBlocksValue int + FlagBlockSizeValue int + FlagLeanValue bool + FlagCommitValue bool + FlagOnOperationValue bool // TODO: Remove in favor of binary search for invariant violation + FlagAllInvariantsValue bool + + FlagEnabledValue bool + FlagVerboseValue bool + FlagPeriodValue uint + FlagGenesisTimeValue int64 +) + +// GetSimulatorFlags gets the values of all the available simulation flags +func GetSimulatorFlags() { + // config fields + flag.StringVar(&FlagGenesisFileValue, "Genesis", "", "custom simulation genesis file; cannot be used with params file") + flag.StringVar(&FlagParamsFileValue, "Params", "", "custom simulation params file which overrides any random params; cannot be used with genesis") + flag.StringVar(&FlagExportParamsPathValue, "ExportParamsPath", "", "custom file path to save the exported params JSON") + flag.IntVar(&FlagExportParamsHeightValue, "ExportParamsHeight", 0, "height to which export the randomly generated params") + flag.StringVar(&FlagExportStatePathValue, "ExportStatePath", "", "custom file path to save the exported app state JSON") + flag.StringVar(&FlagExportStatsPathValue, "ExportStatsPath", "", "custom file path to save the exported simulation statistics JSON") + flag.Int64Var(&FlagSeedValue, "Seed", 42, "simulation random seed") + flag.IntVar(&FlagInitialBlockHeightValue, "InitialBlockHeight", 1, "initial block to start the simulation") + flag.IntVar(&FlagNumBlocksValue, "NumBlocks", 500, "number of new blocks to simulate from the initial block height") + flag.IntVar(&FlagBlockSizeValue, "BlockSize", 200, "operations per block") + flag.BoolVar(&FlagLeanValue, "Lean", false, "lean simulation log output") + flag.BoolVar(&FlagCommitValue, "Commit", false, "have the simulation commit") + flag.BoolVar(&FlagOnOperationValue, "SimulateEveryOperation", false, "run slow invariants every operation") + flag.BoolVar(&FlagAllInvariantsValue, "PrintAllInvariants", false, "print all invariants if a broken invariant is found") + + // simulation flags + flag.BoolVar(&FlagEnabledValue, "Enabled", false, "enable the simulation") + flag.BoolVar(&FlagVerboseValue, "Verbose", false, "verbose log output") + flag.UintVar(&FlagPeriodValue, "Period", 0, "run slow invariants only once every period assertions") + flag.Int64Var(&FlagGenesisTimeValue, "GenesisTime", 0, "override genesis UNIX time instead of using a random UNIX time") +} + +// NewConfigFromFlags creates a simulation from the retrieved values of the flags. +func NewConfigFromFlags() simulation.Config { + return simulation.Config{ + GenesisFile: FlagGenesisFileValue, + ParamsFile: FlagParamsFileValue, + ExportParamsPath: FlagExportParamsPathValue, + ExportParamsHeight: FlagExportParamsHeightValue, + ExportStatePath: FlagExportStatePathValue, + ExportStatsPath: FlagExportStatsPathValue, + Seed: FlagSeedValue, + InitialBlockHeight: FlagInitialBlockHeightValue, + NumBlocks: FlagNumBlocksValue, + BlockSize: FlagBlockSizeValue, + Lean: FlagLeanValue, + Commit: FlagCommitValue, + OnOperation: FlagOnOperationValue, + AllInvariants: FlagAllInvariantsValue, + } +} diff --git a/app/simulation_test.go b/app/simulation_test.go index 8423f77..6b84031 100644 --- a/app/simulation_test.go +++ b/app/simulation_test.go @@ -9,21 +9,24 @@ import ( "os" "testing" + "github.com/scorum/cosmos-network/app/sim" + "github.com/cosmos/cosmos-sdk/testutil/sims" dbm "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/store" - "github.com/cosmos/cosmos-sdk/types/module/testutil" simulationtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" "github.com/scorum/cosmos-network/app" "github.com/stretchr/testify/require" ) +const ChainID = "scorum" + func init() { - sims.GetSimulatorFlags() + sim.GetSimulatorFlags() } // interBlockCacheOpt returns a BaseApp option function that sets the persistent @@ -33,7 +36,7 @@ func interBlockCacheOpt() func(*baseapp.BaseApp) { } func TestAppStateDeterminism(t *testing.T) { - config := sims.NewConfigFromFlags() + config := sim.NewConfigFromFlags() config.InitialBlockHeight = 1 config.ExportParamsPath = "" config.OnOperation = false @@ -41,7 +44,7 @@ func TestAppStateDeterminism(t *testing.T) { config.NumBlocks = 250 config.BlockSize = 100 config.Commit = true - config.ChainID = sims.SimAppChainID + config.ChainID = ChainID numSeeds := 5 numTimesToRunPerSeed := 3 @@ -52,24 +55,24 @@ func TestAppStateDeterminism(t *testing.T) { for j := 0; j < numTimesToRunPerSeed; j++ { var logger log.Logger - if sims.FlagVerboseValue { + if sim.FlagVerboseValue { logger = log.TestingLogger() } else { logger = log.NewNopLogger() } db := dbm.NewMemDB() - app := app.New( + simapp := app.New( logger, db, nil, true, map[int64]bool{}, - sims.DefaultNodeHome, - sims.FlagPeriodValue, - testutil.TestEncodingConfig(), + app.DefaultNodeHome, + sim.FlagPeriodValue, sims.AppOptionsMap{}, interBlockCacheOpt(), + baseapp.SetChainID(ChainID), ) fmt.Printf( @@ -80,21 +83,17 @@ func TestAppStateDeterminism(t *testing.T) { _, _, err := simulation.SimulateFromSeed( t, os.Stdout, - app.BaseApp, - sims.AppStateFn(app.AppCodec(), app.SimulationManager()), + simapp.BaseApp, + sims.AppStateFn(simapp.AppCodec(), simapp.SimulationManager(), app.NewDefaultGenesisState(simapp.AppCodec())), simulationtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1 - sims.SimulationOperations(app, app.AppCodec(), config), - app.ModuleAccountAddrs(), + sims.SimulationOperations(simapp, simapp.AppCodec(), config), + simapp.ModuleAccountAddrs(), config, - app.AppCodec(), + simapp.AppCodec(), ) require.NoError(t, err) - if config.Commit { - PrintStats(db) - } - - appHash := app.LastCommitID().Hash + appHash := simapp.LastCommitID().Hash appHashList[j] = appHash if j != 0 { @@ -106,10 +105,3 @@ func TestAppStateDeterminism(t *testing.T) { } } } - -// PrintStats prints the corresponding statistics from the app DB. -func PrintStats(db dbm.DB) { - fmt.Println("\nLevelDB Stats") - fmt.Println(db.Stats()["leveldb.stats"]) - fmt.Println("LevelDB cached block size", db.Stats()["leveldb.cachedblock"]) -} diff --git a/app/upgrade/v110/upgrade.go b/app/upgrade/v110/upgrade.go index ddfbd74..d423696 100644 --- a/app/upgrade/v110/upgrade.go +++ b/app/upgrade/v110/upgrade.go @@ -4,7 +4,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" upgrade "github.com/cosmos/cosmos-sdk/x/upgrade/types" - ibctmmigrations "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint/migrations" ) const Name = "v1.0.1 Scorum Upgrade" @@ -14,12 +13,6 @@ func Handler( mm *module.Manager, ) func(ctx sdk.Context, _ upgrade.Plan, _ module.VersionMap) (module.VersionMap, error) { return func(ctx sdk.Context, _ upgrade.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - // prune expired tendermint consensus states to save storage space - _, err := ibctmmigrations.PruneExpiredConsensusStates(ctx, app.Codec, app.IBCKeeper.ClientKeeper) - if err != nil { - return nil, err - } - return mm.RunMigrations(ctx, cfg, fromVM) } } diff --git a/cmd/scorumd/cmd/collectgentx.go b/cmd/scorumd/cmd/collectgentx.go index 9aaf179..7703ec0 100644 --- a/cmd/scorumd/cmd/collectgentx.go +++ b/cmd/scorumd/cmd/collectgentx.go @@ -4,6 +4,8 @@ import ( "encoding/json" "fmt" + "github.com/scorum/cosmos-network/app" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/types" @@ -18,7 +20,12 @@ import ( ) func CollectGenTxsCmd(genBalIterator banktypes.GenesisBalancesIterator, defaultNodeHome string) *cobra.Command { - cmd := genutilcli.CollectGenTxsCmd(genBalIterator, defaultNodeHome) + gentxModule, ok := app.ModuleBasics[genutiltypes.ModuleName].(genutil.AppModuleBasic) + if !ok { + panic(fmt.Errorf("expected %s module to be an instance of type %T", genutiltypes.ModuleName, genutil.AppModuleBasic{})) + } + + cmd := genutilcli.CollectGenTxsCmd(genBalIterator, defaultNodeHome, gentxModule.GenTxValidator) cmd.PreRunE = func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) @@ -31,10 +38,10 @@ func CollectGenTxsCmd(genBalIterator banktypes.GenesisBalancesIterator, defaultN } bankGenState := banktypes.GetGenesisStateFromAppState(cdc, appState) - bankGenState.Params.SendEnabled = append( - bankGenState.Params.SendEnabled, - &banktypes.SendEnabled{Denom: scorumtypes.SPDenom, Enabled: false}, - &banktypes.SendEnabled{Denom: scorumtypes.GasDenom, Enabled: false}, + bankGenState.SendEnabled = append( + bankGenState.SendEnabled, + banktypes.SendEnabled{Denom: scorumtypes.SPDenom, Enabled: false}, + banktypes.SendEnabled{Denom: scorumtypes.GasDenom, Enabled: false}, ) bankGenStateBz, err := cdc.MarshalJSON(bankGenState) diff --git a/go.mod b/go.mod index 7ca39f4..51bd544 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/cometbft/cometbft-db v0.12.1-0.20240508134034-e9d8487735c2 github.com/cosmos/cosmos-sdk v0.47.11 github.com/cosmos/gogoproto v1.4.10 - github.com/cosmos/ibc-go/v7 v7.5.0 + github.com/cosmos/ibc-go/v7 v7.4.0 github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.4 github.com/google/uuid v1.6.0 @@ -24,7 +24,6 @@ require ( github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.9.0 - golang.org/x/exp v0.0.0-20230905200255-921286631fa9 google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 google.golang.org/grpc v1.62.1 gopkg.in/yaml.v2 v2.4.0 @@ -171,6 +170,7 @@ require ( go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.9.0 // indirect golang.org/x/crypto v0.21.0 // indirect + golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/net v0.23.0 // indirect golang.org/x/oauth2 v0.16.0 // indirect golang.org/x/sync v0.6.0 // indirect @@ -191,3 +191,5 @@ require ( ) replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 + +replace golang.org/x/exp => golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb // remove on bump to v0.50 diff --git a/go.sum b/go.sum index e73a1db..b9d1667 100644 --- a/go.sum +++ b/go.sum @@ -202,7 +202,6 @@ cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw= cosmossdk.io/tools/rosetta v0.2.1/go.mod h1:Pqdc1FdvkNV3LcNIkYWt2RQY6IP1ge6YWZk8MhhO9Hw= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek= filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= @@ -218,7 +217,6 @@ github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0/go.mod h1:tPaiy8S5bQ github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM= github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= @@ -409,8 +407,8 @@ github.com/cosmos/gogoproto v1.4.10 h1:QH/yT8X+c0F4ZDacDv3z+xE3WU1P1Z3wQoLMBRJoK github.com/cosmos/gogoproto v1.4.10/go.mod h1:3aAZzeRWpAwr+SS/LLkICX2/kDFyaYVzckBDzygIxek= github.com/cosmos/iavl v0.20.1 h1:rM1kqeG3/HBT85vsZdoSNsehciqUQPWrR4BYmqE2+zg= github.com/cosmos/iavl v0.20.1/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A= -github.com/cosmos/ibc-go/v7 v7.5.0 h1:tvPyuTsNqS1hZK69Wq7MZIvZIg8AblMkcnkAndtQet0= -github.com/cosmos/ibc-go/v7 v7.5.0/go.mod h1:ktFg5GvKOyrGCqTWtW7Grj5uweU4ZapxrNeVS1CLLbo= +github.com/cosmos/ibc-go/v7 v7.4.0 h1:8FqYMptvksgMvlbN4UW9jFxTXzsPyfAzEZurujXac8M= +github.com/cosmos/ibc-go/v7 v7.4.0/go.mod h1:L/KaEhzV5TGUCTfGysVgMBQtl5Dm7hHitfpk+GIeoAo= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.12.4 h1:drvWt+GJP7Aiw550yeb3ON/zsrgW0jgh5saFCr7pDnw= @@ -527,9 +525,6 @@ github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1T github.com/go-chi/chi/v5 v5.0.0/go.mod h1:BBug9lr0cqtdAhsu6R4AAdvufI0/XBzAQSsUqJpoZOs= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= @@ -1282,27 +1277,12 @@ golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWP golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= +golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb h1:xIApU0ow1zwMa2uL1VDNeQlNVFTWMQxZUZCMDy0Q4Us= +golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1315,18 +1295,16 @@ golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPI golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= +golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1451,7 +1429,6 @@ golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1463,7 +1440,6 @@ golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1581,7 +1557,6 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= @@ -1590,9 +1565,7 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -1608,7 +1581,6 @@ golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -1637,6 +1609,7 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/testutil/keeper/account.go b/testutil/keeper/account.go index 8ba1ab8..6a216d9 100644 --- a/testutil/keeper/account.go +++ b/testutil/keeper/account.go @@ -7,8 +7,9 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/nft" - typesparams "github.com/cosmos/cosmos-sdk/x/params/types" scorumtypes "github.com/scorum/cosmos-network/x/scorum/types" ) @@ -18,23 +19,16 @@ func AccountKeeper(t testing.TB, ctx TestContext) keeper.AccountKeeper { types.RegisterInterfaces(registry) - paramsSubspace := typesparams.NewSubspace(cdc, - codec.NewLegacyAmino(), - ctx.KVKeys[typesparams.StoreKey], - ctx.TKeys[typesparams.TStoreKey], - types.ModuleName, - ) - k := keeper.NewAccountKeeper( cdc, ctx.KVKeys[types.StoreKey], - paramsSubspace, types.ProtoBaseAccount, map[string][]string{ scorumtypes.ModuleName: {types.Minter, types.Burner}, nft.ModuleName: nil, }, "scorum", + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) // Initialize params diff --git a/testutil/keeper/bank.go b/testutil/keeper/bank.go index e6d9f2c..62fe47a 100644 --- a/testutil/keeper/bank.go +++ b/testutil/keeper/bank.go @@ -3,11 +3,13 @@ package keeper import ( "testing" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/bank/types" - typesparams "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/scorum/cosmos-network/app" scorumtypes "github.com/scorum/cosmos-network/x/scorum/types" ) @@ -18,19 +20,12 @@ func BankKeeper(t testing.TB, ctx TestContext) keeper.Keeper { types.RegisterInterfaces(registry) - paramsSubspace := typesparams.NewSubspace(cdc, - codec.NewLegacyAmino(), - ctx.KVKeys[typesparams.StoreKey], - ctx.TKeys[typesparams.TStoreKey], - types.ModuleName, - ) - k := keeper.NewBaseKeeper( cdc, ctx.KVKeys[types.StoreKey], AccountKeeper(t, ctx), - paramsSubspace, (&app.App{}).BlockedModuleAccountAddrs(), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) // Initialize params diff --git a/testutil/keeper/context.go b/testutil/keeper/context.go index efd7e2b..e731c3f 100644 --- a/testutil/keeper/context.go +++ b/testutil/keeper/context.go @@ -3,6 +3,8 @@ package keeper import ( "testing" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + ibcnfttransfertypes "github.com/bianjieai/nft-transfer/types" tmdb "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/libs/log" @@ -28,7 +30,6 @@ import ( icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - ibchost "github.com/cosmos/ibc-go/v7/modules/core/24-host" aviatrixmoduletypes "github.com/scorum/cosmos-network/x/aviatrix/types" scorumtypes "github.com/scorum/cosmos-network/x/scorum/types" "github.com/stretchr/testify/require" @@ -46,7 +47,7 @@ func GetContext(t testing.TB) TestContext { keys := sdk.NewKVStoreKeys( authtypes.StoreKey, authz.ModuleName, banktypes.StoreKey, stakingtypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, - paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, + paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, icahosttypes.StoreKey, capabilitytypes.StoreKey, group.StoreKey, icacontrollertypes.StoreKey, nft.StoreKey, scorumtypes.StoreKey, aviatrixmoduletypes.StoreKey, ibcnfttransfertypes.StoreKey, diff --git a/testutil/network/network.go b/testutil/network/network.go deleted file mode 100644 index bfc6679..0000000 --- a/testutil/network/network.go +++ /dev/null @@ -1,82 +0,0 @@ -package network - -import ( - "testing" - "time" - - "github.com/scorum/cosmos-network/app" - scorumtypes "github.com/scorum/cosmos-network/x/scorum/types" - - tmdb "github.com/cometbft/cometbft-db" - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/crypto/hd" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - - //pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" - servertypes "github.com/cosmos/cosmos-sdk/server/types" - - //"github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/testutil/network" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/stretchr/testify/require" - //tmrand "github.com/tendermint/tendermint/libs/rand" -) - -type ( - Network = network.Network - Config = network.Config -) - -// New creates instance with fully configured cosmos network. -// Accepts optional config, that will be used in place of the DefaultConfig() if provided. -func New(t *testing.T, configs ...network.Config) *network.Network { - if len(configs) > 1 { - panic("at most one config should be provided") - } - var cfg network.Config - if len(configs) == 0 { - cfg = DefaultConfig() - } else { - cfg = configs[0] - } - net, err := network.New(t, t.TempDir(), cfg) - require.NoError(t, err) - t.Cleanup(net.Cleanup) - return net -} - -// DefaultConfig will initialize config for the network with custom application, -// genesis and single validator. All other parameters are inherited from cosmos-sdk/testutil/network.DefaultConfig -func DefaultConfig() network.Config { - encoding := app.MakeEncodingConfig() - return network.Config{ - Codec: encoding.Marshaler, - TxConfig: encoding.TxConfig, - LegacyAmino: encoding.Amino, - InterfaceRegistry: encoding.InterfaceRegistry, - AccountRetriever: authtypes.AccountRetriever{}, - AppConstructor: func(val network.Validator) servertypes.Application { - return app.New( - val.Ctx.Logger, tmdb.NewMemDB(), nil, true, map[int64]bool{}, val.Ctx.Config.RootDir, 0, - encoding, - nil, - //baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), - baseapp.SetMinGasPrices(scorumtypes.GasPrice.String()), - ) - }, - GenesisState: app.ModuleBasics.DefaultGenesis(encoding.Marshaler), - TimeoutCommit: 2 * time.Second, - //ChainID: "chain-" + tmrand.NewRand().Str(6), - NumValidators: 1, - BondDenom: scorumtypes.SPDenom, - MinGasPrices: scorumtypes.GasPrice.String(), - AccountTokens: sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction), - StakingTokens: sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction), - BondedTokens: sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction), - //PruningStrategy: pruningtypes.PruningOptionNothing, - CleanupDir: true, - SigningAlgo: string(hd.Secp256k1Type), - KeyringOptions: []keyring.Option{}, - } -} diff --git a/x/aviatrix/module.go b/x/aviatrix/module.go index 937bcbf..9519a05 100644 --- a/x/aviatrix/module.go +++ b/x/aviatrix/module.go @@ -122,17 +122,6 @@ func NewAppModule( } } -// Deprecated: use RegisterServices -func (am AppModule) Route() sdk.Route { return sdk.Route{} } - -// Deprecated: use RegisterServices -func (AppModule) QuerierRoute() string { return types.RouterKey } - -// Deprecated: use RegisterServices -func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { - return nil -} - // RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) @@ -182,7 +171,7 @@ func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes } // RandomizedParams creates randomized distribution param changes for the simulator. -func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { +func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.LegacyParamChange { return simulation.ParamChanges(r) } diff --git a/x/aviatrix/simulation/operations.go b/x/aviatrix/simulation/operations.go index 383b9e9..6437be2 100644 --- a/x/aviatrix/simulation/operations.go +++ b/x/aviatrix/simulation/operations.go @@ -3,6 +3,8 @@ package simulation import ( "math/rand" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -114,9 +116,9 @@ func SimulateMsgCreatePlane( } txCtx := simulation.OperationInput{ - R: r, - App: app, - //TxGen: simapp.MakeTestEncodingConfig().TxConfig, + R: r, + App: app, + TxGen: moduletestutil.MakeTestEncodingConfig().TxConfig, Cdc: nil, Msg: msg, MsgType: msg.Type(), @@ -172,9 +174,9 @@ func SimulateMsgUpdatePlaneExperience( } txCtx := simulation.OperationInput{ - R: r, - App: app, - //TxGen: simapp.MakeTestEncodingConfig().TxConfig, + R: r, + App: app, + TxGen: moduletestutil.MakeTestEncodingConfig().TxConfig, Cdc: nil, Msg: msg, MsgType: msg.Type(), @@ -230,9 +232,9 @@ func SimulateMsgAdjustPlaneExperience( } txCtx := simulation.OperationInput{ - R: r, - App: app, - //TxGen: simapp.MakeTestEncodingConfig().TxConfig, + R: r, + App: app, + TxGen: moduletestutil.MakeTestEncodingConfig().TxConfig, Cdc: nil, Msg: msg, MsgType: msg.Type(), diff --git a/x/aviatrix/simulation/params.go b/x/aviatrix/simulation/params.go index c597d18..e4cdaba 100644 --- a/x/aviatrix/simulation/params.go +++ b/x/aviatrix/simulation/params.go @@ -6,6 +6,6 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" ) -func ParamChanges(r *rand.Rand) []simtypes.ParamChange { - return []simtypes.ParamChange{} +func ParamChanges(r *rand.Rand) []simtypes.LegacyParamChange { + return []simtypes.LegacyParamChange{} } diff --git a/x/scorum/keeper/gas.go b/x/scorum/keeper/gas.go index a6383c2..1b80106 100644 --- a/x/scorum/keeper/gas.go +++ b/x/scorum/keeper/gas.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/scorum/cosmos-network/x/scorum/types" - "golang.org/x/exp/slices" ) var gasConsumedAddressesPrefix = []byte("gas_consumed") @@ -75,7 +74,7 @@ func (k Keeper) GetAverageSPBalance(ctx sdk.Context) sdk.Dec { supervisors := k.GetParams(ctx).Supervisors total, size := sdk.ZeroDec(), int64(0) k.bankKeeper.IterateAllBalances(ctx, func(addr sdk.AccAddress, coin sdk.Coin) (stop bool) { - if slices.Contains(supervisors, addr.String()) { + if contains(supervisors, addr.String()) { return false } diff --git a/x/scorum/keeper/keeper.go b/x/scorum/keeper/keeper.go index dee1de7..26e59a6 100644 --- a/x/scorum/keeper/keeper.go +++ b/x/scorum/keeper/keeper.go @@ -81,3 +81,13 @@ func (k Keeper) Burn(ctx sdk.Context, addr sdk.AccAddress, coin sdk.Coin) error return nil } + +func contains[T comparable](s []T, v T) bool { + for i := range s { + if s[i] == v { + return true + } + } + + return false +} diff --git a/x/scorum/keeper/params.go b/x/scorum/keeper/params.go index ba4ce6d..0e01d43 100644 --- a/x/scorum/keeper/params.go +++ b/x/scorum/keeper/params.go @@ -3,7 +3,6 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/scorum/cosmos-network/x/scorum/types" - "golang.org/x/exp/slices" ) // GetParams get all parameters as types.Params @@ -19,5 +18,5 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { } func (k Keeper) IsSupervisor(ctx sdk.Context, addr string) bool { - return slices.Contains(k.GetParams(ctx).Supervisors, addr) + return contains(k.GetParams(ctx).Supervisors, addr) } diff --git a/x/scorum/module.go b/x/scorum/module.go index 9c15019..91a1d16 100644 --- a/x/scorum/module.go +++ b/x/scorum/module.go @@ -116,17 +116,6 @@ func NewAppModule( } } -// Deprecated: use RegisterServices -func (am AppModule) Route() sdk.Route { return sdk.Route{} } - -// Deprecated: use RegisterServices -func (AppModule) QuerierRoute() string { return types.RouterKey } - -// Deprecated: use RegisterServices -func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { - return nil -} - // RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(am.keeper)) @@ -182,7 +171,7 @@ func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes } // RandomizedParams creates randomized distribution param changes for the simulator. -func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { +func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.LegacyParamChange { return simulation.ParamChanges(r) } diff --git a/x/scorum/simulation/operations.go b/x/scorum/simulation/operations.go index 2695ece..ce8f830 100644 --- a/x/scorum/simulation/operations.go +++ b/x/scorum/simulation/operations.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/simulation" @@ -125,9 +126,9 @@ func SimulateMsgBurn( } txCtx := simulation.OperationInput{ - R: r, - App: app, - //TxGen: simapp.MakeTestEncodingConfig().TxConfig, + R: r, + App: app, + TxGen: moduletestutil.MakeTestEncodingConfig().TxConfig, Cdc: nil, Msg: msg, MsgType: msg.Type(), @@ -176,9 +177,9 @@ func SimulateMsgMintGas( } txCtx := simulation.OperationInput{ - R: r, - App: app, - //TxGen: simapp.MakeTestEncodingConfig().TxConfig, + R: r, + App: app, + TxGen: moduletestutil.MakeTestEncodingConfig().TxConfig, Cdc: nil, Msg: msg, MsgType: msg.Type(), @@ -221,9 +222,9 @@ func SimulateMsgConvertSCR2SP( } txCtx := simulation.OperationInput{ - R: r, - App: app, - //TxGen: simapp.MakeTestEncodingConfig().TxConfig, + R: r, + App: app, + TxGen: moduletestutil.MakeTestEncodingConfig().TxConfig, Cdc: nil, Msg: msg, MsgType: msg.Type(), @@ -269,9 +270,9 @@ func SimulateMsgWithdrawSP( } txCtx := simulation.OperationInput{ - R: r, - App: app, - //TxGen: simapp.MakeTestEncodingConfig().TxConfig, + R: r, + App: app, + TxGen: moduletestutil.MakeTestEncodingConfig().TxConfig, Cdc: nil, Msg: msg, MsgType: msg.Type(), @@ -321,9 +322,9 @@ func SimulateMsgStopSPWithdrawal( } txCtx := simulation.OperationInput{ - R: r, - App: app, - //TxGen: simapp.MakeTestEncodingConfig().TxConfig, + R: r, + App: app, + TxGen: moduletestutil.MakeTestEncodingConfig().TxConfig, Cdc: nil, Msg: msg, MsgType: msg.Type(), diff --git a/x/scorum/simulation/params.go b/x/scorum/simulation/params.go index d06da13..376fa08 100644 --- a/x/scorum/simulation/params.go +++ b/x/scorum/simulation/params.go @@ -10,9 +10,9 @@ import ( "github.com/scorum/cosmos-network/x/scorum/types" ) -func ParamChanges(r *rand.Rand) []simtypes.ParamChange { - return []simtypes.ParamChange{ - simulation.NewSimParamChange(types.ModuleName, string(types.KeyGasLimit), +func ParamChanges(r *rand.Rand) []simtypes.LegacyParamChange { + return []simtypes.LegacyParamChange{ + simulation.NewSimLegacyParamChange(types.ModuleName, string(types.KeyGasLimit), func(r *rand.Rand) string { return fmt.Sprintf( `{"int": "%d"}`, @@ -20,7 +20,7 @@ func ParamChanges(r *rand.Rand) []simtypes.ParamChange { ) }, ), - simulation.NewSimParamChange(types.ModuleName, string(types.KeyGasUnconditionedAmount), + simulation.NewSimLegacyParamChange(types.ModuleName, string(types.KeyGasUnconditionedAmount), func(r *rand.Rand) string { return fmt.Sprintf( `{"int": "%d"}`, @@ -28,7 +28,7 @@ func ParamChanges(r *rand.Rand) []simtypes.ParamChange { ) }, ), - simulation.NewSimParamChange(types.ModuleName, string(types.KeyGasAdjustCoefficient), + simulation.NewSimLegacyParamChange(types.ModuleName, string(types.KeyGasAdjustCoefficient), func(r *rand.Rand) string { return fmt.Sprintf( `{"dec": "%s"}`, @@ -36,7 +36,7 @@ func ParamChanges(r *rand.Rand) []simtypes.ParamChange { ) }, ), - simulation.NewSimParamChange(types.ModuleName, string(types.KeySPWithdrawalTotalPeriods), + simulation.NewSimLegacyParamChange(types.ModuleName, string(types.KeySPWithdrawalTotalPeriods), func(r *rand.Rand) string { return fmt.Sprintf( `%d`, @@ -44,7 +44,7 @@ func ParamChanges(r *rand.Rand) []simtypes.ParamChange { ) }, ), - simulation.NewSimParamChange(types.ModuleName, string(types.KeySPWithdrawalPeriodDurationSeconds), + simulation.NewSimLegacyParamChange(types.ModuleName, string(types.KeySPWithdrawalPeriodDurationSeconds), func(r *rand.Rand) string { return fmt.Sprintf( `%d`,