From ece78ce065f0bc88b98112f7cc845c92aaae067b Mon Sep 17 00:00:00 2001 From: Khanh Hoa Date: Thu, 16 May 2024 13:35:31 +0700 Subject: [PATCH] merge from develop --- app/app.go | 5 +- app/upgrades/v6_5_5/constants.go | 0 app/upgrades/v6_5_5/upgrade.go | 24 -------- app/upgrades/v6_6_1/constants.go | 20 ------- app/upgrades/v6_6_1/upgrade.go | 60 ------------------- app/upgrades/v6_6_2/constants.go | 20 ------- app/upgrades/v6_6_2/upgrade.go | 32 ---------- app/upgrades/v6_6_4/constants.go | 20 ------- bech32-migration/ibchooks/ibchooks.go | 29 --------- .../ibctransfermiddleware.go | 32 ---------- custom/ibc-transfer/keeper/keeper.go | 14 ++--- custom/ibc-transfer/keeper/msg_server.go | 2 +- x/transfermiddleware/ibc_middleware.go | 1 - 13 files changed, 10 insertions(+), 249 deletions(-) delete mode 100644 app/upgrades/v6_5_5/constants.go delete mode 100644 app/upgrades/v6_5_5/upgrade.go delete mode 100644 app/upgrades/v6_6_1/constants.go delete mode 100644 app/upgrades/v6_6_1/upgrade.go delete mode 100644 app/upgrades/v6_6_2/constants.go delete mode 100644 app/upgrades/v6_6_2/upgrade.go delete mode 100644 app/upgrades/v6_6_4/constants.go delete mode 100644 bech32-migration/ibchooks/ibchooks.go delete mode 100644 bech32-migration/ibctransfermiddleware/ibctransfermiddleware.go diff --git a/app/app.go b/app/app.go index daeb16859..367002548 100644 --- a/app/app.go +++ b/app/app.go @@ -1,6 +1,8 @@ package app import ( + "cosmossdk.io/client/v2/autocli" + "cosmossdk.io/core/appmodule" "fmt" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services" @@ -8,7 +10,6 @@ import ( "io" "os" "path/filepath" - "github.com/notional-labs/composable/v6/app/upgrades/v6_6_4" "cosmossdk.io/x/circuit" circuittypes "cosmossdk.io/x/circuit/types" @@ -146,7 +147,7 @@ var ( // https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34 EnableSpecificProposals = "" - Upgrades = []upgrades.Upgrade{v7_0_1.Upgrade, v6_6_4.Upgrade} + Upgrades = []upgrades.Upgrade{v7_0_1.Upgrade} Forks = []upgrades.Fork{} ) diff --git a/app/upgrades/v6_5_5/constants.go b/app/upgrades/v6_5_5/constants.go deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/upgrades/v6_5_5/upgrade.go b/app/upgrades/v6_5_5/upgrade.go deleted file mode 100644 index 2226d99ef..000000000 --- a/app/upgrades/v6_5_5/upgrade.go +++ /dev/null @@ -1,24 +0,0 @@ -package v6_5_5 - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - - "github.com/cosmos/cosmos-sdk/codec" - "github.com/notional-labs/composable/v6/app/keepers" - - "github.com/notional-labs/composable/v6/app/upgrades" -) - -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - _ upgrades.BaseAppParamManager, - _ codec.Codec, - keepers *keepers.AppKeepers, -) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { - return mm.RunMigrations(ctx, configurator, vm) - } -} diff --git a/app/upgrades/v6_6_1/constants.go b/app/upgrades/v6_6_1/constants.go deleted file mode 100644 index 012196502..000000000 --- a/app/upgrades/v6_6_1/constants.go +++ /dev/null @@ -1,20 +0,0 @@ -package v6_6_1 - -import ( - store "github.com/cosmos/cosmos-sdk/store/types" - "github.com/notional-labs/composable/v6/app/upgrades" -) - -const ( - // UpgradeName defines the on-chain upgrade name for the composable upgrade. - UpgradeName = "v6_6_1" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: UpgradeName, - CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: store.StoreUpgrades{ - Added: []string{}, - Deleted: []string{}, - }, -} diff --git a/app/upgrades/v6_6_1/upgrade.go b/app/upgrades/v6_6_1/upgrade.go deleted file mode 100644 index f8f146e83..000000000 --- a/app/upgrades/v6_6_1/upgrade.go +++ /dev/null @@ -1,60 +0,0 @@ -package v6_6_1 - -import ( - "github.com/CosmWasm/wasmd/x/wasm" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - routertypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types" - icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" - ibchookstypes "github.com/notional-labs/composable/v6/x/ibc-hooks/types" - ibctransfermiddlewaretypes "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types" - - "github.com/notional-labs/composable/v6/app/keepers" - "github.com/notional-labs/composable/v6/app/upgrades" - bech32authmigration "github.com/notional-labs/composable/v6/bech32-migration/auth" - bech32govmigration "github.com/notional-labs/composable/v6/bech32-migration/gov" - bech32IbcHooksMigration "github.com/notional-labs/composable/v6/bech32-migration/ibchooks" - bench32ibctransfermiddleware "github.com/notional-labs/composable/v6/bech32-migration/ibctransfermiddleware" - bech32icamigration "github.com/notional-labs/composable/v6/bech32-migration/ica" - bech32mintmigration "github.com/notional-labs/composable/v6/bech32-migration/mint" - bech32PfmMigration "github.com/notional-labs/composable/v6/bech32-migration/pfmmiddleware" - bech32slashingmigration "github.com/notional-labs/composable/v6/bech32-migration/slashing" - bech32stakingmigration "github.com/notional-labs/composable/v6/bech32-migration/staking" - bech32transfermiddlewaremigration "github.com/notional-labs/composable/v6/bech32-migration/transfermiddleware" - bech32WasmMigration "github.com/notional-labs/composable/v6/bech32-migration/wasm" - transfermiddlewaretypes "github.com/notional-labs/composable/v6/x/transfermiddleware/types" -) - -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - _ upgrades.BaseAppParamManager, - codec codec.Codec, - keepers *keepers.AppKeepers, -) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { - keys := keepers.GetKVStoreKey() - // Migration prefix - ctx.Logger().Info("First step: Migrate addresses stored in bech32 form to use new prefix") - bech32stakingmigration.MigrateAddressBech32(ctx, keys[stakingtypes.StoreKey], codec) - bech32stakingmigration.MigrateUnbonding(ctx, keys[stakingtypes.StoreKey], codec) - bech32slashingmigration.MigrateAddressBech32(ctx, keys[slashingtypes.StoreKey], codec) - bech32govmigration.MigrateAddressBech32(ctx, keys[govtypes.StoreKey], codec) - bech32authmigration.MigrateAddressBech32(ctx, keys[authtypes.StoreKey], codec) - bech32icamigration.MigrateAddressBech32(ctx, keys[icahosttypes.StoreKey], codec) - bech32mintmigration.MigrateAddressBech32(ctx, keys[minttypes.StoreKey], codec) - bech32transfermiddlewaremigration.MigrateAddressBech32(ctx, keys[transfermiddlewaretypes.StoreKey], codec) - bech32WasmMigration.MigrateAddressBech32(ctx, keys[wasm.StoreKey], codec) - bech32PfmMigration.MigrateAddressBech32(ctx, keys[routertypes.StoreKey], codec, keepers) - bench32ibctransfermiddleware.MigrateAddressBech32(ctx, keys[ibctransfermiddlewaretypes.StoreKey], codec) - bech32IbcHooksMigration.MigrateAddressBech32(ctx, keys[ibchookstypes.StoreKey], codec) - return mm.RunMigrations(ctx, configurator, vm) - } -} diff --git a/app/upgrades/v6_6_2/constants.go b/app/upgrades/v6_6_2/constants.go deleted file mode 100644 index edc47ab59..000000000 --- a/app/upgrades/v6_6_2/constants.go +++ /dev/null @@ -1,20 +0,0 @@ -package v6_6_2 - -import ( - store "github.com/cosmos/cosmos-sdk/store/types" - "github.com/notional-labs/composable/v6/app/upgrades" -) - -const ( - // UpgradeName defines the on-chain upgrade name for the composable upgrade. - UpgradeName = "v6_6_2" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: UpgradeName, - CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: store.StoreUpgrades{ - Added: []string{}, - Deleted: []string{}, - }, -} diff --git a/app/upgrades/v6_6_2/upgrade.go b/app/upgrades/v6_6_2/upgrade.go deleted file mode 100644 index 15db9ee1b..000000000 --- a/app/upgrades/v6_6_2/upgrade.go +++ /dev/null @@ -1,32 +0,0 @@ -package v6_6_2 - -import ( - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - ibchookstypes "github.com/notional-labs/composable/v6/x/ibc-hooks/types" - ibctransfermiddlewaretypes "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types" - - "github.com/notional-labs/composable/v6/app/keepers" - "github.com/notional-labs/composable/v6/app/upgrades" - bech32IbcHooksMigration "github.com/notional-labs/composable/v6/bech32-migration/ibchooks" - bench32ibctransfermiddleware "github.com/notional-labs/composable/v6/bech32-migration/ibctransfermiddleware" -) - -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - _ upgrades.BaseAppParamManager, - codec codec.Codec, - keepers *keepers.AppKeepers, -) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { - keys := keepers.GetKVStoreKey() - // Migration prefix - ctx.Logger().Info("First step: Migrate addresses stored in bech32 form to use new prefix") - bench32ibctransfermiddleware.MigrateAddressBech32(ctx, keys[ibctransfermiddlewaretypes.StoreKey], codec) - bech32IbcHooksMigration.MigrateAddressBech32(ctx, keys[ibchookstypes.StoreKey], codec) - return mm.RunMigrations(ctx, configurator, vm) - } -} diff --git a/app/upgrades/v6_6_4/constants.go b/app/upgrades/v6_6_4/constants.go deleted file mode 100644 index 460f8d743..000000000 --- a/app/upgrades/v6_6_4/constants.go +++ /dev/null @@ -1,20 +0,0 @@ -package v6_6_4 - -import ( - store "github.com/cosmos/cosmos-sdk/store/types" - "github.com/notional-labs/composable/v6/app/upgrades" -) - -const ( - // UpgradeName defines the on-chain upgrade name for the composable upgrade. - UpgradeName = "v6_6_4" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: UpgradeName, - CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: store.StoreUpgrades{ - Added: []string{}, - Deleted: []string{}, - }, -} diff --git a/bech32-migration/ibchooks/ibchooks.go b/bech32-migration/ibchooks/ibchooks.go deleted file mode 100644 index 0f62560f0..000000000 --- a/bech32-migration/ibchooks/ibchooks.go +++ /dev/null @@ -1,29 +0,0 @@ -package ibchooks - -import ( - "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/notional-labs/composable/v6/bech32-migration/utils" -) - -func MigrateAddressBech32(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) { - ctx.Logger().Info("Migration of address bech32 for ibchooks module begin") - totalAddr := uint64(0) - store := ctx.KVStore(storeKey) - channelKey := []byte("channel") - iterator := sdk.KVStorePrefixIterator(store, channelKey) - for ; iterator.Valid(); iterator.Next() { - totalAddr++ - fullKey := iterator.Key() - contract := string(store.Get(fullKey)) - contract = utils.SafeConvertAddress(contract) - totalAddr++ - store.Set(fullKey, []byte(contract)) - } - - ctx.Logger().Info( - "Migration of address bech32 for ibchooks module done", - "totalAddr", totalAddr, - ) -} diff --git a/bech32-migration/ibctransfermiddleware/ibctransfermiddleware.go b/bech32-migration/ibctransfermiddleware/ibctransfermiddleware.go deleted file mode 100644 index c4f1ad646..000000000 --- a/bech32-migration/ibctransfermiddleware/ibctransfermiddleware.go +++ /dev/null @@ -1,32 +0,0 @@ -package ibctransfermiddleware - -import ( - "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/notional-labs/composable/v6/bech32-migration/utils" - "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types" -) - -func MigrateAddressBech32(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) { - ctx.Logger().Info("Migration of address bech32 for ibctransfermiddleware module begin") - totalAddr := uint64(0) - store := ctx.KVStore(storeKey) - bz := store.Get(types.ParamsKey) - if bz == nil { - return - } - var params types.Params - cdc.MustUnmarshal(bz, ¶ms) - for i := range params.ChannelFees { - totalAddr++ - params.ChannelFees[i].FeeAddress = utils.SafeConvertAddress(params.ChannelFees[i].FeeAddress) - } - bz = cdc.MustMarshal(¶ms) - store.Set(types.ParamsKey, bz) - - ctx.Logger().Info( - "Migration of address bech32 for ibctransfermiddleware module done", - "totalAddr", totalAddr, - ) -} diff --git a/custom/ibc-transfer/keeper/keeper.go b/custom/ibc-transfer/keeper/keeper.go index a4fb86406..6681f3b10 100644 --- a/custom/ibc-transfer/keeper/keeper.go +++ b/custom/ibc-transfer/keeper/keeper.go @@ -2,23 +2,21 @@ package keeper import ( "context" + sdkmath "cosmossdk.io/math" + "encoding/json" "fmt" "time" "github.com/cosmos/cosmos-sdk/codec" - ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" - - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" - custombankkeeper "github.com/notional-labs/composable/v6/custom/bank/keeper" - "time" storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" "github.com/cosmos/ibc-go/v8/modules/core/exported" + custombankkeeper "github.com/notional-labs/composable/v6/custom/bank/keeper" ibctransfermiddleware "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/keeper" ibctransfermiddlewaretypes "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types" ) @@ -63,7 +61,7 @@ func NewKeeper( func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.MsgTransferResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) params := k.IbcTransfermiddleware.GetParams(ctx) - charge_coin := sdk.NewCoin(msg.Token.Denom, sdk.ZeroInt()) + charge_coin := sdk.NewCoin(msg.Token.Denom, sdkmath.ZeroInt()) if params.ChannelFees != nil && len(params.ChannelFees) > 0 { channelFee := findChannelParams(params.ChannelFees, msg.SourceChannel) if channelFee != nil { @@ -125,7 +123,7 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types. return nil, send_err } - if newAmount.LTE(sdk.ZeroInt()) { + if newAmount.LTE(sdkmath.ZeroInt()) { return &types.MsgTransferResponse{}, nil } msg.Token.Amount = newAmount diff --git a/custom/ibc-transfer/keeper/msg_server.go b/custom/ibc-transfer/keeper/msg_server.go index 9b209f23f..4669c9af8 100644 --- a/custom/ibc-transfer/keeper/msg_server.go +++ b/custom/ibc-transfer/keeper/msg_server.go @@ -34,7 +34,7 @@ func NewMsgServerImpl(ibcKeeper Keeper, bankKeeper custombankkeeper.Keeper) type func (k msgServer) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.MsgTransferResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) params := k.Keeper.IbcTransfermiddleware.GetParams(ctx) - charge_coin := sdk.NewCoin(msg.Token.Denom, sdk.ZeroInt()) + charge_coin := sdk.NewCoin(msg.Token.Denom, sdkmath.ZeroInt()) if params.ChannelFees != nil && len(params.ChannelFees) > 0 { channelFee := findChannelParams(params.ChannelFees, msg.SourceChannel) if channelFee != nil { diff --git a/x/transfermiddleware/ibc_middleware.go b/x/transfermiddleware/ibc_middleware.go index e6aca540f..ebfddf100 100644 --- a/x/transfermiddleware/ibc_middleware.go +++ b/x/transfermiddleware/ibc_middleware.go @@ -2,7 +2,6 @@ package transfermiddleware import ( "cosmossdk.io/errors" - sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"