diff --git a/simulation/simulation_test.go b/simulation/simulation_test.go index a55ed91575..d28c85068e 100644 --- a/simulation/simulation_test.go +++ b/simulation/simulation_test.go @@ -250,6 +250,15 @@ func TestFullAppSimulation(t *testing.T) { zetasimulation.PrintStats(db) } +// TestFullAppSimulationAfterImport tests the application simulation after importing the state exported from a previous.At a high level,it does the following +// 1. It runs a full simulation and exports the state +// 2. It creates a new app, and db +// 3. It imports the exported state into the new app +// 4. It compares the two apps +// a. First app which ran the simulation +// b. Second app which imported the state + +// This can verify the export and import process do not modify the state in anyway irrespective of the operations performed func TestAppImportExport(t *testing.T) { config := zetasimulation.NewConfigFromFlags() diff --git a/x/crosschain/genesis.go b/x/crosschain/genesis.go index 467f532a53..17ecf9bc07 100644 --- a/x/crosschain/genesis.go +++ b/x/crosschain/genesis.go @@ -1,7 +1,11 @@ package crosschain import ( + "fmt" + + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/node/pkg/coin" "github.com/zeta-chain/node/x/crosschain/keeper" "github.com/zeta-chain/node/x/crosschain/types" @@ -10,7 +14,8 @@ import ( // InitGenesis initializes the crosschain module's state from a provided genesis // state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { - k.SetZetaAccounting(ctx, genState.ZetaAccounting) + + k.SetZetaAccounting(ctx, types.ZetaAccounting{AbortedZetaAmount: sdkmath.ZeroUint()}) // Set all the outbound tracker for _, elem := range genState.OutboundTrackerList { k.SetOutboundTracker(ctx, elem) diff --git a/x/crosschain/keeper/cctx.go b/x/crosschain/keeper/cctx.go index f2234362f0..ee769d5aa4 100644 --- a/x/crosschain/keeper/cctx.go +++ b/x/crosschain/keeper/cctx.go @@ -49,7 +49,7 @@ func (k Keeper) SetCctxAndNonceToCctxAndInboundHashToCctx( } k.SetInboundHashToCctx(ctx, in) - if cctx.CctxStatus.Status == types.CctxStatus_Aborted && cctx.InboundParams.CoinType == coin.CoinType_Zeta { + if cctx.CctxStatus.Status == types.CctxStatus_Aborted && cctx.InboundParams.CoinType == coin.CoinType_Zeta && cctx.CctxStatus.IsAbortRefunded == false { k.AddZetaAbortedAmount(ctx, GetAbortedAmount(cctx)) } } diff --git a/x/crosschain/keeper/msg_server_abort_stuck_cctx.go b/x/crosschain/keeper/msg_server_abort_stuck_cctx.go index fd2e9aba7d..97b3fa1a52 100644 --- a/x/crosschain/keeper/msg_server_abort_stuck_cctx.go +++ b/x/crosschain/keeper/msg_server_abort_stuck_cctx.go @@ -2,11 +2,10 @@ package keeper import ( "context" - "fmt" "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - + "github.com/zeta-chain/node/pkg/coin" authoritytypes "github.com/zeta-chain/node/x/authority/types" "github.com/zeta-chain/node/x/crosschain/types" ) @@ -41,8 +40,6 @@ func (k msgServer) AbortStuckCCTX( cctx.CctxStatus.Status == types.CctxStatus_PendingInbound || cctx.CctxStatus.Status == types.CctxStatus_PendingRevert if !isPending { - fmt.Println("CCTX not in pending", cctx.Index, cctx.CctxStatus.Status) - return nil, types.ErrStatusNotPending } @@ -52,6 +49,10 @@ func (k msgServer) AbortStuckCCTX( } k.SetCrossChainTx(ctx, cctx) + // TODO replace with updated code from develop + if cctx.InboundParams.CoinType == coin.CoinType_Zeta { + k.AddZetaAbortedAmount(ctx, GetAbortedAmount(cctx)) + } return &types.MsgAbortStuckCCTXResponse{}, nil }