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

docs(baseapp): add instructions to change DefaultGenesis #21680

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

ziscky
Copy link
Contributor

@ziscky ziscky commented Sep 12, 2024

Description

Closes: #11008

Add documentation on how to change the default genesis.


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 customizable CustomStakingModule for enhanced control over the Staking module's behavior.
    • Added functionality for modifying default genesis parameters, allowing developers to customize values like BondDenom.
  • Improvements

    • Simplified module architecture by removing the basic module manager, promoting a more streamlined integration process.

These changes enhance the modularity and configurability of the Cosmos SDK application framework, making it easier for developers to tailor module behaviors.

Copy link
Contributor

coderabbitai bot commented Sep 12, 2024

Walkthrough

Walkthrough

The pull request introduces significant changes to the handling of the DefaultGenesis method within the Cosmos SDK application framework. It allows for customization of the Staking module through a new CustomStakingModule, which can be implemented using a global variable, an existing manager, or dependency injection. Additionally, a new file outlines how to modify default genesis parameters, enhancing the modularity and configurability of application modules.

Changes

Files Change Summary
docs/build/building-apps/01-app-go-di.md Added documentation on customizing DefaultGenesis with CustomStakingModule and its options.
docs/build/building-apps/06-app-go-genesis.md Introduced functionality for modifying default genesis parameters, including a custom implementation for the Staking module.
module/... Modified to include CustomStakingModule in NewBasicManager and NewManagerFromMap.

Assessment against linked issues

Objective Addressed Explanation
Document how to change default genesis ( #11008 )

Possibly related PRs

Suggested labels

C:x/genutil, C:x/authz, backport/v0.52.x


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.

@ziscky ziscky changed the title feat(baseapp/docs): add instructions to change DefaultGenesis docs(baseapp): add instructions to change DefaultGenesis Sep 12, 2024
CHANGELOG.md Outdated Show resolved Hide resolved
@ziscky ziscky marked this pull request as ready for review September 12, 2024 16:27
@ziscky ziscky requested a review from a team as a code owner September 12, 2024 16:27
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 (1)
docs/build/building-apps/01-app-go-di.md (1)

176-176: Add a blank line before the fenced code block.

To adhere to the Markdown formatting best practices, add a blank line before the fenced code block. This improves the readability of the documentation.

Apply this change:

-```go
+
+```go
Tools
Markdownlint

176-176: null
Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bd52dcf and bf11346.

Files selected for processing (1)
  • docs/build/building-apps/01-app-go-di.md (1 hunks)
Additional context used
Path-based instructions (1)
docs/build/building-apps/01-app-go-di.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

Markdownlint
docs/build/building-apps/01-app-go-di.md

176-176: null
Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)

Additional comments not posted (5)
docs/build/building-apps/01-app-go-di.md (5)

121-222: Valuable addition to the documentation, but consider moving to a separate page and updating for v0.52.

The new content on modifying the DefaultGenesis parameters for modules provides helpful insights for developers looking to customize their Cosmos SDK applications. The code examples clearly demonstrate the different approaches available.

However, as mentioned in the previous review comment, this content may be better suited in a separate documentation page, rather than being included in the "Overview of app_di.go" section. This would help keep the documentation more focused and organized.

Additionally, it's important to ensure that the documentation and code examples are up-to-date with the latest version of the Cosmos SDK (v0.52). Some concepts or APIs mentioned here may have changed or been deprecated in newer versions.

Tools
Markdownlint

176-176: null
Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


129-157: Code example for option 1 looks good.

The code example demonstrating how to use a custom CustomStakingModule to override the DefaultGenesis method using the ModuleBasics variable is clear and easy to understand. It shows how to wrap the existing staking module and provide a custom implementation.


159-167: Code example for option 2 is clear and concise.

The code example for option 2 demonstrates how to create a basic module manager from the existing module manager and override the staking module's AppModuleBasic implementation. This approach is straightforward and allows for targeted customization of specific modules.


168-174: Code example for option 3 showcases the use of depinject.

The code example for option 3 illustrates how to use depinject.Supply to provide custom module basics. This approach leverages dependency injection to customize the behavior of specific modules. It's a clean and flexible way to extend or modify module functionality.


181-208: Code example for customizing DefaultGenesis using the new module manager is well-structured.

The code example demonstrates how to create a CustomStakingModule that embeds the staking.AppModule and overrides the DefaultGenesis method. It shows two options for integrating the custom module:

  1. Creating a new module manager with the custom staking module.
  2. Overriding the existing module manager's staking module with the custom one.

Both approaches are clearly explained and the code is properly structured.

docs/build/building-apps/01-app-go-di.md Outdated Show resolved Hide resolved
Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

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

Files that changed from the base of the PR and between bf11346 and 83b248a.

Files selected for processing (1)
  • docs/build/building-apps/06-app-go-genesis.md (1 hunks)
Additional context used
Path-based instructions (1)
docs/build/building-apps/06-app-go-genesis.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

Markdownlint
docs/build/building-apps/06-app-go-genesis.md

6-6: null
First line in a file should be a top-level heading

(MD041, first-line-heading, first-line-h1)

Additional comments not posted (1)
docs/build/building-apps/06-app-go-genesis.md (1)

13-53: LGTM!

The Go code example is well-structured and follows best practices. It provides a clear demonstration of how to modify the DefaultGenesis parameters for the staking module. The two options for overriding the module manager are also helpful for different use cases.

docs/build/building-apps/06-app-go-genesis.md Show resolved Hide resolved
docs/build/building-apps/06-app-go-genesis.md Show resolved Hide resolved
}


// depinject users
Copy link
Member

Choose a reason for hiding this comment

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

I think the flow is backwards:

  • first you inject a module manager (or have it already without depinject)
  • then you modify it (option 2 for depinject users, option 1 for non depinject users)
  • then you set it on the app (missing here)

&moduleManager,
)

// non-depinject users
Copy link
Member

Choose a reason for hiding this comment

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

this is unrelated, non depinject users always need to call this

})
}

// option 1: use new module manager
Copy link
Member

Choose a reason for hiding this comment

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

I'd say this is the option for non depinject users

// other modules ...
})

// option 2: override previous module manager
Copy link
Member

Choose a reason for hiding this comment

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

This one is best for depinject users

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

document how to change defaultGenesis
3 participants