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

Drop patch number from upgrade name, v7.0.0 to v7.0 #2512

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

adamfraser
Copy link
Contributor

@adamfraser adamfraser commented Oct 17, 2024

Changelist

Modifies the upgrade name to follow the new convention of not including minor patch numbers.
v7.0.0 to v7.0

Summary by CodeRabbit

  • New Features

    • Updated versioning to reflect a more concise format (from v7.0.0 to v7.0).
    • Introduced new functions for initializing module accounts, caching currency pair IDs, and migrating vault parameters during the upgrade process.
  • Bug Fixes

    • Adjusted test imports and package names to align with the new versioning.
  • Documentation

    • Version string updated in the testing protocol to reflect the latest version.

@adamfraser adamfraser force-pushed the adam/change-upgrade-name-v7.0 branch from 3908f16 to de0d889 Compare October 17, 2024 19:28
@adamfraser adamfraser marked this pull request as ready for review October 17, 2024 20:21
@adamfraser adamfraser requested a review from a team as a code owner October 17, 2024 20:21
Copy link
Contributor

coderabbitai bot commented Oct 17, 2024

Walkthrough

The pull request modifies versioning constants and package names across several files. The UpgradeName constant in constants.go is updated to reflect a new version format. The test file upgrade_container_test.go has its package name and import paths adjusted accordingly. Additionally, the version string in VERSION_CURRENT is simplified by removing the patch level. These changes ensure consistency in versioning across the codebase.

Changes

File Path Change Summary
protocol/app/upgrades/v7.0/constants.go Updated UpgradeName constant from "v7.0.0" to "v7.0"; changed package name from v_7_0_0 to v_7_0.
protocol/app/upgrades/v7.0/upgrade.go Changed package name from v_7_0_0 to v_7_0; added functions for initializing module accounts, caching currency pair IDs, migrating vault parameters, and managing vault shares.
protocol/app/upgrades/v7.0/upgrade_container_test.go Changed package name from v_7_0_0_test to v_7_0_test and updated import path from v_7_0_0 to v_7_0. Adjusted TestStateUpgrade function accordingly.
protocol/testing/version/VERSION_CURRENT Modified version string from v7.0.0 to v7.0, removing the patch level.

Possibly related PRs

Suggested labels

backport/protocol/v7.x

Suggested reviewers

  • vincentwschau
  • shrenujb

🐇 In the meadow, where bunnies play,
A version change brightens the day.
From v7.0.0 to v7.0 we leap,
With tests in place, our code runs deep.
Hopping forward, we cheer and sing,
For every upgrade, joy it brings! 🌼


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.

@adamfraser adamfraser force-pushed the adam/change-upgrade-name-v7.0 branch from de0d889 to 452c16d Compare October 17, 2024 21:40
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 (5)
protocol/app/upgrades/v7.0/upgrade.go (5)

Line range hint 29-31: Update panic message to accurately reflect behavior.

In the initializeModuleAccs function, the panic message states "This is not expected. Skipping.", but since the code panics, execution will halt immediately rather than skip processing. Consider updating the message to accurately reflect that the upgrade cannot proceed.

Apply this diff to update the message:

- panic(fmt.Sprintf(
-   "Did not find %v in `ak.GetModuleAddressAndPermissions`. This is not expected. Skipping.",
+ panic(fmt.Sprintf(
+   "Did not find %v in `ak.GetModuleAddressAndPermissions`. Cannot proceed with upgrade.",
    modAccName,
))

Line range hint 119-122: Handle potential division by zero in owner shares calculation.

In the migrateVaultSharesToMegavaultShares function, when calculating ownerShares, ensure that equity.Denom() is not zero to prevent a division by zero panic.

Consider adding a check before performing the division:

if equity.Denom().Sign() == 0 {
  ctx.Logger().Warn(fmt.Sprintf(
    "Owner %s has zero equity denominator, skipping calculation",
    owner,
  ))
  continue
}

Line range hint 72-76: Avoid panicking on setting vault params failure.

In the migrateVaultQuotingParamsToVaultParams function, panicking when SetVaultParams fails may halt the entire upgrade process. Consider handling the error to allow the upgrade to continue or to provide better diagnostic information.

Update the error handling as follows:

if err != nil {
  ctx.Logger().Error(fmt.Sprintf(
    "Failed to set vault params for vault %v with params %v: %s",
    vaultId,
    vaultParams,
    err,
  ))
  // Decide whether to continue or rollback based on the severity.
  // For critical errors, you might want to return or panic.
  continue
}

Line range hint 203-205: Enhance logging after module migrations.

After running mm.RunMigrations, it would be helpful to log the successful migration of each module to ensure all migrations have been applied as expected.

Consider adding detailed logging:

newVM, err := mm.RunMigrations(ctx, configurator, vm)
if err != nil {
  return nil, err
}
for moduleName, moduleVersion := range newVM {
  sdkCtx.Logger().Info(fmt.Sprintf("Module %s migrated to version %d", moduleName, moduleVersion))
}
return newVM, nil

Line range hint 8-27: Consider reusing module account initialization logic.

The initializeModuleAccs function mentions that the logic is copied from the v3.0.0 upgrade handler. To promote code reuse and maintainability, consider abstracting this logic into a shared utility function or method if it's used across multiple versions.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between de0d889 and 452c16d.

📒 Files selected for processing (5)
  • protocol/app/upgrades.go (2 hunks)
  • protocol/app/upgrades/v7.0/constants.go (2 hunks)
  • protocol/app/upgrades/v7.0/upgrade.go (1 hunks)
  • protocol/app/upgrades/v7.0/upgrade_container_test.go (3 hunks)
  • protocol/testing/version/VERSION_CURRENT (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • protocol/app/upgrades/v7.0/constants.go
  • protocol/app/upgrades/v7.0/upgrade_container_test.go
  • protocol/testing/version/VERSION_CURRENT
🧰 Additional context used
🔇 Additional comments (6)
protocol/app/upgrades.go (5)

17-17: LGTM. Upgrade reference updated correctly.

The Upgrades slice has been updated to use the new v7_0.Upgrade reference, which is consistent with the import statement change and the PR objectives.


25-26: LGTM. Upgrade name references updated correctly.

The HasHandler check and the panic message have been updated to use the new v7_0.UpgradeName reference, which is consistent with the previous changes and the PR objectives.


6-6: LGTM. Verify the new import path.

The import statement has been correctly updated to reflect the new version without the patch number, which is consistent with the PR objectives.

Let's verify that the new import path exists:

#!/bin/bash
# Verify that the new import path exists
fd -t d "v7\.0$" protocol/app/upgrades

29-30: LGTM. Upgrade handler references updated correctly.

The SetUpgradeHandler call has been updated to use the new v7_0.UpgradeName and v7_0.CreateUpgradeHandler references, which is consistent with the previous changes and the PR objectives.

To ensure the upgrade handler's functionality remains intact, let's verify its implementation:


Line range hint 6-30: Summary: Version update successfully implemented

The changes in this file consistently update the upgrade name from v7.0.0 to v7.0 across import statements, upgrade references, and handler registrations. These modifications align with the PR objectives to drop the patch number from the upgrade name.

Key points:

  1. Import path updated
  2. Upgrades slice reference updated
  3. HasHandler check and panic message updated
  4. SetUpgradeHandler call updated

The changes appear to be complete and correct for this file. However, ensure that any other files referencing the old version (v7.0.0) are also updated accordingly throughout the codebase.

Let's verify if there are any remaining references to the old version:

protocol/app/upgrades/v7.0/upgrade.go (1)

1-1: Verify package name change impacts.

The package name has been changed from v_7_0_0 to v_7_0. Ensure that all references to this package throughout the codebase have been updated to prevent import errors or inconsistencies.

Run the following script to find any remaining references to the old package name:

@adamfraser adamfraser force-pushed the adam/change-upgrade-name-v7.0 branch from 452c16d to 296deda Compare October 17, 2024 21:50
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)
protocol/app/upgrades/v7.0/upgrade.go (2)

Line range hint 23-56: Refactor to eliminate code duplication

The initializeModuleAccs function duplicates module account initialization logic from the v3.0.0 upgrade handler. To enhance maintainability and reduce code duplication, consider abstracting this logic into a shared utility function that can be reused across multiple upgrade handlers.


Line range hint 107-109: Prevent potential division by zero in ownerShares calculation

In the calculation of ownerShares, there is a potential risk of division by zero if equity.Denom() is zero. To avoid a runtime panic, add a check to ensure that equity.Denom() is not zero before performing the division.

Apply this diff to add the zero denominator check:

+		if equity.Denom().Sign() == 0 {
+			ctx.Logger().Warn(fmt.Sprintf(
+				"Owner %s has zero denominator in equity: %s",
+				owner,
+				equity,
+			))
+			continue
+		}
		ownerShares := new(big.Int).Quo(
			equity.Num(),
			equity.Denom(),
		)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 452c16d and 296deda.

📒 Files selected for processing (5)
  • protocol/app/upgrades.go (2 hunks)
  • protocol/app/upgrades/v7.0/constants.go (2 hunks)
  • protocol/app/upgrades/v7.0/upgrade.go (1 hunks)
  • protocol/app/upgrades/v7.0/upgrade_container_test.go (3 hunks)
  • protocol/testing/version/VERSION_CURRENT (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • protocol/app/upgrades.go
  • protocol/app/upgrades/v7.0/constants.go
  • protocol/app/upgrades/v7.0/upgrade_container_test.go
  • protocol/testing/version/VERSION_CURRENT
🧰 Additional context used
🔇 Additional comments (1)
protocol/app/upgrades/v7.0/upgrade.go (1)

1-1: Ensure package name consistency across the codebase

The package name has been updated to v_7_0. Please verify that all references and import statements in the codebase have been updated accordingly to prevent any broken imports.

@adamfraser adamfraser merged commit 66d7a5d into main Oct 18, 2024
22 checks passed
@adamfraser adamfraser deleted the adam/change-upgrade-name-v7.0 branch October 18, 2024 15:10
@adamfraser
Copy link
Contributor Author

@mergify backport release/protocol/v7.x

Copy link
Contributor

mergify bot commented Oct 18, 2024

backport release/protocol/v7.x

✅ Backports have been created

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

Successfully merging this pull request may close these issues.

3 participants