From edea798f89e01bd38f11f3b72d4b1d31f158c514 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 29 Feb 2024 02:16:51 -0500 Subject: [PATCH 1/2] optional strategy for maintaining app versions --- app/setup_handlers.go | 22 +- common/version.go | 2 + x/crosschain/keeper/migrator.go | 5 + x/crosschain/migrations/v14/migrate.go | 137 +++++++++++ x/crosschain/migrations/v14/migrate_test.go | 257 ++++++++++++++++++++ x/crosschain/module.go | 6 +- x/emissions/module.go | 8 +- x/fungible/module.go | 8 +- x/observer/module.go | 8 +- 9 files changed, 438 insertions(+), 15 deletions(-) create mode 100644 x/crosschain/migrations/v14/migrate.go create mode 100644 x/crosschain/migrations/v14/migrate_test.go diff --git a/app/setup_handlers.go b/app/setup_handlers.go index b773745398..8c8c76ea85 100644 --- a/app/setup_handlers.go +++ b/app/setup_handlers.go @@ -1,14 +1,20 @@ package app import ( + "fmt" + 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/x/upgrade/types" + "github.com/zeta-chain/zetacore/common" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" + emissionstypes "github.com/zeta-chain/zetacore/x/emissions/types" + fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" + observerTypes "github.com/zeta-chain/zetacore/x/observer/types" ) -const releaseVersion = "v14" +var releaseVersion = fmt.Sprintf("v%d", common.AppVersion) func SetupHandlers(app *App) { app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, plan types.Plan, vm module.VersionMap) (module.VersionMap, error) { @@ -17,7 +23,10 @@ func SetupHandlers(app *App) { for m, mb := range app.mm.Modules { vm[m] = mb.ConsensusVersion() } - VersionMigrator{v: vm}.TriggerMigration(crosschaintypes.ModuleName) + zetaModules := []string{crosschaintypes.ModuleName, observerTypes.ModuleName, fungibletypes.ModuleName, emissionstypes.ModuleName} + for _, zetaModule := range zetaModules { + vm[zetaModule] = common.AppVersion - 1 + } return app.mm.RunMigrations(ctx, app.configurator, vm) }) @@ -37,12 +46,3 @@ func SetupHandlers(app *App) { app.SetStoreLoader(types.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) } } - -type VersionMigrator struct { - v module.VersionMap -} - -func (v VersionMigrator) TriggerMigration(moduleName string) module.VersionMap { - v.v[moduleName] = v.v[moduleName] - 1 - return v.v -} diff --git a/common/version.go b/common/version.go index ceb247379f..84f0f9c7b5 100644 --- a/common/version.go +++ b/common/version.go @@ -6,3 +6,5 @@ var ( CommitHash = "" BuildTime = "" ) + +const AppVersion = 14 diff --git a/x/crosschain/keeper/migrator.go b/x/crosschain/keeper/migrator.go index 4de64140c8..152f4c2d7b 100644 --- a/x/crosschain/keeper/migrator.go +++ b/x/crosschain/keeper/migrator.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + v14 "github.com/zeta-chain/zetacore/x/crosschain/migrations/v14" v2 "github.com/zeta-chain/zetacore/x/crosschain/migrations/v2" v3 "github.com/zeta-chain/zetacore/x/crosschain/migrations/v3" v4 "github.com/zeta-chain/zetacore/x/crosschain/migrations/v4" @@ -39,3 +40,7 @@ func (m Migrator) Migrate3to4(ctx sdk.Context) error { func (m Migrator) Migrate4to5(ctx sdk.Context) error { return v5.MigrateStore(ctx, m.crossChainKeeper, m.crossChainKeeper.zetaObserverKeeper) } + +func (m Migrator) Migrate13to14(ctx sdk.Context) error { + return v14.MigrateStore(ctx, m.crossChainKeeper, m.crossChainKeeper.zetaObserverKeeper) +} diff --git a/x/crosschain/migrations/v14/migrate.go b/x/crosschain/migrations/v14/migrate.go new file mode 100644 index 0000000000..7b181f865e --- /dev/null +++ b/x/crosschain/migrations/v14/migrate.go @@ -0,0 +1,137 @@ +package v14 + +import ( + "fmt" + + sdkmath "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/common" + "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +// crosschainKeeper is an interface to prevent cyclic dependency +type crosschainKeeper interface { + GetStoreKey() storetypes.StoreKey + GetCodec() codec.Codec + GetAllCrossChainTx(ctx sdk.Context) []types.CrossChainTx + + SetCrossChainTx(ctx sdk.Context, cctx types.CrossChainTx) + AddFinalizedInbound(ctx sdk.Context, inboundTxHash string, senderChainID int64, height uint64) + + SetZetaAccounting(ctx sdk.Context, accounting types.ZetaAccounting) +} + +// MigrateStore migrates the x/crosschain module state from the consensus version 4 to 5 +// It resets the aborted zeta amount to use the inbound tx amount instead in situations where the outbound cctx is never created. +func MigrateStore(ctx sdk.Context, crosschainKeeper crosschainKeeper, observerKeeper types.ObserverKeeper) error { + err := SetZetaAccounting(ctx, crosschainKeeper, observerKeeper) + if err != nil { + return err + } + ResetTestnetNonce(ctx, observerKeeper) + + return nil +} + +func ResetTestnetNonce( + ctx sdk.Context, + observerKeeper types.ObserverKeeper, +) { + tss, found := observerKeeper.GetTSS(ctx) + if !found { + return + } + for chain, nonce := range CurrentTestnetChains() { + cn, found := observerKeeper.GetChainNonces(ctx, chain.ChainName.String()) + if !found { + continue + } + cn.Nonce = nonce.nonceHigh + observerKeeper.SetChainNonces(ctx, cn) + pn, found := observerKeeper.GetPendingNonces(ctx, tss.TssPubkey, chain.ChainId) + if !found { + continue + } + pn.NonceLow = int64(nonce.nonceLow) + pn.NonceHigh = int64(nonce.nonceHigh) + observerKeeper.SetPendingNonces(ctx, pn) + } +} + +type Nonce struct { + nonceHigh uint64 + nonceLow uint64 +} + +func CurrentTestnetChains() map[common.Chain]Nonce { + return map[common.Chain]Nonce{ + common.GoerliChain(): {nonceHigh: 226841, nonceLow: 226841}, + common.MumbaiChain(): {nonceHigh: 200599, nonceLow: 200599}, + common.BscTestnetChain(): {nonceHigh: 110454, nonceLow: 110454}, + common.BtcTestNetChain(): {nonceHigh: 4881, nonceLow: 4881}, + } +} + +func SetZetaAccounting( + ctx sdk.Context, + crosschainKeeper crosschainKeeper, + observerKeeper types.ObserverKeeper, +) error { + ccctxList := crosschainKeeper.GetAllCrossChainTx(ctx) + abortedAmountZeta := sdkmath.ZeroUint() + for _, cctx := range ccctxList { + if cctx.CctxStatus.Status == types.CctxStatus_Aborted { + + switch cctx.InboundTxParams.CoinType { + case common.CoinType_ERC20: + { + receiverChain := observerKeeper.GetSupportedChainFromChainID(ctx, cctx.GetCurrentOutTxParam().ReceiverChainId) + if receiverChain == nil { + ctx.Logger().Error(fmt.Sprintf("Error getting chain from chain id: %d , cctx index", cctx.GetCurrentOutTxParam().ReceiverChainId), cctx.Index) + continue + } + // There is a chance that this cctx has already been refunded, so we set the isRefunded flag to true. + // Even though, there is a slight possibility that the refund tx failed when doing an auto refund; there is no way for us to know. Which is why we can mark this type of cctx as non-refundable + // Auto refunds are done for ERC20 cctx's when the receiver chain is a zeta chain. + if receiverChain.IsZetaChain() { + cctx.CctxStatus.IsAbortRefunded = true + } else { + cctx.CctxStatus.IsAbortRefunded = false + } + } + case common.CoinType_Zeta: + { + // add the required amount into the zeta accounting. + // GetAbortedAmount replaces using Outbound Amount directly, to make sure we refund the amount deposited by the user if the outbound is never created and the cctx is aborted. + // For these cctx's we allow the refund to be processed later and the Aborted amount would be adjusted when the refund is processed. + abortedValue := GetAbortedAmount(cctx) + abortedAmountZeta = abortedAmountZeta.Add(abortedValue) + cctx.CctxStatus.IsAbortRefunded = false + + } + case common.CoinType_Gas: + { + // CointType gas can be processed as normal and we can issue the refund using the admin refund tx . + cctx.CctxStatus.IsAbortRefunded = false + } + } + crosschainKeeper.SetCrossChainTx(ctx, cctx) + } + + } + crosschainKeeper.SetZetaAccounting(ctx, types.ZetaAccounting{AbortedZetaAmount: abortedAmountZeta}) + + return nil +} +func GetAbortedAmount(cctx types.CrossChainTx) sdkmath.Uint { + if cctx.OutboundTxParams != nil && !cctx.GetCurrentOutTxParam().Amount.IsZero() { + return cctx.GetCurrentOutTxParam().Amount + } + if cctx.InboundTxParams != nil { + return cctx.InboundTxParams.Amount + } + + return sdkmath.ZeroUint() +} diff --git a/x/crosschain/migrations/v14/migrate_test.go b/x/crosschain/migrations/v14/migrate_test.go new file mode 100644 index 0000000000..a79ed78895 --- /dev/null +++ b/x/crosschain/migrations/v14/migrate_test.go @@ -0,0 +1,257 @@ +package v14_test + +import ( + "fmt" + "math/rand" + "testing" + + "cosmossdk.io/math" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/common" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + crosschainkeeper "github.com/zeta-chain/zetacore/x/crosschain/keeper" + v5 "github.com/zeta-chain/zetacore/x/crosschain/migrations/v5" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" +) + +func TestMigrateStore(t *testing.T) { + t.Run("TestMigrateStore", func(t *testing.T) { + k, ctx, _, zk := keepertest.CrosschainKeeper(t) + cctxList := CrossChainTxList(100) + v5ZetaAccountingAmount := math.ZeroUint() + v4ZetaAccountingAmount := math.ZeroUint() + for _, cctx := range cctxList { + k.SetCrossChainTx(ctx, cctx) + if cctx.CctxStatus.Status != crosschaintypes.CctxStatus_Aborted || cctx.GetCurrentOutTxParam().CoinType != common.CoinType_Zeta { + continue + } + v5ZetaAccountingAmount = v5ZetaAccountingAmount.Add(crosschainkeeper.GetAbortedAmount(cctx)) + v4ZetaAccountingAmount = v4ZetaAccountingAmount.Add(cctx.GetCurrentOutTxParam().Amount) + } + + require.True(t, v5ZetaAccountingAmount.GT(v4ZetaAccountingAmount)) + // Previously set the zeta accounting + k.SetZetaAccounting(ctx, crosschaintypes.ZetaAccounting{ + AbortedZetaAmount: v4ZetaAccountingAmount, + }) + err := v5.MigrateStore(ctx, k, k.GetObserverKeeper()) + require.NoError(t, err) + zetaAccounting, found := k.GetZetaAccounting(ctx) + require.True(t, found) + require.True(t, v5ZetaAccountingAmount.Equal(zetaAccounting.AbortedZetaAmount)) + cctxListUpdated := k.GetAllCrossChainTx(ctx) + // Check refund status of the cctx + for _, cctx := range cctxListUpdated { + switch cctx.InboundTxParams.CoinType { + case common.CoinType_ERC20: + receiverChain := zk.ObserverKeeper.GetSupportedChainFromChainID(ctx, cctx.GetCurrentOutTxParam().ReceiverChainId) + require.NotNil(t, receiverChain) + if receiverChain.IsZetaChain() { + require.True(t, cctx.CctxStatus.IsAbortRefunded) + } else { + require.False(t, cctx.CctxStatus.IsAbortRefunded) + } + case common.CoinType_Zeta: + require.False(t, cctx.CctxStatus.IsAbortRefunded) + case common.CoinType_Gas: + require.False(t, cctx.CctxStatus.IsAbortRefunded) + } + } + }) + +} + +func TestResetTestnetNonce(t *testing.T) { + t.Run("reset only testnet nonce without changing mainnet chains", func(t *testing.T) { + k, ctx, _, zk := keepertest.CrosschainKeeper(t) + testnetChains := []common.Chain{common.GoerliChain(), common.MumbaiChain(), common.BscTestnetChain(), common.BtcTestNetChain()} + mainnetChains := []common.Chain{common.EthChain(), common.BscMainnetChain(), common.BtcMainnetChain()} + nonceLow := int64(1) + nonceHigh := int64(10) + tss := sample.Tss() + zk.ObserverKeeper.SetTSS(ctx, tss) + for _, chain := range mainnetChains { + zk.ObserverKeeper.SetChainNonces(ctx, observertypes.ChainNonces{ + Index: chain.ChainName.String(), + ChainId: chain.ChainId, + Nonce: uint64(nonceHigh), + }) + zk.ObserverKeeper.SetPendingNonces(ctx, observertypes.PendingNonces{ + Tss: tss.TssPubkey, + ChainId: chain.ChainId, + NonceLow: nonceLow, + NonceHigh: nonceHigh, + }) + } + for _, chain := range testnetChains { + zk.ObserverKeeper.SetPendingNonces(ctx, observertypes.PendingNonces{ + Tss: tss.TssPubkey, + ChainId: chain.ChainId, + NonceLow: nonceLow, + NonceHigh: nonceHigh, + }) + zk.ObserverKeeper.SetChainNonces(ctx, observertypes.ChainNonces{ + Index: chain.ChainName.String(), + ChainId: chain.ChainId, + Nonce: uint64(nonceHigh), + }) + } + err := v5.MigrateStore(ctx, k, zk.ObserverKeeper) + require.NoError(t, err) + assertValues := map[common.Chain]int64{ + common.GoerliChain(): 226841, + common.MumbaiChain(): 200599, + common.BscTestnetChain(): 110454, + common.BtcTestNetChain(): 4881, + } + + for _, chain := range testnetChains { + pn, found := zk.ObserverKeeper.GetPendingNonces(ctx, tss.TssPubkey, chain.ChainId) + require.True(t, found) + require.Equal(t, assertValues[chain], pn.NonceHigh) + require.Equal(t, assertValues[chain], pn.NonceLow) + cn, found := zk.ObserverKeeper.GetChainNonces(ctx, chain.ChainName.String()) + require.True(t, found) + require.Equal(t, uint64(assertValues[chain]), cn.Nonce) + } + for _, chain := range mainnetChains { + pn, found := zk.ObserverKeeper.GetPendingNonces(ctx, tss.TssPubkey, chain.ChainId) + require.True(t, found) + require.Equal(t, nonceHigh, pn.NonceHigh) + require.Equal(t, nonceLow, pn.NonceLow) + cn, found := zk.ObserverKeeper.GetChainNonces(ctx, chain.ChainName.String()) + require.True(t, found) + require.Equal(t, uint64(nonceHigh), cn.Nonce) + } + }) + + t.Run("reset nonce even if some chain values are missing", func(t *testing.T) { + k, ctx, _, zk := keepertest.CrosschainKeeper(t) + testnetChains := []common.Chain{common.GoerliChain()} + nonceLow := int64(1) + nonceHigh := int64(10) + tss := sample.Tss() + zk.ObserverKeeper.SetTSS(ctx, tss) + for _, chain := range testnetChains { + zk.ObserverKeeper.SetPendingNonces(ctx, observertypes.PendingNonces{ + Tss: tss.TssPubkey, + ChainId: chain.ChainId, + NonceLow: nonceLow, + NonceHigh: nonceHigh, + }) + zk.ObserverKeeper.SetChainNonces(ctx, observertypes.ChainNonces{ + Index: chain.ChainName.String(), + ChainId: chain.ChainId, + Nonce: uint64(nonceHigh), + }) + } + err := v5.MigrateStore(ctx, k, zk.ObserverKeeper) + require.NoError(t, err) + assertValuesSet := map[common.Chain]int64{ + common.GoerliChain(): 226841, + } + assertValuesNotSet := []common.Chain{common.MumbaiChain(), common.BscTestnetChain(), common.BtcTestNetChain()} + + for _, chain := range testnetChains { + pn, found := zk.ObserverKeeper.GetPendingNonces(ctx, tss.TssPubkey, chain.ChainId) + require.True(t, found) + require.Equal(t, assertValuesSet[chain], pn.NonceHigh) + require.Equal(t, assertValuesSet[chain], pn.NonceLow) + cn, found := zk.ObserverKeeper.GetChainNonces(ctx, chain.ChainName.String()) + require.True(t, found) + require.Equal(t, uint64(assertValuesSet[chain]), cn.Nonce) + } + for _, chain := range assertValuesNotSet { + _, found := zk.ObserverKeeper.GetPendingNonces(ctx, tss.TssPubkey, chain.ChainId) + require.False(t, found) + _, found = zk.ObserverKeeper.GetChainNonces(ctx, chain.ChainName.String()) + require.False(t, found) + } + }) +} + +func CrossChainTxList(count int) []crosschaintypes.CrossChainTx { + cctxList := make([]crosschaintypes.CrossChainTx, count+100) + i := 0 + r := rand.New(rand.NewSource(9)) + for ; i < count/2; i++ { + amount := math.NewUint(uint64(r.Uint32())) + cctxList[i] = crosschaintypes.CrossChainTx{ + Index: fmt.Sprintf("%d", i), + CctxStatus: &crosschaintypes.Status{Status: crosschaintypes.CctxStatus_Aborted}, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Amount: amount.Add(math.NewUint(uint64(r.Uint32()))), + CoinType: common.CoinType_Zeta, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{{ + Amount: amount, + CoinType: common.CoinType_Zeta, + }}, + } + for ; i < count; i++ { + amount := math.NewUint(uint64(r.Uint32())) + cctxList[i] = crosschaintypes.CrossChainTx{ + Index: fmt.Sprintf("%d", i), + CctxStatus: &crosschaintypes.Status{Status: crosschaintypes.CctxStatus_Aborted}, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Amount: amount, + CoinType: common.CoinType_Zeta, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{{ + Amount: math.ZeroUint(), + CoinType: common.CoinType_Zeta, + }}, + } + } + for ; i < count+20; i++ { + amount := math.NewUint(uint64(r.Uint32())) + cctxList[i] = crosschaintypes.CrossChainTx{ + Index: fmt.Sprintf("%d", i), + CctxStatus: &crosschaintypes.Status{Status: crosschaintypes.CctxStatus_Aborted}, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Amount: amount, + CoinType: common.CoinType_ERC20, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{{ + Amount: math.ZeroUint(), + CoinType: common.CoinType_ERC20, + ReceiverChainId: common.ZetaPrivnetChain().ChainId, + }}, + } + } + for ; i < count+50; i++ { + amount := math.NewUint(uint64(r.Uint32())) + cctxList[i] = crosschaintypes.CrossChainTx{ + Index: fmt.Sprintf("%d", i), + CctxStatus: &crosschaintypes.Status{Status: crosschaintypes.CctxStatus_Aborted}, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Amount: amount, + CoinType: common.CoinType_ERC20, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{{ + Amount: math.ZeroUint(), + CoinType: common.CoinType_ERC20, + ReceiverChainId: common.GoerliLocalnetChain().ChainId, + }}, + } + } + for ; i < count+100; i++ { + amount := math.NewUint(uint64(r.Uint32())) + cctxList[i] = crosschaintypes.CrossChainTx{ + Index: fmt.Sprintf("%d", i), + CctxStatus: &crosschaintypes.Status{Status: crosschaintypes.CctxStatus_Aborted}, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Amount: amount, + CoinType: common.CoinType_Gas, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{{ + Amount: amount, + CoinType: common.CoinType_Gas, + }}, + } + } + } + return cctxList +} diff --git a/x/crosschain/module.go b/x/crosschain/module.go index 7c81f220e8..ea09c5cb63 100644 --- a/x/crosschain/module.go +++ b/x/crosschain/module.go @@ -9,6 +9,7 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" + "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/x/crosschain/keeper" "github.com/cosmos/cosmos-sdk/client" @@ -154,6 +155,9 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { if err := cfg.RegisterMigration(types.ModuleName, 4, m.Migrate4to5); err != nil { panic(err) } + if err := cfg.RegisterMigration(types.ModuleName, 13, m.Migrate13to14); err != nil { + panic(err) + } } // RegisterInvariants registers the crosschain module's invariants. @@ -181,7 +185,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 5 } +func (AppModule) ConsensusVersion() uint64 { return common.AppVersion } // BeginBlock executes all ABCI BeginBlock logic respective to the crosschain module. func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { diff --git a/x/emissions/module.go b/x/emissions/module.go index 7086c998fc..a30b218ec9 100644 --- a/x/emissions/module.go +++ b/x/emissions/module.go @@ -8,6 +8,7 @@ import ( "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/x/emissions/client/cli" emissionskeeper "github.com/zeta-chain/zetacore/x/emissions/keeper" "github.com/zeta-chain/zetacore/x/emissions/types" @@ -137,6 +138,11 @@ func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), emissionskeeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + if err := cfg.RegisterMigration(types.ModuleName, 13, func(s sdk.Context) error { + return nil + }); err != nil { + panic(err) + } } // RegisterInvariants registers the emissions module's invariants. @@ -165,7 +171,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 2 } +func (AppModule) ConsensusVersion() uint64 { return common.AppVersion } // BeginBlock executes all ABCI BeginBlock logic respective to the emissions module. func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { diff --git a/x/fungible/module.go b/x/fungible/module.go index 5a88d9e11b..f9855cd253 100644 --- a/x/fungible/module.go +++ b/x/fungible/module.go @@ -8,6 +8,7 @@ import ( "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/common" abci "github.com/tendermint/tendermint/abci/types" @@ -137,6 +138,11 @@ func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + if err := cfg.RegisterMigration(types.ModuleName, 13, func(s sdk.Context) error { + return nil + }); err != nil { + panic(err) + } } // RegisterInvariants registers the fungible module's invariants. @@ -167,7 +173,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 2 } +func (AppModule) ConsensusVersion() uint64 { return common.AppVersion } // BeginBlock executes all ABCI BeginBlock logic respective to the fungible module. func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} diff --git a/x/observer/module.go b/x/observer/module.go index efb851964d..986bb8899a 100644 --- a/x/observer/module.go +++ b/x/observer/module.go @@ -8,6 +8,7 @@ import ( "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/common" abci "github.com/tendermint/tendermint/abci/types" @@ -153,6 +154,11 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { if err := cfg.RegisterMigration(types.ModuleName, 5, m.Migrate5to6); err != nil { panic(err) } + if err := cfg.RegisterMigration(types.ModuleName, 13, func(s sdk.Context) error { + return nil + }); err != nil { + panic(err) + } } // RegisterInvariants registers the observer module's invariants. @@ -177,7 +183,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 6 } +func (AppModule) ConsensusVersion() uint64 { return common.AppVersion } // BeginBlock executes all ABCI BeginBlock logic respective to the observer module. func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { From a6e1f48aec72e6c3144bcab6ac4ec7af5bb7aab9 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 29 Feb 2024 02:19:21 -0500 Subject: [PATCH 2/2] remove error check --- x/emissions/module.go | 6 ++---- x/fungible/module.go | 6 ++---- x/observer/module.go | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/x/emissions/module.go b/x/emissions/module.go index a30b218ec9..48cfbe4c78 100644 --- a/x/emissions/module.go +++ b/x/emissions/module.go @@ -138,11 +138,9 @@ func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), emissionskeeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) - if err := cfg.RegisterMigration(types.ModuleName, 13, func(s sdk.Context) error { + _ = cfg.RegisterMigration(types.ModuleName, 13, func(s sdk.Context) error { return nil - }); err != nil { - panic(err) - } + }) } // RegisterInvariants registers the emissions module's invariants. diff --git a/x/fungible/module.go b/x/fungible/module.go index f9855cd253..a44550cf9e 100644 --- a/x/fungible/module.go +++ b/x/fungible/module.go @@ -138,11 +138,9 @@ func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) - if err := cfg.RegisterMigration(types.ModuleName, 13, func(s sdk.Context) error { + _ = cfg.RegisterMigration(types.ModuleName, 13, func(s sdk.Context) error { return nil - }); err != nil { - panic(err) - } + }) } // RegisterInvariants registers the fungible module's invariants. diff --git a/x/observer/module.go b/x/observer/module.go index 986bb8899a..423fc01724 100644 --- a/x/observer/module.go +++ b/x/observer/module.go @@ -154,11 +154,9 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { if err := cfg.RegisterMigration(types.ModuleName, 5, m.Migrate5to6); err != nil { panic(err) } - if err := cfg.RegisterMigration(types.ModuleName, 13, func(s sdk.Context) error { + _ = cfg.RegisterMigration(types.ModuleName, 13, func(s sdk.Context) error { return nil - }); err != nil { - panic(err) - } + }) } // RegisterInvariants registers the observer module's invariants.