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

feat: umfx denom metadata migration #103

Merged
merged 6 commits into from
Oct 24, 2024

Conversation

fmorency
Copy link
Collaborator

@fmorency fmorency commented Oct 24, 2024

This PR adds the umfx-denom-metadata migration that adds the following bank denom metadata for the umfx token

metadata := banktypes.Metadata{
	Description: "The Manifest Network token",
	DenomUnits: []*banktypes.DenomUnit{
		{
			Denom:    "umfx",
			Exponent: 0,
			Aliases:  []string{},
		},
		{
			Denom:    "mfx",
			Exponent: 6,
			Aliases:  []string{},
		},
	},
	Base:    "umfx",
	Display: "MFX",
	Symbol:  "MFX",
	Name:    "Manifest Network Token",
}

Summary by CodeRabbit

  • New Features

    • Introduced a new upgrade mechanism, ensuring at least one upgrade is registered.
    • Added a new upgrade "umfx-denom-metadata" with metadata for the Manifest Network token.
  • Improvements

    • Enhanced upgrade handling logic by including banking functionalities.
  • Bug Fixes

    • Updated versioning to reflect the latest changes (v0.0.1-alpha.18).

@fmorency fmorency self-assigned this Oct 24, 2024
Copy link

coderabbitai bot commented Oct 24, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes in this pull request involve updates to multiple files related to versioning and upgrade mechanisms in the application. The Makefile reflects a version increment from v0.0.1-alpha.17 to v0.0.1-alpha.18. The app/upgrades.go file introduces a predefined upgrade instance and enhances the upgrade handling logic by including a BankKeeper. A new file, app/upgrades/next/upgrades.go, defines an upgrade process with a handler for setting metadata and running migrations. Lastly, app/upgrades/types.go modifies the AppKeepers struct to include the new BankKeeper.

Changes

File Change Summary
Makefile Updated VERSION from v0.0.1-alpha.17 to v0.0.1-alpha.18.
app/upgrades.go Initialized Upgrades with next.NewUpgrade(); added BankKeeper to keepers in RegisterUpgradeHandlers.
app/upgrades/next/upgrades.go Added NewUpgrade function and CreateUpgradeHandler function to define an upgrade process.
app/upgrades/types.go Renamed AccountKeeper field and added BankKeeper field to AppKeepers struct.

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant Upgrades
    participant BankKeeper
    participant ModuleManager

    App->>Upgrades: Initialize Upgrades
    Upgrades->>BankKeeper: Create Metadata
    BankKeeper->>ModuleManager: Set Denom Metadata
    ModuleManager->>BankKeeper: Run Migrations
Loading

🐰 "In the garden of code, where the upgrades bloom,
With a hop and a skip, we make room!
From alpha seventeen to eighteen we leap,
With BankKeeper's help, our upgrades run deep.
So let’s cheer for the changes, both big and small,
In the world of our app, we’ll conquer them all!" 🌼


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

@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: 2

🧹 Outside diff range and nitpick comments (1)
app/upgrades/next/upgrades.go (1)

13-22: Add function documentation for better maintainability.

Consider adding a doc comment explaining the purpose of this upgrade and why no store upgrades are needed.

+// NewUpgrade creates a new upgrade handler for setting umfx denom metadata.
+// This is a non-breaking upgrade that only adds metadata to the bank module.
 func NewUpgrade() upgrades.Upgrade {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 51a03df and 39034fd.

📒 Files selected for processing (4)
  • Makefile (1 hunks)
  • app/upgrades.go (2 hunks)
  • app/upgrades/next/upgrades.go (1 hunks)
  • app/upgrades/types.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • Makefile
🔇 Additional comments (6)
app/upgrades/types.go (2)

6-6: LGTM: Required import for BankKeeper.

The addition of the bankkeeper import is necessary to support the new BankKeeper field and aligns with the PR's objective of managing denom metadata.


13-14: LGTM: Keeper additions for metadata management.

The changes appropriately:

  1. Make the AccountKeeper type explicit
  2. Add BankKeeper which is required for managing denomination metadata

These modifications provide the necessary infrastructure for the umfx denom metadata migration.

Let's verify the BankKeeper usage in the upgrade handler:

✅ Verification successful

Let's search more broadly for BankKeeper usage in the upgrades directory to understand how it's being utilized.


BankKeeper is correctly used for setting denomination metadata

The verification confirms that BankKeeper is properly utilized in the upgrade handler (app/upgrades/next/upgrades.go) to set denomination metadata for the "umfx" token. Specifically:

  • The upgrade is named "umfx-denom-metadata"
  • BankKeeper.SetDenomMetaData is called with appropriate metadata configuration
  • The metadata includes description and denomination units for "umfx"

This validates that the BankKeeper addition in the types.go file is necessary and correctly implemented for its intended purpose of managing denomination metadata during the upgrade.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that BankKeeper is used for metadata operations in the upgrade handler
# Expected: Find usage of BankKeeper.SetDenomMetadata or similar methods

# Search for BankKeeper usage in upgrade-related files
rg -A 5 "BankKeeper.*SetDenomMetadata" app/upgrades/

Length of output: 54


Script:

#!/bin/bash
# Search for any BankKeeper usage in upgrade-related files
rg -A 5 "BankKeeper" app/upgrades/

# Also search for any metadata-related operations
rg -A 5 "metadata" app/upgrades/ -i

Length of output: 1796

app/upgrades.go (2)

23-23: Verify BankKeeper initialization and error handling.

The addition of BankKeeper is necessary for managing token denominations and metadata. However, we should ensure proper initialization and error handling.

Let's verify the BankKeeper setup:

#!/bin/bash
# Description: Verify BankKeeper initialization and usage in the upgrade handler

# Test 1: Check BankKeeper initialization in the app
ast-grep --pattern 'type ManifestApp struct {
  $$$
  BankKeeper $$$
  $$$
}'

# Test 2: Verify error handling in the upgrade handler
rg -A 5 'BankKeeper.*SetDenomMetadata'

14-14: LGTM: Upgrade registration for umfx denom metadata.

The initialization of Upgrades with next.NewUpgrade() aligns with the PR objective of adding bank denom metadata for the umfx token.

Let's verify the upgrade registration:

✅ Verification successful

Let me generate additional scripts to verify the upgrade implementation and metadata configuration, as the previous search didn't yield the expected results.


Based on the shell script results, I can now provide a final response as we have found clear evidence of the upgrade implementation and its purpose.

Verified: The upgrade registration is correctly implemented for umfx denom metadata

The next.NewUpgrade() implementation in app/upgrades/next/upgrades.go properly sets up the upgrade handler to:

  • Add metadata for the umfx token
  • Configure proper denomination units (umfx at exponent 0, mfx at exponent 6)
  • Set display properties (name, symbol, description)
  • Use BankKeeper.SetDenomMetaData to register the metadata

The upgrade is appropriately named "umfx-denom-metadata" and aligns with the PR's objective of adding bank denom metadata for the umfx token.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the upgrade implementation exists and contains the expected metadata

# Test 1: Verify the upgrade implementation
ast-grep --pattern 'func NewUpgrade() Upgrade {
  $$$
}'

# Test 2: Check for umfx metadata configuration
rg -A 10 'umfx.*metadata' 

Length of output: 3032


Script:

#!/bin/bash
# Let's try different approaches to locate the upgrade implementation and metadata

# Check for upgrade implementation in the next package
fd -e go -E "vendor" . | xargs rg -l "NewUpgrade"

# Look for any metadata-related code in upgrade handlers
rg -A 5 "SetDenomMetadata|DenomMetadata" 

# Search for umfx token configuration
rg -A 5 "umfx" 

# Look specifically in app/upgrades directory
fd . app/upgrades -t f -E "vendor" | xargs cat

Length of output: 27734

app/upgrades/next/upgrades.go (2)

1-11: LGTM: Package and imports are well-structured.

The imports are appropriate and necessary for implementing a Cosmos SDK upgrade handler.


53-53: LGTM: Proper migration execution.

Running migrations after setting metadata is the correct order of operations.

app/upgrades/next/upgrades.go Show resolved Hide resolved
app/upgrades/next/upgrades.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 29.72973% with 26 lines in your changes missing coverage. Please review.

Project coverage is 76.40%. Comparing base (51a03df) to head (00fbbf6).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
app/upgrades/next/upgrades.go 27.77% 25 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #103      +/-   ##
==========================================
- Coverage   77.98%   76.40%   -1.58%     
==========================================
  Files          33       34       +1     
  Lines        2189     2225      +36     
==========================================
- Hits         1707     1700       -7     
- Misses        395      436      +41     
- Partials       87       89       +2     

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

@fmorency fmorency merged commit 8ce2e61 into liftedinit:main Oct 24, 2024
13 checks passed
@fmorency fmorency deleted the umfx-denom-metadata branch October 24, 2024 14:53
@coderabbitai coderabbitai bot mentioned this pull request Nov 25, 2024
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.

1 participant