From 85da88055fedd3d388a5ce7a30b43e421ec30d5b Mon Sep 17 00:00:00 2001 From: tungle Date: Mon, 18 Mar 2024 19:02:40 +0700 Subject: [PATCH] rebase and change conflict version --- app/app.go | 4 +- app/test_helpers.go | 5 -- app/upgrades/v6_4_6/contants.go | 22 ++++++++ app/upgrades/v6_4_6/upgrade.go | 28 +++++++++++ app/upgrades/v6_4_7/constants.go | 2 +- app/upgrades/v6_4_8/constants.go | 15 ++++++ app/upgrades/v6_4_8/upgrade.go | 50 +++++++++++++++++++ .../{v6_4_7 => v6_4_8}/upgrades_test.go | 2 +- scripts/test-upgrade-cosmos-chains.sh | 10 ++-- scripts/test-upgrade.sh | 6 +-- .../post-script-ibc-transfer.sh | 0 .../{v_6_4_7 => v_6_4_8}/post-script.sh | 0 .../pre-script-ibc-transfer.sh | 0 .../{v_6_4_7 => v_6_4_8}/pre-script.sh | 0 14 files changed, 127 insertions(+), 17 deletions(-) create mode 100644 app/upgrades/v6_4_6/contants.go create mode 100644 app/upgrades/v6_4_6/upgrade.go create mode 100644 app/upgrades/v6_4_8/constants.go create mode 100644 app/upgrades/v6_4_8/upgrade.go rename app/upgrades/{v6_4_7 => v6_4_8}/upgrades_test.go (99%) rename scripts/upgrade/{v_6_4_7 => v_6_4_8}/post-script-ibc-transfer.sh (100%) rename scripts/upgrade/{v_6_4_7 => v_6_4_8}/post-script.sh (100%) rename scripts/upgrade/{v_6_4_7 => v_6_4_8}/pre-script-ibc-transfer.sh (100%) rename scripts/upgrade/{v_6_4_7 => v_6_4_8}/pre-script.sh (100%) diff --git a/app/app.go b/app/app.go index a59d241ea..fbf96e3ef 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_4_7" + "github.com/notional-labs/composable/v6/app/upgrades/v6_4_8" // 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_4_7.Upgrade} + Upgrades = []upgrades.Upgrade{v6_4_8.Upgrade} Forks = []upgrades.Fork{} ) diff --git a/app/test_helpers.go b/app/test_helpers.go index ad38faf37..893b6b17a 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -183,12 +183,7 @@ func setup(tb testing.TB, withGenesis bool, invCheckPeriod uint) (*ComposableApp invCheckPeriod, MakeEncodingConfig(), EmptyBaseAppOptions{}, -<<<<<<< HEAD - wasmOpts, - baseAppOpts...) -======= wasmOpts, nil) ->>>>>>> 828e70a1 (refactor: update test) if withGenesis { return app, NewDefaultGenesisState() } diff --git a/app/upgrades/v6_4_6/contants.go b/app/upgrades/v6_4_6/contants.go new file mode 100644 index 000000000..cbb8a3658 --- /dev/null +++ b/app/upgrades/v6_4_6/contants.go @@ -0,0 +1,22 @@ +package v6_4_6 + +import ( + store "github.com/cosmos/cosmos-sdk/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_4_5" +) + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: store.StoreUpgrades{ + Added: []string{ibctransfermiddleware.StoreKey}, + Deleted: []string{}, + }, +} diff --git a/app/upgrades/v6_4_6/upgrade.go b/app/upgrades/v6_4_6/upgrade.go new file mode 100644 index 000000000..183e63e80 --- /dev/null +++ b/app/upgrades/v6_4_6/upgrade.go @@ -0,0 +1,28 @@ +package v6_4_6 + +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" + 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 sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + // Add params for custom middleware + custommiddlewareparams := ibctransfermiddleware.DefaultGenesisState() + keepers.IbcTransferMiddlewareKeeper.SetParams(ctx, custommiddlewareparams.Params) + + return mm.RunMigrations(ctx, configurator, vm) + } +} diff --git a/app/upgrades/v6_4_7/constants.go b/app/upgrades/v6_4_7/constants.go index e6bdd1fcd..549c1e41e 100644 --- a/app/upgrades/v6_4_7/constants.go +++ b/app/upgrades/v6_4_7/constants.go @@ -8,7 +8,7 @@ import ( const ( // UpgradeName defines the on-chain upgrade name for the composable upgrade. - UpgradeName = "v6_4_7" + UpgradeName = "v6_4_6" ) var Upgrade = upgrades.Upgrade{ diff --git a/app/upgrades/v6_4_8/constants.go b/app/upgrades/v6_4_8/constants.go new file mode 100644 index 000000000..aa728ef62 --- /dev/null +++ b/app/upgrades/v6_4_8/constants.go @@ -0,0 +1,15 @@ +package v6_4_8 + +import ( + "github.com/notional-labs/composable/v6/app/upgrades" +) + +const ( + // UpgradeName defines the on-chain upgrade name for the composable upgrade. + UpgradeName = "v6_4_7" +) + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, +} diff --git a/app/upgrades/v6_4_8/upgrade.go b/app/upgrades/v6_4_8/upgrade.go new file mode 100644 index 000000000..7efee8ce7 --- /dev/null +++ b/app/upgrades/v6_4_8/upgrade.go @@ -0,0 +1,50 @@ +package v6_4_8 + +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" + icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/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" + bech32icamigration "github.com/notional-labs/composable/v6/bech32-migration/ica" + bech32mintmigration "github.com/notional-labs/composable/v6/bech32-migration/mint" + 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) + return mm.RunMigrations(ctx, configurator, vm) + } +} diff --git a/app/upgrades/v6_4_7/upgrades_test.go b/app/upgrades/v6_4_8/upgrades_test.go similarity index 99% rename from app/upgrades/v6_4_7/upgrades_test.go rename to app/upgrades/v6_4_8/upgrades_test.go index f87ee94d5..20c73f7e4 100644 --- a/app/upgrades/v6_4_7/upgrades_test.go +++ b/app/upgrades/v6_4_8/upgrades_test.go @@ -1,4 +1,4 @@ -package v6_4_7_test +package v6_4_8_test import ( "encoding/json" diff --git a/scripts/test-upgrade-cosmos-chains.sh b/scripts/test-upgrade-cosmos-chains.sh index a7b7f5db7..6268fc345 100755 --- a/scripts/test-upgrade-cosmos-chains.sh +++ b/scripts/test-upgrade-cosmos-chains.sh @@ -9,9 +9,9 @@ HOME=mytestnet ROOT=$(pwd) DENOM=stake CHAIN_ID1=test-1 -SOFTWARE_UPGRADE_NAME="v6_4_6" -ADDITIONAL_PRE_SCRIPTS="./scripts/upgrade/v_6_4_7/pre-script-ibc-transfer.sh" -ADDITIONAL_AFTER_SCRIPTS="./scripts/upgrade/v_6_4_7/post-script-ibc-transfer.sh" +SOFTWARE_UPGRADE_NAME="v6_4_8" +ADDITIONAL_PRE_SCRIPTS="./scripts/upgrade/v_6_4_8/pre-script-ibc-transfer.sh" +ADDITIONAL_AFTER_SCRIPTS="./scripts/upgrade/v_6_4_8/post-script-ibc-transfer.sh" SETUP_RELAYER_SCRIPTS="./scripts/relayer/relayer-init.sh" CHAIN_DIR=$(pwd)/data @@ -61,7 +61,7 @@ source $SETUP_RELAYER_SCRIPTS # Transfer from chain 1 to chain 2 and return balance of sender on chain 1 echo "executing additional pre scripts from $ADDITIONAL_PRE_SCRIPTS" -bash ./scripts/upgrade/v_6_4_7/pre-script-ibc-transfer.sh +bash ./scripts/upgrade/v_6_4_8/pre-script-ibc-transfer.sh run_fork () { echo "forking" @@ -148,7 +148,7 @@ CONTINUE="true" bash scripts/two-testnodes.sh _build/new/picad sleep 5 echo "executing additional post scripts from $ADDITIONAL_AFTER_SCRIPTS" -bash ./scripts/upgrade/v_6_4_7/post-script-ibc-transfer.sh +bash ./scripts/upgrade/v_6_4_8/post-script-ibc-transfer.sh echo "" echo "#########################################################" diff --git a/scripts/test-upgrade.sh b/scripts/test-upgrade.sh index e584f8a25..99c11fcfc 100755 --- a/scripts/test-upgrade.sh +++ b/scripts/test-upgrade.sh @@ -9,9 +9,9 @@ HOME=mytestnet ROOT=$(pwd) DENOM=upica CHAIN_ID=localpica -SOFTWARE_UPGRADE_NAME="v6_4_7" -ADDITIONAL_PRE_SCRIPTS="./scripts/upgrade/v_6_4_7/pre-script.sh" -ADDITIONAL_AFTER_SCRIPTS="./scripts/upgrade/v_6_4_7/post-script.sh" +SOFTWARE_UPGRADE_NAME="v6_4_8" +ADDITIONAL_PRE_SCRIPTS="./scripts/upgrade/v_6_4_8/pre-script.sh" +ADDITIONAL_AFTER_SCRIPTS="./scripts/upgrade/v_6_4_8/post-script.sh" SLEEP_TIME=1 diff --git a/scripts/upgrade/v_6_4_7/post-script-ibc-transfer.sh b/scripts/upgrade/v_6_4_8/post-script-ibc-transfer.sh similarity index 100% rename from scripts/upgrade/v_6_4_7/post-script-ibc-transfer.sh rename to scripts/upgrade/v_6_4_8/post-script-ibc-transfer.sh diff --git a/scripts/upgrade/v_6_4_7/post-script.sh b/scripts/upgrade/v_6_4_8/post-script.sh similarity index 100% rename from scripts/upgrade/v_6_4_7/post-script.sh rename to scripts/upgrade/v_6_4_8/post-script.sh diff --git a/scripts/upgrade/v_6_4_7/pre-script-ibc-transfer.sh b/scripts/upgrade/v_6_4_8/pre-script-ibc-transfer.sh similarity index 100% rename from scripts/upgrade/v_6_4_7/pre-script-ibc-transfer.sh rename to scripts/upgrade/v_6_4_8/pre-script-ibc-transfer.sh diff --git a/scripts/upgrade/v_6_4_7/pre-script.sh b/scripts/upgrade/v_6_4_8/pre-script.sh similarity index 100% rename from scripts/upgrade/v_6_4_7/pre-script.sh rename to scripts/upgrade/v_6_4_8/pre-script.sh