From b15a3aa47ec9cb91a4d41557124643d837a70053 Mon Sep 17 00:00:00 2001 From: swelf Date: Wed, 20 Sep 2023 18:31:56 +0300 Subject: [PATCH 1/3] merged upgrades --- app/app.go | 11 ++ app/upgrades/nextupgrade/constants.go | 8 - app/upgrades/nextupgrade/upgrades.go | 211 ++++++++++++++++++++-- app/upgrades/nextupgrade/upgrades_test.go | 36 ++++ app/upgrades/sdk47/constants.go | 15 -- app/upgrades/sdk47/upgrades.go | 210 --------------------- wasmbinding/message_plugin.go | 2 +- x/interchaintxs/types/params.go | 10 + 8 files changed, 254 insertions(+), 249 deletions(-) delete mode 100644 app/upgrades/sdk47/constants.go delete mode 100644 app/upgrades/sdk47/upgrades.go diff --git a/app/app.go b/app/app.go index 33b5f1d55..2194e8f09 100644 --- a/app/app.go +++ b/app/app.go @@ -1018,6 +1018,8 @@ func (app *App) setupUpgradeHandlers() { SlashingKeeper: app.SlashingKeeper, ParamsKeeper: app.ParamsKeeper, CapabilityKeeper: app.CapabilityKeeper, + BuilderKeeper: app.BuilderKeeper, + ContractManager: app.ContractManagerKeeper, GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName), CcvConsumerSubspace: app.GetSubspace(ccvconsumertypes.ModuleName), }, @@ -1184,6 +1186,15 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(globalfee.ModuleName) paramsKeeper.Subspace(ccvconsumertypes.ModuleName) + + // MOTE: legacy subspaces for migration sdk47 only + paramsKeeper.Subspace(crontypes.StoreKey).WithKeyTable(crontypes.ParamKeyTable()) + paramsKeeper.Subspace(feeburnertypes.StoreKey).WithKeyTable(feeburnertypes.ParamKeyTable()) + paramsKeeper.Subspace(feetypes.StoreKey).WithKeyTable(feetypes.ParamKeyTable()) + paramsKeeper.Subspace(tokenfactorytypes.StoreKey).WithKeyTable(tokenfactorytypes.ParamKeyTable()) + paramsKeeper.Subspace(interchainqueriesmoduletypes.StoreKey).WithKeyTable(interchainqueriesmoduletypes.ParamKeyTable()) + paramsKeeper.Subspace(interchaintxstypes.StoreKey).WithKeyTable(interchaintxstypes.ParamKeyTable()) + return paramsKeeper } diff --git a/app/upgrades/nextupgrade/constants.go b/app/upgrades/nextupgrade/constants.go index 11ddc35b9..e180e71ef 100644 --- a/app/upgrades/nextupgrade/constants.go +++ b/app/upgrades/nextupgrade/constants.go @@ -1,9 +1,6 @@ package nextupgrade import ( - store "github.com/cosmos/cosmos-sdk/store/types" - - "github.com/cosmos/gaia/v11/x/globalfee" "github.com/neutron-org/neutron/app/upgrades" ) @@ -15,9 +12,4 @@ const ( var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: store.StoreUpgrades{ - Added: []string{ - globalfee.ModuleName, - }, - }, } diff --git a/app/upgrades/nextupgrade/upgrades.go b/app/upgrades/nextupgrade/upgrades.go index 656a5c8c6..eeb484e9a 100644 --- a/app/upgrades/nextupgrade/upgrades.go +++ b/app/upgrades/nextupgrade/upgrades.go @@ -1,27 +1,41 @@ package nextupgrade import ( - "errors" - - ccvconsumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" - - ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - ibcchanneltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - + "cosmossdk.io/math" + "fmt" "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/types/bech32" "github.com/cosmos/cosmos-sdk/types/module" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/cosmos/gaia/v11/x/globalfee/types" + v6 "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/migrations/v6" + ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + ibcchanneltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + ccvconsumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" "github.com/neutron-org/neutron/app/upgrades" + contractmanagerkeeper "github.com/neutron-org/neutron/x/contractmanager/keeper" + contractmanagertypes "github.com/neutron-org/neutron/x/contractmanager/types" + crontypes "github.com/neutron-org/neutron/x/cron/types" + feeburnerkeeper "github.com/neutron-org/neutron/x/feeburner/keeper" + feeburnertypes "github.com/neutron-org/neutron/x/feeburner/types" + feerefundertypes "github.com/neutron-org/neutron/x/feerefunder/types" + icqtypes "github.com/neutron-org/neutron/x/interchainqueries/types" + interchaintxstypes "github.com/neutron-org/neutron/x/interchaintxs/types" + tokenfactorytypes "github.com/neutron-org/neutron/x/tokenfactory/types" + builderkeeper "github.com/skip-mev/pob/x/builder/keeper" + buildertypes "github.com/skip-mev/pob/x/builder/types" ) func CreateUpgradeHandler( mm *module.Manager, configurator module.Configurator, keepers *upgrades.UpgradeKeepers, - _ upgrades.StoreKeys, - _ codec.Codec, + storeKeys upgrades.StoreKeys, + codec codec.Codec, ) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { ctx.Logger().Info("Starting module migrations...") @@ -30,36 +44,203 @@ func CreateUpgradeHandler( return vm, err } + ctx.Logger().Info("Migrating channel capability...") + // https://github.com/cosmos/ibc-go/blob/v7.0.1/docs/migrations/v5-to-v6.md#upgrade-proposal + if err := v6.MigrateICS27ChannelCapability(ctx, codec, storeKeys.GetKey(capabilitytypes.StoreKey), keepers.CapabilityKeeper, interchaintxstypes.ModuleName); err != nil { + return nil, err + } + + ctx.Logger().Info("Migrating cron module parameters...") + if err := migrateCronParams(ctx, keepers.ParamsKeeper, storeKeys.GetKey(crontypes.StoreKey), codec); err != nil { + return nil, err + } + + ctx.Logger().Info("Migrating feerefunder module parameters...") + if err := migrateFeeRefunderParams(ctx, keepers.ParamsKeeper, storeKeys.GetKey(feerefundertypes.StoreKey), codec); err != nil { + return nil, err + } + + ctx.Logger().Info("Migrating tokenfactory module parameters...") + if err := migrateTokenFactoryParams(ctx, keepers.ParamsKeeper, storeKeys.GetKey(tokenfactorytypes.StoreKey), codec); err != nil { + return nil, err + } + + ctx.Logger().Info("Migrating feeburner module parameters...") + if err := migrateFeeburnerParams(ctx, keepers.ParamsKeeper, storeKeys.GetKey(feeburnertypes.StoreKey), codec); err != nil { + return nil, err + } + + ctx.Logger().Info("Migrating interchainqueries module parameters...") + if err := migrateInterchainQueriesParams(ctx, keepers.ParamsKeeper, storeKeys.GetKey(icqtypes.StoreKey), codec); err != nil { + return nil, err + } + + ctx.Logger().Info("Migrating interchaintxs module parameters...") + if err := setInterchainTxsParams(ctx, keepers.ParamsKeeper, storeKeys.GetKey(interchaintxstypes.StoreKey), codec); err != nil { + return nil, err + } + + ctx.Logger().Info("Setting pob params...") + err = setPobParams(ctx, keepers.FeeBurnerKeeper, keepers.BuilderKeeper) + if err != nil { + return nil, err + } + + ctx.Logger().Info("Setting sudo callback limit...") + err = setContractManagerParams(ctx, keepers.ContractManager) + if err != nil { + return nil, err + } + + ctx.Logger().Info("Migrating globalminfees module parameters...") err = migrateGlobalFees(ctx, keepers) if err != nil { ctx.Logger().Error("failed to migrate GlobalFees", "err", err) return vm, err } + ctx.Logger().Info("Updating ccv reward denoms...") err = migrateRewardDenoms(ctx, keepers) if err != nil { - ctx.Logger().Error("failed to migrate reward denoms", "err", err) + ctx.Logger().Error("failed to update reward denoms", "err", err) return vm, err } ctx.Logger().Info("Upgrade complete") - return vm, err + return vm, nil + } +} + +func setPobParams(ctx sdk.Context, feeBurnerKeeper *feeburnerkeeper.Keeper, builderKeeper builderkeeper.Keeper) error { + treasury := feeBurnerKeeper.GetParams(ctx).TreasuryAddress + _, data, err := bech32.DecodeAndConvert(treasury) + if err != nil { + return err + } + + builderParams := buildertypes.Params{ + MaxBundleSize: 2, + EscrowAccountAddress: data, + ReserveFee: sdk.Coin{Denom: "untrn", Amount: sdk.NewInt(1_000_000)}, + MinBidIncrement: sdk.Coin{Denom: "untrn", Amount: sdk.NewInt(1_000_000)}, + FrontRunningProtection: true, + ProposerFee: math.LegacyNewDecWithPrec(25, 2), + } + return builderKeeper.SetParams(ctx, builderParams) +} + +func setContractManagerParams(ctx sdk.Context, keeper contractmanagerkeeper.Keeper) error { + cmParams := contractmanagertypes.Params{ + SudoCallGasLimit: contractmanagertypes.DefaultSudoCallGasLimit, } + return keeper.SetParams(ctx, cmParams) +} + +func migrateCronParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error { + store := ctx.KVStore(storeKey) + var currParams crontypes.Params + subspace, _ := paramsKeepers.GetSubspace(crontypes.StoreKey) + subspace.GetParamSet(ctx, &currParams) + + if err := currParams.Validate(); err != nil { + return err + } + + bz := codec.MustMarshal(&currParams) + store.Set(crontypes.ParamsKey, bz) + return nil +} + +func migrateFeeRefunderParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error { + store := ctx.KVStore(storeKey) + var currParams feerefundertypes.Params + subspace, _ := paramsKeepers.GetSubspace(feerefundertypes.StoreKey) + subspace.GetParamSet(ctx, &currParams) + + if err := currParams.Validate(); err != nil { + return err + } + + bz := codec.MustMarshal(&currParams) + store.Set(feerefundertypes.ParamsKey, bz) + return nil +} + +func migrateTokenFactoryParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error { + store := ctx.KVStore(storeKey) + var currParams tokenfactorytypes.Params + subspace, _ := paramsKeepers.GetSubspace(tokenfactorytypes.StoreKey) + subspace.GetParamSet(ctx, &currParams) + currParams.DenomCreationGasConsume = 0 + + if err := currParams.Validate(); err != nil { + return err + } + + bz := codec.MustMarshal(&currParams) + store.Set(tokenfactorytypes.ParamsKey, bz) + return nil +} + +func migrateFeeburnerParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error { + store := ctx.KVStore(storeKey) + var currParams feeburnertypes.Params + subspace, _ := paramsKeepers.GetSubspace(feeburnertypes.StoreKey) + subspace.GetParamSet(ctx, &currParams) + + if err := currParams.Validate(); err != nil { + return err + } + + bz := codec.MustMarshal(&currParams) + store.Set(feeburnertypes.ParamsKey, bz) + return nil +} + +func migrateInterchainQueriesParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error { + store := ctx.KVStore(storeKey) + var currParams icqtypes.Params + subspace, _ := paramsKeepers.GetSubspace(icqtypes.StoreKey) + subspace.GetParamSet(ctx, &currParams) + + if err := currParams.Validate(); err != nil { + return err + } + + bz := codec.MustMarshal(&currParams) + store.Set(icqtypes.ParamsKey, bz) + return nil +} + +func setInterchainTxsParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error { + store := ctx.KVStore(storeKey) + var currParams interchaintxstypes.Params + subspace, _ := paramsKeepers.GetSubspace(interchaintxstypes.StoreKey) + subspace.GetParamSet(ctx, &currParams) + currParams.RegisterFee = interchaintxstypes.DefaultRegisterFee + + if err := currParams.Validate(); err != nil { + return err + } + + bz := codec.MustMarshal(&currParams) + store.Set(interchaintxstypes.ParamsKey, bz) + return nil } func migrateGlobalFees(ctx sdk.Context, keepers *upgrades.UpgradeKeepers) error { ctx.Logger().Info("Implementing GlobalFee Params...") if !keepers.GlobalFeeSubspace.Has(ctx, types.ParamStoreKeyMinGasPrices) { - return errors.New("minimum_gas_prices param not found") + return fmt.Errorf("minimum_gas_prices param not found") } if !keepers.GlobalFeeSubspace.Has(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes) { - return errors.New("bypass_min_fee_msg_types param not found") + return fmt.Errorf("bypass_min_fee_msg_types param not found") } if !keepers.GlobalFeeSubspace.Has(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage) { - return errors.New("max_total_bypass_min_fee_msg_gas_usage param not found") + return fmt.Errorf("max_total_bypass_min_fee_msg_gas_usage param not found") } // global fee is empty set, set global fee to equal to 0.05 USD (for 200k of gas) in appropriate coin @@ -96,7 +277,7 @@ func migrateRewardDenoms(ctx sdk.Context, keepers *upgrades.UpgradeKeepers) erro ctx.Logger().Info("Migrating reword denoms...") if !keepers.CcvConsumerSubspace.Has(ctx, ccvconsumertypes.KeyRewardDenoms) { - return errors.New("key_reward_denoms param not found") + return fmt.Errorf("key_reward_denoms param not found") } var denoms []string diff --git a/app/upgrades/nextupgrade/upgrades_test.go b/app/upgrades/nextupgrade/upgrades_test.go index 4a056b036..07fb6ea7d 100644 --- a/app/upgrades/nextupgrade/upgrades_test.go +++ b/app/upgrades/nextupgrade/upgrades_test.go @@ -1,6 +1,12 @@ package nextupgrade_test import ( + crontypes "github.com/neutron-org/neutron/x/cron/types" + feeburnertypes "github.com/neutron-org/neutron/x/feeburner/types" + feerefundertypes "github.com/neutron-org/neutron/x/feerefunder/types" + icqtypes "github.com/neutron-org/neutron/x/interchainqueries/types" + interchaintxstypes "github.com/neutron-org/neutron/x/interchaintxs/types" + tokenfactorytypes "github.com/neutron-org/neutron/x/tokenfactory/types" "testing" "github.com/neutron-org/neutron/app/params" @@ -20,12 +26,42 @@ import ( type UpgradeTestSuite struct { testutil.IBCConnectionTestSuite + ctx sdk.Context } func TestKeeperTestSuite(t *testing.T) { suite.Run(t, new(UpgradeTestSuite)) } +func (suite *UpgradeTestSuite) SetupTest() { + suite.IBCConnectionTestSuite.SetupTest() + app := suite.GetNeutronZoneApp(suite.ChainA) + ctx := suite.ChainA.GetContext() + subspace, _ := app.ParamsKeeper.GetSubspace(crontypes.StoreKey) + pcron := crontypes.DefaultParams() + subspace.SetParamSet(ctx, &pcron) + + subspace, _ = app.ParamsKeeper.GetSubspace(feeburnertypes.StoreKey) + p := feeburnertypes.NewParams(feeburnertypes.DefaultNeutronDenom, "neutron17dtl0mjt3t77kpuhg2edqzjpszulwhgzcdvagh") + subspace.SetParamSet(ctx, &p) + + subspace, _ = app.ParamsKeeper.GetSubspace(feerefundertypes.StoreKey) + pFeeRefunder := feerefundertypes.DefaultParams() + subspace.SetParamSet(ctx, &pFeeRefunder) + + subspace, _ = app.ParamsKeeper.GetSubspace(tokenfactorytypes.StoreKey) + pTokenfactory := tokenfactorytypes.DefaultParams() + subspace.SetParamSet(ctx, &pTokenfactory) + + subspace, _ = app.ParamsKeeper.GetSubspace(icqtypes.StoreKey) + pICQTypes := icqtypes.DefaultParams() + subspace.SetParamSet(ctx, &pICQTypes) + + subspace, _ = app.ParamsKeeper.GetSubspace(interchaintxstypes.StoreKey) + pICAtx := interchaintxstypes.DefaultParams() + subspace.SetParamSet(ctx, &pICAtx) +} + func (suite *UpgradeTestSuite) TestGlobalFeesUpgrade() { var ( app = suite.GetNeutronZoneApp(suite.ChainA) diff --git a/app/upgrades/sdk47/constants.go b/app/upgrades/sdk47/constants.go deleted file mode 100644 index d92b1e06f..000000000 --- a/app/upgrades/sdk47/constants.go +++ /dev/null @@ -1,15 +0,0 @@ -package sdk47 - -import ( - "github.com/neutron-org/neutron/app/upgrades" -) - -const ( - // UpgradeName defines the on-chain upgrades name. - UpgradeName = "cosmos-sdk47" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: UpgradeName, - CreateUpgradeHandler: CreateUpgradeHandler, -} diff --git a/app/upgrades/sdk47/upgrades.go b/app/upgrades/sdk47/upgrades.go deleted file mode 100644 index 0c4b81cf6..000000000 --- a/app/upgrades/sdk47/upgrades.go +++ /dev/null @@ -1,210 +0,0 @@ -package sdk47 - -import ( - "cosmossdk.io/math" - "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/types/bech32" - "github.com/cosmos/cosmos-sdk/types/module" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - v6 "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/migrations/v6" - "github.com/neutron-org/neutron/app/upgrades" - contractmanagerkeeper "github.com/neutron-org/neutron/x/contractmanager/keeper" - contractmanagertypes "github.com/neutron-org/neutron/x/contractmanager/types" - crontypes "github.com/neutron-org/neutron/x/cron/types" - feeburnerkeeper "github.com/neutron-org/neutron/x/feeburner/keeper" - feeburnertypes "github.com/neutron-org/neutron/x/feeburner/types" - feerefundertypes "github.com/neutron-org/neutron/x/feerefunder/types" - icqtypes "github.com/neutron-org/neutron/x/interchainqueries/types" - interchaintxstypes "github.com/neutron-org/neutron/x/interchaintxs/types" - tokenfactorytypes "github.com/neutron-org/neutron/x/tokenfactory/types" - builderkeeper "github.com/skip-mev/pob/x/builder/keeper" - buildertypes "github.com/skip-mev/pob/x/builder/types" -) - -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - keepers *upgrades.UpgradeKeepers, - storeKeys upgrades.StoreKeys, - codec codec.Codec, -) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { - ctx.Logger().Info("Starting module migrations...") - vm, err := mm.RunMigrations(ctx, configurator, vm) - if err != nil { - return vm, err - } - - ctx.Logger().Info("Migrating channel capability...") - // https://github.com/cosmos/ibc-go/blob/v7.0.1/docs/migrations/v5-to-v6.md#upgrade-proposal - if err := v6.MigrateICS27ChannelCapability(ctx, codec, storeKeys.GetKey(capabilitytypes.StoreKey), keepers.CapabilityKeeper, interchaintxstypes.ModuleName); err != nil { - return nil, err - } - - ctx.Logger().Info("Migrating cron module parameters...") - if err := migrateCronParams(ctx, keepers.ParamsKeeper, storeKeys.GetKey(crontypes.StoreKey), codec); err != nil { - return nil, err - } - - ctx.Logger().Info("Migrating feerefunder module parameters...") - if err := migrateFeeRefunderParams(ctx, keepers.ParamsKeeper, storeKeys.GetKey(feerefundertypes.StoreKey), codec); err != nil { - return nil, err - } - - ctx.Logger().Info("Migrating tokenfactory module parameters...") - if err := migrateTokenFactoryParams(ctx, keepers.ParamsKeeper, storeKeys.GetKey(tokenfactorytypes.StoreKey), codec); err != nil { - return nil, err - } - - ctx.Logger().Info("Migrating feeburner module parameters...") - if err := migrateFeeburnerParams(ctx, keepers.ParamsKeeper, storeKeys.GetKey(feeburnertypes.StoreKey), codec); err != nil { - return nil, err - } - - ctx.Logger().Info("Migrating interchainqueries module parameters...") - if err := migrateInterchainQueriesParams(ctx, keepers.ParamsKeeper, storeKeys.GetKey(icqtypes.StoreKey), codec); err != nil { - return nil, err - } - - ctx.Logger().Info("Migrating interchaintxs module parameters...") - if err := migrateInterchainTxsParams(ctx, keepers.ParamsKeeper, storeKeys.GetKey(interchaintxstypes.StoreKey), codec); err != nil { - return nil, err - } - - ctx.Logger().Info("Setting pob params...") - err = setPobParams(ctx, keepers.FeeBurnerKeeper, keepers.BuilderKeeper) - if err != nil { - return nil, err - } - - ctx.Logger().Info("Setting sudo callback limit...") - err = setContractManagerParams(ctx, keepers.ContractManager) - if err != nil { - return nil, err - } - - ctx.Logger().Info("Upgrade complete") - return vm, nil - } -} - -func setPobParams(ctx sdk.Context, feeBurnerKeeper *feeburnerkeeper.Keeper, builderKeeper builderkeeper.Keeper) error { - treasury := feeBurnerKeeper.GetParams(ctx).TreasuryAddress - _, data, err := bech32.DecodeAndConvert(treasury) - if err != nil { - return err - } - - builderParams := buildertypes.Params{ - MaxBundleSize: 2, - EscrowAccountAddress: data, - ReserveFee: sdk.Coin{Denom: "untrn", Amount: sdk.NewInt(1_000_000)}, - MinBidIncrement: sdk.Coin{Denom: "untrn", Amount: sdk.NewInt(1_000_000)}, - FrontRunningProtection: true, - ProposerFee: math.LegacyNewDecWithPrec(25, 2), - } - return builderKeeper.SetParams(ctx, builderParams) -} - -func setContractManagerParams(ctx sdk.Context, keeper contractmanagerkeeper.Keeper) error { - cmParams := contractmanagertypes.Params{ - SudoCallGasLimit: contractmanagertypes.DefaultSudoCallGasLimit, - } - return keeper.SetParams(ctx, cmParams) -} - -func migrateCronParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error { - store := ctx.KVStore(storeKey) - var currParams crontypes.Params - subspace, _ := paramsKeepers.GetSubspace(crontypes.StoreKey) - subspace.GetParamSet(ctx, &currParams) - - if err := currParams.Validate(); err != nil { - return err - } - - bz := codec.MustMarshal(&currParams) - store.Set(crontypes.ParamsKey, bz) - return nil -} - -func migrateFeeRefunderParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error { - store := ctx.KVStore(storeKey) - var currParams feerefundertypes.Params - subspace, _ := paramsKeepers.GetSubspace(feerefundertypes.StoreKey) - subspace.GetParamSet(ctx, &currParams) - - if err := currParams.Validate(); err != nil { - return err - } - - bz := codec.MustMarshal(&currParams) - store.Set(feerefundertypes.ParamsKey, bz) - return nil -} - -func migrateTokenFactoryParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error { - store := ctx.KVStore(storeKey) - var currParams tokenfactorytypes.Params - subspace, _ := paramsKeepers.GetSubspace(tokenfactorytypes.StoreKey) - subspace.GetParamSet(ctx, &currParams) - currParams.DenomCreationGasConsume = 0 - - if err := currParams.Validate(); err != nil { - return err - } - - bz := codec.MustMarshal(&currParams) - store.Set(tokenfactorytypes.ParamsKey, bz) - return nil -} - -func migrateFeeburnerParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error { - store := ctx.KVStore(storeKey) - var currParams feeburnertypes.Params - subspace, _ := paramsKeepers.GetSubspace(feeburnertypes.StoreKey) - subspace.GetParamSet(ctx, &currParams) - - if err := currParams.Validate(); err != nil { - return err - } - - bz := codec.MustMarshal(&currParams) - store.Set(feeburnertypes.ParamsKey, bz) - return nil -} - -func migrateInterchainQueriesParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error { - store := ctx.KVStore(storeKey) - var currParams icqtypes.Params - subspace, _ := paramsKeepers.GetSubspace(icqtypes.StoreKey) - subspace.GetParamSet(ctx, &currParams) - - if err := currParams.Validate(); err != nil { - return err - } - - bz := codec.MustMarshal(&currParams) - store.Set(icqtypes.ParamsKey, bz) - return nil -} - -func migrateInterchainTxsParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error { - store := ctx.KVStore(storeKey) - var currParams interchaintxstypes.Params - subspace, _ := paramsKeepers.GetSubspace(interchaintxstypes.StoreKey) - subspace.GetParamSet(ctx, &currParams) - currParams.RegisterFee = interchaintxstypes.DefaultRegisterFee - - if err := currParams.Validate(); err != nil { - return err - } - - bz := codec.MustMarshal(&currParams) - store.Set(interchaintxstypes.ParamsKey, bz) - return nil -} diff --git a/wasmbinding/message_plugin.go b/wasmbinding/message_plugin.go index 1b1017b20..a130dae31 100644 --- a/wasmbinding/message_plugin.go +++ b/wasmbinding/message_plugin.go @@ -310,7 +310,7 @@ func (m *CustomMessenger) submitAdminProposal(ctx sdk.Context, contractAddr sdk. if err != nil { return nil, nil, errors.Wrap(err, "invalid proposal quantity") } - // here we handle pre-sdk47 style of proposals: param change, upgrade, client update + // here we handle pre-nextupgrade style of proposals: param change, upgrade, client update if m.isLegacyProposal(adminProposal) { resp, err := m.performSubmitAdminProposalLegacy(ctx, contractAddr, adminProposal) if err != nil { diff --git a/x/interchaintxs/types/params.go b/x/interchaintxs/types/params.go index 7a9f54638..8c9ad0e9f 100644 --- a/x/interchaintxs/types/params.go +++ b/x/interchaintxs/types/params.go @@ -17,6 +17,16 @@ var ( DefaultRegisterFee = sdk.NewCoins(sdk.NewCoin(params.DefaultDenom, sdk.NewInt(1000))) ) +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable( + paramtypes.NewParamSetPair( + KeyMsgSubmitTxMaxMessages, + DefaultMsgSubmitTxMaxMessages, + validateMsgSubmitTxMaxMessages, + ), + ) +} + // NewParams creates a new Params instance func NewParams(msgSubmitTxMaxMessages uint64, registerFee sdk.Coins) Params { return Params{ From 2bcd25a62b73e505bb1efaf5e7072049ec85fb30 Mon Sep 17 00:00:00 2001 From: swelf Date: Wed, 20 Sep 2023 18:51:26 +0300 Subject: [PATCH 2/3] linter fixes --- app/app.go | 52 +++++++++---------- app/upgrades/nextupgrade/upgrades.go | 4 +- app/upgrades/nextupgrade/upgrades_test.go | 4 +- cmd/neutrond/root.go | 4 +- .../contractmanager/keeper/contractmanager.go | 3 +- testutil/cron/keeper/cron.go | 3 +- testutil/feeburner/keeper/feeburner.go | 3 +- testutil/feerefunder/keeper/fee.go | 3 +- .../keeper/interchainqueries.go | 3 +- .../interchaintxs/keeper/interchaintxs.go | 6 ++- .../interchaintxs/keeper/sudo_middleware.go | 5 +- wasmbinding/test/custom_message_test.go | 6 ++- wasmbinding/wasm.go | 3 +- x/contractmanager/genesis_test.go | 4 +- x/contractmanager/ibc_middleware.go | 5 +- x/contractmanager/ibc_middleware_test.go | 3 +- x/cron/module_simulation.go | 2 +- x/feeburner/module_simulation.go | 2 +- x/interchainqueries/module_simulation.go | 2 +- x/interchainqueries/types/tx.go | 6 ++- x/interchaintxs/keeper/ibc_handlers.go | 6 ++- x/interchaintxs/keeper/ibc_handlers_test.go | 4 +- x/interchaintxs/keeper/keeper.go | 4 +- x/interchaintxs/keeper/msg_server_test.go | 5 +- x/interchaintxs/module_simulation.go | 2 +- x/interchaintxs/types/params.go | 1 + x/tokenfactory/keeper/createdenom.go | 7 +-- x/tokenfactory/keeper/genesis.go | 5 +- x/tokenfactory/keeper/grpc_query.go | 2 +- x/tokenfactory/types/msgs.go | 2 +- x/tokenfactory/types/params.go | 10 ++-- x/transfer/ibc_handlers_test.go | 3 +- 32 files changed, 102 insertions(+), 72 deletions(-) diff --git a/app/app.go b/app/app.go index 2194e8f09..f4421740d 100644 --- a/app/app.go +++ b/app/app.go @@ -217,7 +217,7 @@ var ( buildertypes.ModuleName: nil, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, icatypes.ModuleName: nil, - wasm.ModuleName: {authtypes.Burner}, + wasmtypes.ModuleName: {authtypes.Burner}, interchainqueriesmoduletypes.ModuleName: nil, feetypes.ModuleName: nil, feeburnertypes.ModuleName: nil, @@ -307,7 +307,7 @@ type App struct { ConsensusParamsKeeper consensusparamkeeper.Keeper - WasmKeeper wasm.Keeper + WasmKeeper wasmkeeper.Keeper // mm is the module manager mm *module.Manager @@ -347,30 +347,30 @@ func New( invCheckPeriod uint, encodingConfig appparams.EncodingConfig, appOpts servertypes.AppOptions, - wasmOpts []wasm.Option, + wasmOpts []wasmkeeper.Option, baseAppOptions ...func(*baseapp.BaseApp), ) *App { appCodec := encodingConfig.Marshaler legacyAmino := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry - config := mempool.NewDefaultAuctionFactory(encodingConfig.TxConfig.TxDecoder()) + cfg := mempool.NewDefaultAuctionFactory(encodingConfig.TxConfig.TxDecoder()) // 0 - unlimited amount of txs maxTx := 0 - mempool := mempool.NewAuctionMempool(encodingConfig.TxConfig.TxDecoder(), encodingConfig.TxConfig.TxEncoder(), maxTx, config) + memPool := mempool.NewAuctionMempool(encodingConfig.TxConfig.TxDecoder(), encodingConfig.TxConfig.TxEncoder(), maxTx, cfg) bApp := baseapp.NewBaseApp(Name, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) bApp.SetVersion(version.Version) bApp.SetInterfaceRegistry(interfaceRegistry) - bApp.SetMempool(mempool) + bApp.SetMempool(memPool) keys := sdk.NewKVStoreKeys( authzkeeper.StoreKey, authtypes.StoreKey, banktypes.StoreKey, slashingtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, icacontrollertypes.StoreKey, icahosttypes.StoreKey, capabilitytypes.StoreKey, - interchainqueriesmoduletypes.StoreKey, contractmanagermoduletypes.StoreKey, interchaintxstypes.StoreKey, wasm.StoreKey, feetypes.StoreKey, + interchainqueriesmoduletypes.StoreKey, contractmanagermoduletypes.StoreKey, interchaintxstypes.StoreKey, wasmtypes.StoreKey, feetypes.StoreKey, feeburnertypes.StoreKey, adminmoduletypes.StoreKey, ccvconsumertypes.StoreKey, tokenfactorytypes.StoreKey, routertypes.StoreKey, crontypes.StoreKey, ibchookstypes.StoreKey, consensusparamtypes.StoreKey, crisistypes.StoreKey, buildertypes.StoreKey, ) @@ -403,7 +403,7 @@ func New( scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName) scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) - scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasm.ModuleName) + scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName) scopedInterTxKeeper := app.CapabilityKeeper.ScopeToModule(interchaintxstypes.ModuleName) scopedCCVConsumerKeeper := app.CapabilityKeeper.ScopeToModule(ccvconsumertypes.ModuleName) @@ -598,7 +598,7 @@ func New( wasmDir := filepath.Join(homePath, "wasm") wasmConfig, err := wasm.ReadWasmConfig(appOpts) if err != nil { - panic(fmt.Sprintf("error while reading wasm config: %s", err)) + panic(fmt.Sprintf("error while reading wasm cfg: %s", err)) } // The last arguments can contain custom message handlers, and custom query handlers, @@ -657,9 +657,9 @@ func New( &wasmkeeper.QueryPlugins{Stargate: wasmkeeper.AcceptListStargateQuerier(wasmbinding.AcceptedStargateQueries(), app.GRPCQueryRouter(), appCodec)}) wasmOpts = append(wasmOpts, queryPlugins) - app.WasmKeeper = wasm.NewKeeper( + app.WasmKeeper = wasmkeeper.NewKeeper( appCodec, - keys[wasm.StoreKey], + keys[wasmtypes.StoreKey], app.AccountKeeper, &app.BankKeeper, nil, @@ -721,7 +721,7 @@ func New( AddRoute(icahosttypes.SubModuleName, icaHostIBCModule). AddRoute(ibctransfertypes.ModuleName, ibcStack). AddRoute(interchaintxstypes.ModuleName, icaControllerStack). - AddRoute(wasm.ModuleName, wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper)). + AddRoute(wasmtypes.ModuleName, wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper)). AddRoute(ccvconsumertypes.ModuleName, consumerModule) app.IBCKeeper.SetRouter(ibcRouter) @@ -792,7 +792,7 @@ func New( interchainqueriesmoduletypes.ModuleName, interchaintxstypes.ModuleName, contractmanagermoduletypes.ModuleName, - wasm.ModuleName, + wasmtypes.ModuleName, feetypes.ModuleName, feeburnertypes.ModuleName, adminmoduletypes.ModuleName, @@ -823,7 +823,7 @@ func New( interchainqueriesmoduletypes.ModuleName, interchaintxstypes.ModuleName, contractmanagermoduletypes.ModuleName, - wasm.ModuleName, + wasmtypes.ModuleName, feetypes.ModuleName, feeburnertypes.ModuleName, adminmoduletypes.ModuleName, @@ -859,7 +859,7 @@ func New( interchainqueriesmoduletypes.ModuleName, interchaintxstypes.ModuleName, contractmanagermoduletypes.ModuleName, - wasm.ModuleName, + wasmtypes.ModuleName, feetypes.ModuleName, feeburnertypes.ModuleName, adminmoduletypes.ModuleName, @@ -918,10 +918,10 @@ func New( }, IBCKeeper: app.IBCKeeper, WasmConfig: &wasmConfig, - TXCounterStoreKey: keys[wasm.StoreKey], + TXCounterStoreKey: keys[wasmtypes.StoreKey], ConsumerKeeper: app.ConsumerKeeper, buildKeeper: app.BuilderKeeper, - mempool: mempool, + mempool: memPool, GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName), }, app.Logger(), @@ -934,7 +934,7 @@ func New( app.SetEndBlocker(app.EndBlocker) handler := proposalhandler.NewProposalHandler( - mempool, + memPool, bApp.Logger(), anteHandler, encodingConfig.TxConfig.TxEncoder(), @@ -946,7 +946,7 @@ func New( checkTxHandler := proposalhandler.NewCheckTxHandler( app.BaseApp, encodingConfig.TxConfig.TxDecoder(), - mempool, + memPool, anteHandler, chainID, ) @@ -989,25 +989,25 @@ func New( func (app *App) setupUpgradeStoreLoaders() { upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() if err != nil { - panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) + panic(fmt.Sprintf("failed to read upgrd info from disk %s", err)) } if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { return } - for _, upgrade := range Upgrades { - if upgradeInfo.Name == upgrade.UpgradeName { - app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrade.StoreUpgrades)) + for _, upgrd := range Upgrades { + if upgradeInfo.Name == upgrd.UpgradeName { + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrd.StoreUpgrades)) } } } func (app *App) setupUpgradeHandlers() { - for _, upgrade := range Upgrades { + for _, upgrd := range Upgrades { app.UpgradeKeeper.SetUpgradeHandler( - upgrade.UpgradeName, - upgrade.CreateUpgradeHandler( + upgrd.UpgradeName, + upgrd.CreateUpgradeHandler( app.mm, app.configurator, &upgrades.UpgradeKeepers{ diff --git a/app/upgrades/nextupgrade/upgrades.go b/app/upgrades/nextupgrade/upgrades.go index eeb484e9a..0b6334df7 100644 --- a/app/upgrades/nextupgrade/upgrades.go +++ b/app/upgrades/nextupgrade/upgrades.go @@ -1,8 +1,10 @@ package nextupgrade import ( - "cosmossdk.io/math" "fmt" + + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/app/upgrades/nextupgrade/upgrades_test.go b/app/upgrades/nextupgrade/upgrades_test.go index 07fb6ea7d..55d5fd6a2 100644 --- a/app/upgrades/nextupgrade/upgrades_test.go +++ b/app/upgrades/nextupgrade/upgrades_test.go @@ -1,13 +1,14 @@ package nextupgrade_test import ( + "testing" + crontypes "github.com/neutron-org/neutron/x/cron/types" feeburnertypes "github.com/neutron-org/neutron/x/feeburner/types" feerefundertypes "github.com/neutron-org/neutron/x/feerefunder/types" icqtypes "github.com/neutron-org/neutron/x/interchainqueries/types" interchaintxstypes "github.com/neutron-org/neutron/x/interchaintxs/types" tokenfactorytypes "github.com/neutron-org/neutron/x/tokenfactory/types" - "testing" "github.com/neutron-org/neutron/app/params" @@ -26,7 +27,6 @@ import ( type UpgradeTestSuite struct { testutil.IBCConnectionTestSuite - ctx sdk.Context } func TestKeeperTestSuite(t *testing.T) { diff --git a/cmd/neutrond/root.go b/cmd/neutrond/root.go index 8f5f651a5..7674d3652 100644 --- a/cmd/neutrond/root.go +++ b/cmd/neutrond/root.go @@ -225,7 +225,7 @@ func (ac appCreator) newApp( if err != nil { panic(err) } - var wasmOpts []wasm.Option + var wasmOpts []wasmkeeper.Option if cast.ToBool(appOpts.Get("telemetry.enabled")) { wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer)) } @@ -287,7 +287,7 @@ func (ac appCreator) appExport( } loadLatest := height == -1 - var emptyWasmOpts []wasm.Option + var emptyWasmOpts []wasmkeeper.Option interchainapp = app.New( logger, chainID, diff --git a/testutil/contractmanager/keeper/contractmanager.go b/testutil/contractmanager/keeper/contractmanager.go index 9ef0b75ec..f23aa3282 100644 --- a/testutil/contractmanager/keeper/contractmanager.go +++ b/testutil/contractmanager/keeper/contractmanager.go @@ -1,9 +1,10 @@ package keeper import ( + "testing" + adminmoduletypes "github.com/cosmos/admin-module/x/adminmodule/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "testing" tmdb "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/libs/log" diff --git a/testutil/cron/keeper/cron.go b/testutil/cron/keeper/cron.go index 85fc35392..04987958c 100644 --- a/testutil/cron/keeper/cron.go +++ b/testutil/cron/keeper/cron.go @@ -1,9 +1,10 @@ package keeper import ( + "testing" + adminmoduletypes "github.com/cosmos/admin-module/x/adminmodule/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "testing" tmdb "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/libs/log" diff --git a/testutil/feeburner/keeper/feeburner.go b/testutil/feeburner/keeper/feeburner.go index 71f1e9e1c..c5e0c51b9 100644 --- a/testutil/feeburner/keeper/feeburner.go +++ b/testutil/feeburner/keeper/feeburner.go @@ -1,9 +1,10 @@ package keeper import ( + "testing" + adminmoduletypes "github.com/cosmos/admin-module/x/adminmodule/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "testing" tmdb "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/libs/log" diff --git a/testutil/feerefunder/keeper/fee.go b/testutil/feerefunder/keeper/fee.go index d6ecd9a85..71de9bb33 100644 --- a/testutil/feerefunder/keeper/fee.go +++ b/testutil/feerefunder/keeper/fee.go @@ -1,9 +1,10 @@ package keeper import ( + "testing" + adminmoduletypes "github.com/cosmos/admin-module/x/adminmodule/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "testing" tmdb "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/libs/log" diff --git a/testutil/interchainqueries/keeper/interchainqueries.go b/testutil/interchainqueries/keeper/interchainqueries.go index c6d3cebb2..eb51ce57d 100644 --- a/testutil/interchainqueries/keeper/interchainqueries.go +++ b/testutil/interchainqueries/keeper/interchainqueries.go @@ -1,9 +1,10 @@ package keeper import ( + "testing" + adminmoduletypes "github.com/cosmos/admin-module/x/adminmodule/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "testing" ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" diff --git a/testutil/interchaintxs/keeper/interchaintxs.go b/testutil/interchaintxs/keeper/interchaintxs.go index 8f1c62333..83d4114c2 100644 --- a/testutil/interchaintxs/keeper/interchaintxs.go +++ b/testutil/interchaintxs/keeper/interchaintxs.go @@ -1,9 +1,10 @@ package keeper import ( + "testing" + adminmoduletypes "github.com/cosmos/admin-module/x/adminmodule/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "testing" tmdb "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/libs/log" @@ -26,7 +27,8 @@ func InterchainTxsKeeper( icaControllerKeeper types.ICAControllerKeeper, channelKeeper types.ChannelKeeper, bankKeeper types.BankKeeper, - feeburnerKeeper types.FeeBurnerKeeper) (*keeper.Keeper, sdk.Context) { + feeburnerKeeper types.FeeBurnerKeeper, +) (*keeper.Keeper, sdk.Context) { storeKey := sdk.NewKVStoreKey(types.StoreKey) memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) diff --git a/testutil/interchaintxs/keeper/sudo_middleware.go b/testutil/interchaintxs/keeper/sudo_middleware.go index 5d586f342..8ab8742e1 100644 --- a/testutil/interchaintxs/keeper/sudo_middleware.go +++ b/testutil/interchaintxs/keeper/sudo_middleware.go @@ -1,6 +1,8 @@ package keeper import ( + "testing" + tmdb "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/libs/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" @@ -10,7 +12,6 @@ import ( "github.com/neutron-org/neutron/x/contractmanager" "github.com/neutron-org/neutron/x/contractmanager/types" "github.com/stretchr/testify/require" - "testing" ) func NewSudoLimitWrapper(t testing.TB, cmKeeper types.ContractManagerKeeper, wasmKeeper types.WasmKeeper) (types.WasmKeeper, sdk.Context, *storetypes.KVStoreKey) { @@ -19,7 +20,7 @@ func NewSudoLimitWrapper(t testing.TB, cmKeeper types.ContractManagerKeeper, was stateStore := store.NewCommitMultiStore(db) stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) require.NoError(t, stateStore.LoadLatestVersion()) - + limitWrapper := contractmanager.NewSudoLimitWrapper(cmKeeper, wasmKeeper) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/wasmbinding/test/custom_message_test.go b/wasmbinding/test/custom_message_test.go index 8b6db4bf0..6008a058f 100644 --- a/wasmbinding/test/custom_message_test.go +++ b/wasmbinding/test/custom_message_test.go @@ -3,9 +3,10 @@ package test import ( "encoding/json" "fmt" + "testing" + keeper2 "github.com/neutron-org/neutron/x/contractmanager/keeper" feeburnertypes "github.com/neutron-org/neutron/x/feeburner/types" - "testing" ibcchanneltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" @@ -486,7 +487,8 @@ func (suite *CustomMessengerTestSuite) TestSoftwareUpgradeProposal() { // Craft CancelSubmitAdminProposal message msg, err = json.Marshal(bindings.NeutronMsg{ SubmitAdminProposal: &bindings.SubmitAdminProposal{ - AdminProposal: bindings.AdminProposal{ProposalExecuteMessage: &bindings.ProposalExecuteMessage{Message: executeMsg}}}, + AdminProposal: bindings.AdminProposal{ProposalExecuteMessage: &bindings.ProposalExecuteMessage{Message: executeMsg}}, + }, }) suite.NoError(err) diff --git a/wasmbinding/wasm.go b/wasmbinding/wasm.go index cdb9ec5dd..19312011f 100644 --- a/wasmbinding/wasm.go +++ b/wasmbinding/wasm.go @@ -1,7 +1,6 @@ package wasmbinding import ( - "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" contractmanagerkeeper "github.com/neutron-org/neutron/x/contractmanager/keeper" @@ -39,7 +38,7 @@ func RegisterCustomPlugins( CustomMessageDecorator(ictxKeeper, icqKeeper, transfer, adminKeeper, bank, tfk, cronKeeper, contractmanagerKeeper), ) - return []wasm.Option{ + return []wasmkeeper.Option{ queryPluginOpt, messagePluginOpt, } diff --git a/x/contractmanager/genesis_test.go b/x/contractmanager/genesis_test.go index ddfa24682..e7633402a 100644 --- a/x/contractmanager/genesis_test.go +++ b/x/contractmanager/genesis_test.go @@ -1,9 +1,10 @@ package contractmanager_test import ( - "github.com/neutron-org/neutron/x/contractmanager/keeper" "testing" + "github.com/neutron-org/neutron/x/contractmanager/keeper" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" "github.com/stretchr/testify/require" @@ -29,6 +30,7 @@ func TestGenesis(t *testing.T) { channeltypes.Packet{ Sequence: 2, }, nil) + require.NoError(t, err) genesisState := types.GenesisState{ Params: types.DefaultParams(), diff --git a/x/contractmanager/ibc_middleware.go b/x/contractmanager/ibc_middleware.go index 739de0860..1b3370f86 100644 --- a/x/contractmanager/ibc_middleware.go +++ b/x/contractmanager/ibc_middleware.go @@ -1,8 +1,10 @@ package contractmanager import ( - "cosmossdk.io/errors" "fmt" + + "cosmossdk.io/errors" + "github.com/cometbft/cometbft/libs/log" sdk "github.com/cosmos/cosmos-sdk/types" contractmanagertypes "github.com/neutron-org/neutron/x/contractmanager/types" @@ -31,7 +33,6 @@ func (k SudoLimitWrapper) Sudo(ctx sdk.Context, contractAddress sdk.AccAddress, // Actually we have only one kind of error returned from acknowledgement // maybe later we'll retrieve actual errors from events resp, err = k.WasmKeeper.Sudo(cacheCtx, contractAddress, msg) - }() if err != nil { // the contract either returned an error or panicked with `out of gas` diff --git a/x/contractmanager/ibc_middleware_test.go b/x/contractmanager/ibc_middleware_test.go index 0815be992..991d93af7 100644 --- a/x/contractmanager/ibc_middleware_test.go +++ b/x/contractmanager/ibc_middleware_test.go @@ -2,13 +2,14 @@ package contractmanager_test import ( "fmt" + "testing" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/golang/mock/gomock" test_keeper "github.com/neutron-org/neutron/testutil/interchaintxs/keeper" mock_types "github.com/neutron-org/neutron/testutil/mocks/contractmanager/types" "github.com/neutron-org/neutron/x/contractmanager/types" "github.com/stretchr/testify/require" - "testing" ) var ( diff --git a/x/cron/module_simulation.go b/x/cron/module_simulation.go index 45f4ace31..bd9023e3e 100644 --- a/x/cron/module_simulation.go +++ b/x/cron/module_simulation.go @@ -36,7 +36,7 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { } // ProposalContents doesn't return any content functions for governance proposals -func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalMsg { return nil } diff --git a/x/feeburner/module_simulation.go b/x/feeburner/module_simulation.go index 7eefd95cb..80ab87783 100644 --- a/x/feeburner/module_simulation.go +++ b/x/feeburner/module_simulation.go @@ -39,7 +39,7 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { } // ProposalContents doesn't return any content functions for governance proposals -func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalMsg { return nil } diff --git a/x/interchainqueries/module_simulation.go b/x/interchainqueries/module_simulation.go index 55cef2305..51af522ef 100644 --- a/x/interchainqueries/module_simulation.go +++ b/x/interchainqueries/module_simulation.go @@ -35,7 +35,7 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { } // ProposalContents doesn't return any content functions for governance proposals -func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalMsg { return nil } diff --git a/x/interchainqueries/types/tx.go b/x/interchainqueries/types/tx.go index bb698bf83..eafe7de7d 100644 --- a/x/interchainqueries/types/tx.go +++ b/x/interchainqueries/types/tx.go @@ -15,8 +15,10 @@ const ( MaxKVQueryKeysCount = 32 ) -var _ sdk.Msg = &MsgSubmitQueryResult{} -var _ codectypes.UnpackInterfacesMessage = MsgSubmitQueryResult{} +var ( + _ sdk.Msg = &MsgSubmitQueryResult{} + _ codectypes.UnpackInterfacesMessage = MsgSubmitQueryResult{} +) func (msg MsgSubmitQueryResult) Route() string { return RouterKey diff --git a/x/interchaintxs/keeper/ibc_handlers.go b/x/interchaintxs/keeper/ibc_handlers.go index 1540a8c9a..f9aacea39 100644 --- a/x/interchaintxs/keeper/ibc_handlers.go +++ b/x/interchaintxs/keeper/ibc_handlers.go @@ -1,9 +1,10 @@ package keeper import ( - "github.com/neutron-org/neutron/x/contractmanager/keeper" "time" + "github.com/neutron-org/neutron/x/contractmanager/keeper" + "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/telemetry" @@ -100,6 +101,9 @@ func (k *Keeper) HandleChanOpenAck( CounterpartyChannelID: counterpartyChannelID, CounterpartyVersion: counterpartyVersion, }) + if err != nil { + return errors.Wrapf(sdkerrors.ErrJSONMarshal, "failed to marshal OpenAckDetails: %v", err) + } _, err = k.sudoKeeper.Sudo(ctx, icaOwner.GetContract(), payload) if err != nil { diff --git a/x/interchaintxs/keeper/ibc_handlers_test.go b/x/interchaintxs/keeper/ibc_handlers_test.go index c0a8c40b6..d6fd0d88b 100644 --- a/x/interchaintxs/keeper/ibc_handlers_test.go +++ b/x/interchaintxs/keeper/ibc_handlers_test.go @@ -2,9 +2,10 @@ package keeper_test import ( "fmt" - "github.com/neutron-org/neutron/x/contractmanager/keeper" "testing" + "github.com/neutron-org/neutron/x/contractmanager/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" @@ -105,7 +106,6 @@ func TestHandleTimeout(t *testing.T) { wmKeeper.EXPECT().Sudo(ctx, contractAddress, msgAck).Return(nil, fmt.Errorf("SudoTimeout error")) err = icak.HandleTimeout(ctx, p, relayerAddress) require.NoError(t, err) - } func TestHandleChanOpenAck(t *testing.T) { diff --git a/x/interchaintxs/keeper/keeper.go b/x/interchaintxs/keeper/keeper.go index 43e909e7d..fe13695f3 100644 --- a/x/interchaintxs/keeper/keeper.go +++ b/x/interchaintxs/keeper/keeper.go @@ -1,8 +1,10 @@ package keeper import ( - "cosmossdk.io/errors" "fmt" + + "cosmossdk.io/errors" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cometbft/cometbft/libs/log" diff --git a/x/interchaintxs/keeper/msg_server_test.go b/x/interchaintxs/keeper/msg_server_test.go index 635464474..bbb3d8d04 100644 --- a/x/interchaintxs/keeper/msg_server_test.go +++ b/x/interchaintxs/keeper/msg_server_test.go @@ -2,11 +2,12 @@ package keeper_test import ( "fmt" - "github.com/neutron-org/neutron/app/params" - feeburnertypes "github.com/neutron-org/neutron/x/feeburner/types" "testing" "time" + "github.com/neutron-org/neutron/app/params" + feeburnertypes "github.com/neutron-org/neutron/x/feeburner/types" + icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" feerefundertypes "github.com/neutron-org/neutron/x/feerefunder/types" "github.com/neutron-org/neutron/x/interchaintxs/keeper" diff --git a/x/interchaintxs/module_simulation.go b/x/interchaintxs/module_simulation.go index be6fb51e8..9bc6f895f 100644 --- a/x/interchaintxs/module_simulation.go +++ b/x/interchaintxs/module_simulation.go @@ -33,7 +33,7 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { } // ProposalContents doesn't return any content functions for governance proposals -func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalMsg { return nil } diff --git a/x/interchaintxs/types/params.go b/x/interchaintxs/types/params.go index 8c9ad0e9f..58ae59bbe 100644 --- a/x/interchaintxs/types/params.go +++ b/x/interchaintxs/types/params.go @@ -2,6 +2,7 @@ package types import ( "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/neutron-org/neutron/app/params" diff --git a/x/tokenfactory/keeper/createdenom.go b/x/tokenfactory/keeper/createdenom.go index ff84e935c..8123dc2ce 100644 --- a/x/tokenfactory/keeper/createdenom.go +++ b/x/tokenfactory/keeper/createdenom.go @@ -3,8 +3,9 @@ package keeper import ( "fmt" + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/neutron-org/neutron/x/tokenfactory/types" @@ -93,7 +94,7 @@ func (k Keeper) chargeForCreateDenom(ctx sdk.Context, creatorAddr string) (err e feeCollectorAddr, err := sdk.AccAddressFromBech32(params.FeeCollectorAddress) if err != nil { - return sdkerrors.Wrapf(err, "wrong fee collector address: %v", err) + return errors.Wrapf(err, "wrong fee collector address: %v", err) } err = k.bankKeeper.SendCoins( @@ -103,7 +104,7 @@ func (k Keeper) chargeForCreateDenom(ctx sdk.Context, creatorAddr string) (err e ) if err != nil { - return sdkerrors.Wrap(err, "unable to send coins to fee collector") + return errors.Wrap(err, "unable to send coins to fee collector") } } diff --git a/x/tokenfactory/keeper/genesis.go b/x/tokenfactory/keeper/genesis.go index 8bd6e28ec..9b44f2413 100644 --- a/x/tokenfactory/keeper/genesis.go +++ b/x/tokenfactory/keeper/genesis.go @@ -14,7 +14,10 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { if genState.Params.DenomCreationFee == nil { genState.Params.DenomCreationFee = sdk.NewCoins() } - k.SetParams(ctx, genState.Params) + err := k.SetParams(ctx, genState.Params) + if err != nil { + panic("failed to init params") + } for _, genDenom := range genState.GetFactoryDenoms() { creator, _, err := types.DeconstructDenom(genDenom.GetDenom()) diff --git a/x/tokenfactory/keeper/grpc_query.go b/x/tokenfactory/keeper/grpc_query.go index ba8fd43cc..30b910749 100644 --- a/x/tokenfactory/keeper/grpc_query.go +++ b/x/tokenfactory/keeper/grpc_query.go @@ -11,7 +11,7 @@ import ( var _ types.QueryServer = Keeper{} -func (k Keeper) Params(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { +func (k Keeper) Params(ctx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) params := k.GetParams(sdkCtx) diff --git a/x/tokenfactory/types/msgs.go b/x/tokenfactory/types/msgs.go index eafdc8547..4020c3cf2 100644 --- a/x/tokenfactory/types/msgs.go +++ b/x/tokenfactory/types/msgs.go @@ -106,7 +106,7 @@ func NewMsgBurn(sender string, amount sdk.Coin) *MsgBurn { } // NewMsgBurn creates a message to burn tokens -func NewMsgBurnFrom(sender string, amount sdk.Coin, burnFromAddress string) *MsgBurn { +func NewMsgBurnFrom(sender string, amount sdk.Coin, _ string) *MsgBurn { return &MsgBurn{ Sender: sender, Amount: amount, diff --git a/x/tokenfactory/types/params.go b/x/tokenfactory/types/params.go index 4a109cf73..2e587c27a 100644 --- a/x/tokenfactory/types/params.go +++ b/x/tokenfactory/types/params.go @@ -13,9 +13,9 @@ var ( KeyDenomCreationGasConsume = []byte("DenomCreationGasConsume") KeyFeeCollectorAddress = []byte("FeeCollectorAddress") // We don't want to charge users for denom creation - DefaultDenomCreationFee sdk.Coins = nil - DefaultDenomCreationGasConsume uint64 = 0 - DefaultFeeCollectorAddress = "" + DefaultDenomCreationFee sdk.Coins + DefaultDenomCreationGasConsume uint64 + DefaultFeeCollectorAddress = "" ) // ParamKeyTable the param key table for tokenfactory module. @@ -47,11 +47,11 @@ func (p Params) Validate() error { } if err := validateDenomCreationFee(p.DenomCreationFee); err != nil { - return err + return fmt.Errorf("failed to validate params: %w", err) } if err := validateFeeCollectorAddress(p.FeeCollectorAddress); err != nil { - return err + return fmt.Errorf("failed to validate params: %w", err) } return nil diff --git a/x/transfer/ibc_handlers_test.go b/x/transfer/ibc_handlers_test.go index 03ebab6f7..bdb763b56 100644 --- a/x/transfer/ibc_handlers_test.go +++ b/x/transfer/ibc_handlers_test.go @@ -2,9 +2,10 @@ package transfer_test import ( "fmt" - "github.com/neutron-org/neutron/x/contractmanager/keeper" "testing" + "github.com/neutron-org/neutron/x/contractmanager/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" From 2dc47ebc3404c1e3a216564b752e6e979693f9ef Mon Sep 17 00:00:00 2001 From: swelf Date: Wed, 20 Sep 2023 19:05:40 +0300 Subject: [PATCH 3/3] linter fixes --- app/simulation_test.go | 4 ++-- x/contractmanager/keeper/sudo.go | 2 +- x/tokenfactory/types/events.go | 2 +- x/transfer/types/tx.go | 2 ++ 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/simulation_test.go b/app/simulation_test.go index ebd049780..1645ec375 100644 --- a/app/simulation_test.go +++ b/app/simulation_test.go @@ -26,7 +26,7 @@ package app_test // simapp.GetSimulatorFlags() // } // -//type SimApp interface { +// type SimApp interface { // GetBaseApp() *baseapp.BaseApp // AppCodec() codec.Codec // SimulationManager() *module.SimulationManager @@ -51,7 +51,7 @@ package app_test //// `starport chain simulate -v --numBlocks 200 --blockSize 50` //// Running as go benchmark test: //// `go test -benchmem -run=^$ -bench ^BenchmarkSimulation ./app -NumBlocks=200 -BlockSize 50 -Commit=true -Verbose=true -Enabled=true` -//func BenchmarkSimulation(b *testing.B) { +// func BenchmarkSimulation(b *testing.B) { // simapp.FlagEnabledValue = true // simapp.FlagCommitValue = true // diff --git a/x/contractmanager/keeper/sudo.go b/x/contractmanager/keeper/sudo.go index 13a5e9e50..b5e574f57 100644 --- a/x/contractmanager/keeper/sudo.go +++ b/x/contractmanager/keeper/sudo.go @@ -22,7 +22,7 @@ func (k Keeper) HasContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) func PrepareSudoCallbackMessage(request channeltypes.Packet, ack *channeltypes.Acknowledgement) ([]byte, error) { m := types.MessageSudoCallback{} - if ack != nil && ack.GetError() == "" { + if ack != nil && ack.GetError() == "" { //nolint:gocritic // m.Response = &types.ResponseSudoPayload{ Data: ack.GetResult(), Request: request, diff --git a/x/tokenfactory/types/events.go b/x/tokenfactory/types/events.go index 0ccec062f..d6b18483f 100644 --- a/x/tokenfactory/types/events.go +++ b/x/tokenfactory/types/events.go @@ -5,7 +5,7 @@ const ( AttributeAmount = "amount" AttributeCreator = "creator" AttributeSubdenom = "subdenom" - AttributeNewTokenDenom = "new_token_denom" + AttributeNewTokenDenom = "new_token_denom" //nolint:gosec // token name, not a credential AttributeMintToAddress = "mint_to_address" AttributeBurnFromAddress = "burn_from_address" AttributeTransferFromAddress = "transfer_from_address" diff --git a/x/transfer/types/tx.go b/x/transfer/types/tx.go index 661f74b3f..1d1e1ebb2 100644 --- a/x/transfer/types/tx.go +++ b/x/transfer/types/tx.go @@ -26,6 +26,8 @@ func (msg *MsgTransfer) GetSigners() []sdk.AccAddress { // MsgOrigTransferHandler - 1) helps to bind `/neutron.transfer.Msg/Transfer` as a handler for `ibc.applications.transfer.v1.MsgTransfer` // 2) converts `ibc.applications.transfer.v1.MsgTransfer` into neutron.transfer.MsgTransfer` before processing. +// +//nolint:revive // we cant rearrange arguments since we need to meet the type requirement func MsgOrigTransferHandler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(types.MsgTransfer) if err := dec(in); err != nil {