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

fix: app config and simapp (v1,v2) fixes #14209

Merged
merged 16 commits into from
Dec 8, 2022
Merged

fix: app config and simapp (v1,v2) fixes #14209

merged 16 commits into from
Dec 8, 2022

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Dec 7, 2022

Description

  • Remove NewDefaultGenesisState because it not take in account modules registered manually with runtime.RegisterModules
  • Register the upgrade handler after the configurator is instantiated
  • LoadStreamingServices was using an empty list of keys

Follow-up

  • Improve app config configuration of x/upgrade.
  • Set the genesis init and export order directly in app config (needs 1.)

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@julienrbrt julienrbrt requested a review from a team as a code owner December 7, 2022 21:38
@julienrbrt julienrbrt added the backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release label Dec 7, 2022
@julienrbrt julienrbrt changed the title refactor: set genesis module order in app config fix: set genesis module order in app config Dec 7, 2022
@@ -86,7 +85,6 @@ func (a *App) Load(loadLatest bool) error {

if len(a.config.InitGenesis) != 0 {
a.ModuleManager.SetOrderInitGenesis(a.config.InitGenesis...)
a.SetInitChainer(a.InitChainer)
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this needed?

Copy link
Member

@aaronc aaronc Dec 7, 2022

Choose a reason for hiding this comment

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

I guess we need to set the module version map set for x/upgrade. But this should really be done somehow automatically with app config

Copy link
Member Author

Choose a reason for hiding this comment

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

app_v2.go already sets it, so this was overwritting it and not calling app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()).
Didn't run the integration tests locally, if you use runtime standalone it is indeed needed.

Copy link
Member

Choose a reason for hiding this comment

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

What I'm saying is that app_v2.go shouldn't need to manually call it. Is there a clean way to make that happen? Doesn't need to be in this PR btw

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, let me check 👍🏾

Copy link
Member Author

Choose a reason for hiding this comment

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

Because we need the store to be available, I have not found a clean way.

@julienrbrt julienrbrt marked this pull request as draft December 7, 2022 22:02
@@ -144,7 +144,8 @@ func AppStateRandomizedFn(
accs []simtypes.Account, genesisTimestamp time.Time, appParams simtypes.AppParams,
) (json.RawMessage, []simtypes.Account) {
numAccs := int64(len(accs))
genesisState := NewDefaultGenesisState(cdc)
// TODO - in case runtime.RegisterModules(...) is used, the genesis state of the module won't be reflected here
genesisState := ModuleBasics.DefaultGenesis(cdc)
Copy link
Member Author

Choose a reason for hiding this comment

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

not sure how to avoid this.

@github-actions github-actions bot added the C:CLI label Dec 8, 2022
@julienrbrt julienrbrt marked this pull request as ready for review December 8, 2022 00:32
@julienrbrt julienrbrt changed the title fix: set genesis module order in app config fix: app config and simapp (v1,v2) fixes Dec 8, 2022
simapp/go.mod Outdated Show resolved Hide resolved
@julienrbrt julienrbrt mentioned this pull request Dec 8, 2022
19 tasks
@julienrbrt
Copy link
Member Author

I will refactor upgrade app config in a follow during my audit. Reverting it from this PR.

@@ -591,6 +608,11 @@ func (app *SimApp) TxConfig() client.TxConfig {
return app.txConfig
}

// DefaultGenesis returns a default genesis from the registered AppModuleBasic's.
func (a *SimApp) DefaultGenesis() map[string]json.RawMessage {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this?

Copy link
Member Author

@julienrbrt julienrbrt Dec 8, 2022

Choose a reason for hiding this comment

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

Because we replace NewDefaultGenesisState by this. In the case of appv2 it could lead to something different than ModuleBasics.

@github-actions github-actions bot added C:orm C:Rosetta Issues and PR related to Rosetta labels Dec 8, 2022
@sonarcloud
Copy link

sonarcloud bot commented Dec 8, 2022

[Cosmos SDK - Client V2] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented Dec 8, 2022

[Cosmos SDK - Tx] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented Dec 8, 2022

[Cosmos SDK Core] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented Dec 8, 2022

[Cosmos SDK - SimApp] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented Dec 8, 2022

[Cosmos SDK - Rosetta] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented Dec 8, 2022

[Cosmos SDK] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
No Duplication information No Duplication information

@julienrbrt julienrbrt merged commit 4e2196f into main Dec 8, 2022
@julienrbrt julienrbrt deleted the julien/appv2 branch December 8, 2022 22:08
mergify bot pushed a commit that referenced this pull request Dec 8, 2022
(cherry picked from commit 4e2196f)

# Conflicts:
#	tools/rosetta/go.mod
#	tools/rosetta/go.sum
tac0turtle pushed a commit that referenced this pull request Dec 9, 2022
Co-authored-by: Julien Robert <julien@rbrt.fr>
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release C:CLI C:orm C:Rosetta Issues and PR related to Rosetta
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants