-
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: Params from File #4435
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4435 +/- ##
=======================================
Coverage 54.58% 54.58%
=======================================
Files 248 248
Lines 15967 15967
=======================================
Hits 8716 8716
Misses 6617 6617
Partials 634 634 |
Should we also consider adding new parameters to control some hardcoded values like e.g.: Line 312 in d099d84
What do you think? |
Good idea @npinto! Yes, I'll include this too. |
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.
Few comments - changes are good, docs is great, as such deserves better go doc compliant formatting
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.
minor comments only
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.
ACK
@alessio I fixed the godoc. It's pretty now. Ty |
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.
pending tiny corrections - else this looks good
Co-Authored-By: Alessio Treglia <quadrispro@ubuntu.com>
Co-Authored-By: Alessio Treglia <quadrispro@ubuntu.com>
What do you think about allowing pausing/resuming of these simulations (w.r.t. eg blocks) ? That is: (1) having a way to dump the full state of the simulator at the end of a given number of blocks, and (2) taking this state and resuming the simulation for another given number of blocks. This could allow "in-flight" fine tuning of parameters and also much better optimizations of simulations (e.g. "early stopping" of non promising simulations). |
@npinto good idea but out of scope of this PR! Let's open up another issue for that. I'd like to keep the PRs as minimal and focused as possible 👍 |
@alexanderbez sounds good, I'll open another feature request for this. Thanks! |
Should we consider printing out a
It might then be easier to parse them out if they need to be analyzed/optimized. |
That would be nice but maybe not for the scope of this PR. I'd merge this and then improve it afterwards with the comments you suggested @npinto |
Yeah sure @npinto, mind opening up another issue for this? |
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.
Looks good, great documentation section.
Few comments throughout, biggest comment is the code structure of using immediately executed function variables while generating module genesis information (aka genXXXXGenesisState
)
var v uint64 | ||
ap.GetOrGenerate(cdc, "max_memo_characters", &v, r, func(r *rand.Rand) { v = simulation.ModuleParamSimulator["max_memo_characters"](r).(uint64) }) | ||
return v | ||
}(r), |
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.
This code structure is quite obfuscated, I understand the thinking to compress all the code required to getOrGen a param into an immediately executed function as is done here. But I think a more intuitive/digestable structure would be to just individually get all the parameters at the top of this function (before defining authGenesis
). Something like:
func genAuthGenesisState(cdc *codec.Codec, r *rand.Rand, ap simulation.AppParams, genesisState map[string]json.RawMessage) {
var maxMemoChars uint64
ap.GetOrGenerate(cdc, "max_memo_characters", &maxMemoChars, r, func(r *rand.Rand) { v = simulation.ModuleParamSimulator["max_memo_characters"](r).(uint64) })
....
authGenesis := auth.NewGenesisState(
nil,
auth.NewParams(
maxMemoChars,
...
This also applies too all modules aka genXXXXGenesisState
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.
Yeah so I understand your concern upon first reading the code. I think the additional verbosity that results from such a suggested change isn't worth it because now that we have constants that are directly mapped to the meaning of the arguments, it's very clear what it's doing and what value it provides.
I'd rather not have to go through each of these for what will probably be a tiny (if any) gain in brevity.
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.
So the code would actually become less verbose under the suggested change, however we would have to come up with variable names - that's pretty much the only downside. I don't mind quickly making these changes if it's just a matter of the work
var v int | ||
ap.GetOrGenerate(cdc, "op_weight_deduct_fee", &v, nil, func(_ *rand.Rand) { v = 5 }) | ||
return v | ||
}(nil), |
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.
ditto on the defining contents of WeightedOperation
before this return statement (not in immediately executed function variables) as per my previous comment on this structure for all the modules (genXXXXGenesisState
)
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.
See response :)
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.
After implementing my suggestion, I've changed my position, I think it makes things even more obfuscated unfortunately. I've opted to keep it, but I expanded up the 2nd layer function variables what were really hidden in there (and also made the lines very long)
* Move distr params to simulation param generator * Cleanup sim params output * Print params when possible instead of entire genesis struct * Update module param simulator keys * Rename module params simulator keys * Add/fix missing module params and implement SimParams * UPdate sim test to accept params file * Allow weights to be provided from file * Create doc.go * Remove TODO * Implement MustMarshalJSONIndent * Use mustMarshalJSONIndent for non-codec * Remove TODO * Fix doc.go * Update points * Update simapp/doc.go Co-Authored-By: Alessio Treglia <quadrispro@ubuntu.com> * Update simapp/doc.go Co-Authored-By: Alessio Treglia <quadrispro@ubuntu.com> * Cleanup appStateFn * Use constants for simulation parameter keys * Update msgs.go * minor formatting
doc.go
)closes: #4428
/cc @npinto
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.
Wrote tests
Updated relevant documentation (
docs/
)Added a relevant changelog entry:
clog add [section] [stanza] [message]
rereviewed
Files changed
in the github PR explorerFor Admin Use: