From 1897d3547bc5f1c32306f283dd64591cd966bc30 Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Tue, 14 May 2024 02:58:32 +0000 Subject: [PATCH 01/14] Added DistributionTransmissionChannel to Whitelist --- app/proposals_whitelisting.go | 1 + 1 file changed, 1 insertion(+) diff --git a/app/proposals_whitelisting.go b/app/proposals_whitelisting.go index d793fa6..1e74b1d 100644 --- a/app/proposals_whitelisting.go +++ b/app/proposals_whitelisting.go @@ -70,6 +70,7 @@ var WhitelistedParams = map[paramChangeKey]struct{}{ // ccv params (note: some CCV params should not be configurable or require special coordination with the provider chain) {Subspace: consumertypes.ModuleName, Key: "ProviderRewardDenoms"}: {}, {Subspace: consumertypes.ModuleName, Key: "RewardDenoms"}: {}, + {Subspace: consumertypes.ModuleName, Key: "DistributionTransmissionChannel"}: {}, {Subspace: consumertypes.ModuleName, Key: "ConsumerRedistributionFraction"}: {}, {Subspace: consumertypes.ModuleName, Key: "BlocksPerDistributionTransmission"}: {}, {Subspace: consumertypes.ModuleName, Key: "TransferTimeoutPeriod"}: {}, From d789ddc7e16764a5f08cdf09ddd3a29c9443b4d6 Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Wed, 15 May 2024 19:15:18 +0000 Subject: [PATCH 02/14] Change upgrade version --- app/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index 357464a..bc067d7 100644 --- a/app/app.go +++ b/app/app.go @@ -124,7 +124,7 @@ import ( const ( AppName = "onex" - upgradeName = "v1.1.0" + upgradeName = "v1.1.2-testnet" AccountAddressPrefix = "onomy" ) From 8fe963d684bcb4594ec4e5ad6f0ee9541c0cdae1 Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Thu, 16 May 2024 17:21:40 +0000 Subject: [PATCH 03/14] Add in upgrade handler --- app/app.go | 18 ++++++++---------- app/upgrades/v1.1.3/upgrade.go | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 app/upgrades/v1.1.3/upgrade.go diff --git a/app/app.go b/app/app.go index bc067d7..cc8dd3d 100644 --- a/app/app.go +++ b/app/app.go @@ -8,8 +8,6 @@ import ( "os" "path/filepath" - // v0 "github.com/onomyprotocol/onex/app/upgrades/" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" @@ -120,15 +118,17 @@ import ( marketclient "github.com/pendulum-labs/market/x/market/client" marketkeeper "github.com/pendulum-labs/market/x/market/keeper" markettypes "github.com/pendulum-labs/market/x/market/types" + + v1_1_3 "github.com/onomyprotocol/onex/app/upgrades/v1.1.3" ) const ( AppName = "onex" - upgradeName = "v1.1.2-testnet" AccountAddressPrefix = "onomy" ) var ( + // DefaultNodeHome default home directories for the application daemon DefaultNodeHome string @@ -554,6 +554,7 @@ func New( consumertypes.ModuleName, ) app.MM.SetOrderEndBlockers( + upgradetypes.ModuleName, crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName, @@ -567,7 +568,6 @@ func New( authz.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, - upgradetypes.ModuleName, vestingtypes.ModuleName, ibctransfertypes.ModuleName, ibchost.ModuleName, @@ -582,6 +582,7 @@ func New( // so that other modules that want to create or claim capabilities afterwards in InitChain // can do so safely. app.MM.SetOrderInitGenesis( + upgradetypes.ModuleName, capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, @@ -595,7 +596,6 @@ func New( authz.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, - upgradetypes.ModuleName, vestingtypes.ModuleName, ibchost.ModuleName, ibctransfertypes.ModuleName, @@ -659,7 +659,7 @@ func New( app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) - app.setupUpgradeHandlers(app.configurator) + app.setupUpgradeHandlers() if loadLatest { if err := app.LoadLatestVersion(); err != nil { @@ -918,10 +918,8 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino return paramsKeeper } -func (app *App) setupUpgradeHandlers(cfg module.Configurator) { - app.UpgradeKeeper.SetUpgradeHandler(upgradeName, func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { - return app.MM.RunMigrations(ctx, cfg, vm) - }) +func (app *App) setupUpgradeHandlers() { + app.UpgradeKeeper.SetUpgradeHandler(v1_1_3.Name, v1_1_3.UpgradeHandler) upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() if err != nil { diff --git a/app/upgrades/v1.1.3/upgrade.go b/app/upgrades/v1.1.3/upgrade.go new file mode 100644 index 0000000..4a7c3e9 --- /dev/null +++ b/app/upgrades/v1.1.3/upgrade.go @@ -0,0 +1,16 @@ +// Package v1_1_3 is contains chain upgrade of the corresponding version. +package v1_1_3 //nolint:revive,stylecheck // app version + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +// Name is migration name. +const Name = "v1.1.3" + +// UpgradeHandler is an x/upgrade handler. +func UpgradeHandler(_ sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + return vm, nil +} From 113be772dc5fc1600c70cbc685542cca4132fb31 Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Sun, 26 May 2024 14:19:16 -0500 Subject: [PATCH 04/14] Add in Market v1.1.3-dev dependency and pool reset --- app/app.go | 36 +++++++++++++--------- app/upgrades/types.go | 33 ++++++++++++++++++++ app/upgrades/v1.1.3/upgrade.go | 16 ---------- app/upgrades/v1.1.4/constants.go | 15 +++++++++ app/upgrades/v1.1.4/upgrade.go | 52 ++++++++++++++++++++++++++++++++ go.mod | 2 +- go.sum | 4 +-- 7 files changed, 125 insertions(+), 33 deletions(-) create mode 100644 app/upgrades/types.go delete mode 100644 app/upgrades/v1.1.3/upgrade.go create mode 100644 app/upgrades/v1.1.4/constants.go create mode 100644 app/upgrades/v1.1.4/upgrade.go diff --git a/app/app.go b/app/app.go index cc8dd3d..c3af161 100644 --- a/app/app.go +++ b/app/app.go @@ -18,7 +18,6 @@ import ( "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/simapp" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/version" @@ -119,7 +118,8 @@ import ( marketkeeper "github.com/pendulum-labs/market/x/market/keeper" markettypes "github.com/pendulum-labs/market/x/market/types" - v1_1_3 "github.com/onomyprotocol/onex/app/upgrades/v1.1.3" + "github.com/onomyprotocol/onex/app/upgrades" + v1_1_4 "github.com/onomyprotocol/onex/app/upgrades/v1.1.4" ) const ( @@ -128,6 +128,7 @@ const ( ) var ( + Upgrades = []upgrades.Upgrade{v1_1_4.Upgrade} // DefaultNodeHome default home directories for the application daemon DefaultNodeHome string @@ -918,27 +919,34 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino return paramsKeeper } -func (app *App) setupUpgradeHandlers() { - app.UpgradeKeeper.SetUpgradeHandler(v1_1_3.Name, v1_1_3.UpgradeHandler) - +func (app *App) setupUpgradeStoreLoaders() { upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() if err != nil { - panic(fmt.Errorf("failed to read upgrade info from disk: %w", err)) + panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) } - // configure store loader that checks if version == upgradeHeight and applies store upgrades if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { return } - var storeUpgrades *storetypes.StoreUpgrades - - switch upgradeInfo.Name { - default: - // no store upgrades + for _, upgrade := range Upgrades { + if upgradeInfo.Name == upgrade.UpgradeName { + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrade.StoreUpgrades)) + } } +} - if storeUpgrades != nil { - app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, storeUpgrades)) +func (app *App) setupUpgradeHandlers() { + for _, upgrade := range Upgrades { + app.UpgradeKeeper.SetUpgradeHandler( + upgrade.UpgradeName, + upgrade.CreateUpgradeHandler( + app.MM, + app.configurator, + &upgrades.UpgradeKeepers{ + MarketKeeper: app.MarketKeeper, + }, + ), + ) } } diff --git a/app/upgrades/types.go b/app/upgrades/types.go new file mode 100644 index 0000000..6515d07 --- /dev/null +++ b/app/upgrades/types.go @@ -0,0 +1,33 @@ +package upgrades + +import ( + store "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/types/module" + slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" + marketkeeper "github.com/pendulum-labs/market/x/market/keeper" +) + +// Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal +// must have written, in order for the state migration to go smoothly. +// An upgrade must implement this struct, and then set it in the app.go. +// The app.go will then define the handler. +type Upgrade struct { + // Upgrade version name, for the upgrade handler, e.g. `v7` + UpgradeName string + + // CreateUpgradeHandler defines the function that creates an upgrade handler + CreateUpgradeHandler func(*module.Manager, module.Configurator, *UpgradeKeepers) upgradetypes.UpgradeHandler + + // Store upgrades, should be used for any new modules introduced, new modules deleted, or store names renamed. + StoreUpgrades store.StoreUpgrades +} + +type UpgradeKeepers struct { + // keepers + SlashingKeeper slashingkeeper.Keeper + ParamsKeeper paramskeeper.Keeper + MarketKeeper marketkeeper.Keeper +} diff --git a/app/upgrades/v1.1.3/upgrade.go b/app/upgrades/v1.1.3/upgrade.go deleted file mode 100644 index 4a7c3e9..0000000 --- a/app/upgrades/v1.1.3/upgrade.go +++ /dev/null @@ -1,16 +0,0 @@ -// Package v1_1_3 is contains chain upgrade of the corresponding version. -package v1_1_3 //nolint:revive,stylecheck // app version - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" -) - -// Name is migration name. -const Name = "v1.1.3" - -// UpgradeHandler is an x/upgrade handler. -func UpgradeHandler(_ sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { - return vm, nil -} diff --git a/app/upgrades/v1.1.4/constants.go b/app/upgrades/v1.1.4/constants.go new file mode 100644 index 0000000..7c8ec07 --- /dev/null +++ b/app/upgrades/v1.1.4/constants.go @@ -0,0 +1,15 @@ +package v1_1_4 + +import ( + "github.com/onomyprotocol/onex/app/upgrades" +) + +const ( + // UpgradeName defines the on-chain upgrades name. + UpgradeName = "v1.1.4" +) + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, +} diff --git a/app/upgrades/v1.1.4/upgrade.go b/app/upgrades/v1.1.4/upgrade.go new file mode 100644 index 0000000..983d14d --- /dev/null +++ b/app/upgrades/v1.1.4/upgrade.go @@ -0,0 +1,52 @@ +// Package v1_1_4 is contains chain upgrade of the corresponding version. +package v1_1_4 //nolint:revive,stylecheck // app version + +import ( + "github.com/onomyprotocol/onex/app/upgrades" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + markettypes "github.com/pendulum-labs/market/x/market/types" +) + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + keepers *upgrades.UpgradeKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + ctx.Logger().Info("Starting module migrations...") + + // Deactivate all drops + drops := keepers.MarketKeeper.GetAllDrop(ctx) + for _, drop := range drops { + drop.Active = false + keepers.MarketKeeper.SetDrop(ctx, drop) + } + + // Set pool drops to zero and wipe leaders + pools := keepers.MarketKeeper.GetAllPool(ctx) + for _, pool := range pools { + pool.Drops = sdk.ZeroInt() + pool.Leaders = []*markettypes.Leader{} + + keepers.MarketKeeper.SetPool(ctx, pool) + } + + // Set member balances to zero + members := keepers.MarketKeeper.GetAllMember(ctx) + for _, member := range members { + member.Balance = sdk.ZeroInt() + keepers.MarketKeeper.SetMember(ctx, member) + } + + vm, err := mm.RunMigrations(ctx, configurator, vm) + if err != nil { + return vm, err + } + + ctx.Logger().Info("Upgrade complete") + return vm, err + } +} diff --git a/go.mod b/go.mod index 10ea8a3..895e0e8 100644 --- a/go.mod +++ b/go.mod @@ -155,7 +155,7 @@ replace ( github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.45.16-ics github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 - github.com/pendulum-labs/market => github.com/onomyprotocol/market v1.1.2-dev + github.com/pendulum-labs/market => github.com/onomyprotocol/market v1.1.3-dev github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.28 google.golang.org/grpc => google.golang.org/grpc v1.33.2 ) diff --git a/go.sum b/go.sum index e5f844f..521c298 100644 --- a/go.sum +++ b/go.sum @@ -2204,8 +2204,8 @@ github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:v github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.2/go.mod h1:rSAaSIOAGT9odnlyGlUfAJaoc5w2fSBUmeGDbRWPxyQ= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/onomyprotocol/market v1.1.2-dev h1:uLCI2DMclMrKJ9YGi7RyOz5EmG8b7EvJoNwgqfwp5Ks= -github.com/onomyprotocol/market v1.1.2-dev/go.mod h1:OFWUMLq8cfNRQnc6WqReQYq+hNYRqoc2RmMvECSxdwk= +github.com/onomyprotocol/market v1.1.3-dev h1:t1auMPtqHiFumVjlpYibVMe4dI8LdgsCH0h5Ybo3YR8= +github.com/onomyprotocol/market v1.1.3-dev/go.mod h1:OFWUMLq8cfNRQnc6WqReQYq+hNYRqoc2RmMvECSxdwk= github.com/onsi/ginkgo v0.0.0-20151202141238-7f8ab55aaf3b/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= From 74ef7c5cf4cb8610b517aa2d241c3fa69028da5c Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Sun, 26 May 2024 15:47:23 -0500 Subject: [PATCH 05/14] Add in reclaimation of pool funds --- app/app.go | 5 +++-- app/upgrades/types.go | 9 +++----- app/upgrades/{v1.1.4 => v1.1.5}/constants.go | 4 ++-- app/upgrades/{v1.1.4 => v1.1.5}/upgrade.go | 22 ++++++++++++++++++-- 4 files changed, 28 insertions(+), 12 deletions(-) rename app/upgrades/{v1.1.4 => v1.1.5}/constants.go (85%) rename app/upgrades/{v1.1.4 => v1.1.5}/upgrade.go (58%) diff --git a/app/app.go b/app/app.go index c3af161..8f3fd32 100644 --- a/app/app.go +++ b/app/app.go @@ -119,7 +119,7 @@ import ( markettypes "github.com/pendulum-labs/market/x/market/types" "github.com/onomyprotocol/onex/app/upgrades" - v1_1_4 "github.com/onomyprotocol/onex/app/upgrades/v1.1.4" + v1_1_5 "github.com/onomyprotocol/onex/app/upgrades/v1.1.5" ) const ( @@ -128,7 +128,7 @@ const ( ) var ( - Upgrades = []upgrades.Upgrade{v1_1_4.Upgrade} + Upgrades = []upgrades.Upgrade{v1_1_5.Upgrade} // DefaultNodeHome default home directories for the application daemon DefaultNodeHome string @@ -944,6 +944,7 @@ func (app *App) setupUpgradeHandlers() { app.MM, app.configurator, &upgrades.UpgradeKeepers{ + BankKeeper: app.BankKeeper, MarketKeeper: app.MarketKeeper, }, ), diff --git a/app/upgrades/types.go b/app/upgrades/types.go index 6515d07..d775913 100644 --- a/app/upgrades/types.go +++ b/app/upgrades/types.go @@ -3,10 +3,8 @@ package upgrades import ( store "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/types/module" - slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - - paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" marketkeeper "github.com/pendulum-labs/market/x/market/keeper" ) @@ -27,7 +25,6 @@ type Upgrade struct { type UpgradeKeepers struct { // keepers - SlashingKeeper slashingkeeper.Keeper - ParamsKeeper paramskeeper.Keeper - MarketKeeper marketkeeper.Keeper + BankKeeper bankkeeper.Keeper + MarketKeeper marketkeeper.Keeper } diff --git a/app/upgrades/v1.1.4/constants.go b/app/upgrades/v1.1.5/constants.go similarity index 85% rename from app/upgrades/v1.1.4/constants.go rename to app/upgrades/v1.1.5/constants.go index 7c8ec07..1bdc280 100644 --- a/app/upgrades/v1.1.4/constants.go +++ b/app/upgrades/v1.1.5/constants.go @@ -1,4 +1,4 @@ -package v1_1_4 +package v1_1_5 import ( "github.com/onomyprotocol/onex/app/upgrades" @@ -6,7 +6,7 @@ import ( const ( // UpgradeName defines the on-chain upgrades name. - UpgradeName = "v1.1.4" + UpgradeName = "v1.1.5" ) var Upgrade = upgrades.Upgrade{ diff --git a/app/upgrades/v1.1.4/upgrade.go b/app/upgrades/v1.1.5/upgrade.go similarity index 58% rename from app/upgrades/v1.1.4/upgrade.go rename to app/upgrades/v1.1.5/upgrade.go index 983d14d..c22e8e2 100644 --- a/app/upgrades/v1.1.4/upgrade.go +++ b/app/upgrades/v1.1.5/upgrade.go @@ -1,5 +1,5 @@ -// Package v1_1_4 is contains chain upgrade of the corresponding version. -package v1_1_4 //nolint:revive,stylecheck // app version +// Package v1_1_5 is contains chain upgrade of the corresponding version. +package v1_1_5 //nolint:revive,stylecheck // app version import ( "github.com/onomyprotocol/onex/app/upgrades" @@ -41,6 +41,24 @@ func CreateUpgradeHandler( keepers.MarketKeeper.SetMember(ctx, member) } + onexAmount, _ := sdk.NewIntFromString("94784650277373001264452") + + ibc1Amount, _ := sdk.NewIntFromString("998915079") + + ibc2Amount, _ := sdk.NewIntFromString("28966246179579930912901") + + ibc3Amount, _ := sdk.NewIntFromString("2952795016") + + onexCoin := sdk.NewCoin("aonex", onexAmount) + ibc1 := sdk.NewCoin("ibc/30EDC220372A2C3D0FC1D987E19062E35375DECD1001A5EFA44EB92FF59D1867", ibc1Amount) + ibc2 := sdk.NewCoin("ibc/5BDD8875CC2AF7BC842BE44236ACD576EA4F53C36347F74903B852060D6BF29A", ibc2Amount) + ibc3 := sdk.NewCoin("ibc/CCCBD7307FEB70B0CF7ADF8503F711F6741F41623D25BAD8CB736E03BE384264", ibc3Amount) + + reclaimCoins := sdk.NewCoins(onexCoin, ibc1, ibc2, ibc3) + reclaimer, _ := sdk.AccAddressFromBech32("onomy1yc0lg97cy5e80jyajtkz0zke2rr4734anugf9g") + + keepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, markettypes.ModuleName, reclaimer, reclaimCoins) + vm, err := mm.RunMigrations(ctx, configurator, vm) if err != nil { return vm, err From c26e1cdad178542baa5a3e590c169487d9c82fb6 Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Sun, 26 May 2024 17:17:41 -0500 Subject: [PATCH 06/14] Add in fork logic --- app/app.go | 4 +- app/fork.go | 19 +++++++++ app/upgrades/types.go | 22 ++++++++++ app/upgrades/v1.1.5/constants.go | 10 +++-- app/upgrades/v1.1.5/fork.go | 59 +++++++++++++++++++++++++++ app/upgrades/v1.1.5/upgrade.go | 70 -------------------------------- 6 files changed, 109 insertions(+), 75 deletions(-) create mode 100644 app/fork.go create mode 100644 app/upgrades/v1.1.5/fork.go delete mode 100644 app/upgrades/v1.1.5/upgrade.go diff --git a/app/app.go b/app/app.go index 8f3fd32..fb5f6a9 100644 --- a/app/app.go +++ b/app/app.go @@ -128,7 +128,8 @@ const ( ) var ( - Upgrades = []upgrades.Upgrade{v1_1_5.Upgrade} + Upgrades = []upgrades.Upgrade{} + Forks = []upgrades.Fork{v1_1_5.Fork} // DefaultNodeHome default home directories for the application daemon DefaultNodeHome string @@ -680,6 +681,7 @@ func (app *App) Name() string { return app.BaseApp.Name() } // BeginBlocker application updates every begin block func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { + BeginBlockForks(ctx, app) return app.MM.BeginBlock(ctx, req) } diff --git a/app/fork.go b/app/fork.go new file mode 100644 index 0000000..9b36742 --- /dev/null +++ b/app/fork.go @@ -0,0 +1,19 @@ +package app + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/onomyprotocol/onex/app/upgrades" +) + +// BeginBlockForks is intended to be ran in a chain upgrade. +func BeginBlockForks(ctx sdk.Context, app *App) { + for _, fork := range Forks { + if ctx.BlockHeight() == fork.UpgradeHeight { + fork.BeginForkLogic(ctx, &upgrades.ForkKeepers{ + BankKeeper: app.BankKeeper, + MarketKeeper: app.MarketKeeper, + }) + return + } + } +} diff --git a/app/upgrades/types.go b/app/upgrades/types.go index d775913..8379495 100644 --- a/app/upgrades/types.go +++ b/app/upgrades/types.go @@ -2,6 +2,7 @@ package upgrades import ( store "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" @@ -28,3 +29,24 @@ type UpgradeKeepers struct { BankKeeper bankkeeper.Keeper MarketKeeper marketkeeper.Keeper } + +// Fork defines a struct containing the requisite fields for a non-software upgrade proposal +// Hard Fork at a given height to implement. +// There is one time code that can be added for the start of the Fork, in `BeginForkLogic`. +// Any other change in the code should be height-gated, if the goal is to have old and new binaries +// to be compatible prior to the upgrade height. +type Fork struct { + // Upgrade version name, for the upgrade handler, e.g. `v7` + UpgradeName string + // height the upgrade occurs at + UpgradeHeight int64 + + // Function that runs some custom state transition code at the beginning of a fork. + BeginForkLogic func(ctx sdk.Context, keepers *ForkKeepers) +} + +type ForkKeepers struct { + // keepers + BankKeeper bankkeeper.Keeper + MarketKeeper marketkeeper.Keeper +} diff --git a/app/upgrades/v1.1.5/constants.go b/app/upgrades/v1.1.5/constants.go index 1bdc280..9f36004 100644 --- a/app/upgrades/v1.1.5/constants.go +++ b/app/upgrades/v1.1.5/constants.go @@ -6,10 +6,12 @@ import ( const ( // UpgradeName defines the on-chain upgrades name. - UpgradeName = "v1.1.5" + UpgradeName = "v1_1_5" + UpgradeHeight = 389310 ) -var Upgrade = upgrades.Upgrade{ - UpgradeName: UpgradeName, - CreateUpgradeHandler: CreateUpgradeHandler, +var Fork = upgrades.Fork{ + UpgradeName: UpgradeName, + UpgradeHeight: UpgradeHeight, + BeginForkLogic: RunForkLogic, } diff --git a/app/upgrades/v1.1.5/fork.go b/app/upgrades/v1.1.5/fork.go new file mode 100644 index 0000000..d8cae7e --- /dev/null +++ b/app/upgrades/v1.1.5/fork.go @@ -0,0 +1,59 @@ +// Package v1_1_5 is contains chain fork of the corresponding version. +package v1_1_5 //nolint:revive,stylecheck // app version + +import ( + "github.com/onomyprotocol/onex/app/upgrades" + + sdk "github.com/cosmos/cosmos-sdk/types" + markettypes "github.com/pendulum-labs/market/x/market/types" +) + +func RunForkLogic( + ctx sdk.Context, + keepers *upgrades.ForkKeepers, +) { + ctx.Logger().Info("Starting fork...") + + // Deactivate all drops + drops := keepers.MarketKeeper.GetAllDrop(ctx) + for _, drop := range drops { + drop.Active = false + keepers.MarketKeeper.SetDrop(ctx, drop) + } + + // Set pool drops to zero and wipe leaders + pools := keepers.MarketKeeper.GetAllPool(ctx) + for _, pool := range pools { + pool.Drops = sdk.ZeroInt() + pool.Leaders = []*markettypes.Leader{} + + keepers.MarketKeeper.SetPool(ctx, pool) + } + + // Set member balances to zero + members := keepers.MarketKeeper.GetAllMember(ctx) + for _, member := range members { + member.Balance = sdk.ZeroInt() + keepers.MarketKeeper.SetMember(ctx, member) + } + + onexAmount, _ := sdk.NewIntFromString("94784650277373001264452") + + ibc1Amount, _ := sdk.NewIntFromString("998915079") + + ibc2Amount, _ := sdk.NewIntFromString("28966246179579930912901") + + ibc3Amount, _ := sdk.NewIntFromString("2952795016") + + onexCoin := sdk.NewCoin("aonex", onexAmount) + ibc1 := sdk.NewCoin("ibc/30EDC220372A2C3D0FC1D987E19062E35375DECD1001A5EFA44EB92FF59D1867", ibc1Amount) + ibc2 := sdk.NewCoin("ibc/5BDD8875CC2AF7BC842BE44236ACD576EA4F53C36347F74903B852060D6BF29A", ibc2Amount) + ibc3 := sdk.NewCoin("ibc/CCCBD7307FEB70B0CF7ADF8503F711F6741F41623D25BAD8CB736E03BE384264", ibc3Amount) + + reclaimCoins := sdk.NewCoins(onexCoin, ibc1, ibc2, ibc3) + reclaimer, _ := sdk.AccAddressFromBech32("onomy1yc0lg97cy5e80jyajtkz0zke2rr4734anugf9g") + + keepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, markettypes.ModuleName, reclaimer, reclaimCoins) + + ctx.Logger().Info("Fork complete") +} diff --git a/app/upgrades/v1.1.5/upgrade.go b/app/upgrades/v1.1.5/upgrade.go deleted file mode 100644 index c22e8e2..0000000 --- a/app/upgrades/v1.1.5/upgrade.go +++ /dev/null @@ -1,70 +0,0 @@ -// Package v1_1_5 is contains chain upgrade of the corresponding version. -package v1_1_5 //nolint:revive,stylecheck // app version - -import ( - "github.com/onomyprotocol/onex/app/upgrades" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - markettypes "github.com/pendulum-labs/market/x/market/types" -) - -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - keepers *upgrades.UpgradeKeepers, -) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { - ctx.Logger().Info("Starting module migrations...") - - // Deactivate all drops - drops := keepers.MarketKeeper.GetAllDrop(ctx) - for _, drop := range drops { - drop.Active = false - keepers.MarketKeeper.SetDrop(ctx, drop) - } - - // Set pool drops to zero and wipe leaders - pools := keepers.MarketKeeper.GetAllPool(ctx) - for _, pool := range pools { - pool.Drops = sdk.ZeroInt() - pool.Leaders = []*markettypes.Leader{} - - keepers.MarketKeeper.SetPool(ctx, pool) - } - - // Set member balances to zero - members := keepers.MarketKeeper.GetAllMember(ctx) - for _, member := range members { - member.Balance = sdk.ZeroInt() - keepers.MarketKeeper.SetMember(ctx, member) - } - - onexAmount, _ := sdk.NewIntFromString("94784650277373001264452") - - ibc1Amount, _ := sdk.NewIntFromString("998915079") - - ibc2Amount, _ := sdk.NewIntFromString("28966246179579930912901") - - ibc3Amount, _ := sdk.NewIntFromString("2952795016") - - onexCoin := sdk.NewCoin("aonex", onexAmount) - ibc1 := sdk.NewCoin("ibc/30EDC220372A2C3D0FC1D987E19062E35375DECD1001A5EFA44EB92FF59D1867", ibc1Amount) - ibc2 := sdk.NewCoin("ibc/5BDD8875CC2AF7BC842BE44236ACD576EA4F53C36347F74903B852060D6BF29A", ibc2Amount) - ibc3 := sdk.NewCoin("ibc/CCCBD7307FEB70B0CF7ADF8503F711F6741F41623D25BAD8CB736E03BE384264", ibc3Amount) - - reclaimCoins := sdk.NewCoins(onexCoin, ibc1, ibc2, ibc3) - reclaimer, _ := sdk.AccAddressFromBech32("onomy1yc0lg97cy5e80jyajtkz0zke2rr4734anugf9g") - - keepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, markettypes.ModuleName, reclaimer, reclaimCoins) - - vm, err := mm.RunMigrations(ctx, configurator, vm) - if err != nil { - return vm, err - } - - ctx.Logger().Info("Upgrade complete") - return vm, err - } -} From c72245380d215b6337e12f7d7d6bc7b8de129905 Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Sun, 26 May 2024 17:29:40 -0500 Subject: [PATCH 07/14] Add store upgrade handler --- app/app.go | 1 + 1 file changed, 1 insertion(+) diff --git a/app/app.go b/app/app.go index fb5f6a9..c973a9c 100644 --- a/app/app.go +++ b/app/app.go @@ -661,6 +661,7 @@ func New( app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) + app.setupUpgradeStoreLoaders() app.setupUpgradeHandlers() if loadLatest { From 05d925ca4a6437cff0cb11b3133b73da5bc3323c Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Sun, 26 May 2024 18:01:14 -0500 Subject: [PATCH 08/14] Prepare for v1.1.6 and update Market Module --- app/app.go | 4 ++-- app/upgrades/{v1.1.5 => v1.1.6}/constants.go | 4 ++-- app/upgrades/{v1.1.5 => v1.1.6}/fork.go | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) rename app/upgrades/{v1.1.5 => v1.1.6}/constants.go (86%) rename app/upgrades/{v1.1.5 => v1.1.6}/fork.go (93%) diff --git a/app/app.go b/app/app.go index c973a9c..b2bb5d6 100644 --- a/app/app.go +++ b/app/app.go @@ -119,7 +119,7 @@ import ( markettypes "github.com/pendulum-labs/market/x/market/types" "github.com/onomyprotocol/onex/app/upgrades" - v1_1_5 "github.com/onomyprotocol/onex/app/upgrades/v1.1.5" + v1_1_6 "github.com/onomyprotocol/onex/app/upgrades/v1.1.6" ) const ( @@ -129,7 +129,7 @@ const ( var ( Upgrades = []upgrades.Upgrade{} - Forks = []upgrades.Fork{v1_1_5.Fork} + Forks = []upgrades.Fork{v1_1_6.Fork} // DefaultNodeHome default home directories for the application daemon DefaultNodeHome string diff --git a/app/upgrades/v1.1.5/constants.go b/app/upgrades/v1.1.6/constants.go similarity index 86% rename from app/upgrades/v1.1.5/constants.go rename to app/upgrades/v1.1.6/constants.go index 9f36004..2f6208f 100644 --- a/app/upgrades/v1.1.5/constants.go +++ b/app/upgrades/v1.1.6/constants.go @@ -1,4 +1,4 @@ -package v1_1_5 +package v1_1_6 import ( "github.com/onomyprotocol/onex/app/upgrades" @@ -6,7 +6,7 @@ import ( const ( // UpgradeName defines the on-chain upgrades name. - UpgradeName = "v1_1_5" + UpgradeName = "v1_1_6" UpgradeHeight = 389310 ) diff --git a/app/upgrades/v1.1.5/fork.go b/app/upgrades/v1.1.6/fork.go similarity index 93% rename from app/upgrades/v1.1.5/fork.go rename to app/upgrades/v1.1.6/fork.go index d8cae7e..beff378 100644 --- a/app/upgrades/v1.1.5/fork.go +++ b/app/upgrades/v1.1.6/fork.go @@ -1,5 +1,5 @@ -// Package v1_1_5 is contains chain fork of the corresponding version. -package v1_1_5 //nolint:revive,stylecheck // app version +// Package v1_1_6 is contains chain fork of the corresponding version. +package v1_1_6 //nolint:revive,stylecheck // app version import ( "github.com/onomyprotocol/onex/app/upgrades" diff --git a/go.mod b/go.mod index 895e0e8..0a615a3 100644 --- a/go.mod +++ b/go.mod @@ -155,7 +155,7 @@ replace ( github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.45.16-ics github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 - github.com/pendulum-labs/market => github.com/onomyprotocol/market v1.1.3-dev + github.com/pendulum-labs/market => github.com/onomyprotocol/market v1.1.4-dev github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.28 google.golang.org/grpc => google.golang.org/grpc v1.33.2 ) diff --git a/go.sum b/go.sum index 521c298..bf36f74 100644 --- a/go.sum +++ b/go.sum @@ -2204,8 +2204,8 @@ github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:v github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.2/go.mod h1:rSAaSIOAGT9odnlyGlUfAJaoc5w2fSBUmeGDbRWPxyQ= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/onomyprotocol/market v1.1.3-dev h1:t1auMPtqHiFumVjlpYibVMe4dI8LdgsCH0h5Ybo3YR8= -github.com/onomyprotocol/market v1.1.3-dev/go.mod h1:OFWUMLq8cfNRQnc6WqReQYq+hNYRqoc2RmMvECSxdwk= +github.com/onomyprotocol/market v1.1.4-dev h1:fA1O3NAatEBx/YU2++2LcdBNRs+aX9N50rY/bWxmXfU= +github.com/onomyprotocol/market v1.1.4-dev/go.mod h1:OFWUMLq8cfNRQnc6WqReQYq+hNYRqoc2RmMvECSxdwk= github.com/onsi/ginkgo v0.0.0-20151202141238-7f8ab55aaf3b/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= From c63775ac3a7a715280a8c0e0d4f083a42b155ef1 Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Mon, 27 May 2024 07:19:53 -0500 Subject: [PATCH 09/14] Updated genesis-with-ccv to correct version --- .../{genesis.json => genesis-with-ccv.json} | 98 ++++++++++++++----- 1 file changed, 75 insertions(+), 23 deletions(-) rename chain/onex-mainnet-1/{genesis.json => genesis-with-ccv.json} (99%) diff --git a/chain/onex-mainnet-1/genesis.json b/chain/onex-mainnet-1/genesis-with-ccv.json similarity index 99% rename from chain/onex-mainnet-1/genesis.json rename to chain/onex-mainnet-1/genesis-with-ccv.json index 39ac7de..1ea1583 100644 --- a/chain/onex-mainnet-1/genesis.json +++ b/chain/onex-mainnet-1/genesis-with-ccv.json @@ -296698,8 +296698,12 @@ "historical_entries": "10000", "unbonding_period": "1728000s", "soft_opt_out_threshold": "0.0", - "reward_denoms": [], - "provider_reward_denoms": [] + "reward_denoms": [ + "aonex" + ], + "provider_reward_denoms": [ + "anom" + ] }, "provider_client_id": "", "provider_channel_id": "", @@ -296719,7 +296723,7 @@ }, "latest_height": { "revision_number": "1", - "revision_height": "7163380" + "revision_height": "7521388" }, "proof_specs": [ { @@ -296775,61 +296779,109 @@ "allow_update_after_misbehaviour": true }, "provider_consensus_state": { - "timestamp": "2024-03-16T17:00:01.554275435Z", + "timestamp": "2024-04-28T17:00:05.727604714Z", "root": { - "hash": "Qm3scK/xkzZCVKvwZSl8tO0q0kpxWsCryqGhnnCYdME=" + "hash": "qzI4Xz9tvkoO5OVvCsM86PqAysXbNr7sEgqZxt/zOZc=" }, - "next_validators_hash": "2099AD56C603AF33205698A6A6767CC5E632784EE3B1CCC1CC156C2F0C47D7B8" + "next_validators_hash": "9B81F7ADAB3FD1AD152ED6EC45ACAC3FC15536275E0A1B4C9F896173CF769227" }, "maturing_packets": [], "initial_val_set": [ { "pub_key": { - "ed25519": "48JXsFC0RQgJvP4NzvjFE8puP/tve0sZoH4iE8wb6TU=" + "ed25519": "OJQ0oPDfSTWHEiplKTGQm0sjHtsmxkeAuFdGKb55UCQ=" + }, + "power": "936430" + }, + { + "pub_key": { + "ed25519": "ruW1GeY8fy9vEls7WWoZq1kUIsYe9Z/ihK/fZ+I6iKA=" + }, + "power": "4067080" + }, + { + "pub_key": { + "ed25519": "9kkkgSnKrbVNDjE1mBCKT13waXum2aYGX2IzsZl6bec=" + }, + "power": "3025795" + }, + { + "pub_key": { + "ed25519": "T2EJjGcnHmR4HwJe8q16D1REuXtzzHRp9iaDwqYQPeQ=" + }, + "power": "7217495" + }, + { + "pub_key": { + "ed25519": "I2fWbYC5Rq2dFKhw139gNuxLUzukRqhgkvE9WgE2oP0=" + }, + "power": "3155793" + }, + { + "pub_key": { + "ed25519": "HkUDqNrZGrRGgGwOsszEmD9iwIsZCY6UwJIxKI6ycns=" + }, + "power": "5708292" + }, + { + "pub_key": { + "ed25519": "i2WvfyngSCLMtr4vesVo/9s4lAKMAfv8hSmOHBIMRY8=" + }, + "power": "7219284" + }, + { + "pub_key": { + "ed25519": "pfCvKs6uy+5BRC9gP2/Yjk8Altg+MsjZVt/4axNPkHk=" + }, + "power": "4710540" + }, + { + "pub_key": { + "ed25519": "5X/Z7V5a2SOp3ntPlsd9On5MO/FgPBoFIg8cG2BV9XM=" }, - "power": "527942" + "power": "1786483" }, { "pub_key": { - "ed25519": "LKwKvQPVTwxwW4UDpyIvGW8Sa9sUdaxhhhVdOigrEyA=" + "ed25519": "OiLUo1dx20YIY+Gg14ObrA8bQo+JO+8qD+x5owdxXJc=" }, - "power": "466262" + "power": "6335088" }, { "pub_key": { - "ed25519": "E/iqQSF00fEWivlvbYEcVRSBL0XzqQ7q7HC+nH9UUo8=" + "ed25519": "3pmIWEJyXjVcprSaQsIY5pVrUMbpFSPpedu0SxrVFoY=" }, - "power": "653925" + "power": "379964" }, { "pub_key": { - "ed25519": "Gyqukm/oZ3Vx3O/OcU/QZoUNtgKjxXO+tqy5ZzvhY10=" + "ed25519": "4fcxzdv8gADS7pzeZTGCH7ikQbGxqsJVMsNBR8oaCac=" }, - "power": "796155" + "power": "4533842" }, { "pub_key": { - "ed25519": "iLKoAUu0/woUEAFUAlZ6t5/Eyg4nj2w0LBErUlpj9gI=" + "ed25519": "82TrqvWuxMI/CJlYS503LYOhSnDYxLBSW1x3KbZ2cn8=" }, - "power": "260493" + "power": "6558620" }, { "pub_key": { - "ed25519": "lZjOSHvpbIvv1tfakopelLFTop8avnEb0V15ywXAD7k=" + "ed25519": "YaIOqk7+3KMAuYEqVDnYedtZuv1/Y+7gjWRSjTR5mbc=" }, - "power": "483534" + "power": "5935290" }, { "pub_key": { - "ed25519": "oAgD36Wrf669dsNfjYKHskr0xRYxoI3/8jDJujrz4gs=" + "ed25519": "FMH8Yeyxg2U9hfVBa1JP0GtrOnZES/ZCtT8OU86kAM0=" }, - "power": "711346" + "power": "4064104" }, { "pub_key": { - "ed25519": "QM+/TMatIUzOduIsFAS6vglsMy5TEm7v5Zji0MJFRzE=" + "ed25519": "FZBAofv/DhiVYE7fh+XGwL3mKq5Excsce27qaK0HesA=" }, - "power": "543559" + "power": "7675607" } ], "height_to_valset_update_id": [], @@ -296994,4 +297046,4 @@ "upgrade": {}, "vesting": {} } -} \ No newline at end of file +} From 39d27a7ba55f6c992df26e3844532a7e28aeded7 Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Wed, 29 May 2024 10:43:57 -0500 Subject: [PATCH 10/14] Return funds upgrade --- app/app.go | 3 ++- app/upgrades/v1.1.7/constants.go | 15 ++++++++++++ app/upgrades/v1.1.7/upgrade.go | 42 ++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 app/upgrades/v1.1.7/constants.go create mode 100644 app/upgrades/v1.1.7/upgrade.go diff --git a/app/app.go b/app/app.go index b2bb5d6..7229a96 100644 --- a/app/app.go +++ b/app/app.go @@ -120,6 +120,7 @@ import ( "github.com/onomyprotocol/onex/app/upgrades" v1_1_6 "github.com/onomyprotocol/onex/app/upgrades/v1.1.6" + v1_1_7 "github.com/onomyprotocol/onex/app/upgrades/v1.1.7" ) const ( @@ -128,7 +129,7 @@ const ( ) var ( - Upgrades = []upgrades.Upgrade{} + Upgrades = []upgrades.Upgrade{v1_1_7.Upgrade} Forks = []upgrades.Fork{v1_1_6.Fork} // DefaultNodeHome default home directories for the application daemon diff --git a/app/upgrades/v1.1.7/constants.go b/app/upgrades/v1.1.7/constants.go new file mode 100644 index 0000000..643c475 --- /dev/null +++ b/app/upgrades/v1.1.7/constants.go @@ -0,0 +1,15 @@ +package v1_1_7 + +import ( + "github.com/onomyprotocol/onex/app/upgrades" +) + +const ( + // UpgradeName defines the on-chain upgrades name. + UpgradeName = "v1.1.7" +) + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, +} diff --git a/app/upgrades/v1.1.7/upgrade.go b/app/upgrades/v1.1.7/upgrade.go new file mode 100644 index 0000000..86b4362 --- /dev/null +++ b/app/upgrades/v1.1.7/upgrade.go @@ -0,0 +1,42 @@ +// Package v1_1_7 is contains chain upgrade of the corresponding version. +package v1_1_7 //nolint:revive,stylecheck // app version + +import ( + "github.com/onomyprotocol/onex/app/upgrades" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + markettypes "github.com/pendulum-labs/market/x/market/types" +) + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + keepers *upgrades.UpgradeKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + ctx.Logger().Info("Starting module migrations...") + + onexAmount, _ := sdk.NewIntFromString("65975935131986921086784") + ibc1Amount, _ := sdk.NewIntFromString("17216827458309103931141") + ibc2Amount, _ := sdk.NewIntFromString("20100000") + + onexCoin := sdk.NewCoin("aonex", onexAmount) + ibc1 := sdk.NewCoin("ibc/5BDD8875CC2AF7BC842BE44236ACD576EA4F53C36347F74903B852060D6BF29A", ibc1Amount) + ibc2 := sdk.NewCoin("ibc/CCCBD7307FEB70B0CF7ADF8503F711F6741F41623D25BAD8CB736E03BE384264", ibc2Amount) + + returnCoins := sdk.NewCoins(onexCoin, ibc1, ibc2) + returner, _ := sdk.AccAddressFromBech32("onomy1yc0lg97cy5e80jyajtkz0zke2rr4734anugf9g") + + keepers.BankKeeper.SendCoinsFromAccountToModule(ctx, returner, markettypes.ModuleName, returnCoins) + + vm, err := mm.RunMigrations(ctx, configurator, vm) + if err != nil { + return vm, err + } + + ctx.Logger().Info("Upgrade complete") + return vm, err + } +} From 3365ec34d55a2c556dc3cdaeb55259171628cbe2 Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Fri, 14 Jun 2024 19:34:50 +0000 Subject: [PATCH 11/14] Add in v1.2.0-dev market module and upgrade --- app/app.go | 4 +- app/upgrades/types.go | 6 ++- app/upgrades/v1.2.0/constants.go | 15 +++++++ app/upgrades/v1.2.0/upgrade.go | 75 ++++++++++++++++++++++++++++++++ go.mod | 20 ++++----- go.sum | 36 +++++++-------- 6 files changed, 125 insertions(+), 31 deletions(-) create mode 100644 app/upgrades/v1.2.0/constants.go create mode 100644 app/upgrades/v1.2.0/upgrade.go diff --git a/app/app.go b/app/app.go index 7229a96..51636fe 100644 --- a/app/app.go +++ b/app/app.go @@ -121,6 +121,7 @@ import ( "github.com/onomyprotocol/onex/app/upgrades" v1_1_6 "github.com/onomyprotocol/onex/app/upgrades/v1.1.6" v1_1_7 "github.com/onomyprotocol/onex/app/upgrades/v1.1.7" + v1_2_0 "github.com/onomyprotocol/onex/app/upgrades/v1.2.0" ) const ( @@ -129,7 +130,7 @@ const ( ) var ( - Upgrades = []upgrades.Upgrade{v1_1_7.Upgrade} + Upgrades = []upgrades.Upgrade{v1_1_7.Upgrade, v1_2_0.Upgrade} Forks = []upgrades.Fork{v1_1_6.Fork} // DefaultNodeHome default home directories for the application daemon @@ -950,6 +951,7 @@ func (app *App) setupUpgradeHandlers() { &upgrades.UpgradeKeepers{ BankKeeper: app.BankKeeper, MarketKeeper: app.MarketKeeper, + AccountKeeper: app.AccountKeeper, }, ), ) diff --git a/app/upgrades/types.go b/app/upgrades/types.go index 8379495..a7d1d87 100644 --- a/app/upgrades/types.go +++ b/app/upgrades/types.go @@ -4,6 +4,7 @@ import ( store "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" marketkeeper "github.com/pendulum-labs/market/x/market/keeper" @@ -26,8 +27,9 @@ type Upgrade struct { type UpgradeKeepers struct { // keepers - BankKeeper bankkeeper.Keeper - MarketKeeper marketkeeper.Keeper + BankKeeper bankkeeper.Keeper + MarketKeeper marketkeeper.Keeper + AccountKeeper authkeeper.AccountKeeper } // Fork defines a struct containing the requisite fields for a non-software upgrade proposal diff --git a/app/upgrades/v1.2.0/constants.go b/app/upgrades/v1.2.0/constants.go new file mode 100644 index 0000000..fa38125 --- /dev/null +++ b/app/upgrades/v1.2.0/constants.go @@ -0,0 +1,15 @@ +package v1_2_0 + +import ( + "github.com/onomyprotocol/onex/app/upgrades" +) + +const ( + // UpgradeName defines the on-chain upgrades name. + UpgradeName = "v1.2.0" +) + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, +} diff --git a/app/upgrades/v1.2.0/upgrade.go b/app/upgrades/v1.2.0/upgrade.go new file mode 100644 index 0000000..0bbef62 --- /dev/null +++ b/app/upgrades/v1.2.0/upgrade.go @@ -0,0 +1,75 @@ +// Package v1_2_0 is contains chain upgrade of the corresponding version. +package v1_2_0 //nolint:revive,stylecheck // app version + +import ( + "github.com/onomyprotocol/onex/app/upgrades" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + markettypes "github.com/pendulum-labs/market/x/market/types" +) + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + keepers *upgrades.UpgradeKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + ctx.Logger().Info("Starting module migrations...") + + // Deactivate all drops and remove owners + drops := keepers.MarketKeeper.GetAllDrop(ctx) + for _, drop := range drops { + drop.Active = false + keepers.MarketKeeper.SetDrop(ctx, drop) + keepers.MarketKeeper.RemoveDropOwner(ctx, drop) + } + + // Set pool drops to zero and wipe leaders + pools := keepers.MarketKeeper.GetAllPool(ctx) + for _, pool := range pools { + pool.Drops = sdk.ZeroInt() + pool.History = 0 + pool.Leaders = []*markettypes.Leader{} + pool.Volume1.Amount = sdk.ZeroInt() + pool.Volume2.Amount = sdk.ZeroInt() + keepers.MarketKeeper.SetPool(ctx, pool) + } + + // Set member balances to zero + members := keepers.MarketKeeper.GetAllMember(ctx) + for _, member := range members { + member.Balance = sdk.ZeroInt() + member.Limit = 0 + member.Stop = 0 + member.Previous = sdk.ZeroInt() + keepers.MarketKeeper.SetMember(ctx, member) + } + + // Set order status to balances to zero + orders := keepers.MarketKeeper.GetAllOrder(ctx) + for _, order := range orders { + if order.Status == "active" { + order.Status = "canceled" + } + keepers.MarketKeeper.SetOrder(ctx, order) + } + + marketAccount := keepers.AccountKeeper.GetModuleAccount(ctx, markettypes.ModuleName) + + marketCoins := keepers.BankKeeper.GetAllBalances(ctx, marketAccount.GetAddress()) + + reclaimer, _ := sdk.AccAddressFromBech32("onomy1yc0lg97cy5e80jyajtkz0zke2rr4734anugf9g") + + keepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, markettypes.ModuleName, reclaimer, marketCoins) + + vm, err := mm.RunMigrations(ctx, configurator, vm) + if err != nil { + return vm, err + } + + ctx.Logger().Info("Upgrade complete") + return vm, err + } +} diff --git a/go.mod b/go.mod index 0a615a3..9e723ce 100644 --- a/go.mod +++ b/go.mod @@ -132,17 +132,17 @@ require ( github.com/zondax/hid v0.9.1 // indirect github.com/zondax/ledger-go v0.14.1 // indirect go.etcd.io/bbolt v1.3.6 // indirect - golang.org/x/crypto v0.18.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20221019170559-20944726eadf // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/sys v0.16.0 // indirect - golang.org/x/term v0.16.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/net v0.23.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect + golang.org/x/text v0.15.0 // indirect google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe // indirect - google.golang.org/grpc v1.61.0 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 // indirect + google.golang.org/grpc v1.64.0 // indirect + google.golang.org/protobuf v1.34.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect @@ -155,7 +155,7 @@ replace ( github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.45.16-ics github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 - github.com/pendulum-labs/market => github.com/onomyprotocol/market v1.1.4-dev + github.com/pendulum-labs/market => github.com/onomyprotocol/market v1.2.0-dev github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.28 google.golang.org/grpc => google.golang.org/grpc v1.33.2 ) diff --git a/go.sum b/go.sum index bf36f74..9eda381 100644 --- a/go.sum +++ b/go.sum @@ -2204,8 +2204,8 @@ github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:v github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.2/go.mod h1:rSAaSIOAGT9odnlyGlUfAJaoc5w2fSBUmeGDbRWPxyQ= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/onomyprotocol/market v1.1.4-dev h1:fA1O3NAatEBx/YU2++2LcdBNRs+aX9N50rY/bWxmXfU= -github.com/onomyprotocol/market v1.1.4-dev/go.mod h1:OFWUMLq8cfNRQnc6WqReQYq+hNYRqoc2RmMvECSxdwk= +github.com/onomyprotocol/market v1.2.0-dev h1:nlcU9kZpXvDZ8kqJgnUCUtYRQrvGEBDRHO9LpYm8KCQ= +github.com/onomyprotocol/market v1.2.0-dev/go.mod h1:sBeDReQziVBheY0/RiDrnZUztwdiu1ogWZpRQb3LDWA= github.com/onsi/ginkgo v0.0.0-20151202141238-7f8ab55aaf3b/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -3008,8 +3008,8 @@ golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw golang.org/x/crypto v0.2.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -3171,8 +3171,8 @@ golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180724155351-3d292e4d0cdc/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -3415,8 +3415,8 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -3431,8 +3431,8 @@ golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= -golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -3448,8 +3448,8 @@ golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -3835,10 +3835,10 @@ google.golang.org/genproto v0.0.0-20221201164419-0e50fba7f41c/go.mod h1:rZS5c/ZV google.golang.org/genproto v0.0.0-20230125152338-dcaf20b6aeaa/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac h1:ZL/Teoy/ZGnzyrqK/Optxxp2pmVh+fmJ97slxSRyzUg= google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:+Rvu7ElI+aLzyDQhpHMFMMltsD6m7nqpuWDd2CwJw3k= -google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe h1:0poefMBYvYbs7g5UkjS6HcxBPaTRAmznle9jnxYoAI8= -google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:4jWUdICTdgc3Ibxmr8nAJiiLHwQBY0UI0XZcEMaFKaA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe h1:bQnxqljG/wqi4NTXu2+DJ3n7APcEA882QZ1JvhQAq9o= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= +google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 h1:W5Xj/70xIA4x60O/IFyXivR5MGqblAb8R3w26pnD6No= +google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8/go.mod h1:vPrPUTsDCYxXWjP7clS81mZ6/803D8K4iM9Ma27VKas= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 h1:mxSlqyb8ZAHsYDCfiXN1EDdNTdvjUJSLY+OnAUtYNYA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8/go.mod h1:I7Y+G38R2bu5j1aLzfFmQfTcU/WnFuqDwLZAbvKTKpM= google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -3858,8 +3858,8 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 41739721be216c26cd9b235449f95ca50fe65779 Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Fri, 14 Jun 2024 19:56:25 +0000 Subject: [PATCH 12/14] Update v1.2.0 upgrade code --- app/upgrades/v1.2.0/upgrade.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/app/upgrades/v1.2.0/upgrade.go b/app/upgrades/v1.2.0/upgrade.go index 0bbef62..8061f87 100644 --- a/app/upgrades/v1.2.0/upgrade.go +++ b/app/upgrades/v1.2.0/upgrade.go @@ -18,6 +18,8 @@ func CreateUpgradeHandler( return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { ctx.Logger().Info("Starting module migrations...") + marketAccount := keepers.AccountKeeper.GetModuleAccount(ctx, markettypes.ModuleName) + // Deactivate all drops and remove owners drops := keepers.MarketKeeper.GetAllDrop(ctx) for _, drop := range drops { @@ -47,17 +49,30 @@ func CreateUpgradeHandler( keepers.MarketKeeper.SetMember(ctx, member) } - // Set order status to balances to zero + // Set order status to canceled orders := keepers.MarketKeeper.GetAllOrder(ctx) for _, order := range orders { if order.Status == "active" { order.Status = "canceled" + order.Prev = 0 + order.Next = 0 + order.UpdTime = ctx.BlockHeader().Time.Unix() + coinRefund := sdk.NewCoin(order.DenomBid, order.Amount) + marketBal := keepers.BankKeeper.GetBalance(ctx, marketAccount.GetAddress(), order.DenomBid) + if marketBal.Amount.GTE(order.Amount) { + refundAddr, _ := sdk.AccAddressFromBech32(order.Owner) + keepers.BankKeeper.SendCoinsFromModuleToAccount( + ctx, + markettypes.ModuleName, + refundAddr, + sdk.NewCoins(coinRefund), + ) + } + + keepers.MarketKeeper.SetOrder(ctx, order) } - keepers.MarketKeeper.SetOrder(ctx, order) } - marketAccount := keepers.AccountKeeper.GetModuleAccount(ctx, markettypes.ModuleName) - marketCoins := keepers.BankKeeper.GetAllBalances(ctx, marketAccount.GetAddress()) reclaimer, _ := sdk.AccAddressFromBech32("onomy1yc0lg97cy5e80jyajtkz0zke2rr4734anugf9g") From d530352837ee4ab88bf0dea9d9a3b405eaf3819f Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Sat, 15 Jun 2024 02:50:00 +0000 Subject: [PATCH 13/14] Gofumpt --- app/app.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/app.go b/app/app.go index 51636fe..5d94761 100644 --- a/app/app.go +++ b/app/app.go @@ -949,8 +949,8 @@ func (app *App) setupUpgradeHandlers() { app.MM, app.configurator, &upgrades.UpgradeKeepers{ - BankKeeper: app.BankKeeper, - MarketKeeper: app.MarketKeeper, + BankKeeper: app.BankKeeper, + MarketKeeper: app.MarketKeeper, AccountKeeper: app.AccountKeeper, }, ), From e7774b9b19c5f374505e47986299afbcf2be51cb Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Sat, 15 Jun 2024 02:51:14 +0000 Subject: [PATCH 14/14] Update market version to v1.2.0 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9e723ce..332049a 100644 --- a/go.mod +++ b/go.mod @@ -155,7 +155,7 @@ replace ( github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.45.16-ics github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 - github.com/pendulum-labs/market => github.com/onomyprotocol/market v1.2.0-dev + github.com/pendulum-labs/market => github.com/onomyprotocol/market v1.2.0 github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.28 google.golang.org/grpc => google.golang.org/grpc v1.33.2 ) diff --git a/go.sum b/go.sum index 9eda381..59dd2aa 100644 --- a/go.sum +++ b/go.sum @@ -2204,8 +2204,8 @@ github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:v github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.2/go.mod h1:rSAaSIOAGT9odnlyGlUfAJaoc5w2fSBUmeGDbRWPxyQ= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/onomyprotocol/market v1.2.0-dev h1:nlcU9kZpXvDZ8kqJgnUCUtYRQrvGEBDRHO9LpYm8KCQ= -github.com/onomyprotocol/market v1.2.0-dev/go.mod h1:sBeDReQziVBheY0/RiDrnZUztwdiu1ogWZpRQb3LDWA= +github.com/onomyprotocol/market v1.2.0 h1:XhmmXohKbKLLYucNaVtU9MIFn/94D8ugrk4YJ/CZj6Q= +github.com/onomyprotocol/market v1.2.0/go.mod h1:sBeDReQziVBheY0/RiDrnZUztwdiu1ogWZpRQb3LDWA= github.com/onsi/ginkgo v0.0.0-20151202141238-7f8ab55aaf3b/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=