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

refactor(x/genutil,server): add export functions to x/gentutil #18303

Merged
merged 5 commits into from
Oct 30, 2023

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Oct 30, 2023

Description

Add exports functions x/genutil. Genutil manages the genesis and exports to a genesis, so it consolidates x/genutil functionalities and simplifies server.


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
  • run make lint and make test
  • 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)

Summary by CodeRabbit

Bug Fixes:

  • Fixed a code change that could potentially affect the logic or functionality of the application.

Chores:

  • Updated dependencies to the latest versions.

Please note that the provided summary of changes does not include any specific bug fixes or chores. If there are any bug fixes or chores that were not mentioned in the summary, please provide the details so that they can be included in the release notes.

@julienrbrt julienrbrt requested a review from a team as a code owner October 30, 2023 12:01
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 30, 2023

Walkthrough

This update introduces significant changes to the CLI commands and the migration process in the Cosmos SDK. The changes include reorganization of CLI commands, introduction of in-place store migrations, and modifications to function calls and test functions. The update also includes changes to the way the database is opened and the addition of new functionalities to the genutil package.

Changes

File(s) Summary
CHANGELOG.md CLI commands have been reorganized and modified.
docs/architecture/adr-041-in-place-store-migrations.md Introduced in-place store migrations during chain upgrades.
server/cmt_cmds.go, server/rollback.go, server/start.go, server/util.go Function calls have been modified, particularly the openDB function has been replaced with OpenDB.
server/constructors_test.go, x/genutil/client/cli/export_test.go, x/genutil/client/cli/init_test.go Test functions have been renamed and updated.
simapp/simd/cmd/commands.go, x/genutil/client/cli/commands.go Changes in function parameters and calls.
tools/cosmovisor/process.go Modification in the comment of the WaitForUpgradeOrExit function.
x/genutil/README.md New functionality added to the genutil package.
x/genutil/client/cli/export.go Package name changed, function and variable names updated, and import paths modified.

Poem

🍂 As the leaves fall and the air grows colder, 🍁

Our code evolves, becoming bolder. 🚀

With CLI commands reorganized, 📝

And in-place migrations, a pleasant surprise! 🎁

The database opens in a new way, 🗃️

And genutil has more to say. 🗣️

So let's celebrate this update, so neat, 🎉

With a cup of hot cocoa, and a well-deserved treat! 🍫🍪


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.json

@github-actions github-actions bot added C:CLI C:x/genutil genutil module issues C:Cosmovisor Issues and PR related to Cosmovisor Type: ADR labels Oct 30, 2023
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 393de26 and 549221e.
Files selected for processing (14)
  • CHANGELOG.md (1 hunks)
  • docs/architecture/adr-041-in-place-store-migrations.md (2 hunks)
  • server/cmt_cmds.go (1 hunks)
  • server/constructors_test.go (1 hunks)
  • server/rollback.go (1 hunks)
  • server/start.go (6 hunks)
  • server/util.go (3 hunks)
  • simapp/simd/cmd/commands.go (2 hunks)
  • tools/cosmovisor/process.go (1 hunks)
  • x/genutil/README.md (2 hunks)
  • x/genutil/client/cli/commands.go (2 hunks)
  • x/genutil/client/cli/export.go (5 hunks)
  • x/genutil/client/cli/export_test.go (3 hunks)
  • x/genutil/client/cli/init_test.go (2 hunks)
Files skipped from review due to trivial changes (5)
  • server/constructors_test.go
  • tools/cosmovisor/process.go
  • x/genutil/client/cli/export.go
  • x/genutil/client/cli/export_test.go
  • x/genutil/client/cli/init_test.go
Additional comments: 22
CHANGELOG.md (1)
  • 187-193: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [190-194]

The changes in the CLI commands are well documented. Ensure that all users are informed about these breaking changes to avoid confusion and potential issues. Also, consider providing examples of the new command usage for better clarity.

server/rollback.go (1)
  • 27-33: The function OpenDB is used here instead of openDB. Ensure that the OpenDB function is correctly defined and exported, and that it has the same functionality as the previous openDB function. Also, verify that the change in function signature does not affect the rest of the codebase.
server/util.go (2)
  • 344-349: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [323-349]

The ExportCmd command is removed from the list of commands added to rootCmd. Ensure that this command is added elsewhere in the codebase to maintain functionality.

  • 454-458: The openDB function has been renamed to OpenDB. Ensure that all calls to this function throughout the codebase have been updated to match the new name.
docs/architecture/adr-041-in-place-store-migrations.md (2)
  • 14-20: The context provided here is clear and gives a good understanding of the current state of the system and the problems it presents.

  • 147-161: The consequences of the proposed changes are well outlined, including potential issues that could arise if module developers do not correctly track consensus-breaking changes. It's good to see that the Cosmos SDK will continue to support JSON migrations, providing flexibility for developers.

server/cmt_cmds.go (1)
  • 372-378: The openDB function has been replaced with OpenDB. Ensure that the OpenDB function has the same functionality as the openDB function or that any differences are accounted for in the code. Also, ensure that the OpenDB function is properly handling any errors that may occur when opening the database.
simapp/simd/cmd/commands.go (3)
  • 54-54: Ensure that all calls to server.AddCommands throughout the codebase have been updated to match the new signature.

  • 59-59: Ensure that all calls to genesisCommand throughout the codebase have been updated to match the new signature.

  • 71-71: Ensure that all calls to genesisCommand throughout the codebase have been updated to match the new signature.

x/genutil/README.md (3)
  • 12-15: The addition of the new functionality "Application state export into a genesis file" is well documented. Ensure that the implementation aligns with the documentation.

  • 88-90: This warning is important and should be clearly visible to the users. It helps to prevent potential issues when validating a genesis from a previous version of the application.

  • 92-105: The documentation for the new export command is clear and concise. It explains the purpose of the command and how to use it, including the available flags. Ensure that the actual implementation of the command aligns with this documentation.

x/genutil/client/cli/commands.go (3)
  • 16-18: The function signature of Commands has been updated to include a new parameter appExport of type servertypes.AppExporter. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

  • 22-24: The function signature of CommandsWithCustomMigrationMap has been updated to include a new parameter appExport of type servertypes.AppExporter. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

  • 38-38: The ExportCmd function is now being called with the appExport parameter. Ensure that the ExportCmd function has been updated to handle this new parameter correctly.

server/start.go (6)
  • 30-32: The new import "cosmossdk.io/log" has been added. Ensure that this package is available and correctly installed in your environment.

  • 117-119: The function opts.DBOpener has been changed from openDB to OpenDB. Make sure that the OpenDB function is defined and accessible in the current scope.

  • 438-444: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [441-446]

The comment added to the getGenDocProvider function provides a clear explanation of its purpose. This is a good practice for code readability and maintainability.

  • 453-457: The function setupTraceWriter has been renamed to SetupTraceWriter and now takes a logger log.Logger parameter in addition to the svrCtx and traceWriterFile parameters. The function also returns a cleanup function. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

  • 467-469: The error handling here is appropriate. If the trace writer fails to close, an error message is logged. This is a good practice for error handling.

  • 627-633: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [630-634]

The function startApp now calls SetupTraceWriter with the svrCtx.Logger and svrCtx.Viper.GetString(flagTraceStore) parameters. Ensure that the SetupTraceWriter function is defined and accessible in the current scope.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 549221e and 9b6bce9.
Files selected for processing (1)
  • CHANGELOG.md (2 hunks)
Additional comments: 2
CHANGELOG.md (2)
  • 79-85: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [82-86]

The changes in the API are well documented. However, it would be helpful to provide more context or examples for the changes, especially for those who are not familiar with the codebase. For instance, what does it mean that "Gov Hooks now returns error and are 'blocking' if they fail"? What are the implications of this change? Also, what is the impact of removing MsgDeposit, MsgRedelegateExec, and MsgUnbondExec due to AutoCLI migration?

  • 191-194: The CLI breaking changes are also well documented. However, similar to the API changes, it would be beneficial to provide more context or examples for these changes. For instance, what is the impact of moving appd export with other genesis commands? How does the change in the order of arguments for appd tx vesting create-vesting-account affect its usage? What are the implications of the change in behavior for appd tx distribution withdraw-rewards?

CHANGELOG.md Outdated 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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 9b6bce9 and d464a88.
Files selected for processing (2)
  • CHANGELOG.md (2 hunks)
  • tests/e2e/genutil/export_test.go (4 hunks)
Additional comments: 6
CHANGELOG.md (2)
  • 79-85: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [82-86]

The changes in the API are significant and could potentially break existing integrations. Ensure that all dependencies and integrations are updated to reflect these changes. Also, the change in the behavior of Gov Hooks could affect the application flow, so it's important to verify that the application behaves as expected after these changes.

  • 188-194: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [191-195]

The changes in the CLI commands could potentially break existing scripts or automated tasks that use these commands. Make sure to update all scripts and tasks to use the new command syntax. Also, the change in the behavior of the appd tx distribution withdraw-rewards command could affect the expected results, so it's important to verify that the command behaves as expected after these changes.

tests/e2e/genutil/export_test.go (4)
  • 1-7: The package name has been changed from server_test to genutil_test. This change is fine as long as it doesn't conflict with any other packages in the project.

  • 27-32: The import statement genutilcli has been added. This is fine as long as the package is used in the code.

  • 77-90: The test cases have been updated to use the new flag names --height and --for-zero-height instead of server.FlagHeight and server.FlagForZeroHeight respectively. This is a good change as it makes the test cases more readable and less dependent on the server package.

  • 200-203: The function ExportCmd has been modified to use genutilcli.ExportCmd instead of server.ExportCmd. This is a good change as it consolidates the export functionality into the genutilcli package.

Copy link
Member

@facundomedica facundomedica left a comment

Choose a reason for hiding this comment

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

utACK

@github-actions github-actions bot removed the C:Cosmovisor Issues and PR related to Cosmovisor label Oct 30, 2023
@julienrbrt julienrbrt added this pull request to the merge queue Oct 30, 2023
Merged via the queue into main with commit d82503e Oct 30, 2023
57 of 59 checks passed
@julienrbrt julienrbrt deleted the julien/export branch October 30, 2023 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants