forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge PR cosmos#4435: Simulation: Params from File
* Move distr params to simulation param generator * Cleanup sim params output * Print params when possible instead of entire genesis struct * Update module param simulator keys * Rename module params simulator keys * Add/fix missing module params and implement SimParams * UPdate sim test to accept params file * Allow weights to be provided from file * Create doc.go * Remove TODO * Implement MustMarshalJSONIndent * Use mustMarshalJSONIndent for non-codec * Remove TODO * Fix doc.go * Update points * Update simapp/doc.go Co-Authored-By: Alessio Treglia <quadrispro@ubuntu.com> * Update simapp/doc.go Co-Authored-By: Alessio Treglia <quadrispro@ubuntu.com> * Cleanup appStateFn * Use constants for simulation parameter keys * Update msgs.go * minor formatting
- Loading branch information
1 parent
0785fac
commit 3d2c159
Showing
4 changed files
with
674 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
Package simapp implements a full fledged Cosmos SDK application used for executing | ||
simulation test suites. | ||
Simulation App | ||
The SimApp type defines an application used for running extensive simulation | ||
testing suites. It contains all core modules, including governance, staking, | ||
slashing, and distribution. | ||
Simulation is executed with various inputs including the number of blocks to | ||
simulate, the block size, whether the app should commit or not, the invariant | ||
checking period, and a seed which is used as a source of pseudo-randomness. | ||
In addition to the various inputs, simulation runs mainly in three modes: | ||
1. Completely random where the initial state, module parameters and simulation | ||
parameters are pseudo-randomly generated. | ||
2. From a genesis file where the initial state and the module parameters are defined. | ||
This mode is helpful for running simulations on a known state such as a live | ||
network export where a new (mostly likely breaking) version of the application | ||
needs to be tested. | ||
3. From a params file where the initial state is pseudo-randomly generated but the | ||
module and simulation parameters can be provided manually. This allows for a more | ||
controlled and deterministic simulation setup while allowing the state space to | ||
still be pseudo-randomly simulated. | ||
The simulation test suite also supports testing determinism and import/export | ||
functionality. | ||
Randomness | ||
Currently, simulation uses a single seed (integer) as a source for a PRNG by | ||
which all random operations are executed from. Any call to the PRNG changes all | ||
future operations as the internal state of the PRNG is modified. For example, | ||
if a new message type is created and needs to be simulated, the new introduced | ||
PRNG call will change all subsequent operations. | ||
This may can often be problematic when testing fixes to simulation faults. One | ||
current solution to this is to use a params file as mentioned above. In the future | ||
the simulation suite is expected to support a series of PRNGs that can be used | ||
uniquely per module and simulation component so that they will not effect each | ||
others state execution outcome. | ||
Usage | ||
To execute a completely pseudo-random simulation: | ||
$ go test -mod=readonly github.com/cosmos/cosmos-sdk/simapp \ | ||
-run=TestFullAppSimulation \ | ||
-SimulationEnabled=true \ | ||
-SimulationNumBlocks=100 \ | ||
-SimulationBlockSize=200 \ | ||
-SimulationCommit=true \ | ||
-SimulationSeed=99 \ | ||
-SimulationPeriod=5 \ | ||
-v -timeout 24h | ||
To execute simulation from a genesis file: | ||
$ go test -mod=readonly github.com/cosmos/cosmos-sdk/simapp \ | ||
-run=TestFullAppSimulation \ | ||
-SimulationEnabled=true \ | ||
-SimulationNumBlocks=100 \ | ||
-SimulationBlockSize=200 \ | ||
-SimulationCommit=true \ | ||
-SimulationSeed=99 \ | ||
-SimulationPeriod=5 \ | ||
-SimulationGenesis=/path/to/genesis.json \ | ||
-v -timeout 24h | ||
To execute simulation from a params file: | ||
$ go test -mod=readonly github.com/cosmos/cosmos-sdk/simapp \ | ||
-run=TestFullAppSimulation \ | ||
-SimulationEnabled=true \ | ||
-SimulationNumBlocks=100 \ | ||
-SimulationBlockSize=200 \ | ||
-SimulationCommit=true \ | ||
-SimulationSeed=99 \ | ||
-SimulationPeriod=5 \ | ||
-SimulationParams=/path/to/params.json \ | ||
-v -timeout 24h | ||
Params | ||
Params that are provided to simulation from a JSON file are used to used to set | ||
both module parameters and simulation parameters. See sim_test.go for the full | ||
set of parameters that can be provided. | ||
*/ | ||
package simapp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package simapp | ||
|
||
// Simulation parameter constants | ||
const ( | ||
StakePerAccount = "stake_per_account" | ||
InitiallyBondedValidators = "initially_bonded_validators" | ||
OpWeightDeductFee = "op_weight_deduct_fee" | ||
OpWeightMsgSend = "op_weight_msg_send" | ||
OpWeightSingleInputMsgMultiSend = "op_weight_single_input_msg_multisend" | ||
OpWeightMsgSetWithdrawAddress = "op_weight_msg_set_withdraw_address" | ||
OpWeightMsgWithdrawDelegationReward = "op_weight_msg_withdraw_delegation_reward" | ||
OpWeightMsgWithdrawValidatorCommission = "op_weight_msg_withdraw_validator_commission" | ||
OpWeightSubmitVotingSlashingTextProposal = "op_weight_submit_voting_slashing_text_proposal" | ||
OpWeightSubmitVotingSlashingCommunitySpendProposal = "op_weight_submit_voting_slashing_community_spend_proposal" | ||
OpWeightSubmitVotingSlashingParamChangeProposal = "op_weight_submit_voting_slashing_param_change_proposal" | ||
OpWeightMsgDeposit = "op_weight_msg_deposit" | ||
OpWeightMsgCreateValidator = "op_weight_msg_create_validator" | ||
OpWeightMsgEditValidator = "op_weight_msg_edit_validator" | ||
OpWeightMsgDelegate = "op_weight_msg_delegate" | ||
OpWeightMsgUndelegate = "op_weight_msg_undelegate" | ||
OpWeightMsgBeginRedelegate = "op_weight_msg_begin_redelegate" | ||
OpWeightMsgUnjail = "op_weight_msg_unjail" | ||
) |
Oops, something went wrong.