Skip to content

Commit

Permalink
remove isPending check for aborted cctx
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Dec 11, 2024
1 parent 2de15bf commit 25fef78
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 44 deletions.
6 changes: 3 additions & 3 deletions testutil/sample/crosschain.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ func InboundVote(coinType coin.CoinType, from, to int64) types.MsgVoteInbound {

// InboundVoteFromRand creates a simulated inbound vote message. This function uses the provided source of randomness to generate the vot
// InboundVoteFromRand creates a simulated inbound vote message. This function uses the provided source of randomness to generate the vote
func InboundVoteFromRand(coinType coin.CoinType, from, to int64, r *rand.Rand) types.MsgVoteInbound {
EthAddress()
func InboundVoteFromRand(from, to int64, r *rand.Rand, asset string) types.MsgVoteInbound {
coinType := CoinTypeFromRand(r)
return types.MsgVoteInbound{
Creator: "",
Sender: EthAddressFromRand(r).String(),
Expand All @@ -376,7 +376,7 @@ func InboundVoteFromRand(coinType coin.CoinType, from, to int64, r *rand.Rand) t
InboundHash: ethcommon.BytesToHash(RandomBytes(r)).String(),
CoinType: coinType,
TxOrigin: EthAddressFromRand(r).String(),
Asset: StringRandom(r, 32),
Asset: asset,
EventIndex: r.Uint64(),
}
}
Expand Down
1 change: 0 additions & 1 deletion testutil/sample/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/require"

"github.com/zeta-chain/node/pkg/chains"
"github.com/zeta-chain/node/pkg/cosmos"
Expand Down
9 changes: 0 additions & 9 deletions x/crosschain/simulation/operation_abort_stuck_cctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,6 @@ func SimulateMsgAbortStuckCCTX(k keeper.Keeper) simtypes.Operation {
), nil, nil
}

// TODO : Remove this check after pending nonces fix is merged. Remove in this pr
if !cctx.CctxStatus.Status.IsPendingStatus() {
return simtypes.NoOpMsg(
types.ModuleName,
types.TypeMsgAbortStuckCCTX,
"cctx not in pending status",
), nil, nil
}

msg := types.MsgAbortStuckCCTX{
Creator: policyAccount.Address.String(),
CctxIndex: cctx.Index,
Expand Down
11 changes: 4 additions & 7 deletions x/crosschain/simulation/operation_add_inbound_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,10 @@ func SimulateMsgAddInboundTracker(k keeper.Keeper) simtypes.Operation {

// Add a new inbound Tracker
msg := types.MsgAddInboundTracker{
Creator: randomObserver,
ChainId: randomChainID,
TxHash: txHash.String(),
CoinType: coinType,
Proof: nil,
BlockHash: "",
TxIndex: 0,
Creator: randomObserver,
ChainId: randomChainID,
TxHash: txHash.String(),
CoinType: coinType,
}

err = msg.ValidateBasic()
Expand Down
11 changes: 4 additions & 7 deletions x/crosschain/simulation/operation_add_outbound_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,10 @@ func SimulateMsgAddOutboundTracker(k keeper.Keeper) simtypes.Operation {
}
// Add a new inbound Tracker
msg := types.MsgAddOutboundTracker{
Creator: randomObserver,
ChainId: chainID,
Nonce: uint64(nonce),
TxHash: txHash.String(),
Proof: nil,
BlockHash: "",
TxIndex: 0,
Creator: randomObserver,
ChainId: chainID,
Nonce: uint64(nonce),
TxHash: txHash.String(),
}

err = msg.ValidateBasic()
Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/simulation/operation_vote_inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func SimulateVoteInbound(k keeper.Keeper) simtypes.Operation {
return simtypes.NoOpMsg(types.ModuleName, authz.InboundVoter.String(), "unable to get asset"), nil, err
}

msg := sample.InboundVoteSim(from, to, r, asset)
msg := sample.InboundVoteFromRand(from, to, r, asset)

cf, found := k.GetObserverKeeper().GetCrosschainFlags(ctx)
if !found {
Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/simulation/operation_vote_outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func SimulateVoteOutbound(k keeper.Keeper) simtypes.Operation {
}

msg.OutboundTssNonce = cctx.GetCurrentOutboundParam().TssNonce
k.SetCctxAndNonceToCctxAndInboundHashToCctx(ctx, cctx, tss.TssPubkey)
k.SaveCCTXUpdate(ctx, cctx, tss.TssPubkey)

// Pick a random observer to create the ballot
// If this returns an error, it is likely that the entire observer set has been removed
Expand Down
8 changes: 0 additions & 8 deletions x/crosschain/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@ package simulation

import (
"fmt"
"math"
"math/rand"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"

"github.com/zeta-chain/node/pkg/authz"
"github.com/zeta-chain/node/pkg/chains"
"github.com/zeta-chain/node/testutil/sample"
"github.com/zeta-chain/node/x/crosschain/keeper"
"github.com/zeta-chain/node/x/crosschain/types"
observerTypes "github.com/zeta-chain/node/x/observer/types"
Expand All @@ -33,9 +28,6 @@ import (
// Based on the weights assigned in the cosmos sdk modules,
// 100 seems to the max weight used,and we should use relative weights
// to signify the number of each operation in a block.

// TODO Add more details to comment based on what the number represents in terms of percentage of operations in a block
// https://github.com/zeta-chain/node/issues/3100
const (
DefaultWeightAddOutboundTracker = 10
DefaultWeightAddInboundTracker = 10
Expand Down
6 changes: 3 additions & 3 deletions x/fungible/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (
)

// Simulation operation weights constants
// Operation weights are used by the simulation program to simulate the weight of different operations.
// This decides what percentage of a certain type of operation is part of a block.
// Based on the weights assigned in the cosmos sdk modules , 100 seems to the max weight used , and therefore guarantees that at least one operation of that type is present in a block.
// Operation weights are used by the `SimulateFromSeed`
// function to pick a random operation based on the weights.The functions with higher weights are more likely to be picked.

Expand All @@ -24,9 +27,6 @@ import (
// Based on the weights assigned in the cosmos sdk modules,
// 100 seems to the max weight used,and we should use relative weights
// to signify the number of each operation in a block.

// TODO Add more details to comment based on what the number represents in terms of percentage of operations in a block
// https://github.com/zeta-chain/node/issues/3100
const (
// #nosec G101 not a hardcoded credential
OpWeightMsgDeploySystemContracts = "op_weight_msg_deploy_system_contracts"
Expand Down
3 changes: 1 addition & 2 deletions x/observer/simulation/operation_vote_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"
"github.com/zeta-chain/node/testutil/sample"

"github.com/zeta-chain/node/pkg/chains"
"github.com/zeta-chain/node/testutil/sample"
"github.com/zeta-chain/node/x/observer/keeper"
"github.com/zeta-chain/node/x/observer/types"
)
Expand Down Expand Up @@ -55,7 +55,6 @@ func operationSimulateVoteTss(
// SimulateVoteOutbound generates a MsgVoteOutbound with random values
// This is the only operation which saves a cctx directly to the store.
func SimulateMsgVoteTSS(k keeper.Keeper) simtypes.Operation {

return func(
r *rand.Rand,
app *baseapp.BaseApp,
Expand Down
10 changes: 8 additions & 2 deletions x/observer/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ import (
// Operation weights are used by the simulation program to simulate the weight of different operations.
// This decides what percentage of a certain type of operation is part of a block.
// Based on the weights assigned in the cosmos sdk modules , 100 seems to the max weight used , and therefore guarantees that at least one operation of that type is present in a block.
// TODO Add more details to comment based on what the number represents in terms of percentage of operations in a block
// https://github.com/zeta-chain/node/issues/3100
// Operation weights are used by the `SimulateFromSeed`
// function to pick a random operation based on the weights.The functions with higher weights are more likely to be picked.

// Therefore, this decides the percentage of a certain operation that is part of a block.

// Based on the weights assigned in the cosmos sdk modules,
// 100 seems to the max weight used,and we should use relative weights
// to signify the number of each operation in a block.
const (
// #nosec G101 not a hardcoded credential
OpWeightMsgTypeMsgEnableCCTX = "op_weight_msg_enable_crosschain_flags"
Expand Down

0 comments on commit 25fef78

Please sign in to comment.