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: initialize tokenfactory before bank module #100

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

fmorency
Copy link
Collaborator

@fmorency fmorency commented Oct 23, 2024

The TokenFactory module should be initialized before the bank module otherwise it will overwrite the denom metadata.

See https://github.com/strangelove-ventures/tokenfactory/blob/9f137b7ba03210d74d685a965da2613316bc3e93/x/tokenfactory/keeper/createdenom.go#L28-L39

Summary by CodeRabbit

  • New Features

    • Improved initialization sequence for the token factory module, enhancing its integration with other functionalities.
    • Updated block processing lifecycle to include the token factory module.
  • Bug Fixes

    • Ensured proper order of module initialization and exportation, potentially resolving issues related to module interactions.

@fmorency fmorency added the bug Something isn't working label Oct 23, 2024
@fmorency fmorency self-assigned this Oct 23, 2024
Copy link

coderabbitai bot commented Oct 23, 2024

Walkthrough

The pull request introduces updates to the app/app.go file, focusing on the initialization and configuration of the ManifestApp structure. It includes the integration of the tokenfactorytypes.ModuleName into various module order settings, ensuring its processing occurs before the bank module during genesis. Additionally, modifications to the ModuleManager methods enhance the token factory module's role in the block processing lifecycle. The changes solidify the token factory's interaction with other modules while maintaining the overall structure of the ManifestApp.

Changes

File Change Summary
app/app.go - Added tokenfactorytypes.ModuleName to SetOrderInitGenesis, SetOrderBeginBlockers, SetOrderEndBlockers, and SetOrderExportGenesis methods.
- Updated module initialization order to process the token factory module before the bank module.
- Registered ManifestApp with various keepers and established IBC router with token factory integration.

Possibly related PRs

  • chore: bump tokenfactory to 0.54.0 #97: The changes in this PR involve updating the TokenFactory library, which is directly related to the modifications made in the main PR regarding the integration of the token factory module into the ManifestApp structure and its initialization order.

Poem

In the garden where tokens play,
The factory blooms in a bright array.
With modules dancing, side by side,
The bank and tokens take a ride.
Hopping through genesis, oh what a sight,
Together they flourish, in morning light! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2ab4fcb and 54f4397.

📒 Files selected for processing (1)
  • app/app.go (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
app/app.go (1)

787-787: LGTM! Verify TokenFactory dependencies.

The placement of tokenfactorytypes.ModuleName before banktypes.ModuleName in the genesis initialization order correctly addresses the issue of preventing bank module from overwriting denomination metadata.

Let's verify that TokenFactory doesn't have critical dependencies on the auth module:

✅ Verification successful

Let me analyze the results and gather more specific information about TokenFactory's dependencies.

The previous results show that TokenFactory has permissions for minting and burning tokens (authtypes.Minter, authtypes.Burner), but we need to verify if there are any initialization-time dependencies that would require auth to be initialized first. Let's check the keeper initialization and imports to make a conclusive decision.


Let me try a different approach to find TokenFactory related files and their dependencies.

We need to locate the TokenFactory module files first and then analyze its dependencies and initialization requirements to make a conclusive decision about the safety of its placement before auth module.


Let me try one final search to locate the TokenFactory module and its dependencies.

We need to find where TokenFactory is defined and how it's integrated into the application to make a conclusive decision about its placement in the initialization order.


Based on the comprehensive search results, I can now make a conclusive decision about the TokenFactory module's placement in the initialization order.

TokenFactory's placement before auth module is safe and correct

The search results reveal that:

  1. TokenFactory keeper only depends on basic interfaces from auth (Minter, Burner permissions) which don't require auth module initialization
  2. TokenFactory keeper initialization shows dependencies only on codec, store key, module account permissions, AccountKeeper, BankKeeper, and DistrKeeper interfaces
  3. The module is correctly placed before bank to prevent denomination metadata overwriting, which was the original intent
  4. No initialization-time dependencies on auth module were found that would require auth to be initialized first

The placement is safe because:

  • The module account permissions (authtypes.Minter, authtypes.Burner) are static definitions that don't require auth module initialization
  • The AccountKeeper interface is available before auth module initialization
  • No direct imports or usage of auth types were found in the TokenFactory module that would require auth initialization
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential TokenFactory dependencies on auth module
# Test: Search for auth imports and usage in TokenFactory module
rg -A 5 "authtypes\." --type go

Length of output: 9867


Script:

#!/bin/bash
# Check TokenFactory's direct dependencies and initialization requirements
rg -A 5 "NewKeeper.*TokenFactory" --type go

# Check if TokenFactory has any direct imports or usage of auth types
rg -l "\"github.com/cosmos/cosmos-sdk/x/auth/types\"" x/tokenfactory/

Length of output: 171


Script:

#!/bin/bash
# Find TokenFactory related files
fd -t f tokenfactory

# Once we find the files, let's check their content for dependencies
rg -A 5 "type Keeper struct" 

# Check module initialization order in app.go
rg -B 5 -A 10 "OrderInitGenesis" app/app.go

Length of output: 994


Script:

#!/bin/bash
# Search for TokenFactory in imports and module registration
rg -A 5 "tokenfactory" --type go

# Look for the complete genesis order configuration
rg -B 10 -A 5 "genesisModuleOrder :=" app/app.go

Length of output: 9184


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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

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

codecov bot commented Oct 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.98%. Comparing base (2ab4fcb) to head (54f4397).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #100      +/-   ##
==========================================
+ Coverage   77.57%   77.98%   +0.41%     
==========================================
  Files          33       33              
  Lines        1712     2189     +477     
==========================================
+ Hits         1328     1707     +379     
- Misses        298      395      +97     
- Partials       86       87       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fmorency fmorency merged commit 5bda05b into liftedinit:main Oct 23, 2024
16 checks passed
@fmorency fmorency deleted the tf-genesis-order branch October 23, 2024 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant