From 4e51b63245d30b26f29d9194fc3d468f6eeec23a Mon Sep 17 00:00:00 2001 From: rustdev Date: Wed, 27 Mar 2024 18:18:30 +0000 Subject: [PATCH 1/5] remove the upgrade handler code that tried remove proposal.. --- app/upgrades/v6_5_0/upgrade.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/upgrades/v6_5_0/upgrade.go b/app/upgrades/v6_5_0/upgrade.go index 25f58d78..18cf2ad5 100644 --- a/app/upgrades/v6_5_0/upgrade.go +++ b/app/upgrades/v6_5_0/upgrade.go @@ -23,14 +23,13 @@ func CreateUpgradeHandler( keepers.IbcTransferMiddlewareKeeper.SetParams(ctx, custommiddlewareparams.Params) // remove broken proposals - BrokenProposals := [3]uint64{2, 6, 11} - for _, proposal_id := range BrokenProposals { - _, ok := keepers.GovKeeper.GetProposal(ctx, proposal_id) - if ok { - keepers.GovKeeper.DeleteProposal(ctx, proposal_id) - } - - } + // BrokenProposals := [3]uint64{2, 6, 11} + // for _, proposal_id := range BrokenProposals { + // _, ok := keepers.GovKeeper.GetProposal(ctx, proposal_id) + // if ok { + // keepers.GovKeeper.DeleteProposal(ctx, proposal_id) + // } + // } // burn extra ppica in escrow account // this ppica is unused because it is a native token stored in escrow account From 23cfc5e3ac1a3badcf71a84a31213debacec8837 Mon Sep 17 00:00:00 2001 From: rustdev Date: Tue, 2 Apr 2024 16:18:12 +0100 Subject: [PATCH 2/5] SetTransferKeeper for PFM to replace original ibc transfer to wrapper --- app/keepers/keepers.go | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index ab40fd3a..ddcfd9bb 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -315,6 +315,18 @@ func (appKeepers *AppKeepers) InitNormalKeepers( authorityAddress, ) + appKeepers.RouterKeeper = routerkeeper.NewKeeper( + appCodec, + appKeepers.keys[routertypes.StoreKey], + appKeepers.GetSubspace(routertypes.ModuleName), + appKeepers.TransferKeeper.Keeper, + appKeepers.IBCKeeper.ChannelKeeper, + &appKeepers.DistrKeeper, + appKeepers.BankKeeper, + appKeepers.TransferMiddlewareKeeper, + appKeepers.IBCKeeper.ChannelKeeper, + ) + appKeepers.TransferKeeper = customibctransferkeeper.NewKeeper( appCodec, appKeepers.keys[ibctransfertypes.StoreKey], appKeepers.GetSubspace(ibctransfertypes.ModuleName), @@ -327,17 +339,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers( &appKeepers.IbcTransferMiddlewareKeeper, ) - appKeepers.RouterKeeper = routerkeeper.NewKeeper( - appCodec, - appKeepers.keys[routertypes.StoreKey], - appKeepers.GetSubspace(routertypes.ModuleName), - appKeepers.TransferKeeper.Keeper, - appKeepers.IBCKeeper.ChannelKeeper, - &appKeepers.DistrKeeper, - appKeepers.BankKeeper, - appKeepers.TransferMiddlewareKeeper, - appKeepers.IBCKeeper.ChannelKeeper, - ) + appKeepers.RouterKeeper.SetTransferKeeper(appKeepers.TransferKeeper) appKeepers.RatelimitKeeper = *ratelimitmodulekeeper.NewKeeper( appCodec, From afddb401194512db2b606008a54d3b9f62818de5 Mon Sep 17 00:00:00 2001 From: rustdev Date: Tue, 2 Apr 2024 16:38:58 +0100 Subject: [PATCH 3/5] added UpgradeName = "v6_5_1" --- app/app.go | 4 ++-- app/upgrades/v6_5_1/constants.go | 20 ++++++++++++++++++++ app/upgrades/v6_5_1/upgrade.go | 23 +++++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 app/upgrades/v6_5_1/constants.go create mode 100644 app/upgrades/v6_5_1/upgrade.go diff --git a/app/app.go b/app/app.go index c43f67d1..1095336e 100644 --- a/app/app.go +++ b/app/app.go @@ -36,7 +36,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" "github.com/notional-labs/composable/v6/app/keepers" - "github.com/notional-labs/composable/v6/app/upgrades/v6_5_0" + "github.com/notional-labs/composable/v6/app/upgrades/v6_5_1" // bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" @@ -147,7 +147,7 @@ var ( // https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34 EnableSpecificProposals = "" - Upgrades = []upgrades.Upgrade{v6_5_0.Upgrade} + Upgrades = []upgrades.Upgrade{v6_5_1.Upgrade} Forks = []upgrades.Fork{} ) diff --git a/app/upgrades/v6_5_1/constants.go b/app/upgrades/v6_5_1/constants.go new file mode 100644 index 00000000..4c7f2b5e --- /dev/null +++ b/app/upgrades/v6_5_1/constants.go @@ -0,0 +1,20 @@ +package v6_5_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_5_1" +) + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: store.StoreUpgrades{ + Added: []string{}, + Deleted: []string{}, + }, +} diff --git a/app/upgrades/v6_5_1/upgrade.go b/app/upgrades/v6_5_1/upgrade.go new file mode 100644 index 00000000..3d8fd257 --- /dev/null +++ b/app/upgrades/v6_5_1/upgrade.go @@ -0,0 +1,23 @@ +package v6_5_1 + +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) + } +} From 1307015b302541acae616fe54f767fd79cb1225d Mon Sep 17 00:00:00 2001 From: Khanh Hoa Date: Wed, 3 Apr 2024 09:58:59 +0700 Subject: [PATCH 4/5] merge from develop2 --- app/app.go | 4 +-- app/upgrades/v6_5_0/constants.go | 21 ------------- app/upgrades/v6_5_0/upgrade.go | 51 -------------------------------- app/upgrades/v6_5_1/constants.go | 2 +- app/upgrades/v6_5_1/upgrade.go | 6 ++-- 5 files changed, 6 insertions(+), 78 deletions(-) delete mode 100644 app/upgrades/v6_5_0/constants.go delete mode 100644 app/upgrades/v6_5_0/upgrade.go diff --git a/app/app.go b/app/app.go index c4a32fad..81dbfcc9 100644 --- a/app/app.go +++ b/app/app.go @@ -6,6 +6,7 @@ import ( "fmt" runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services" authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" + "github.com/notional-labs/composable/v6/app/upgrades/v6_5_1" "io" "os" "path/filepath" @@ -46,7 +47,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" "github.com/notional-labs/composable/v6/app/keepers" - "github.com/notional-labs/composable/v6/app/upgrades/v6_5_0" "github.com/notional-labs/composable/v6/app/upgrades/v7_0_1" // bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" @@ -152,7 +152,7 @@ var ( // https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34 EnableSpecificProposals = "" - Upgrades = []upgrades.Upgrade{v6_5_0.Upgrade, v7_0_1.Upgrade} + Upgrades = []upgrades.Upgrade{v6_5_1.Upgrade, v7_0_1.Upgrade} Forks = []upgrades.Fork{} ) diff --git a/app/upgrades/v6_5_0/constants.go b/app/upgrades/v6_5_0/constants.go deleted file mode 100644 index 4ce8eca1..00000000 --- a/app/upgrades/v6_5_0/constants.go +++ /dev/null @@ -1,21 +0,0 @@ -package v6_5_0 - -import ( - store "cosmossdk.io/store/types" - "github.com/notional-labs/composable/v6/app/upgrades" - ibctransfermiddleware "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types" -) - -const ( - // UpgradeName defines the on-chain upgrade name for the composable upgrade. - UpgradeName = "v6_5_0" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: UpgradeName, - CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: store.StoreUpgrades{ - Added: []string{ibctransfermiddleware.StoreKey}, - Deleted: []string{}, - }, -} diff --git a/app/upgrades/v6_5_0/upgrade.go b/app/upgrades/v6_5_0/upgrade.go deleted file mode 100644 index 92ea1d65..00000000 --- a/app/upgrades/v6_5_0/upgrade.go +++ /dev/null @@ -1,51 +0,0 @@ -package v6_5_0 - -import ( - "context" - - sdkmath "cosmossdk.io/math" - upgradetypes "cosmossdk.io/x/upgrade/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - - "github.com/cosmos/cosmos-sdk/codec" - "github.com/notional-labs/composable/v6/app/keepers" - "github.com/notional-labs/composable/v6/app/upgrades" - ibctransfermiddleware "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types" -) - -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - _ upgrades.BaseAppParamManager, - _ codec.Codec, - keepers *keepers.AppKeepers, -) upgradetypes.UpgradeHandler { - return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { - sdkctx := sdk.UnwrapSDKContext(ctx) - custommiddlewareparams := ibctransfermiddleware.DefaultGenesisState() - keepers.IbcTransferMiddlewareKeeper.SetParams(sdkctx, custommiddlewareparams.Params) - - // remove broken proposals - //BrokenProposals := [3]uint64{2, 6, 11} - //for _, proposal_id := range BrokenProposals { - // _, err := keepers.GovKeeper.Proposals.Get(sdkctx, proposal_id) - // if err != nil { - // keepers.GovKeeper.DeleteProposal(sdkctx, proposal_id) - // } - // - //} - - // burn extra ppica in escrow account - // this ppica is unused because it is a native token stored in escrow account - // it was unnecessarily minted to match pica escrowed on picasso to ppica minted - // in genesis, to make initial native ppica transferrable to picasso - amount, ok := sdkmath.NewIntFromString("1066669217167120000000") - if ok { - coins := sdk.Coins{sdk.NewCoin("ppica", amount)} - keepers.BankKeeper.SendCoinsFromAccountToModule(ctx, sdk.MustAccAddressFromBech32("centauri12k2pyuylm9t7ugdvz67h9pg4gmmvhn5vmvgw48"), "gov", coins) - keepers.BankKeeper.BurnCoins(ctx, "gov", coins) - } - return mm.RunMigrations(ctx, configurator, vm) - } -} diff --git a/app/upgrades/v6_5_1/constants.go b/app/upgrades/v6_5_1/constants.go index 4c7f2b5e..2189e34a 100644 --- a/app/upgrades/v6_5_1/constants.go +++ b/app/upgrades/v6_5_1/constants.go @@ -1,7 +1,7 @@ package v6_5_1 import ( - store "github.com/cosmos/cosmos-sdk/store/types" + store "cosmossdk.io/store/types" "github.com/notional-labs/composable/v6/app/upgrades" ) diff --git a/app/upgrades/v6_5_1/upgrade.go b/app/upgrades/v6_5_1/upgrade.go index 3d8fd257..4de00e4f 100644 --- a/app/upgrades/v6_5_1/upgrade.go +++ b/app/upgrades/v6_5_1/upgrade.go @@ -1,9 +1,9 @@ package v6_5_1 import ( - sdk "github.com/cosmos/cosmos-sdk/types" + "context" + upgradetypes "cosmossdk.io/x/upgrade/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" @@ -17,7 +17,7 @@ func CreateUpgradeHandler( _ codec.Codec, keepers *keepers.AppKeepers, ) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { return mm.RunMigrations(ctx, configurator, vm) } } From 9c1f2211841a1bbb45cdfccbe66a8241ee026fe5 Mon Sep 17 00:00:00 2001 From: Khanh Hoa Date: Wed, 3 Apr 2024 11:03:41 +0700 Subject: [PATCH 5/5] refactor pfm --- app/keepers/keepers.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index c3b5ff41..347233b6 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -330,6 +330,17 @@ func (appKeepers *AppKeepers) InitNormalKeepers( authorityAddress, ) + appKeepers.RouterKeeper = routerkeeper.NewKeeper( + appCodec, + appKeepers.keys[routertypes.StoreKey], + appKeepers.TransferKeeper.Keeper, + appKeepers.IBCKeeper.ChannelKeeper, + &appKeepers.DistrKeeper, + appKeepers.BankKeeper, + &appKeepers.TransferMiddlewareKeeper, + govModAddress, + ) + appKeepers.TransferKeeper = customibctransferkeeper.NewKeeper( appCodec, appKeepers.keys[ibctransfertypes.StoreKey], appKeepers.GetSubspace(ibctransfertypes.ModuleName), @@ -342,17 +353,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers( &appKeepers.IbcTransferMiddlewareKeeper, govModAddress, ) - - appKeepers.RouterKeeper = routerkeeper.NewKeeper( - appCodec, - appKeepers.keys[routertypes.StoreKey], - appKeepers.TransferKeeper.Keeper, - appKeepers.IBCKeeper.ChannelKeeper, - &appKeepers.DistrKeeper, - appKeepers.BankKeeper, - &appKeepers.TransferMiddlewareKeeper, - govModAddress, - ) + appKeepers.RouterKeeper.SetTransferKeeper(appKeepers.TransferKeeper) appKeepers.RatelimitKeeper = *ratelimitmodulekeeper.NewKeeper( appCodec,