Skip to content

Commit

Permalink
update zeta accounting genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Dec 4, 2024
1 parent 0189453 commit df1b22c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
9 changes: 9 additions & 0 deletions simulation/simulation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
7 changes: 6 additions & 1 deletion x/crosschain/genesis.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/keeper/cctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Expand Down
9 changes: 5 additions & 4 deletions x/crosschain/keeper/msg_server_abort_stuck_cctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

0 comments on commit df1b22c

Please sign in to comment.