Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sim refactor 3: move weighted operations to modules #4869

Merged
merged 157 commits into from
Dec 5, 2019
Merged
Show file tree
Hide file tree
Changes from 151 commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
771e305
move GenesisState generators to modules
fedekunze Jul 30, 2019
77d8bd9
minor change on slashing genState generator
fedekunze Aug 2, 2019
52c18e0
move simulation params back to modules (#4839)
fedekunze Aug 5, 2019
bea474f
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into fe…
fedekunze Aug 5, 2019
237b65a
cleanup params
fedekunze Aug 5, 2019
8bb9880
various fixes
fedekunze Aug 5, 2019
84fa364
move store decoders to modules
fedekunze Jul 30, 2019
687125a
fix
fedekunze Aug 5, 2019
eeb0469
module pattern
fedekunze Aug 5, 2019
5fa13a3
split generators for param change
fedekunze Aug 6, 2019
5efe2bd
param changes
fedekunze Aug 6, 2019
3e15e2a
revert util pkg
fedekunze Aug 6, 2019
521c4dd
banksim
fedekunze Aug 6, 2019
5c41dd2
compile
fedekunze Aug 7, 2019
865a5e4
update Decoders params
fedekunze Aug 7, 2019
45a0e3c
fix
fedekunze Aug 7, 2019
da6de9f
address @colin-axner comments
fedekunze Aug 8, 2019
b59f37c
merge master
fedekunze Aug 8, 2019
f25f970
move weighted operations to modules
fedekunze Jul 30, 2019
66d459a
cleanup
fedekunze Aug 8, 2019
867ba5a
merge master
fedekunze Aug 8, 2019
4f59730
cleanup
fedekunze Aug 8, 2019
bd71a17
Update cmd_test.go
fedekunze Aug 8, 2019
3628d90
merge master
fedekunze Aug 9, 2019
564b484
Merge branch 'fedekunze/move-sim-decoders' of https://github.com/cosm…
fedekunze Aug 9, 2019
fc1e72a
simulation manager
fedekunze Aug 9, 2019
cca3a19
mino fixes
fedekunze Aug 9, 2019
c48a035
cleanup
fedekunze Aug 9, 2019
8c02035
merge sim refactor part 1
fedekunze Aug 9, 2019
5fe9b91
add GenerateGenesisState to simulation manager
fedekunze Aug 9, 2019
225bea3
Apply suggestions from code review
fedekunze Aug 9, 2019
9f3525b
address @rigelrozanski comments
fedekunze Aug 9, 2019
c13ecb6
changelog
fedekunze Aug 9, 2019
4959068
Apply suggestions from code review
fedekunze Aug 10, 2019
4a4db84
update tests
fedekunze Aug 12, 2019
0338964
Merge branch 'fedekunze/move-sim-decoders' of https://github.com/cosm…
fedekunze Aug 12, 2019
84555d9
Merge branch 'fedekunze/move-sim-decoders' of https://github.com/cosm…
fedekunze Aug 12, 2019
258e3e6
restructure modules simulation pkgs
fedekunze Aug 12, 2019
785ac1d
merge sim decoders PR
fedekunze Aug 12, 2019
c627c68
remove cycle deps
fedekunze Aug 12, 2019
427b235
rename funcs and add missing params
fedekunze Aug 12, 2019
7793e11
modularize simulator param changes
fedekunze Aug 13, 2019
d81ba90
build
fedekunze Aug 13, 2019
3899350
fix params keys
fedekunze Aug 13, 2019
c0cd833
make format
fedekunze Aug 13, 2019
e574743
merge master
fedekunze Aug 13, 2019
694e699
merge master
fedekunze Aug 14, 2019
b3ad025
various fixes
fedekunze Aug 14, 2019
538e6e1
fix tests
fedekunze Aug 14, 2019
2ac27a2
minor updates to sim_test
fedekunze Aug 14, 2019
702a257
merge master
fedekunze Aug 16, 2019
d6c669b
cleanup
fedekunze Aug 16, 2019
85ced57
more cleanup
fedekunze Aug 16, 2019
ea76486
modularize genesis generators
fedekunze Aug 16, 2019
9db1881
minor cleanup
fedekunze Aug 16, 2019
cb3f361
remove cdc from generators
fedekunze Aug 20, 2019
d1b96f0
remove cdc
fedekunze Aug 20, 2019
329d32b
merge master
fedekunze Aug 20, 2019
887f2e7
add get or generate
fedekunze Aug 20, 2019
b51949c
fix non-determinism in simulation
fedekunze Aug 20, 2019
ee7c66d
changelog and x/simulation godoc
fedekunze Aug 20, 2019
6bd9554
changes from master
fedekunze Aug 20, 2019
86a6819
merge simulation part 2
fedekunze Aug 20, 2019
4928867
cleanup operations
fedekunze Aug 20, 2019
f22313a
update operations to use baseapp
fedekunze Aug 22, 2019
8f1240c
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into fe…
fedekunze Aug 26, 2019
5a31d65
updates and cleanup operations
fedekunze Aug 26, 2019
89cf7b9
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into fe…
fedekunze Aug 27, 2019
5f606ea
update operations
fedekunze Aug 27, 2019
d450ebb
restructure sim ops params
fedekunze Aug 27, 2019
abb288f
merge master
fedekunze Aug 27, 2019
51bf12b
merge master
fedekunze Aug 28, 2019
fe3f6f3
rename sim /operations/msg.go to /operations.go
fedekunze Aug 28, 2019
f3a398b
move GenTx to a helper pkg to avoid circle deps
fedekunze Aug 28, 2019
666a301
rm msg.ValidateBasic
fedekunze Aug 28, 2019
1bb0adc
changelog
fedekunze Aug 28, 2019
b300de0
random fees; delete auth's DeductFees sim operation
fedekunze Aug 29, 2019
bcf6796
add chain-id for sig verification
fedekunze Aug 29, 2019
bb47279
Update x/simulation/account.go
fedekunze Aug 29, 2019
b52a122
fix bank, gov and distr errors
fedekunze Aug 29, 2019
08af7df
Merge branch 'fedekunze/4935-sim-ops-baseapp' of https://github.com/c…
fedekunze Aug 29, 2019
a0a4105
fix staking and slashing errors; increase prob for send enabled
fedekunze Aug 29, 2019
0d33e53
increase gas x10
fedekunze Aug 29, 2019
d2d8e06
make format
fedekunze Aug 29, 2019
882b529
fix some distr and staking edge cases
fedekunze Aug 29, 2019
86798bd
fix all edge cases
fedekunze Aug 30, 2019
8a5a8f7
golang ci
fedekunze Aug 30, 2019
d2433c8
rename acc vars; default no fees to 0stake
fedekunze Aug 30, 2019
0172569
cleanup; check for exchange rate and skip invalid ops
fedekunze Aug 30, 2019
2a2c369
fixes
fedekunze Aug 30, 2019
50f6959
check for max entries
fedekunze Aug 30, 2019
309348a
add pubkey to genaccounts
fedekunze Aug 30, 2019
4e2d3b3
fix gov bug
fedekunze Sep 2, 2019
e662201
update staking sim ops
fedekunze Sep 2, 2019
f1c3e12
fix small redelegation error
fedekunze Sep 2, 2019
3298d5d
fix small self delegation on unjail
fedekunze Sep 2, 2019
8501356
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into fe…
fedekunze Sep 2, 2019
e615ee1
rm inf loop on random val/accs
fedekunze Sep 2, 2019
9e81756
copy array
fedekunze Sep 2, 2019
490bc77
add ok boolean to RandomValidator return values
fedekunze Sep 2, 2019
2139e75
format
fedekunze Sep 2, 2019
94dcc8c
merge #4946
fedekunze Sep 3, 2019
e64f774
build
fedekunze Sep 3, 2019
0b10ad0
add WeightedOperations to AppModuleSimulation
fedekunze Sep 3, 2019
370a664
define each module proposals content as part of the module pattern
fedekunze Sep 4, 2019
7da6f34
Update x/bank/simulation/operations.go
fedekunze Sep 4, 2019
bd7ed37
Update simapp/helpers/test_helpers.go
fedekunze Sep 4, 2019
59620ed
address @colin-axner comments
fedekunze Sep 4, 2019
b2b4a63
add genaccount pubkey validation
fedekunze Sep 4, 2019
c739839
fix test
fedekunze Sep 4, 2019
8d5a90e
update operations and move RandomFees to x/simulation
fedekunze Sep 5, 2019
52875e5
update gov ops
fedekunze Sep 5, 2019
ae94071
merge master
fedekunze Sep 5, 2019
c49543f
address @alexanderbez comments
fedekunze Sep 6, 2019
86503a9
avoid modifications to config
fedekunze Sep 6, 2019
496fa15
reorder params
fedekunze Sep 6, 2019
0b9b1f4
modularized sim operations working
fedekunze Sep 9, 2019
7aad9cb
merge master
fedekunze Sep 9, 2019
f00fbab
merge sims baseapp PR
fedekunze Sep 9, 2019
337a25c
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into fe…
fedekunze Sep 9, 2019
efcab1d
changelog
fedekunze Sep 9, 2019
70e8bfa
Merge branch 'fedekunze/4935-sim-ops-baseapp' of https://github.com/c…
fedekunze Sep 9, 2019
7543f45
Update types/module/simulation.go
fedekunze Sep 11, 2019
01da23d
Update x/simulation/params.go
fedekunze Sep 11, 2019
cc719ba
Update x/simulation/params.go
fedekunze Sep 11, 2019
ce53f80
update /types/module
fedekunze Sep 11, 2019
d4df4bf
Update x/distribution/simulation/genesis.go
fedekunze Sep 11, 2019
4f9961a
merge master
fedekunze Sep 24, 2019
8396254
Merge branch 'fedekunze/4935-sim-ops-baseapp' of https://github.com/c…
fedekunze Sep 24, 2019
a188a77
remove named return values
fedekunze Sep 24, 2019
ea3594b
ensure all operations are simulated
fedekunze Sep 25, 2019
f39fc77
Merge branch 'master' into fedekunze/4935-sim-ops-baseapp
fedekunze Sep 25, 2019
c79bc9a
golangci
fedekunze Sep 25, 2019
5491db8
Merge branch 'fedekunze/4935-sim-ops-baseapp' of https://github.com/c…
fedekunze Sep 25, 2019
c9faeeb
add nolint
fedekunze Sep 25, 2019
b310b12
disable whitespace and funlen linter
fedekunze Sep 25, 2019
446179d
disable godox
fedekunze Sep 25, 2019
42eebc3
add TODO on unjail
fedekunze Sep 25, 2019
272e08a
update ops weights
fedekunze Sep 25, 2019
5a3712d
address @alexanderbez comments
fedekunze Sep 30, 2019
c45382b
remove dup
fedekunze Sep 30, 2019
efd2edb
update godoc
fedekunze Sep 30, 2019
daa8206
Merge branch 'master' into fedekunze/4935-sim-ops-baseapp
fedekunze Sep 30, 2019
55f4eb2
merge sim baseapp branch
fedekunze Sep 30, 2019
e34af9d
remove unused func
fedekunze Oct 1, 2019
3b9b870
merge master
fedekunze Nov 22, 2019
c16e512
build fixes
fedekunze Nov 22, 2019
a933a05
move weights to the same file
fedekunze Nov 26, 2019
58357f2
scopelint
fedekunze Nov 26, 2019
9e84b66
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into fe…
fedekunze Dec 2, 2019
bfb0a94
changelog
fedekunze Dec 2, 2019
15c015b
address @AdityaSripal comments
fedekunze Dec 3, 2019
a9696c0
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into fe…
fedekunze Dec 3, 2019
6ba787d
Merge branch 'master' into fedekunze/move-sim-operations
alexanderbez Dec 4, 2019
9ba2ec5
Merge branch 'master' into fedekunze/move-sim-operations
fedekunze Dec 4, 2019
cb524e0
address @alexanderbez comments
fedekunze Dec 4, 2019
40a38fa
Merge branch 'fedekunze/move-sim-operations' of https://github.com/co…
fedekunze Dec 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,15 @@ generalized genesis accounts through the `GenesisAccount` interface.
* (simulation) [\#4824](https://github.com/cosmos/cosmos-sdk/issues/4824) PrintAllInvariants flag will print all failed invariants
* (simulation) [\#4490](https://github.com/cosmos/cosmos-sdk/issues/4490) add `InitialBlockHeight` flag to resume a simulation from a given block
* Support exporting the simulation stats to a given JSON file
* (simulation) [\#4847](https://github.com/cosmos/cosmos-sdk/issues/4847), [\#4838](https://github.com/cosmos/cosmos-sdk/pull/4838) `SimApp` and simulation refactors
* (simulation) [\#4847](https://github.com/cosmos/cosmos-sdk/issues/4847), [\#4838](https://github.com/cosmos/cosmos-sdk/pull/4838) and [\#4869](https://github.com/cosmos/cosmos-sdk/pull/4869) `SimApp` and simulation refactors:
* Implement `SimulationManager` for executing modules' simulation functionalities in a modularized way
* Add `RegisterStoreDecoders` to the `SimulationManager` for decoding each module's types
* Add `GenerateGenesisStates` to the `SimulationManager` to generate a randomized `GenState` for each module
* Add `RandomizedParams` to the `SimulationManager` that registers each modules' parameters `Content` to simulate
`ParamChangeProposal`s
* Add `RandomizedParams` to the `SimulationManager` that registers each modules' parameters in order to
simulate `ParamChangeProposal`s' `Content`s
* Add `WeightedOperations` to the `SimulationManager` that define simulation operations (modules' `Msg`s) with their
respective weights (i.e chance of being simulated).
* Add `ProposalContents` to the `SimulationManager` to register each module's governance proposal `Content`s.
* (simulation) [\#4893](https://github.com/cosmos/cosmos-sdk/issues/4893) Change SimApp keepers to be public and add getter functions for keys and codec
* (simulation) [\#4906](https://github.com/cosmos/cosmos-sdk/issues/4906) Add simulation `Config` struct that wraps simulation flags
* (simulation) [\#4935](https://github.com/cosmos/cosmos-sdk/issues/4935) Update simulation to reflect a proper `ABCI` application without bypassing `BaseApp` semantics
Expand Down
13 changes: 7 additions & 6 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ func NewSimApp(
bank.NewAppModule(app.BankKeeper, app.AccountKeeper),
crisis.NewAppModule(&app.CrisisKeeper),
supply.NewAppModule(app.SupplyKeeper, app.AccountKeeper),
gov.NewAppModule(app.GovKeeper, app.SupplyKeeper),
gov.NewAppModule(app.GovKeeper, app.AccountKeeper, app.SupplyKeeper),
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
mint.NewAppModule(app.MintKeeper),
distr.NewAppModule(app.DistrKeeper, app.SupplyKeeper),
slashing.NewAppModule(app.SlashingKeeper, app.StakingKeeper),
slashing.NewAppModule(app.SlashingKeeper, app.AccountKeeper, app.StakingKeeper),
distr.NewAppModule(app.DistrKeeper, app.AccountKeeper, app.SupplyKeeper, app.StakingKeeper),
staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.SupplyKeeper),
upgrade.NewAppModule(app.UpgradeKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
Expand Down Expand Up @@ -259,11 +259,12 @@ func NewSimApp(
auth.NewAppModule(app.AccountKeeper),
bank.NewAppModule(app.BankKeeper, app.AccountKeeper),
supply.NewAppModule(app.SupplyKeeper, app.AccountKeeper),
gov.NewAppModule(app.GovKeeper, app.SupplyKeeper),
gov.NewAppModule(app.GovKeeper, app.AccountKeeper, app.SupplyKeeper),
mint.NewAppModule(app.MintKeeper),
distr.NewAppModule(app.DistrKeeper, app.SupplyKeeper),
staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.SupplyKeeper),
slashing.NewAppModule(app.SlashingKeeper, app.StakingKeeper),
distr.NewAppModule(app.DistrKeeper, app.AccountKeeper, app.SupplyKeeper, app.StakingKeeper),
slashing.NewAppModule(app.SlashingKeeper, app.AccountKeeper, app.StakingKeeper),
params.NewAppModule(), // NOTE: only used for simulation to generate randomized param change proposals
)

app.sm.RegisterStoreDecoders()
Expand Down
21 changes: 2 additions & 19 deletions simapp/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,6 @@ package simapp

// Simulation parameter constants
const (
StakePerAccount = "stake_per_account"
InitiallyBondedValidators = "initially_bonded_validators"
OpWeightDeductFee = "op_weight_deduct_fee"
OpWeightMsgSend = "op_weight_msg_send"
OpWeightMsgMultiSend = "op_weight_msg_multisend"
OpWeightMsgSetWithdrawAddress = "op_weight_msg_set_withdraw_address"
OpWeightMsgWithdrawDelegationReward = "op_weight_msg_withdraw_delegation_reward"
OpWeightMsgWithdrawValidatorCommission = "op_weight_msg_withdraw_validator_commission"
OpWeightSubmitTextProposal = "op_weight_submit_text_proposal"
OpWeightSubmitCommunitySpendProposal = "op_weight_submit_community_spend_proposal"
OpWeightSubmitParamChangeProposal = "op_weight_submit_param_change_proposal"
OpWeightMsgDeposit = "op_weight_msg_deposit"
OpWeightMsgVote = "op_weight_msg_vote"
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"
StakePerAccount = "stake_per_account"
InitiallyBondedValidators = "initially_bonded_validators"
)
19 changes: 19 additions & 0 deletions simapp/params/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Package params defines the simulation parameters in the simapp.

It contains the default weights used for each transaction used on the module's
simulation. These weights define the chance for a transaction to be simulated at
any gived operation.

You can repace the default values for the weights by providing a params.json
file with the weights defined for each of the transaction operations:

{
"op_weight_msg_send": 60,
"op_weight_msg_delegate": 100,
}

In the example above, the `MsgSend` has 60% chance to be simulated, while the
"MsgDelegate" will always be simulated.
*/
package params
18 changes: 18 additions & 0 deletions simapp/params/weights.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package params

// Default simulation weights
const (
DefaultWeightMsgSend int = 100
DefaultWeightMsgMultiSend int = 10
DefaultWeightMsgSetWithdrawAddress int = 50
DefaultWeightMsgWithdrawDelegationReward int = 50
DefaultWeightMsgWithdrawValidatorCommission int = 50
DefaultWeightMsgDeposit int = 100
DefaultWeightMsgVote int = 67
DefaultWeightMsgUnjail int = 100
DefaultWeightMsgCreateValidator int = 100
DefaultWeightMsgEditValidator int = 5
DefaultWeightMsgDelegate int = 100
DefaultWeightMsgUndelegate int = 100
DefaultWeightMsgBeginRedelegate int = 100
)
6 changes: 4 additions & 2 deletions simapp/sim_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ func BenchmarkFullAppSimulation(b *testing.B) {
// TODO: parameterize numbers, save for a later PR
_, simParams, simErr := simulation.SimulateFromSeed(
b, os.Stdout, app.BaseApp, AppStateFn(app.Codec(), app.sm),
testAndRunTxs(app, config), app.ModuleAccountAddrs(), config,
SimulationOperations(app, app.Codec(), config),
app.ModuleAccountAddrs(), config,
)

// export state and params before the simulation error is checked
Expand Down Expand Up @@ -86,7 +87,8 @@ func BenchmarkInvariants(b *testing.B) {
// 2. Run parameterized simulation (w/o invariants)
_, simParams, simErr := simulation.SimulateFromSeed(
b, ioutil.Discard, app.BaseApp, AppStateFn(app.Codec(), app.sm),
testAndRunTxs(app, config), app.ModuleAccountAddrs(), config,
SimulationOperations(app, app.Codec(), config),
app.ModuleAccountAddrs(), config,
)

// export state and params before the simulation error is checked
Expand Down
Loading