From df9b767e189db9d6a0d930dd1b6fe97da1de837c Mon Sep 17 00:00:00 2001 From: rbajollari Date: Wed, 27 Dec 2023 14:00:32 -0500 Subject: [PATCH 1/5] fix: Use gmp module account as relayer address in handler --- app/gmpmiddleware/handler.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/gmpmiddleware/handler.go b/app/gmpmiddleware/handler.go index df20d2af..31ac46fe 100644 --- a/app/gmpmiddleware/handler.go +++ b/app/gmpmiddleware/handler.go @@ -3,6 +3,8 @@ package gmpmiddleware import ( "context" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + gmptypes "github.com/ojo-network/ojo/x/gmp/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ojo-network/ojo/x/gmp/types" ) @@ -52,8 +54,9 @@ func (h GmpHandler) HandleGeneralMessage( if err != nil { return err } + ctx.Logger().Info("HandleGeneralMessage GMP Decoder", "msg", msg) tx := &types.MsgRelayPrice{ - Relayer: srcAddress, + Relayer: authtypes.NewModuleAddress(gmptypes.ModuleName).String(), DestinationChain: srcChain, ClientContractAddress: msg.ContractAddress.Hex(), OjoContractAddress: srcAddress, @@ -66,7 +69,7 @@ func (h GmpHandler) HandleGeneralMessage( if err != nil { return err } - + ctx.Logger().Info("HandleGeneralMessage GMP Decoder", "tx", tx) _, err = h.gmp.RelayPrice(ctx, tx) return err } @@ -99,8 +102,9 @@ func (h GmpHandler) HandleGeneralMessageWithToken( if err != nil { return err } + ctx.Logger().Info("HandleGeneralMessageWithToken GMP Decoder", "msg", msg) tx := &types.MsgRelayPrice{ - Relayer: srcAddress, + Relayer: authtypes.NewModuleAddress(gmptypes.ModuleName).String(), DestinationChain: srcChain, ClientContractAddress: msg.ContractAddress.Hex(), OjoContractAddress: srcAddress, @@ -114,6 +118,7 @@ func (h GmpHandler) HandleGeneralMessageWithToken( if err != nil { return err } + ctx.Logger().Info("HandleGeneralMessage GMP Decoder", "tx", tx) _, err = h.gmp.RelayPrice(ctx, tx) return err } From 9838c6d67967e6ccd1de2a01bcc792a30fc96501 Mon Sep 17 00:00:00 2001 From: rbajollari Date: Wed, 27 Dec 2023 14:01:33 -0500 Subject: [PATCH 2/5] gofmt --- app/gmpmiddleware/handler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/gmpmiddleware/handler.go b/app/gmpmiddleware/handler.go index 31ac46fe..9b758398 100644 --- a/app/gmpmiddleware/handler.go +++ b/app/gmpmiddleware/handler.go @@ -3,10 +3,10 @@ package gmpmiddleware import ( "context" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - gmptypes "github.com/ojo-network/ojo/x/gmp/types" sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ojo-network/ojo/x/gmp/types" + gmptypes "github.com/ojo-network/ojo/x/gmp/types" ) type GmpKeeper interface { From f76731d7b32706c9dd55e5e96ff16a87b26e613d Mon Sep 17 00:00:00 2001 From: rbajollari Date: Wed, 27 Dec 2023 14:06:32 -0500 Subject: [PATCH 3/5] remove duplicate imports --- app/gmpmiddleware/handler.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/gmpmiddleware/handler.go b/app/gmpmiddleware/handler.go index 9b758398..176e62d8 100644 --- a/app/gmpmiddleware/handler.go +++ b/app/gmpmiddleware/handler.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ojo-network/ojo/x/gmp/types" - gmptypes "github.com/ojo-network/ojo/x/gmp/types" ) type GmpKeeper interface { @@ -56,7 +55,7 @@ func (h GmpHandler) HandleGeneralMessage( } ctx.Logger().Info("HandleGeneralMessage GMP Decoder", "msg", msg) tx := &types.MsgRelayPrice{ - Relayer: authtypes.NewModuleAddress(gmptypes.ModuleName).String(), + Relayer: authtypes.NewModuleAddress(types.ModuleName).String(), DestinationChain: srcChain, ClientContractAddress: msg.ContractAddress.Hex(), OjoContractAddress: srcAddress, @@ -104,7 +103,7 @@ func (h GmpHandler) HandleGeneralMessageWithToken( } ctx.Logger().Info("HandleGeneralMessageWithToken GMP Decoder", "msg", msg) tx := &types.MsgRelayPrice{ - Relayer: authtypes.NewModuleAddress(gmptypes.ModuleName).String(), + Relayer: authtypes.NewModuleAddress(types.ModuleName).String(), DestinationChain: srcChain, ClientContractAddress: msg.ContractAddress.Hex(), OjoContractAddress: srcAddress, From c18455321768ddcef512856d27be23a0f3773652 Mon Sep 17 00:00:00 2001 From: rbajollari Date: Wed, 27 Dec 2023 14:11:35 -0500 Subject: [PATCH 4/5] upgrade handler --- app/upgrades.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/upgrades.go b/app/upgrades.go index 8d880af0..652dcbb3 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -39,6 +39,7 @@ func (app App) RegisterUpgradeHandlers() { app.registerUpgrade0_3_0Rc3(upgradeInfo) app.registerUpgrade0_3_0Rc4(upgradeInfo) app.registerUpgrade0_3_0Rc5(upgradeInfo) + app.registerUpgrade0_3_0Rc6(upgradeInfo) } // performs upgrade from v0.1.3 to v0.1.4 @@ -194,6 +195,16 @@ func (app *App) registerUpgrade0_3_0Rc5(_ upgradetypes.Plan) { ) } +func (app *App) registerUpgrade0_3_0Rc6(_ upgradetypes.Plan) { + const planName = "v0.3.0-rc6" + app.UpgradeKeeper.SetUpgradeHandler(planName, + func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + ctx.Logger().Info("Upgrade handler execution", "name", planName) + return app.mm.RunMigrations(ctx, app.configurator, fromVM) + }, + ) +} + // helper function to check if the store loader should be upgraded func (app *App) storeUpgrade(planName string, ui upgradetypes.Plan, stores storetypes.StoreUpgrades) { if ui.Name == planName && !app.UpgradeKeeper.IsSkipHeight(ui.Height) { From dc6ce4d9eebf65e6e8aee5fa3c1d3e04d08163dc Mon Sep 17 00:00:00 2001 From: rbajollari Date: Wed, 27 Dec 2023 14:29:53 -0500 Subject: [PATCH 5/5] make relayer global var --- app/gmpmiddleware/handler.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/gmpmiddleware/handler.go b/app/gmpmiddleware/handler.go index 176e62d8..013983b4 100644 --- a/app/gmpmiddleware/handler.go +++ b/app/gmpmiddleware/handler.go @@ -20,6 +20,8 @@ type GmpHandler struct { gmp GmpKeeper } +var relayer = authtypes.NewModuleAddress(types.ModuleName).String() + func NewGmpHandler(k GmpKeeper) *GmpHandler { return &GmpHandler{ gmp: k, @@ -55,7 +57,7 @@ func (h GmpHandler) HandleGeneralMessage( } ctx.Logger().Info("HandleGeneralMessage GMP Decoder", "msg", msg) tx := &types.MsgRelayPrice{ - Relayer: authtypes.NewModuleAddress(types.ModuleName).String(), + Relayer: relayer, DestinationChain: srcChain, ClientContractAddress: msg.ContractAddress.Hex(), OjoContractAddress: srcAddress, @@ -103,7 +105,7 @@ func (h GmpHandler) HandleGeneralMessageWithToken( } ctx.Logger().Info("HandleGeneralMessageWithToken GMP Decoder", "msg", msg) tx := &types.MsgRelayPrice{ - Relayer: authtypes.NewModuleAddress(types.ModuleName).String(), + Relayer: relayer, DestinationChain: srcChain, ClientContractAddress: msg.ContractAddress.Hex(), OjoContractAddress: srcAddress,