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

Update x/banking and x/crisis InitChain re slow Gaia startup #7764

Merged
merged 13 commits into from
Nov 2, 2020

Conversation

robert-zaremba
Copy link
Collaborator

@robert-zaremba robert-zaremba commented Oct 30, 2020

Description

  • x/bank InitGenesis: remove k.ValidateBalance
  • chain initializtion: move profiling to the top of the startProcess function
  • add more logs and telemetry stats during the initialization process
  • make x/crisis AssertInvariants optional during InitGenesis

closes: #7682

Please don't look at the fmt.Println. I will remove it once I will get ACK that this changeset is OK.


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • 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.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

simapp/app.go Outdated Show resolved Hide resolved
simapp/simd/cmd/root.go Outdated Show resolved Hide resolved
x/bank/module.go Outdated Show resolved Hide resolved
x/crisis/keeper/keeper.go Outdated Show resolved Hide resolved
x/crisis/keeper/keeper.go Outdated Show resolved Hide resolved
x/crisis/keeper/keeper.go Outdated Show resolved Hide resolved
x/crisis/module.go Outdated Show resolved Hide resolved
Copy link
Contributor

@alessio alessio left a comment

Choose a reason for hiding this comment

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

So far so good, I've requested just a few changes (mostly stdout/stderr redirection).

@robert-zaremba
Copy link
Collaborator Author

robert-zaremba commented Oct 30, 2020

Forgot to write in the task description: Please don't look at the fmt.Println. I will remove it once I will get ACK that this changeset is OK.

@robert-zaremba robert-zaremba changed the title Robert/initgensis profiling master Update x/banking and x/crisis InitChain re slow Gaia startup Oct 30, 2020
@codecov
Copy link

codecov bot commented Oct 30, 2020

Codecov Report

Merging #7764 into master will increase coverage by 0.00%.
The diff coverage is 52.00%.

@@           Coverage Diff           @@
##           master    #7764   +/-   ##
=======================================
  Coverage   54.13%   54.14%           
=======================================
  Files         610      610           
  Lines       38842    38854   +12     
=======================================
+ Hits        21028    21037    +9     
- Misses      15667    15670    +3     
  Partials     2147     2147           

@clevinson clevinson mentioned this pull request Oct 31, 2020
9 tasks
x/crisis/module.go Outdated Show resolved Hide resolved
simapp/app.go Outdated Show resolved Hide resolved
@@ -192,6 +197,7 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty
cast.ToString(appOpts.Get(flags.FlagHome)),
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
simapp.MakeTestEncodingConfig(), // Ideally, we would reuse the one created by NewRootCmd.
appOpts,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we remove cast.ToString(appOpts.Get(flags.FlagHome)), cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), and use appOpts directly to read the values inside NewSimApp? Let's minimize the number of arguments when possible. May be not relavant for this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I was planning to group all this config options already long time ago.
Should I do it in this PR or in a new one? Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

A separate PR works too, can you create an issue to track this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I think we should do it in a separate post, because this will be another breaking feature. Also, not sure if that will land in release, @clevinson, @aaronc , what do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here is the old issue I created it. I'm happy that we like to see a reduction of this arguments. It's an easy change.
#7178

Copy link
Contributor

Choose a reason for hiding this comment

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

Well we should still keep the variadic options (which is what I was trying to advocate for in #7178 -- I'm against options structs for ALL arguments in this case). However, for the sake of this PR, we can at least avoid the following calls/args:

cast.ToString(appOpts.Get(flags.FlagHome)),
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),

Just pass appOpts and let the app do the above two calls. This is what I meant.

Comment on lines -23 to -26
if err := k.ValidateBalance(ctx, addr); err != nil {
panic(err)
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this safe to remove? May be we still need ValidateBalance after SetBalances below? @alexanderbez any thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

According to my investigation - yes, because we are calling k.ClearBalances(ctx, addr) in k.SetBalances.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please also have a look here: #7682 (comment)

simapp/app.go Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Comment on lines 198 to +201
func NewSimApp(
logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool,
homePath string, invCheckPeriod uint, encodingConfig simappparams.EncodingConfig, baseAppOptions ...func(*baseapp.BaseApp),
homePath string, invCheckPeriod uint, encodingConfig simappparams.EncodingConfig,
appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp),
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any explicit argument we can remove from this constructor that are found in appOptons?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure. I can handle it in a separate PR.

Copy link
Contributor

@alexanderbez alexanderbez Nov 2, 2020

Choose a reason for hiding this comment

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

Yes, we can omit homePath string, invCheckPeriod uint. Feel free to do it in this PR or another :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would prefer in another and have this one merged. This one is about InitChain options.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added TODOs to #7178

simapp/app.go Outdated Show resolved Hide resolved
@aaronc aaronc added the A:automerge Automatically merge PR once all prerequisites pass. label Nov 2, 2020
@mergify mergify bot merged commit c201963 into master Nov 2, 2020
@mergify mergify bot deleted the robert/initgensis-profiling-master branch November 2, 2020 19:10
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
…7764)

* add more logs during the initialization process

* initializtion: move profiling to the top of the startProcess function

* x/bank InitGenesis: remove k.ValidateBalance

* debug: add logs and telemetry to x/bank and x/crisis

* make x/crisis AssertInvariants optional during InitGenesis

* Add module init flags mechanism

* update changelog

* remove debug fmt.Print

* fix testutil/network/

* fix log message

* update test NewApp calls

* review changes

Co-authored-by: Aaron Craelius <aaron@regen.network>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:genesis relating to chain genesis
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gaia 3.0 takes a long time to start on migrated hub3 state
6 participants