diff --git a/testutil/sample/crosschain.go b/testutil/sample/crosschain.go index 15a8da809a..3634e6e1cc 100644 --- a/testutil/sample/crosschain.go +++ b/testutil/sample/crosschain.go @@ -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(), @@ -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(), } } diff --git a/testutil/sample/observer.go b/testutil/sample/observer.go index 4fe86e89ca..794e5ea4de 100644 --- a/testutil/sample/observer.go +++ b/testutil/sample/observer.go @@ -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" diff --git a/x/crosschain/simulation/operation_abort_stuck_cctx.go b/x/crosschain/simulation/operation_abort_stuck_cctx.go index a9a04de4d7..8f47db001d 100644 --- a/x/crosschain/simulation/operation_abort_stuck_cctx.go +++ b/x/crosschain/simulation/operation_abort_stuck_cctx.go @@ -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, diff --git a/x/crosschain/simulation/operation_add_inbound_tracker.go b/x/crosschain/simulation/operation_add_inbound_tracker.go index 2055b6a84a..909c5cd9dc 100644 --- a/x/crosschain/simulation/operation_add_inbound_tracker.go +++ b/x/crosschain/simulation/operation_add_inbound_tracker.go @@ -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() diff --git a/x/crosschain/simulation/operation_add_outbound_tracker.go b/x/crosschain/simulation/operation_add_outbound_tracker.go index 7c15afc605..d4383eca4b 100644 --- a/x/crosschain/simulation/operation_add_outbound_tracker.go +++ b/x/crosschain/simulation/operation_add_outbound_tracker.go @@ -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() diff --git a/x/crosschain/simulation/operation_vote_inbound.go b/x/crosschain/simulation/operation_vote_inbound.go index 18fcc26a38..d18dc3bcb0 100644 --- a/x/crosschain/simulation/operation_vote_inbound.go +++ b/x/crosschain/simulation/operation_vote_inbound.go @@ -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 { diff --git a/x/crosschain/simulation/operation_vote_outbound.go b/x/crosschain/simulation/operation_vote_outbound.go index 001cbcfafb..8967c90cb9 100644 --- a/x/crosschain/simulation/operation_vote_outbound.go +++ b/x/crosschain/simulation/operation_vote_outbound.go @@ -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 diff --git a/x/crosschain/simulation/operations.go b/x/crosschain/simulation/operations.go index eac7b90865..0b4765f0f5 100644 --- a/x/crosschain/simulation/operations.go +++ b/x/crosschain/simulation/operations.go @@ -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" @@ -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 diff --git a/x/fungible/simulation/operations.go b/x/fungible/simulation/operations.go index 2a14713979..c66d1bb3c9 100644 --- a/x/fungible/simulation/operations.go +++ b/x/fungible/simulation/operations.go @@ -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. @@ -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" diff --git a/x/observer/simulation/operation_vote_tss.go b/x/observer/simulation/operation_vote_tss.go index 63002c7b72..4a9ff62350 100644 --- a/x/observer/simulation/operation_vote_tss.go +++ b/x/observer/simulation/operation_vote_tss.go @@ -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" ) @@ -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, diff --git a/x/observer/simulation/operations.go b/x/observer/simulation/operations.go index 558bb485f2..93d436ca78 100644 --- a/x/observer/simulation/operations.go +++ b/x/observer/simulation/operations.go @@ -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"