-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
simulation: Make governance simulation use future operations to schedule votes #2226
Conversation
votes. In a future PR, functionality to test that slashing occured properly should be added.
// SimulateMsgSubmitProposal simulates a msg Submit Proposal | ||
// Note: Currently doesn't ensure that the proposal txt is in JSON form | ||
func SimulateMsgSubmitProposal(k gov.Keeper, sk stake.Keeper) simulation.Operation { | ||
handler := gov.NewHandler(k) | ||
return func(tb testing.TB, r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, keys []crypto.PrivKey, log string, event func(string)) (action string, fOps []simulation.FutureOperation, err sdk.Error) { | ||
msg := simulationCreateMsgSubmitProposal(tb, r, keys, log) | ||
ctx, write := ctx.CacheContext() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this code has been moved to simulateHandleMsgSubmitProposal
, which just is a verbatim copy of this.
} | ||
|
||
func simulationCreateMsgSubmitProposal(tb testing.TB, r *rand.Rand, sender crypto.PrivKey, log string) gov.MsgSubmitProposal { | ||
addr := sdk.AccAddress(sender.PubKey().Address()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a future PR, we should make a simulation key object which has the privkey, pubkey, and address. The simulator spends ~3% of its time computing pubkeys. Improving this will allow us to simulate greater block sizes. (After we reduce how often governance proposals are. The amount of slashes they induce is what causes the simulator to slow down at blocks > 200)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea
Codecov Report
@@ Coverage Diff @@
## develop #2226 +/- ##
=======================================
Coverage 64.2% 64.2%
=======================================
Files 140 140
Lines 8579 8579
=======================================
Hits 5508 5508
Misses 2694 2694
Partials 377 377 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK, thanks @ValarDragon
In a future PR, functionality to test that slashing occured properly should be added.
#2225 still occurs at block heights greater 210. I think thats independent of this though, and that this functionality is good to merge.
Targeted PR against correct branch (see CONTRIBUTING.md)
Linked to github-issue with discussion and accepted design OR link to spec that describes this work. ref simulation: Allow operations to specify future operations #2166 , Randomized Simulation wishlist #1924
Wrote tests
Added entries in
PENDING.md
with issue # - This change is pretty internal, I don't think we need to add it to the changelogrereviewed
Files changed
in the github PR explorerFor Admin Use: