Skip to content

Commit

Permalink
Merge PR #5419: Parametrise simulation gas value
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessio Treglia authored and alexanderbez committed Dec 18, 2019
1 parent fca4cbe commit eae10b0
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 6 additions & 3 deletions simapp/helpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: gas,
}

sigs := make([]auth.StdSignature, len(priv))
Expand Down
2 changes: 2 additions & 0 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func SignCheckDeliver(
tx := helpers.GenTx(
msgs,
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)},
helpers.DefaultGenTxGas,
"",
accNums,
seq,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions x/bank/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func sendMsgSend(
tx := helpers.GenTx(
[]sdk.Msg{msg},
fees,
helpers.DefaultGenTxGas,
chainID,
[]uint64{account.GetAccountNumber()},
[]uint64{account.GetSequence()},
Expand Down Expand Up @@ -251,6 +252,7 @@ func sendMsgMultiSend(
tx := helpers.GenTx(
[]sdk.Msg{msg},
fees,
helpers.DefaultGenTxGas,
chainID,
accountNumbers,
sequenceNumbers,
Expand Down
4 changes: 4 additions & 0 deletions x/distribution/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()},
Expand Down Expand Up @@ -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()},
Expand Down Expand Up @@ -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()},
Expand Down Expand Up @@ -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()},
Expand Down
3 changes: 3 additions & 0 deletions x/gov/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func SimulateSubmitProposal(
tx := helpers.GenTx(
[]sdk.Msg{msg},
fees,
helpers.DefaultGenTxGas,
chainID,
[]uint64{account.GetAccountNumber()},
[]uint64{account.GetSequence()},
Expand Down Expand Up @@ -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()},
Expand Down Expand Up @@ -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()},
Expand Down
1 change: 1 addition & 0 deletions x/slashing/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()},
Expand Down
5 changes: 5 additions & 0 deletions x/staking/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()},
Expand Down Expand Up @@ -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()},
Expand Down Expand Up @@ -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()},
Expand Down Expand Up @@ -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()},
Expand Down Expand Up @@ -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()},
Expand Down

0 comments on commit eae10b0

Please sign in to comment.