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

simulation: Make governance simulation use future operations to schedule votes #2226

Merged
merged 1 commit into from
Sep 7, 2018

Conversation

ValarDragon
Copy link
Contributor

@ValarDragon ValarDragon commented Sep 4, 2018

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.


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

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()
Copy link
Contributor Author

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())
Copy link
Contributor Author

@ValarDragon ValarDragon Sep 4, 2018

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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea

@codecov
Copy link

codecov bot commented Sep 4, 2018

Codecov Report

Merging #2226 into develop will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           develop   #2226   +/-   ##
=======================================
  Coverage     64.2%   64.2%           
=======================================
  Files          140     140           
  Lines         8579    8579           
=======================================
  Hits          5508    5508           
  Misses        2694    2694           
  Partials       377     377

Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK, thanks @ValarDragon

@cwgoes cwgoes merged commit 44b695c into develop Sep 7, 2018
@cwgoes cwgoes deleted the dev/govsim_use_fops branch September 7, 2018 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants