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 2: move GenesisState generators to modules #4838

Merged
merged 70 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 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
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
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
02e69b0
address some of @rigelrozanski and @alexanderbez suggestions
fedekunze Aug 23, 2019
03f211d
make simulation manager optional for apps
fedekunze Aug 26, 2019
0582c6a
add changes from NFT module
fedekunze Aug 26, 2019
5dd4b1b
address @alexanderbez comments
fedekunze Aug 26, 2019
feb24d5
make format
fedekunze Aug 26, 2019
aebecfb
add constants to param changes keys
fedekunze Aug 27, 2019
9048694
update changelog
fedekunze Aug 27, 2019
1abb14c
revert CI changes
fedekunze Aug 27, 2019
252e59b
increase inv period; reduce % of nft owners
fedekunze Aug 27, 2019
a90002f
go mod verify
fedekunze Aug 27, 2019
68a1a9c
remove nft from sims
fedekunze Aug 28, 2019
e86091e
reduce nft ops weights
fedekunze Aug 28, 2019
3020ab1
change invariant period to 0 for nondeterminism sim
fedekunze Aug 28, 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
37 changes: 4 additions & 33 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ commands:
- go-src-v1-{{ .Revision }}
- checkout
- restore_cache:
name: "Restore go modules cache"
keys:
- go-mod-v2-{{ checksum "go.sum" }}
name: "Restore go modules cache"
keys:
- go-mod-v2-{{ checksum "go.sum" }}
- run:
name: << parameters.description >>
command: |
Expand All @@ -40,7 +40,7 @@ jobs:
steps:
- checkout
- run:
Name : "Build docs"
name: "Build docs"
command: make build-docs
- run:
name: "Upload docs to S3"
Expand Down Expand Up @@ -87,56 +87,27 @@ jobs:
- make:
target: test_sim_import_export
description: "Test application import/export simulation"
- run:
command: |
mkdir -p /tmp/errors
cp /tmp/**/app-simulation-seed* /tmp/errors/
when: on_fail
- store_artifacts:
path: /tmp/errors

test_sim_after_import:
executor: golang
steps:
- make:
target: test_sim_after_import
description: "Test simulation after import"
- run:
command: |
mkdir -p /tmp/errors
cp /tmp/**/app-simulation-seed* /tmp/errors/
when: on_fail
- store_artifacts:
path: /tmp/errors

test_sim_multi_seed_long:
executor: golang
steps:
- make:
target: test_sim_multi_seed_long
description: "Test multi-seed simulation (long)"
- run:
command: |
mkdir -p /tmp/errors
cp /tmp/**/app-simulation-seed* /tmp/errors/
when: on_fail
- store_artifacts:
path: /tmp/errors

test_sim_multi_seed_short:
executor: golang
steps:
- make:
target: test_sim_multi_seed_short
description: "Test multi-seed simulation (short)"
- run:
command: |
mkdir -p /tmp/errors
cp /tmp/**/app-simulation-seed* /tmp/errors/
when: on_fail

- store_artifacts:
path: /tmp/errors

test_cover:
executor: golang
Expand Down
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ longer panics if the store to load contains substores that we didn't explicitly
* (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) `SimApp` and simulation refactors
* (simulation) [\#4847](https://github.com/cosmos/cosmos-sdk/issues/4847), [\#4838](https://github.com/cosmos/cosmos-sdk/pull/4838) `SimApp` and simulation refactors
* Implement `SimulationManager` for executing modules' simulation functionalities in a modularized way
* Add `DecodeStore` to the `SimulationManager` for decoding each module's types
* 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
* (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
* (store) [\#4792](https://github.com/cosmos/cosmos-sdk/issues/4792) panic on non-registered store
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ test_race:
test_sim_nondeterminism:
@echo "Running non-determinism test..."
@go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \
-NumBlocks=100 -BlockSize=200 -Commit=true -v -timeout 24h
-NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h

test_sim_custom_genesis_fast:
@echo "Running custom genesis simulation..."
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d
github.com/cosmos/go-bip39 v0.0.0-20180618194314-52158e4697b8
github.com/cosmos/ledger-cosmos-go v0.10.3
github.com/cosmos/tools v0.0.0-20190729191304-444fa9c55188 // indirect
github.com/fortytw2/leaktest v1.3.0 // indirect
github.com/gogo/protobuf v1.2.1
github.com/golang/mock v1.3.1-0.20190508161146-9fa652df1129
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ github.com/cosmos/ledger-cosmos-go v0.10.3 h1:Qhi5yTR5Pg1CaTpd00pxlGwNl4sFRdtK1J
github.com/cosmos/ledger-cosmos-go v0.10.3/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY=
github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI=
github.com/cosmos/ledger-go v0.9.2/go.mod h1:oZJ2hHAZROdlHiwTg4t7kP+GKIIkBT+o6c9QWFanOyI=
github.com/cosmos/tools v0.0.0-20190729191304-444fa9c55188 h1:KZsNQXLq7ZUURaBjVrztEqZX+d7qpjQkS4a0jbCMHIY=
github.com/cosmos/tools v0.0.0-20190729191304-444fa9c55188/go.mod h1:ycjJZ351OX/Y/DYgZqNn1WLCgpmVH7j29THN8vjbb9U=
github.com/cosmos/tools/cmd/clog v0.0.0-20190722180430-ea942c183cba h1:YhVnGzBkE2TvfBW5fAYBdNVK/3bwTPYVbMaOIGRHFRY=
github.com/cosmos/tools/cmd/clog v0.0.0-20190722180430-ea942c183cba/go.mod h1:TdPuAVaU2rc6K24ejr/AnGznt9Fd2qjtMoRrTO4uFrI=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
23 changes: 20 additions & 3 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ func NewSimApp(
bank.NewAppModule(app.BankKeeper, app.AccountKeeper),
crisis.NewAppModule(&app.CrisisKeeper),
supply.NewAppModule(app.SupplyKeeper, app.AccountKeeper),
distr.NewAppModule(app.DistrKeeper, app.SupplyKeeper),
gov.NewAppModule(app.GovKeeper, app.SupplyKeeper),
mint.NewAppModule(app.MintKeeper),
distr.NewAppModule(app.DistrKeeper, app.SupplyKeeper),
slashing.NewAppModule(app.SlashingKeeper, app.StakingKeeper),
staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.SupplyKeeper),
nft.NewAppModule(app.NFTKeeper),
Expand All @@ -204,13 +204,30 @@ func NewSimApp(
app.mm.SetOrderInitGenesis(
genaccounts.ModuleName, distr.ModuleName, staking.ModuleName,
auth.ModuleName, bank.ModuleName, slashing.ModuleName, gov.ModuleName,
mint.ModuleName, supply.ModuleName, crisis.ModuleName, genutil.ModuleName,
mint.ModuleName, supply.ModuleName, crisis.ModuleName, nft.ModuleName,
genutil.ModuleName,
)

app.mm.RegisterInvariants(&app.CrisisKeeper)
app.mm.RegisterRoutes(app.Router(), app.QueryRouter())

app.sm = module.NewSimulationManager(app.mm.Modules)
// create the simulation manager and define the order of the modules for deterministic simulations
//
// NOTE: this is not required apps that don't use the simulator for fuzz testing
// transactions
app.sm = module.NewSimulationManager(
genaccounts.NewAppModule(app.AccountKeeper),
auth.NewAppModule(app.AccountKeeper),
bank.NewAppModule(app.BankKeeper, app.AccountKeeper),
supply.NewAppModule(app.SupplyKeeper, app.AccountKeeper),
gov.NewAppModule(app.GovKeeper, 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),
// nft.NewAppModule(app.NFTKeeper),
)

app.sm.RegisterStoreDecoders()

// initialize stores
Expand Down
121 changes: 0 additions & 121 deletions simapp/doc.go

This file was deleted.

Loading