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

Add v6.0.0 upgrade handler #1620

Merged
merged 9 commits into from
Jun 5, 2024
Merged

Add v6.0.0 upgrade handler #1620

merged 9 commits into from
Jun 5, 2024

Conversation

jayy04
Copy link
Contributor

@jayy04 jayy04 commented Jun 3, 2024

Changelist

[Describe or list the changes made in this PR]

Test Plan

[Describe how this PR was tested (if applicable)]

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Summary by CodeRabbit

  • New Features

    • Upgraded protocol to version 6.0.0, including new upgrade handlers and constants.
  • Tests

    • Added comprehensive tests for state upgrades to version 6.0.0, including setup, pre-upgrade checks, post-upgrade checks, and order placement.
  • Chores

    • Updated test scripts and configurations to reflect the upgrade from version 5.0.0 to 6.0.0.

Copy link
Contributor

coderabbitai bot commented Jun 3, 2024

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Files selected but had no reviewable changes (1)
  • protocol/testing/containertest/preupgrade_genesis.json

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

Walkthrough

The upgrade involves transitioning the protocol's app package from version 5.0.0 to 6.0.0. It updates import paths, constants, and dependencies, and introduces new test functions and configurations to support the upgrade. Additionally, it modifies the containertest scripts and configurations to reflect the new version.

Changes

File Path Change Summary
protocol/app/upgrades.go Updated import paths and references from version 5.0.0 to 6.0.0 and removed certain dependencies.
protocol/app/upgrades/v6.0.0/constants.go Defined UpgradeName and initialized Upgrade variable for version 6.0.0.
protocol/app/upgrades/v6.0.0/upgrade.go Introduced CreateUpgradeHandler function for version 6.0.0.
protocol/testing/containertest/testnet.go Updated UpgradeToVersion constant from "v5.0.0" to "v6.0.0".
protocol/testing/containertest/containertest.sh Updated PREUPGRADE_VERSION from "v4.1.0" to "v5.0.0".
protocol/testing/containertest/preupgrade_genesis.json Added a new vault section with various parameters.
protocol/app/upgrades/v6.0.0/upgrade_container_test.go Introduced test functions for state upgrades to version 6.0.0.

Poem

In the realm of code, a leap we take,
From version five to six, new paths we make.
Constants and handlers, all aligned anew,
Testing our upgrades, to ensure they’re true.
With scripts and genesis, we pave the way,
For a brighter, better, version six day. 🌟


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d7f0143 and bff8a16.

Files selected for processing (3)
  • protocol/app/upgrades.go (2 hunks)
  • protocol/app/upgrades/v6.0.0/constants.go (1 hunks)
  • protocol/app/upgrades/v6.0.0/upgrade.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • protocol/app/upgrades/v6.0.0/constants.go
Additional comments not posted (3)
protocol/app/upgrades/v6.0.0/upgrade.go (1)

12-20: The implementation of CreateUpgradeHandler looks correct and aligns with the intended upgrade process.

protocol/app/upgrades.go (2)

17-17: The addition of v6_0_0.Upgrade to the Upgrades slice is correctly implemented.


25-30: The setup of the upgrade handler for v6.0.0 is correctly implemented. Ensure that the duplicate handler check is robust.

Verification successful

The search across the entire codebase confirms that there is only one instance of app.UpgradeKeeper.SetUpgradeHandler, ensuring that the duplicate handler check is robust and functioning as intended.

  • : The setup of the upgrade handler for v6.0.0 is correctly implemented, and the duplicate handler check is robust. No multiple registrations of the same upgrade handler were found.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the duplicate handler check is functioning as intended.

# Test: Search for multiple registrations of the same upgrade handler. Expect: No multiple registrations.
rg --type go $'app.UpgradeKeeper.SetUpgradeHandler' protocol/app/upgrades.go

Length of output: 113



Script:

#!/bin/bash
# Description: Verify that the duplicate handler check is functioning as intended across the entire codebase.

# Test: Search for multiple registrations of the same upgrade handler. Expect: No multiple registrations.
rg --type go 'app.UpgradeKeeper.SetUpgradeHandler' -g '*.go'

Length of output: 123

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bff8a16 and 781d3ea.

Files selected for processing (1)
  • protocol/testing/containertest/testnet.go (1 hunks)
Additional comments not posted (1)
protocol/testing/containertest/testnet.go (1)

28-28: Update to UpgradeToVersion constant is correct as per upgrade requirements.

#!/bin/bash
# Description: Verify that the `UpgradeToVersion` constant is correctly used throughout the codebase.

# Test: Search for the constant usage. Expect: Only occurances of the new version.
rg --type go $'UpgradeToVersion'

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: 4

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 781d3ea and c562a72.

Files selected for processing (1)
  • protocol/app/upgrades/v6.0.0/upgrade_container_test.go (1 hunks)
Additional comments not posted (1)
protocol/app/upgrades/v6.0.0/upgrade_container_test.go (1)

52-187: The implementation of placeOrders looks robust and well-handled.

Good use of constants and error handling ensures that the function is both readable and reliable.

Comment on lines +22 to +38
func TestStateUpgrade(t *testing.T) {
testnet, err := containertest.NewTestnetWithPreupgradeGenesis()
require.NoError(t, err, "failed to create testnet - is docker daemon running?")
err = testnet.Start()
require.NoError(t, err)
defer testnet.MustCleanUp()
node := testnet.Nodes["alice"]
nodeAddress := constants.AliceAccAddress.String()

preUpgradeSetups(node, t)
preUpgradeChecks(node, t)

err = containertest.UpgradeTestnet(nodeAddress, t, node, v_6_0_0.UpgradeName)
require.NoError(t, err)

postUpgradeChecks(node, t)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding more detailed checks in preUpgradeChecks and postUpgradeChecks.

It's crucial to ensure that the upgrade does not introduce or miss any critical changes. Detailed checks will help verify the integrity and success of the upgrade process.

Comment on lines +48 to +50
func postUpgradeChecks(node *containertest.Node, t *testing.T) {
// Add test for your upgrade handler logic below
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Implement necessary checks in postUpgradeChecks.

Post-upgrade checks are essential to verify that the upgrade has been applied correctly and that the system behaves as expected. I can help with defining these checks if needed.

Comment on lines +40 to +42
func preUpgradeSetups(node *containertest.Node, t *testing.T) {
placeOrders(node, t)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider expanding the setup procedures in preUpgradeSetups.

Depending on the scope of the upgrade, you might need to prepare more aspects of the system to ensure a comprehensive test environment.

Comment on lines +44 to +46
func preUpgradeChecks(node *containertest.Node, t *testing.T) {
// Add test for your upgrade handler logic below
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Implement necessary checks in preUpgradeChecks.

This function is crucial for ensuring the system's state before the upgrade. If you need help with what checks to implement, I can assist with suggestions or examples.

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/testing/containertest/containertest.sh (2)

Line range hint 110-110: Ensure variables are properly quoted to prevent globbing and word splitting.

- dydxprotocold add-genesis-account "$acct" 100000000000000000$USDC_DENOM,$TESTNET_VALIDATOR_NATIVE_TOKEN_BALANCE$NATIVE_TOKEN --home "$VAL_HOME_DIR"
+ dydxprotocold add-genesis-account "$acct" "100000000000000000$USDC_DENOM,$TESTNET_VALIDATOR_NATIVE_TOKEN_BALANCE$NATIVE_TOKEN" --home "$VAL_HOME_DIR"

This change ensures that the entire string is treated as a single argument, preventing potential issues with spaces or special characters in variables.

Also applies to: 113-113, 116-116, 177-177

Tools
Shellcheck

[info] 7-7: Not following: ./genesis.sh was not specified as input (see shellcheck -x). (SC1091)


Line range hint 177-177: Address the TODO regarding the removal of the function post-migration.

This TODO indicates a planned removal of the function once migration off of persistent peers is complete. Would you like assistance in tracking this task or creating a timeline for its completion?

Tools
Shellcheck

[info] 7-7: Not following: ./genesis.sh was not specified as input (see shellcheck -x). (SC1091)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c562a72 and 4845da2.

Files selected for processing (1)
  • protocol/testing/containertest/containertest.sh (1 hunks)
Additional context used
Shellcheck
protocol/testing/containertest/containertest.sh

[info] 7-7: Not following: ./genesis.sh was not specified as input (see shellcheck -x). (SC1091)


[info] 110-110: Double quote to prevent globbing and word splitting. (SC2086)


[info] 110-110: Double quote to prevent globbing and word splitting. (SC2086)


[info] 110-110: Double quote to prevent globbing and word splitting. (SC2086)


[info] 113-113: Double quote to prevent globbing and word splitting. (SC2086)


[info] 113-113: Double quote to prevent globbing and word splitting. (SC2086)


[info] 113-113: Double quote to prevent globbing and word splitting. (SC2086)


[info] 116-116: Double quote to prevent globbing and word splitting. (SC2086)


[info] 116-116: Double quote to prevent globbing and word splitting. (SC2086)


[info] 177-177: Double quote to prevent globbing and word splitting. (SC2086)

Additional comments not posted (1)
protocol/testing/containertest/containertest.sh (1)

10-10: Update PREUPGRADE_VERSION to align with the new protocol version.

This change correctly updates the pre-upgrade version to "v5.0.0", aligning with the protocol's versioning as part of the upgrade process.

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)
protocol/testing/containertest/testnet.go (1)

Line range hint 40-40: Address undefined types and functions.

The static analysis has identified several issues with undefined types and functions such as Node, dockertest, and newNode. These need to be defined or imported correctly to ensure the code compiles and functions as expected.

Also applies to: 44-45, 53-53, 56-56, 131-131, 175-175

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4845da2 and d0abf57.

Files selected for processing (1)
  • protocol/testing/containertest/testnet.go (2 hunks)
Additional context used
golangci-lint
protocol/testing/containertest/testnet.go

40-40: undefined: Node (typecheck)


44-44: undefined: dockertest (typecheck)


45-45: undefined: dockertest (typecheck)


131-131: undefined: Node (typecheck)


53-53: undefined: Node (typecheck)


56-56: undefined: dockertest (typecheck)


175-175: undefined: newNode (typecheck)

Additional comments not posted (1)
protocol/testing/containertest/testnet.go (1)

28-28: Update to UpgradeToVersion constant to reflect the new version is appropriate for the context of this PR.

Comment on lines 121 to 125
return fmt.Errorf(
"could not connect to node: %s, %+v",
moniker,
err,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling in the connection failure message.

Consider enhancing the error message to provide more context about the failure, which could be beneficial for debugging.

- "could not connect to node: %s, %+v"
+ "Failed to connect to node '%s'. Error: %+v"
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
return fmt.Errorf(
"could not connect to node: %s, %+v",
moniker,
err,
)
return fmt.Errorf(
"Failed to connect to node '%s'. Error: %+v",
moniker,
err,
)

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d0abf57 and f1a523a.

Files selected for processing (1)
  • protocol/testing/containertest/preupgrade_genesis.json (1 hunks)
Files skipped from review due to trivial changes (1)
  • protocol/testing/containertest/preupgrade_genesis.json

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 UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f1a523a and 2701cbe.

Files selected for processing (1)
  • protocol/testing/containertest/testnet.go (2 hunks)
Additional context used
golangci-lint
protocol/testing/containertest/testnet.go

40-40: undefined: Node (typecheck)


44-44: undefined: dockertest (typecheck)


45-45: undefined: dockertest (typecheck)


131-131: undefined: Node (typecheck)


53-53: undefined: Node (typecheck)


56-56: undefined: dockertest (typecheck)


175-175: undefined: newNode (typecheck)

Additional comments not posted (1)
protocol/testing/containertest/testnet.go (1)

28-28: The update to UpgradeToVersion correctly reflects the new protocol version.

Comment on lines +121 to +125
return fmt.Errorf(
"could not connect to node: %s, %w",
moniker,
err,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider enhancing the error message to provide more context about the failure, which could be beneficial for debugging.

- "could not connect to node: %s, %w"
+ "Failed to connect to node '%s'. Error: %w"
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
return fmt.Errorf(
"could not connect to node: %s, %w",
moniker,
err,
)
return fmt.Errorf(
"Failed to connect to node '%s'. Error: %w",
moniker,
err,
)

@jayy04 jayy04 merged commit 0e67d7a into main Jun 5, 2024
18 checks passed
@jayy04 jayy04 deleted the jy/v6-upgrade-handler branch June 5, 2024 20:03
@coderabbitai coderabbitai bot mentioned this pull request Dec 13, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants