From fe72a42a251aa83185b283d29c2fc5efdb9bf1bd Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Tue, 17 Dec 2019 18:41:30 +0100 Subject: [PATCH 1/3] Parametrise simapp/helpers.GenTx()'s gas value --- simapp/helpers/test_helpers.go | 9 ++++++--- simapp/test_helpers.go | 2 ++ x/bank/simulation/operations.go | 2 ++ x/distribution/simulation/operations.go | 4 ++++ x/gov/simulation/operations.go | 3 +++ x/slashing/simulation/operations.go | 1 + x/staking/simulation/operations.go | 5 +++++ 7 files changed, 23 insertions(+), 3 deletions(-) diff --git a/simapp/helpers/test_helpers.go b/simapp/helpers/test_helpers.go index a9127a6fbd45..f87db7fa9aba 100644 --- a/simapp/helpers/test_helpers.go +++ b/simapp/helpers/test_helpers.go @@ -12,13 +12,16 @@ import ( ) // SimAppChainID hardcoded chainID for simulation -const SimAppChainID = "simulation-app" +const ( + DefaultGenTxGas = 1000000 + SimAppChainID = "simulation-app" +) // GenTx generates a signed mock transaction. -func GenTx(msgs []sdk.Msg, feeAmt sdk.Coins, chainID string, accnums []uint64, seq []uint64, priv ...crypto.PrivKey) auth.StdTx { +func GenTx(msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accnums []uint64, seq []uint64, priv ...crypto.PrivKey) auth.StdTx { fee := auth.StdFee{ Amount: feeAmt, - Gas: 1000000, // TODO: this should be a param + Gas: DefaultGenTxGas, // TODO: this should be a param } sigs := make([]auth.StdSignature, len(priv)) diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index c7874bc0b7c9..329edeaed29e 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -120,6 +120,7 @@ func SignCheckDeliver( tx := helpers.GenTx( msgs, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, + helpers.DefaultGenTxGas, "", accNums, seq, @@ -163,6 +164,7 @@ func GenSequenceOfTxs(msgs []sdk.Msg, accNums []uint64, initSeqNums []uint64, nu txs[i] = helpers.GenTx( msgs, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, + helpers.DefaultGenTxGas, "", accNums, initSeqNums, diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index 9e89174e9433..71a88386c960 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -108,6 +108,7 @@ func sendMsgSend( tx := helpers.GenTx( []sdk.Msg{msg}, fees, + helpers.DefaultGenTxGas, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -251,6 +252,7 @@ func sendMsgMultiSend( tx := helpers.GenTx( []sdk.Msg{msg}, fees, + helpers.DefaultGenTxGas, chainID, accountNumbers, sequenceNumbers, diff --git a/x/distribution/simulation/operations.go b/x/distribution/simulation/operations.go index 2ec483cbc1ba..9a9dea6b8d4b 100644 --- a/x/distribution/simulation/operations.go +++ b/x/distribution/simulation/operations.go @@ -102,6 +102,7 @@ func SimulateMsgSetWithdrawAddress(ak types.AccountKeeper, k keeper.Keeper) simu tx := helpers.GenTx( []sdk.Msg{msg}, fees, + helpers.DefaultGenTxGas, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -147,6 +148,7 @@ func SimulateMsgWithdrawDelegatorReward(ak types.AccountKeeper, k keeper.Keeper, tx := helpers.GenTx( []sdk.Msg{msg}, fees, + helpers.DefaultGenTxGas, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -195,6 +197,7 @@ func SimulateMsgWithdrawValidatorCommission(ak types.AccountKeeper, k keeper.Kee tx := helpers.GenTx( []sdk.Msg{msg}, fees, + helpers.DefaultGenTxGas, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -244,6 +247,7 @@ func SimulateMsgFundCommunityPool(ak types.AccountKeeper, k keeper.Keeper, sk st tx := helpers.GenTx( []sdk.Msg{msg}, fees, + helpers.DefaultGenTxGas, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index 4d33d82bc86c..0e0bcd06f600 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -141,6 +141,7 @@ func SimulateSubmitProposal( tx := helpers.GenTx( []sdk.Msg{msg}, fees, + helpers.DefaultGenTxGas, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -223,6 +224,7 @@ func SimulateMsgDeposit(ak types.AccountKeeper, k keeper.Keeper) simulation.Oper tx := helpers.GenTx( []sdk.Msg{msg}, fees, + helpers.DefaultGenTxGas, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -280,6 +282,7 @@ func operationSimulateMsgVote(ak types.AccountKeeper, k keeper.Keeper, tx := helpers.GenTx( []sdk.Msg{msg}, fees, + helpers.DefaultGenTxGas, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index 992513c924d8..3e2a3bc78bad 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/simulation/operations.go @@ -86,6 +86,7 @@ func SimulateMsgUnjail(ak types.AccountKeeper, k keeper.Keeper, sk stakingkeeper tx := helpers.GenTx( []sdk.Msg{msg}, fees, + helpers.DefaultGenTxGas, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, diff --git a/x/staking/simulation/operations.go b/x/staking/simulation/operations.go index d2b2cab87d04..8ddea88aa7c6 100644 --- a/x/staking/simulation/operations.go +++ b/x/staking/simulation/operations.go @@ -154,6 +154,7 @@ func SimulateMsgCreateValidator(ak types.AccountKeeper, k keeper.Keeper) simulat tx := helpers.GenTx( []sdk.Msg{msg}, fees, + helpers.DefaultGenTxGas, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -218,6 +219,7 @@ func SimulateMsgEditValidator(ak types.AccountKeeper, k keeper.Keeper) simulatio tx := helpers.GenTx( []sdk.Msg{msg}, fees, + helpers.DefaultGenTxGas, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -284,6 +286,7 @@ func SimulateMsgDelegate(ak types.AccountKeeper, k keeper.Keeper) simulation.Ope tx := helpers.GenTx( []sdk.Msg{msg}, fees, + helpers.DefaultGenTxGas, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -363,6 +366,7 @@ func SimulateMsgUndelegate(ak types.AccountKeeper, k keeper.Keeper) simulation.O tx := helpers.GenTx( []sdk.Msg{msg}, fees, + helpers.DefaultGenTxGas, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -468,6 +472,7 @@ func SimulateMsgBeginRedelegate(ak types.AccountKeeper, k keeper.Keeper) simulat tx := helpers.GenTx( []sdk.Msg{msg}, fees, + helpers.DefaultGenTxGas, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, From 3738aaf30c025797fcab40eb9919bf6532985239 Mon Sep 17 00:00:00 2001 From: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Date: Tue, 17 Dec 2019 14:58:52 -0300 Subject: [PATCH 2/3] Update simapp/helpers/test_helpers.go --- simapp/helpers/test_helpers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simapp/helpers/test_helpers.go b/simapp/helpers/test_helpers.go index f87db7fa9aba..2341635eeea8 100644 --- a/simapp/helpers/test_helpers.go +++ b/simapp/helpers/test_helpers.go @@ -21,7 +21,7 @@ const ( func GenTx(msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accnums []uint64, seq []uint64, priv ...crypto.PrivKey) auth.StdTx { fee := auth.StdFee{ Amount: feeAmt, - Gas: DefaultGenTxGas, // TODO: this should be a param + Gas: gas, } sigs := make([]auth.StdSignature, len(priv)) From 228f5e55def5a25916a080644db6c02751e888ff Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Wed, 18 Dec 2019 09:32:08 +0100 Subject: [PATCH 3/3] Update changelog [skip ci] --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15b78b68bf43..3f395ba5663c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,7 +77,8 @@ if the provided arguments are invalid. * (modules) [\#5299](https://github.com/cosmos/cosmos-sdk/pull/5299) `HandleDoubleSign` along with params `MaxEvidenceAge` and `DoubleSignJailEndTime` have moved from the `x/slashing` module to the `x/evidence` module. * (keys) [\#4941](https://github.com/cosmos/cosmos-sdk/issues/4941) Initializing a new keybase through `NewKeyringFromHomeFlag`, `NewKeyringFromDir`, `NewKeyBaseFromHomeFlag`, `NewKeyBaseFromDir`, or `NewInMemory` functions now accept optional parameters of type `KeybaseOption`. These optional parameters are also added on the keys subcommands functions, which are now public, and allows these options to be set on the commands or ignored to default to previous behavior. - * The option introduced in this PR is `WithKeygenFunc` which allows a custom bytes to key implementation to be defined when keys are created. + * The option introduced in this PR is `WithKeygenFunc` which allows a custom bytes to key implementation to be defined when keys are created. +* (simapp) [\#5419](https://github.com/cosmos/cosmos-sdk/pull/5419) simapp/helpers.GenTx() now accepts a gas argument. ### Client Breaking Changes