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 126 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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Types of changes (Stanzas):
"Bug Fixes" for any bug fixes.
"Client Breaking" for breaking CLI commands and REST routes used by end-users.
"API Breaking" for breaking exported APIs used by developers building on SDK.
"Genesis Breaking" for breaking changes that require changes on the genesis
file through a migration script.
"State Machine Breaking" for any changes that result in a different AppState given same genesisState and txList.

Ref: https://keepachangelog.com/en/1.0.0/
Expand All @@ -46,6 +48,11 @@ have this method perform a no-op.
* Prepare for module spec integration
* Update gov keys to use big endian encoding instead of little endian

### Genesis Changes

* (sdk) [\#4946](https://github.com/cosmos/cosmos-sdk/pull/4946) Add `PubKey` field
to `GenesisAccount`

### Client Breaking Changes

* (rest) [\#4783](https://github.com/cosmos/cosmos-sdk/issues/4783) The balance field in the DelegationResponse type is now sdk.Coin instead of sdk.Int
Expand Down Expand Up @@ -82,6 +89,7 @@ block time is >= the `halt-time`.
`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
* (simulation) [\#4935](https://github.com/cosmos/cosmos-sdk/issues/4935) Update simulation to reflect a proper `ABCI` application without bypassing `BaseApp` semantics
* (store) [\#4792](https://github.com/cosmos/cosmos-sdk/issues/4792) panic on non-registered store
* (types) [\#4821](https://github.com/cosmos/cosmos-sdk/issues/4821) types/errors package added with support for stacktraces. It is meant as a more feature-rich replacement for sdk.Errors in the mid-term.
* (store) [\#1947](https://github.com/cosmos/cosmos-sdk/issues/1947) Implement inter-block (persistent)
Expand Down
13 changes: 7 additions & 6 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,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),
nft.NewAppModule(app.NFTKeeper),
)
Expand Down Expand Up @@ -220,11 +220,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
// nft.NewAppModule(app.NFTKeeper),
)

Expand Down
45 changes: 45 additions & 0 deletions simapp/helpers/test_helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package helpers

import (
"math/rand"
"time"

"github.com/tendermint/tendermint/crypto"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/simulation"
)

// SimAppChainID hardcoded chainID for simulation
const 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 {
fee := auth.StdFee{
Amount: feeAmt,
Gas: 1000000, // TODO: this should be a param
}

sigs := make([]auth.StdSignature, len(priv))

// create a random length memo
r := rand.New(rand.NewSource(time.Now().UnixNano()))

memo := simulation.RandStringOfLength(r, simulation.RandIntBetween(r, 0, 100))

for i, p := range priv {
// use a empty chainID for ease of testing
sig, err := p.Sign(auth.StdSignBytes(chainID, accnums[i], seq[i], fee, msgs, memo))
if err != nil {
panic(err)
}

sigs[i] = auth.StdSignature{
PubKey: p.PubKey(),
Signature: sig,
}
}

return auth.NewStdTx(msgs, fee, sigs, memo)
}
24 changes: 2 additions & 22 deletions simapp/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +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"
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"
OpWeightMsgTransferNFT = "op_weight_msg_transfer_nft"
OpWeightMsgEditNFTMetadata = "op_weight_msg_edit_nft_metadata"
OpWeightMsgMintNFT = "op_weight_msg_mint_nft"
OpWeightMsgBurnNFT = "op_weight_msg_burn_nft"
StakePerAccount = "stake_per_account"
InitiallyBondedValidators = "initially_bonded_validators"
)
Loading