From 0295da5cf27027a61c96bb7d9bd78de8c38796e1 Mon Sep 17 00:00:00 2001 From: Adu Date: Thu, 30 Jun 2022 23:12:25 +0800 Subject: [PATCH 1/2] fix: Simulation is not deterministic due to GenSignedMockTx (#12374) (cherry picked from commit 17dc4316664bd0a17d5eab779c64264c4c41ea15) # Conflicts: # CHANGELOG.md # simapp/helpers/test_helpers.go # simapp/test_helpers.go # x/authz/simulation/operations.go # x/bank/simulation/operations.go # x/genutil/gentx_test.go # x/gov/simulation/operations.go # x/group/simulation/operations.go # x/nft/simulation/operations.go # x/simulation/util.go # x/slashing/simulation/operations.go --- CHANGELOG.md | 6 ++ simapp/helpers/test_helpers.go | 7 ++- simapp/test_helpers.go | 14 +++++ x/authz/simulation/operations.go | 20 ++++++ x/bank/simulation/operations.go | 19 ++++++ x/distribution/simulation/operations.go | 1 + x/genutil/gentx_test.go | 8 +++ x/gov/simulation/operations.go | 6 ++ x/group/simulation/operations.go | 84 +++++++++++++++++++++++++ x/nft/simulation/operations.go | 6 ++ x/simulation/util.go | 5 ++ x/slashing/simulation/operations.go | 6 ++ x/staking/simulation/operations.go | 2 + 13 files changed, 181 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87995357afe3..750d6946937f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (types) [#12154](https://github.com/cosmos/cosmos-sdk/pull/12154) Add `baseAccountGetter` to avoid invalid account error when create vesting account. * (x/crisis) [#12208](https://github.com/cosmos/cosmos-sdk/pull/12208) Fix progress index of crisis invariant assertion logs. * (types) [#12229](https://github.com/cosmos/cosmos-sdk/pull/12229) Increase sdk.Dec maxApproxRootIterations to 300 +<<<<<<< HEAD +======= +* (x/staking) [#12303](https://github.com/cosmos/cosmos-sdk/pull/12303) Use bytes instead of string comparison in delete validator queue +* (testutil/sims) [#12374](https://github.com/cosmos/cosmos-sdk/pull/12374) fix the non-determinstic behavior in simulations caused by `GenSignedMockTx` and check +empty coins slice before it is used to create `banktype.MsgSend`. +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) ## [v0.46.0-rc1](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.0-rc1) - 2022-05-23 diff --git a/simapp/helpers/test_helpers.go b/simapp/helpers/test_helpers.go index 0dc88f9b4623..e6420e7627ca 100644 --- a/simapp/helpers/test_helpers.go +++ b/simapp/helpers/test_helpers.go @@ -2,7 +2,6 @@ package helpers import ( "math/rand" - "time" "github.com/cosmos/cosmos-sdk/client" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -19,12 +18,14 @@ const ( ) // GenSignedMockTx generates a signed mock transaction. +<<<<<<< HEAD:simapp/helpers/test_helpers.go func GenSignedMockTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { +======= +func GenSignedMockTx(r *rand.Rand, txConfig client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)):testutil/sims/tx_helpers.go sigs := make([]signing.SignatureV2, len(priv)) // create a random length memo - r := rand.New(rand.NewSource(time.Now().UnixNano())) - memo := simulation.RandStringOfLength(r, simulation.RandIntBetween(r, 0, 100)) signMode := gen.SignModeHandler().DefaultMode() diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index dd3bda28f5b9..4bc91a850c73 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -4,8 +4,12 @@ import ( "bytes" "encoding/hex" "encoding/json" +<<<<<<< HEAD "fmt" "strconv" +======= + "math/rand" +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) "testing" "time" @@ -411,7 +415,12 @@ func SignCheckDeliver( t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg, chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey, ) (sdk.GasInfo, *sdk.Result, error) { +<<<<<<< HEAD tx, err := helpers.GenSignedMockTx( +======= + tx, err := simtestutil.GenSignedMockTx( + rand.New(rand.NewSource(time.Now().UnixNano())), +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txCfg, msgs, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, @@ -461,7 +470,12 @@ func GenSequenceOfTxs(txGen client.TxConfig, msgs []sdk.Msg, accNums []uint64, i txs := make([]sdk.Tx, numToGenerate) var err error for i := 0; i < numToGenerate; i++ { +<<<<<<< HEAD txs[i], err = helpers.GenSignedMockTx( +======= + txs[i], err = simtestutil.GenSignedMockTx( + rand.New(rand.NewSource(time.Now().UnixNano())), +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, msgs, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, diff --git a/x/authz/simulation/operations.go b/x/authz/simulation/operations.go index 956a7b4c325d..604a40486273 100644 --- a/x/authz/simulation/operations.go +++ b/x/authz/simulation/operations.go @@ -116,8 +116,14 @@ func SimulateMsgGrant(ak authz.AccountKeeper, bk authz.BankKeeper, _ keeper.Keep if err != nil { return simtypes.NoOpMsg(authz.ModuleName, TypeMsgGrant, err.Error()), nil, err } +<<<<<<< HEAD txCfg := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( +======= + txCfg := tx.NewTxConfig(cdc, tx.DefaultSignModes) + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txCfg, []sdk.Msg{msg}, fees, @@ -187,7 +193,12 @@ func SimulateMsgRevoke(ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Kee msg := authz.NewMsgRevoke(granterAddr, granteeAddr, a.MsgTypeURL()) txCfg := simappparams.MakeTestEncodingConfig().TxConfig account := ak.GetAccount(ctx, granterAddr) +<<<<<<< HEAD tx, err := helpers.GenSignedMockTx( +======= + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txCfg, []sdk.Msg{&msg}, fees, @@ -250,6 +261,10 @@ func SimulateMsgExec(ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keepe granterspendableCoins := bk.SpendableCoins(ctx, granterAddr) coins := simtypes.RandSubsetCoins(r, granterspendableCoins) + // if coins slice is empty, we can not create valid banktype.MsgSend + if len(coins) == 0 { + return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, "empty coins slice"), nil, nil + } // Check send_enabled status of each sent coin denom if err := bk.IsSendEnabledCoins(ctx, coins...); err != nil { @@ -276,7 +291,12 @@ func SimulateMsgExec(ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keepe txCfg := simappparams.MakeTestEncodingConfig().TxConfig granteeAcc := ak.GetAccount(ctx, granteeAddr) +<<<<<<< HEAD tx, err := helpers.GenSignedMockTx( +======= + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txCfg, []sdk.Msg{&msgExec}, fees, diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index dae8471b0edf..d0c2abc2b363 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -60,6 +60,11 @@ func SimulateMsgSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Operatio ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { from, to, coins, skip := randomSendFields(r, ctx, accs, bk, ak) + // if coins slice is empty, we can not create valid types.MsgSend + if len(coins) == 0 { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgSend, "empty coins slice"), nil, nil + } + // Check send_enabled status of each coin denom if err := bk.IsSendEnabledCoins(ctx, coins...); err != nil { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgSend, err.Error()), nil, nil @@ -93,6 +98,10 @@ func SimulateMsgSendToModuleAccount(ak types.AccountKeeper, bk keeper.Keeper, mo spendable := bk.SpendableCoins(ctx, from.Address) coins := simtypes.RandSubsetCoins(r, spendable) + // if coins slice is empty, we can not create valid types.MsgSend + if len(coins) == 0 { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgSend, "empty coins slice"), nil, nil + } // Check send_enabled status of each coin denom if err := bk.IsSendEnabledCoins(ctx, coins...); err != nil { @@ -136,7 +145,12 @@ func sendMsgSend( } } txGen := simappparams.MakeTestEncodingConfig().TxConfig +<<<<<<< HEAD tx, err := helpers.GenSignedMockTx( +======= + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{msg}, fees, @@ -349,7 +363,12 @@ func sendMsgMultiSend( } txGen := simappparams.MakeTestEncodingConfig().TxConfig +<<<<<<< HEAD tx, err := helpers.GenSignedMockTx( +======= + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{msg}, fees, diff --git a/x/distribution/simulation/operations.go b/x/distribution/simulation/operations.go index c76318fe82cd..edd0aef1ff12 100644 --- a/x/distribution/simulation/operations.go +++ b/x/distribution/simulation/operations.go @@ -229,6 +229,7 @@ func SimulateMsgFundCommunityPool(ak types.AccountKeeper, bk types.BankKeeper, k msg := types.NewMsgFundCommunityPool(fundAmount, funder.Address) txCtx := simulation.OperationInput{ + R: r, App: app, TxGen: simappparams.MakeTestEncodingConfig().TxConfig, Cdc: nil, diff --git a/x/genutil/gentx_test.go b/x/genutil/gentx_test.go index a83b310c46d1..628dc951f321 100644 --- a/x/genutil/gentx_test.go +++ b/x/genutil/gentx_test.go @@ -3,7 +3,9 @@ package genutil_test import ( "encoding/json" "fmt" + "math/rand" "testing" + "time" "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -231,8 +233,14 @@ func (suite *GenTxTestSuite) TestDeliverGenTxs() { _ = suite.setAccountBalance(addr1, 50) _ = suite.setAccountBalance(addr2, 1) + r := rand.New(rand.NewSource(time.Now().UnixNano())) msg := banktypes.NewMsgSend(addr1, addr2, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 1)}) +<<<<<<< HEAD tx, err := helpers.GenSignedMockTx( +======= + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) suite.encodingConfig.TxConfig, []sdk.Msg{msg}, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 10)}, diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index 289c9413d6cd..293a34aea0f9 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -169,7 +169,12 @@ func SimulateMsgSubmitProposal( } txGen := simappparams.MakeTestEncodingConfig().TxConfig +<<<<<<< HEAD tx, err := helpers.GenSignedMockTx( +======= + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{msg}, fees, @@ -256,6 +261,7 @@ func SimulateMsgDeposit(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Ke } txCtx := simulation.OperationInput{ + R: r, App: app, TxGen: simappparams.MakeTestEncodingConfig().TxConfig, Cdc: nil, diff --git a/x/group/simulation/operations.go b/x/group/simulation/operations.go index f541393771a3..4aefba6de639 100644 --- a/x/group/simulation/operations.go +++ b/x/group/simulation/operations.go @@ -259,8 +259,14 @@ func SimulateMsgCreateGroup(ak group.AccountKeeper, bk group.BankKeeper) simtype members := genGroupMembers(r, accounts) msg := &group.MsgCreateGroup{Admin: accAddr, Members: members, Metadata: simtypes.RandStringOfLength(r, 10)} +<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( +======= + txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{msg}, fees, @@ -318,8 +324,14 @@ func SimulateMsgCreateGroupWithPolicy(ak group.AccountKeeper, bk group.BankKeepe return simtypes.NoOpMsg(group.ModuleName, msg.Type(), "unable to set decision policy"), nil, err } +<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( +======= + txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{msg}, fees, @@ -377,8 +389,14 @@ func SimulateMsgCreateGroupPolicy(ak group.AccountKeeper, bk group.BankKeeper, k return simtypes.NoOpMsg(group.ModuleName, TypeMsgCreateGroupPolicy, err.Error()), nil, err } +<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( +======= + txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{msg}, fees, @@ -452,8 +470,14 @@ func SimulateMsgSubmitProposal(ak group.AccountKeeper, bk group.BankKeeper, k ke Metadata: simtypes.RandStringOfLength(r, 10), } +<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( +======= + txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{&msg}, fees, @@ -511,8 +535,14 @@ func SimulateMsgUpdateGroupAdmin(ak group.AccountKeeper, bk group.BankKeeper, k NewAdmin: newAdmin.Address.String(), } +<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( +======= + txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{&msg}, fees, @@ -561,8 +591,14 @@ func SimulateMsgUpdateGroupMetadata(ak group.AccountKeeper, bk group.BankKeeper, Metadata: simtypes.RandStringOfLength(r, 10), } +<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( +======= + txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{&msg}, fees, @@ -640,8 +676,14 @@ func SimulateMsgUpdateGroupMembers(ak group.AccountKeeper, MemberUpdates: members, } +<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( +======= + txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{&msg}, fees, @@ -699,8 +741,14 @@ func SimulateMsgUpdateGroupPolicyAdmin(ak group.AccountKeeper, bk group.BankKeep NewAdmin: newAdmin.Address.String(), } +<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( +======= + txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{&msg}, fees, @@ -760,8 +808,14 @@ func SimulateMsgUpdateGroupPolicyDecisionPolicy(ak group.AccountKeeper, return simtypes.NoOpMsg(group.ModuleName, TypeMsgUpdateGroupPolicyDecisionPolicy, err.Error()), nil, err } +<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( +======= + txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{msg}, fees, @@ -811,8 +865,14 @@ func SimulateMsgUpdateGroupPolicyMetadata(ak group.AccountKeeper, Metadata: simtypes.RandStringOfLength(r, 10), } +<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( +======= + txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{&msg}, fees, @@ -913,8 +973,14 @@ func SimulateMsgWithdrawProposal(ak group.AccountKeeper, Address: proposer.Address.String(), } +<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( +======= + txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{&msg}, fees, @@ -1018,8 +1084,14 @@ func SimulateMsgVote(ak group.AccountKeeper, Option: group.VOTE_OPTION_YES, Metadata: simtypes.RandStringOfLength(r, 10), } +<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( +======= + txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{&msg}, fees, @@ -1096,8 +1168,14 @@ func SimulateMsgExec(ak group.AccountKeeper, ProposalId: uint64(proposalID), Executor: acc.Address.String(), } +<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( +======= + txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{&msg}, fees, @@ -1158,8 +1236,14 @@ func SimulateMsgLeaveGroup(k keeper.Keeper, ak group.AccountKeeper, bk group.Ban GroupId: groupInfo.Id, } +<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( +======= + txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{msg}, fees, diff --git a/x/nft/simulation/operations.go b/x/nft/simulation/operations.go index c71ab17c3175..4ad52b1072f6 100644 --- a/x/nft/simulation/operations.go +++ b/x/nft/simulation/operations.go @@ -95,8 +95,14 @@ func SimulateMsgSend( Receiver: receiver.Address.String(), } +<<<<<<< HEAD txCfg := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( +======= + txCfg := tx.NewTxConfig(cdc, tx.DefaultSignModes) + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txCfg, []sdk.Msg{msg}, fees, diff --git a/x/simulation/util.go b/x/simulation/util.go index 3c72f67538cb..3472bcd4940c 100644 --- a/x/simulation/util.go +++ b/x/simulation/util.go @@ -100,7 +100,12 @@ func GenAndDeliverTxWithRandFees(txCtx OperationInput) (simtypes.OperationMsg, [ // GenAndDeliverTx generates a transactions and delivers it. func GenAndDeliverTx(txCtx OperationInput, fees sdk.Coins) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { account := txCtx.AccountKeeper.GetAccount(txCtx.Context, txCtx.SimAccount.Address) +<<<<<<< HEAD tx, err := helpers.GenSignedMockTx( +======= + tx, err := simtestutil.GenSignedMockTx( + txCtx.R, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txCtx.TxGen, []sdk.Msg{txCtx.Msg}, fees, diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index eabe6486b7bc..1dd441abd32e 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/simulation/operations.go @@ -86,8 +86,14 @@ func SimulateMsgUnjail(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Kee msg := types.NewMsgUnjail(validator.GetOperator()) +<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( +======= + txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) + tx, err := simtestutil.GenSignedMockTx( + r, +>>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{msg}, fees, diff --git a/x/staking/simulation/operations.go b/x/staking/simulation/operations.go index 7cff6459db18..c28b489d6a51 100644 --- a/x/staking/simulation/operations.go +++ b/x/staking/simulation/operations.go @@ -164,6 +164,7 @@ func SimulateMsgCreateValidator(ak types.AccountKeeper, bk types.BankKeeper, k k } txCtx := simulation.OperationInput{ + R: r, App: app, TxGen: simappparams.MakeTestEncodingConfig().TxConfig, Cdc: nil, @@ -288,6 +289,7 @@ func SimulateMsgDelegate(ak types.AccountKeeper, bk types.BankKeeper, k keeper.K msg := types.NewMsgDelegate(simAccount.Address, val.GetOperator(), bondAmt) txCtx := simulation.OperationInput{ + R: r, App: app, TxGen: simappparams.MakeTestEncodingConfig().TxConfig, Cdc: nil, From 4c8bb9ba0a0d14eb1ea7e48e6cf087e65ea1c660 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 14 Jul 2022 19:26:28 +0200 Subject: [PATCH 2/2] fix conflicts --- CHANGELOG.md | 7 +-- simapp/helpers/test_helpers.go | 10 ++--- simapp/test_helpers.go | 13 +----- x/authz/simulation/operations.go | 14 +----- x/bank/simulation/operations.go | 8 ---- x/genutil/gentx_test.go | 4 -- x/gov/simulation/operations.go | 4 -- x/group/simulation/operations.go | 70 ----------------------------- x/nft/simulation/operations.go | 5 --- x/simulation/util.go | 4 -- x/slashing/simulation/operations.go | 11 ++--- 11 files changed, 9 insertions(+), 141 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 750d6946937f..d02f1e3c667c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* (testutil/sims) [#12374](https://github.com/cosmos/cosmos-sdk/pull/12374) fix the non-determinstic behavior in simulations caused by `GenSignedMockTx` and check empty coins slice before it is used to create `banktype.MsgSend`. * [#12448](https://github.com/cosmos/cosmos-sdk/pull/12448) Start telemetry independently from the API server. * [#12509](https://github.com/cosmos/cosmos-sdk/pull/12509) Fix `Register{Tx,Tendermint}Service` not being called, resulting in some endpoints like the Simulate endpoint not working. @@ -81,12 +82,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (types) [#12154](https://github.com/cosmos/cosmos-sdk/pull/12154) Add `baseAccountGetter` to avoid invalid account error when create vesting account. * (x/crisis) [#12208](https://github.com/cosmos/cosmos-sdk/pull/12208) Fix progress index of crisis invariant assertion logs. * (types) [#12229](https://github.com/cosmos/cosmos-sdk/pull/12229) Increase sdk.Dec maxApproxRootIterations to 300 -<<<<<<< HEAD -======= -* (x/staking) [#12303](https://github.com/cosmos/cosmos-sdk/pull/12303) Use bytes instead of string comparison in delete validator queue -* (testutil/sims) [#12374](https://github.com/cosmos/cosmos-sdk/pull/12374) fix the non-determinstic behavior in simulations caused by `GenSignedMockTx` and check -empty coins slice before it is used to create `banktype.MsgSend`. ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) ## [v0.46.0-rc1](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.0-rc1) - 2022-05-23 diff --git a/simapp/helpers/test_helpers.go b/simapp/helpers/test_helpers.go index e6420e7627ca..a0888c09019e 100644 --- a/simapp/helpers/test_helpers.go +++ b/simapp/helpers/test_helpers.go @@ -18,17 +18,13 @@ const ( ) // GenSignedMockTx generates a signed mock transaction. -<<<<<<< HEAD:simapp/helpers/test_helpers.go -func GenSignedMockTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { -======= func GenSignedMockTx(r *rand.Rand, txConfig client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)):testutil/sims/tx_helpers.go sigs := make([]signing.SignatureV2, len(priv)) // create a random length memo memo := simulation.RandStringOfLength(r, simulation.RandIntBetween(r, 0, 100)) - signMode := gen.SignModeHandler().DefaultMode() + signMode := txConfig.SignModeHandler().DefaultMode() // 1st round: set SignatureV2 with empty signatures, to set correct // signer infos. @@ -42,7 +38,7 @@ func GenSignedMockTx(r *rand.Rand, txConfig client.TxConfig, msgs []sdk.Msg, fee } } - tx := gen.NewTxBuilder() + tx := txConfig.NewTxBuilder() err := tx.SetMsgs(msgs...) if err != nil { return nil, err @@ -64,7 +60,7 @@ func GenSignedMockTx(r *rand.Rand, txConfig client.TxConfig, msgs []sdk.Msg, fee Sequence: accSeqs[i], PubKey: p.PubKey(), } - signBytes, err := gen.SignModeHandler().GetSignBytes(signMode, signerData, tx.GetTx()) + signBytes, err := txConfig.SignModeHandler().GetSignBytes(signMode, signerData, tx.GetTx()) if err != nil { panic(err) } diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 4bc91a850c73..fc1ac3195260 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -4,12 +4,9 @@ import ( "bytes" "encoding/hex" "encoding/json" -<<<<<<< HEAD "fmt" - "strconv" -======= "math/rand" ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) + "strconv" "testing" "time" @@ -415,12 +412,8 @@ func SignCheckDeliver( t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg, chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey, ) (sdk.GasInfo, *sdk.Result, error) { -<<<<<<< HEAD tx, err := helpers.GenSignedMockTx( -======= - tx, err := simtestutil.GenSignedMockTx( rand.New(rand.NewSource(time.Now().UnixNano())), ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txCfg, msgs, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, @@ -470,12 +463,8 @@ func GenSequenceOfTxs(txGen client.TxConfig, msgs []sdk.Msg, accNums []uint64, i txs := make([]sdk.Tx, numToGenerate) var err error for i := 0; i < numToGenerate; i++ { -<<<<<<< HEAD txs[i], err = helpers.GenSignedMockTx( -======= - txs[i], err = simtestutil.GenSignedMockTx( rand.New(rand.NewSource(time.Now().UnixNano())), ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, msgs, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, diff --git a/x/authz/simulation/operations.go b/x/authz/simulation/operations.go index 604a40486273..5a047bbf6448 100644 --- a/x/authz/simulation/operations.go +++ b/x/authz/simulation/operations.go @@ -116,14 +116,10 @@ func SimulateMsgGrant(ak authz.AccountKeeper, bk authz.BankKeeper, _ keeper.Keep if err != nil { return simtypes.NoOpMsg(authz.ModuleName, TypeMsgGrant, err.Error()), nil, err } -<<<<<<< HEAD + txCfg := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( -======= - txCfg := tx.NewTxConfig(cdc, tx.DefaultSignModes) - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txCfg, []sdk.Msg{msg}, fees, @@ -193,12 +189,8 @@ func SimulateMsgRevoke(ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Kee msg := authz.NewMsgRevoke(granterAddr, granteeAddr, a.MsgTypeURL()) txCfg := simappparams.MakeTestEncodingConfig().TxConfig account := ak.GetAccount(ctx, granterAddr) -<<<<<<< HEAD tx, err := helpers.GenSignedMockTx( -======= - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txCfg, []sdk.Msg{&msg}, fees, @@ -291,12 +283,8 @@ func SimulateMsgExec(ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keepe txCfg := simappparams.MakeTestEncodingConfig().TxConfig granteeAcc := ak.GetAccount(ctx, granteeAddr) -<<<<<<< HEAD tx, err := helpers.GenSignedMockTx( -======= - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txCfg, []sdk.Msg{&msgExec}, fees, diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index d0c2abc2b363..8f6561a0585c 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -145,12 +145,8 @@ func sendMsgSend( } } txGen := simappparams.MakeTestEncodingConfig().TxConfig -<<<<<<< HEAD tx, err := helpers.GenSignedMockTx( -======= - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{msg}, fees, @@ -363,12 +359,8 @@ func sendMsgMultiSend( } txGen := simappparams.MakeTestEncodingConfig().TxConfig -<<<<<<< HEAD tx, err := helpers.GenSignedMockTx( -======= - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{msg}, fees, diff --git a/x/genutil/gentx_test.go b/x/genutil/gentx_test.go index 628dc951f321..be286051321d 100644 --- a/x/genutil/gentx_test.go +++ b/x/genutil/gentx_test.go @@ -235,12 +235,8 @@ func (suite *GenTxTestSuite) TestDeliverGenTxs() { r := rand.New(rand.NewSource(time.Now().UnixNano())) msg := banktypes.NewMsgSend(addr1, addr2, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 1)}) -<<<<<<< HEAD tx, err := helpers.GenSignedMockTx( -======= - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) suite.encodingConfig.TxConfig, []sdk.Msg{msg}, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 10)}, diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index 293a34aea0f9..91ed7f525350 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -169,12 +169,8 @@ func SimulateMsgSubmitProposal( } txGen := simappparams.MakeTestEncodingConfig().TxConfig -<<<<<<< HEAD tx, err := helpers.GenSignedMockTx( -======= - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{msg}, fees, diff --git a/x/group/simulation/operations.go b/x/group/simulation/operations.go index 4aefba6de639..36875b55cc8b 100644 --- a/x/group/simulation/operations.go +++ b/x/group/simulation/operations.go @@ -259,14 +259,9 @@ func SimulateMsgCreateGroup(ak group.AccountKeeper, bk group.BankKeeper) simtype members := genGroupMembers(r, accounts) msg := &group.MsgCreateGroup{Admin: accAddr, Members: members, Metadata: simtypes.RandStringOfLength(r, 10)} -<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( -======= - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{msg}, fees, @@ -324,14 +319,9 @@ func SimulateMsgCreateGroupWithPolicy(ak group.AccountKeeper, bk group.BankKeepe return simtypes.NoOpMsg(group.ModuleName, msg.Type(), "unable to set decision policy"), nil, err } -<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( -======= - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{msg}, fees, @@ -389,14 +379,9 @@ func SimulateMsgCreateGroupPolicy(ak group.AccountKeeper, bk group.BankKeeper, k return simtypes.NoOpMsg(group.ModuleName, TypeMsgCreateGroupPolicy, err.Error()), nil, err } -<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( -======= - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{msg}, fees, @@ -470,14 +455,9 @@ func SimulateMsgSubmitProposal(ak group.AccountKeeper, bk group.BankKeeper, k ke Metadata: simtypes.RandStringOfLength(r, 10), } -<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( -======= - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{&msg}, fees, @@ -535,14 +515,9 @@ func SimulateMsgUpdateGroupAdmin(ak group.AccountKeeper, bk group.BankKeeper, k NewAdmin: newAdmin.Address.String(), } -<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( -======= - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{&msg}, fees, @@ -591,14 +566,9 @@ func SimulateMsgUpdateGroupMetadata(ak group.AccountKeeper, bk group.BankKeeper, Metadata: simtypes.RandStringOfLength(r, 10), } -<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( -======= - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{&msg}, fees, @@ -676,14 +646,9 @@ func SimulateMsgUpdateGroupMembers(ak group.AccountKeeper, MemberUpdates: members, } -<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( -======= - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{&msg}, fees, @@ -741,14 +706,9 @@ func SimulateMsgUpdateGroupPolicyAdmin(ak group.AccountKeeper, bk group.BankKeep NewAdmin: newAdmin.Address.String(), } -<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( -======= - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{&msg}, fees, @@ -808,14 +768,9 @@ func SimulateMsgUpdateGroupPolicyDecisionPolicy(ak group.AccountKeeper, return simtypes.NoOpMsg(group.ModuleName, TypeMsgUpdateGroupPolicyDecisionPolicy, err.Error()), nil, err } -<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( -======= - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{msg}, fees, @@ -865,14 +820,9 @@ func SimulateMsgUpdateGroupPolicyMetadata(ak group.AccountKeeper, Metadata: simtypes.RandStringOfLength(r, 10), } -<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( -======= - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{&msg}, fees, @@ -973,14 +923,9 @@ func SimulateMsgWithdrawProposal(ak group.AccountKeeper, Address: proposer.Address.String(), } -<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( -======= - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{&msg}, fees, @@ -1084,14 +1029,9 @@ func SimulateMsgVote(ak group.AccountKeeper, Option: group.VOTE_OPTION_YES, Metadata: simtypes.RandStringOfLength(r, 10), } -<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( -======= - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{&msg}, fees, @@ -1168,14 +1108,9 @@ func SimulateMsgExec(ak group.AccountKeeper, ProposalId: uint64(proposalID), Executor: acc.Address.String(), } -<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( -======= - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{&msg}, fees, @@ -1236,14 +1171,9 @@ func SimulateMsgLeaveGroup(k keeper.Keeper, ak group.AccountKeeper, bk group.Ban GroupId: groupInfo.Id, } -<<<<<<< HEAD txGen := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( -======= - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txGen, []sdk.Msg{msg}, fees, diff --git a/x/nft/simulation/operations.go b/x/nft/simulation/operations.go index 4ad52b1072f6..c4e9f501ac72 100644 --- a/x/nft/simulation/operations.go +++ b/x/nft/simulation/operations.go @@ -95,14 +95,9 @@ func SimulateMsgSend( Receiver: receiver.Address.String(), } -<<<<<<< HEAD txCfg := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( -======= - txCfg := tx.NewTxConfig(cdc, tx.DefaultSignModes) - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txCfg, []sdk.Msg{msg}, fees, diff --git a/x/simulation/util.go b/x/simulation/util.go index 3472bcd4940c..09278e6aeb8e 100644 --- a/x/simulation/util.go +++ b/x/simulation/util.go @@ -100,12 +100,8 @@ func GenAndDeliverTxWithRandFees(txCtx OperationInput) (simtypes.OperationMsg, [ // GenAndDeliverTx generates a transactions and delivers it. func GenAndDeliverTx(txCtx OperationInput, fees sdk.Coins) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { account := txCtx.AccountKeeper.GetAccount(txCtx.Context, txCtx.SimAccount.Address) -<<<<<<< HEAD tx, err := helpers.GenSignedMockTx( -======= - tx, err := simtestutil.GenSignedMockTx( txCtx.R, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) txCtx.TxGen, []sdk.Msg{txCtx.Msg}, fees, diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index 1dd441abd32e..23be89b1b21f 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/simulation/operations.go @@ -86,15 +86,10 @@ func SimulateMsgUnjail(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Kee msg := types.NewMsgUnjail(validator.GetOperator()) -<<<<<<< HEAD - txGen := simappparams.MakeTestEncodingConfig().TxConfig + txCfg := simappparams.MakeTestEncodingConfig().TxConfig tx, err := helpers.GenSignedMockTx( -======= - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) - tx, err := simtestutil.GenSignedMockTx( r, ->>>>>>> 17dc43166 (fix: Simulation is not deterministic due to GenSignedMockTx (#12374)) - txGen, + txCfg, []sdk.Msg{msg}, fees, helpers.DefaultGenTxGas, @@ -107,7 +102,7 @@ func SimulateMsgUnjail(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Kee return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - _, res, err := app.SimDeliver(txGen.TxEncoder(), tx) + _, res, err := app.SimDeliver(txCfg.TxEncoder(), tx) // result should fail if: // - validator cannot be unjailed due to tombstone