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: remove additional log line when exporting genesis #3038

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

Conversation

kingpinXD
Copy link
Contributor

@kingpinXD kingpinXD commented Oct 24, 2024

Description

  • This pr removes a a log line that prints the list of blocked addresses when initializing the app.
  • It does minor refactoring for the code organization in appExport function

How Has This Been Tested?

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Summary by CodeRabbit

  • New Features

    • Enhanced clarity and maintainability in the initialization of application components within the ZetaChain framework.
    • Improved state export functionality for the genesis file.
  • Bug Fixes

    • Streamlined error handling for loading application state.
  • Refactor

    • Reorganized keeper initialization and module management for better structure and clarity.
    • Updated variable names and comments for improved understanding.

Copy link
Contributor

coderabbitai bot commented Oct 24, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in this pull request primarily focus on refactoring and improving the initialization processes within the ZetaChain application. Modifications include the removal of specific logging related to blocked addresses, a more structured approach to keeper initialization, and enhancements to the module management system. Additionally, the appExport method in cmd/zetacored/root.go has been updated for clarity and efficiency, with improved variable naming and streamlined logic for loading application state. These adjustments aim to enhance the maintainability and clarity of the application code.

Changes

File Path Change Summary
app/app.go - Updated method signature for New, removing logging for blocked addresses.
- Adjusted module account permissions and blocked receiving module accounts.
- Streamlined initialization of various keepers, including AuthorityKeeper, FungibleKeeper, etc.
cmd/zetacored/root.go - Updated appExport method comment for clarity.
- Renamed variable anApp to zetaApp and simplified application instance creation logic.
- Enhanced error handling for loading application state.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App as ZetaChainApp
    participant Keeper as VariousKeepers
    participant ModuleManager as ModuleManager

    User->>App: Initialize Application
    App->>Keeper: Initialize Keepers
    Keeper->>ModuleManager: Register Modules
    ModuleManager-->>App: Modules Ready
    App-->>User: Application Initialized
Loading

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.

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 (2)
cmd/zetacored/root.go (2)

289-300: Consider documenting magic numbers and default values.

While the initialization is correct, consider:

  1. Adding a comment explaining why an empty map is used for skip upgrade heights
  2. Either documenting or extracting the hard-coded check period value (1) into a named constant

301-306: Consider enhancing error message.

While the error handling is correct, consider making the error message more descriptive by including the height value:

-			return servertypes.ExportedApp{}, err
+			return servertypes.ExportedApp{}, fmt.Errorf("failed to load state at height %d: %w", height, err)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b334267 and c6567d8.

📒 Files selected for processing (2)
  • app/app.go (0 hunks)
  • cmd/zetacored/root.go (1 hunks)
💤 Files with no reviewable changes (1)
  • app/app.go
🧰 Additional context used
📓 Path-based instructions (1)
cmd/zetacored/root.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

🔇 Additional comments (4)
cmd/zetacored/root.go (4)

271-271: LGTM! Clear and accurate method documentation.

The updated comment better reflects the method's purpose of exporting application state for genesis file creation.


277-283: LGTM! Improved variable naming and robust path validation.

The variable renaming enhances code readability, and the home path validation properly handles both type assertion and empty string cases.


284-288: LGTM! Clean and focused loading logic.

The introduction of the loadLatest flag simplifies the logic and improves code readability.


308-308: LGTM! Proper state export.

The export call correctly uses the initialized app instance to export the application state and validators.

cmd/zetacored/root.go Outdated Show resolved Hide resolved

homePath, ok := appOpts.Get(flags.FlagHome).(string)
if !ok || homePath == "" {
return servertypes.ExportedApp{}, errors.New("application home not set")
}

loadLatest := false
Copy link
Member

Choose a reason for hiding this comment

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

Why this change in this file? looks unrelated to the purpose of the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does not change the logic , just restructures the code to make it more readable .
I just came across this when investigating , the change seems too small to be part of a separate pr . lmk if you think otherwise

Copy link
Member

Choose a reason for hiding this comment

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

Ok, but left some suggestions

@kingpinXD kingpinXD requested a review from lumtis October 25, 2024 14:26
app/app.go Show resolved Hide resolved
cmd/zetacored/root.go Outdated Show resolved Hide resolved

homePath, ok := appOpts.Get(flags.FlagHome).(string)
if !ok || homePath == "" {
return servertypes.ExportedApp{}, errors.New("application home not set")
}

loadLatest := false
Copy link
Member

Choose a reason for hiding this comment

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

Ok, but left some suggestions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking:cli no-changelog Skip changelog CI check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants