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

test(systemtests): fix export v2 #22799

Merged
merged 6 commits into from
Dec 9, 2024
Merged

test(systemtests): fix export v2 #22799

merged 6 commits into from
Dec 9, 2024

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Dec 9, 2024

Description

ref: #22753


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, you can find examples of the prefixes below:
  • confirmed ! in 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
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • 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.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features

    • Introduced a new command-line flag for-zero-height to allow exports starting from height zero.
    • Added a method to register a custom query router service in the test fixture.
  • Bug Fixes

    • Added validation to ensure the AppDBBackend field in the configuration is not empty, enhancing error handling.
  • Chores

    • Updated the version of the cosmossdk.io/systemtests dependency in the module.
  • Refactor

    • Modified the ExportAppStateAndValidators method to include an additional parameter for zero height.
    • Updated method signatures across various components to accommodate new parameters.

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Dec 9, 2024
Copy link
Contributor

coderabbitai bot commented Dec 9, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request involve modifications to the configuration handling within the Cosmos SDK. The UnmarshalConfig function in server/v2/store/server.go has been updated to streamline the configuration initialization process. A new validation check has been added to the Build method in store/v2/root/builder.go to ensure that the AppDBBackend field is not empty. Additionally, a new command-line flag, for-zero-height, has been introduced in x/genutil/v2/cli/export.go to enhance the export functionality. The go.mod file for system tests has also been updated to reflect a new dependency version.

Changes

File Change Summary
server/v2/store/server.go Modified UnmarshalConfig to initialize config using root.DefaultConfig() instead of root.DefaultStoreOptions(). Error handling remains unchanged.
store/v2/root/builder.go Added validation in Build method to check that AppDBBackend is not empty, returning an error if it is.
tests/systemtests/go.mod Updated cosmossdk.io/systemtests dependency version from v1.0.0-rc.2 to v1.0.0-rc.3.
x/genutil/v2/cli/export.go Introduced new command-line flag for-zero-height to export state from height zero, modifying the method signature accordingly.
store/db/prefixdb_test.go Reordered import statements without changing functionality of test cases.
tests/integration/v2/distribution/fixture_test.go Added registerQueryRouterService method to fixture struct and initialized queryClient in createTestFixture.
simapp/v2/app_test.go Updated ExportAppStateAndValidators method calls to include a false boolean instead of nil.
simapp/v2/export.go Modified ExportAppStateAndValidators method to include an additional forZeroHeight parameter.
x/genutil/v2/cli/commands.go Updated ExportAppStateAndValidators method signature in ExportableApp interface to accept a boolean parameter.

Possibly related issues

  • Make System Test V2 pass #22753: The changes in the PR may help in making system tests pass by ensuring proper configuration handling, which is crucial for test stability.

Possibly related PRs

Suggested reviewers

  • kocubinski
  • testinginprod
  • akhilkumarpilli
  • sontrinh16

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@julienrbrt julienrbrt mentioned this pull request Dec 9, 2024
9 tasks
@github-actions github-actions bot added C:Store C:x/genutil genutil module issues C:server/v2 Issues related to server/v2 labels Dec 9, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6cf9d57 and ee4f817.

⛔ Files ignored due to path filters (1)
  • tests/systemtests/go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • server/v2/store/server.go (1 hunks)
  • store/v2/root/builder.go (1 hunks)
  • tests/systemtests/go.mod (1 hunks)
  • x/genutil/v2/cli/export.go (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tests/systemtests/go.mod
🧰 Additional context used
📓 Path-based instructions (3)
store/v2/root/builder.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

server/v2/store/server.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/genutil/v2/cli/export.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

🪛 golangci-lint (1.62.2)
x/genutil/v2/cli/export.go

114-114: Error return value of (*github.com/spf13/pflag.FlagSet).MarkDeprecated is not checked

(errcheck)

🪛 GitHub Check: golangci-lint
x/genutil/v2/cli/export.go

[failure] 114-114:
Error return value of (*github.com/spf13/pflag.FlagSet).MarkDeprecated is not checked (errcheck)

🔇 Additional comments (3)
server/v2/store/server.go (1)

81-81: LGTM: Simplified configuration initialization

The change to use root.DefaultConfig() directly improves code clarity while maintaining the same functionality.

store/v2/root/builder.go (1)

58-62: LGTM: Added essential validation for AppDBBackend

Good addition of validation to ensure the application database backend is configured before proceeding with store creation.

x/genutil/v2/cli/export.go (1)

20-20: LGTM: Clean implementation of zero-height export flag

The implementation provides a clear way to handle zero-height exports while maintaining backward compatibility.

Also applies to: 60-63

x/genutil/v2/cli/export.go Outdated Show resolved Hide resolved
Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

utACK

x/genutil/v2/cli/export.go Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
x/genutil/v2/cli/export.go (1)

60-63: Add a comment explaining the flag's purpose

While the flag is marked as deprecated in favor of --height=0, it would be helpful to add a comment explaining why this alternative flag exists (e.g., if it's for backward compatibility with existing scripts).

+// forZeroHeight provides an alternative way to export state from height 0
+// This flag is deprecated in favor of --height=0 but maintained for backward compatibility
 forZeroHeight, _ := cmd.Flags().GetBool(flagForZeroHeight)
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ee4f817 and dd66daa.

📒 Files selected for processing (3)
  • store/db/prefixdb_test.go (1 hunks)
  • tests/integration/v2/distribution/fixture_test.go (0 hunks)
  • x/genutil/v2/cli/export.go (3 hunks)
💤 Files with no reviewable changes (1)
  • tests/integration/v2/distribution/fixture_test.go
✅ Files skipped from review due to trivial changes (1)
  • store/db/prefixdb_test.go
🧰 Additional context used
📓 Path-based instructions (1)
x/genutil/v2/cli/export.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

🔇 Additional comments (2)
x/genutil/v2/cli/export.go (2)

20-20: LGTM!

The constant declaration follows Go naming conventions and is appropriately grouped with related flag constants.


113-114: ⚠️ Potential issue

Add error handling for MarkDeprecated

The error returned by MarkDeprecated should be checked to ensure the deprecation notice is properly set.

Apply this fix:

-_ = cmd.Flags().MarkDeprecated(flagForZeroHeight, "use --height=0 instead")
+if err := cmd.Flags().MarkDeprecated(flagForZeroHeight, "use --height=0 instead"); err != nil {
+    panic(fmt.Sprintf("failed to mark flag as deprecated: %v", err))
+}

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
x/genutil/v2/cli/export.go (2)

60-68: Add error handling for flag values

The flag values are retrieved without error checking. While these operations typically don't fail, it's good practice to handle potential errors.

-       forZeroHeight, _ := cmd.Flags().GetBool(flagForZeroHeight)
-       jailAllowedAddrs, _ := cmd.Flags().GetStringSlice(flagJailAllowedAddrs)
+       forZeroHeight, err := cmd.Flags().GetBool(flagForZeroHeight)
+       if err != nil {
+           return fmt.Errorf("failed to get for-zero-height flag: %w", err)
+       }
+       jailAllowedAddrs, err := cmd.Flags().GetStringSlice(flagJailAllowedAddrs)
+       if err != nil {
+           return fmt.Errorf("failed to get jail-allowed-addrs flag: %w", err)
+       }

110-110: Fix typo in flag description

There's a typo in the flag description: "preproccessing" should be "preprocessing".

-       cmd.Flags().Bool(flagForZeroHeight, false, "Export state to start at height zero (perform preproccessing)")
+       cmd.Flags().Bool(flagForZeroHeight, false, "Export state to start at height zero (perform preprocessing)")
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between dd66daa and 18c9168.

📒 Files selected for processing (4)
  • simapp/v2/app_test.go (1 hunks)
  • simapp/v2/export.go (2 hunks)
  • x/genutil/v2/cli/commands.go (1 hunks)
  • x/genutil/v2/cli/export.go (3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
simapp/v2/app_test.go (2)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

simapp/v2/export.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/genutil/v2/cli/commands.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/genutil/v2/cli/export.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

🔇 Additional comments (5)
simapp/v2/export.go (2)

16-16: LGTM! Method signature update is well documented

The addition of the forZeroHeight parameter is well documented and the method signature change is clear and consistent.

Also applies to: 17-20


49-52: LGTM! Height reset logic is correct

The conditional height reset for zero-height exports is implemented correctly.

x/genutil/v2/cli/commands.go (1)

23-23: LGTM! Interface update is consistent

The ExportableApp interface has been correctly updated to match the implementation changes.

x/genutil/v2/cli/export.go (2)

20-21: LGTM! Constants are well defined

The new flag constants are clearly defined and follow the existing naming convention.


110-110: ⚠️ Potential issue

Add error handling for MarkDeprecated

The error returned by MarkDeprecated should be checked to ensure the deprecation notice is properly set.

-       cmd.Flags().Bool(flagForZeroHeight, false, "Export state to start at height zero (perform preprocessing)")
+       cmd.Flags().Bool(flagForZeroHeight, false, "Export state to start at height zero (perform preprocessing)")
+       if err := cmd.Flags().MarkDeprecated(flagForZeroHeight, "use --height=0 instead"); err != nil {
+           panic(fmt.Sprintf("failed to mark flag as deprecated: %v", err))
+       }

simapp/v2/app_test.go Show resolved Hide resolved
Copy link
Contributor

@hieuvubk hieuvubk left a comment

Choose a reason for hiding this comment

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

lgtm

@julienrbrt julienrbrt enabled auto-merge December 9, 2024 12:22
@julienrbrt julienrbrt added this pull request to the merge queue Dec 9, 2024
Merged via the queue into main with commit 34f407d Dec 9, 2024
73 of 75 checks passed
@julienrbrt julienrbrt deleted the julien/export branch December 9, 2024 15:21
mergify bot pushed a commit that referenced this pull request Dec 9, 2024
(cherry picked from commit 34f407d)

# Conflicts:
#	server/v2/store/server.go
#	store/db/prefixdb_test.go
#	store/v2/root/builder.go
#	tests/integration/v2/distribution/fixture_test.go
#	tests/systemtests/go.sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release C:server/v2 Issues related to server/v2 C:Store C:x/genutil genutil module issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants