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: v8.0.0-rc.4 upgrade handler #422

Merged
merged 10 commits into from
Nov 6, 2024
Merged

feat: v8.0.0-rc.4 upgrade handler #422

merged 10 commits into from
Nov 6, 2024

Conversation

boojamya
Copy link
Member

@boojamya boojamya commented Nov 6, 2024

This PR modify's the upgrade handler to add the globalfee module to testnet.

It also adds back a modified and simplified version of the upgrade test that was present in older versions of Noble.
I envision this test being ported over to the main the branch when it becomes needed.

@boojamya boojamya requested a review from a team as a code owner November 6, 2024 08:14
Copy link

coderabbitai bot commented Nov 6, 2024

Walkthrough

The changes in this pull request involve modifications primarily to the Makefile, app.go, and various test files. The Makefile now displays output from the local-image target. The app.go file integrates a new upgrade module, replacing the previous one and streamlining upgrade handling. Several test files have been updated to include a new parameter in the NobleSpinUp function, which affects the test environment setup. Additionally, new files for upgrade testing and utility functions have been introduced, enhancing the testing framework.

Changes

File Change Summary
Makefile Modified local-image target to display output from heighliner build by removing 1> /dev/null.
app.go Updated import from upgrade to upgrade/testnet, modified RegisterUpgradeHandler to use testnet references, and removed several parameters from CreateUpgradeHandler.
cmd/init.go Added copyright notice and licensing information; no functional changes.
cmd/nobled/main.go Added copyright notice and licensing information; no functional changes.
e2e/cctp_deposit_for_burn_test.go Updated TestCCTP_DepositForBurn to include e2e.LocalImages in NobleSpinUp function call.
e2e/cctp_deposit_for_burn_with_caller_test.go Updated TestCCTP_DepositForBurnWithCaller to include e2e.LocalImages in NobleSpinUp function call.
e2e/cctp_receive_message_test.go Updated TestCCTP_ReceiveMessage to include e2e.LocalImages in NobleSpinUp function call.
e2e/cctp_receive_message_with_caller_test.go Updated TestCCTP_ReceiveMessageWithCaller to include e2e.LocalImages in NobleSpinUp function call.
e2e/cctp_replace_deposit_for_burn_test.go Updated TestCCTP_ReplaceDepositForBurn to include e2e.LocalImages in NobleSpinUp function call and added new assertions for event parameters.
e2e/cctp_roles_test.go Updated multiple test functions to include e2e.LocalImages in NobleSpinUp function call.
e2e/conformance_test.go Updated TestConformance to include e2e.LocalImages in NobleSpinUpIBC function call.
e2e/fiat_tf_test.go Updated multiple test functions to include e2e.LocalImages in NobleSpinUp function call.
e2e/module_check_test.go Updated TestRestrictedModules to include e2e.LocalImages in NobleSpinUp function call.
e2e/upgrade_test.go Introduced a new test file for chain upgrades with the TestChainUpgrade function.
e2e/upgrade_utils.go Introduced a new utility file for managing blockchain upgrades with the ChainUpgrade struct and TestChainUpgrade function.
e2e/utils.go Enhanced Docker image handling and role management; updated multiple function signatures to include new parameters.
upgrade/testnet/constants.go Introduced a new file defining the constant UpgradeName for the upgrade.
upgrade/testnet/store.go Introduced a new file with the CreateStoreLoader function for setting up store loaders for upgrades.
upgrade/testnet/upgrade.go Introduced a new file with functions for handling upgrades in a testnet environment, including CreateUpgradeHandler and GetModuleMessages.

Possibly related PRs

  • feat: improve tooling, include ledger build flag #418: The changes in the Makefile related to build configurations and the introduction of a new variable for ledger support are relevant as they involve modifications to the same file as the main PR, which also updates the Makefile for output handling in the local-image target.

Suggested reviewers

  • g-luca

🐰 In the garden, where changes bloom,
A Makefile shines, dispelling gloom.
With upgrades fresh, and tests anew,
The rabbit hops, with joy in view!
For every line, a tale to tell,
In code we trust, all works so well! 🌼


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.

@johnletey johnletey changed the base branch from v8.0.x-testnet to main November 6, 2024 17:37
@johnletey johnletey changed the title feat: modify upgrade handler for testnet + upgrade e2e test feat: v8.0.0-rc.4 upgrade handler Nov 6, 2024
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: 11

🧹 Outside diff range and nitpick comments (16)
e2e/module_check_test.go (1)

Line range hint 31-37: Consider enhancing test documentation and coverage.

While the test logic is sound, consider these improvements:

  1. Add a comment explaining why these specific modules are restricted
  2. Make error messages more descriptive (e.g., include expected behavior)
  3. Consider adding test cases for non-restricted modules to ensure complete coverage

Example enhancement:

 func TestRestrictedModules(t *testing.T) {
 	t.Parallel()
+	// These modules are restricted for security reasons:
+	// - circuit: prevents unauthorized state transitions
+	// - gov: prevents unauthorized governance actions
+	// - group: prevents unauthorized group management
 
 	ctx := context.Background()
 	nw, _ := e2e.NobleSpinUp(t, ctx, e2e.LocalImages, false)
 	noble := nw.Chain.GetNode()
 
 	restrictedModules := []string{"circuit", "gov", "group"}
 
 	for _, module := range restrictedModules {
-		require.False(t, noble.HasCommand(ctx, "query", module), fmt.Sprintf("%s is a restricted module", module))
+		require.False(t, noble.HasCommand(ctx, "query", module),
+			fmt.Sprintf("module %s should be restricted and not have query commands available", module))
 	}
+
+	// Verify non-restricted modules are accessible
+	allowedModules := []string{"bank", "staking"}
+	for _, module := range allowedModules {
+		require.True(t, noble.HasCommand(ctx, "query", module),
+			fmt.Sprintf("module %s should be accessible and have query commands available", module))
+	}
 }
upgrade/testnet/store.go (1)

24-30: Implementation looks good, but consider adding validation.

The store loader implementation correctly adds the globalfee module. However, consider adding validation for the upgradeHeight parameter to ensure it's positive.

 func CreateStoreLoader(upgradeHeight int64) baseapp.StoreLoader {
+	if upgradeHeight <= 0 {
+		panic("upgrade height must be positive")
+	}
 	storeUpgrades := storetypes.StoreUpgrades{
 		Added: []string{globalfeetypes.ModuleName},
 	}
e2e/upgrade_test.go (1)

29-29: Consider making the genesis version configurable.

The hardcoded genesis version might make the test brittle and harder to maintain. Consider making it configurable through a constant or environment variable, especially since this is a testnet upgrade handler.

+const defaultGenesisVersion = "v8.0.0-rc.3-fix"
+
 func TestChainUpgrade(t *testing.T) {
-	genesisVersion := "v8.0.0-rc.3-fix"
+	genesisVersion := os.Getenv("GENESIS_VERSION")
+	if genesisVersion == "" {
+		genesisVersion = defaultGenesisVersion
+	}
e2e/cctp_receive_message_test.go (1)

45-45: Document the NobleSpinUp parameters and return values.

The function call has been updated to include e2e.LocalImages and now returns a second value that's being discarded. Please add comments explaining:

  • The purpose of the e2e.LocalImages parameter
  • What the discarded return value represents
e2e/cctp_receive_message_with_caller_test.go (2)

46-46: Consider handling the ignored return value from NobleSpinUp.

The second return value from NobleSpinUp is being discarded. If this value contains important information (like cleanup functions or error details), it should be properly handled.


Line range hint 1-249: LGTM! Well-structured E2E test implementation.

The test provides comprehensive coverage of the CCTP message flow with proper setup, execution, and verification. It includes:

  • Proper attestation setup and signature handling
  • Token pair linking
  • Minter controller configuration
  • Message construction and verification
  • Balance verification

A few suggestions to enhance the test further:

  1. Consider adding negative test cases (e.g., invalid signatures, wrong message format)
  2. Add cleanup steps to reset the chain state after the test
  3. Consider parameterizing test values (amounts, addresses) for better test maintainability
e2e/cctp_deposit_for_burn_test.go (1)

41-41: LGTM! Consider adding timeout configuration.

The addition of e2e.LocalImages parameter aligns with the PR's objective of modifying the test environment setup.

Consider adding a timeout configuration for NobleSpinUp to ensure test stability:

-	nw, _ := e2e.NobleSpinUp(t, ctx, e2e.LocalImages, true)
+	spinupCtx, cancel := context.WithTimeout(ctx, 5*time.Minute)
+	defer cancel()
+	nw, _ := e2e.NobleSpinUp(t, spinupCtx, e2e.LocalImages, true)
e2e/cctp_deposit_for_burn_with_caller_test.go (1)

Line range hint 27-190: Consider enhancing test coverage with additional scenarios.

While the test thoroughly covers the happy path, consider adding:

  1. Negative test cases (e.g., insufficient balance, invalid addresses)
  2. Edge cases (e.g., zero amounts, maximum amounts)
  3. Table-driven tests for different scenarios

This would provide more comprehensive validation of the CCTP functionality.

e2e/cctp_replace_deposit_for_burn_test.go (1)

Line range hint 1-259: Well-structured and comprehensive test implementation.

The test thoroughly covers the CCTP replace deposit for burn functionality with:

  • Proper setup of attesters and token pairs
  • Comprehensive event verification
  • Strong error handling
  • Clear test flow and assertions

However, consider adding comments to explain the significance of magic numbers and constants:

  • Domain IDs (e.g., SourceDomain: 4)
  • Byte lengths (e.g., make([]byte, 32))
  • Test values (e.g., "12345678901234567890123456789012")
e2e/upgrade_utils.go (3)

57-57: Reconsider the use of t.Parallel() due to potential resource conflicts

Calling t.Parallel() allows the test to run concurrently with other tests. Since this test manipulates shared resources such as Docker containers and network configurations, running it in parallel may lead to resource conflicts, race conditions, or flakiness in tests.

Consider removing t.Parallel() to ensure that the test runs sequentially and does not interfere with other tests:

  if testing.Short() {
      t.Skip()
  }
- t.Parallel()

Alternatively, ensure that the test environment is isolated and that concurrent execution will not cause issues.


91-93: Avoid deferring context cancellation inside loops to prevent resource leaks

Although this instance is not inside a loop, it's good practice to be consistent with context cancellation. Since the context timeoutCtx is only used within a short scope, consider cancelling it immediately after use to release resources promptly.

Modify the code to call timeoutCtxCancel() immediately after it's no longer needed:

  timeoutCtx, timeoutCtxCancel := context.WithTimeout(ctx, time.Second*45)
- defer timeoutCtxCancel()
+
  err = testutil.WaitForBlocks(timeoutCtx, int(blocksAfterUpgrade), noble)
  require.NoError(t, err, "chain did not produce blocks after emergency upgrade")
+ timeoutCtxCancel()

91-96: Refactor duplicated code to improve maintainability

The code for creating a timeout context, waiting for blocks, and handling errors is duplicated in multiple places. This repetition can make the code harder to maintain and more prone to errors.

Consider extracting this logic into a helper function, such as WaitForBlocksWithTimeout, to reduce duplication and improve readability. Here's an example:

func WaitForBlocksWithTimeout(ctx context.Context, duration time.Duration, blocks int, chain *cosmos.CosmosChain) error {
    timeoutCtx, timeoutCtxCancel := context.WithTimeout(ctx, duration)
    defer timeoutCtxCancel()
    return testutil.WaitForBlocks(timeoutCtx, blocks, chain)
}

Then, replace the duplicated code with calls to this helper function:

- timeoutCtx, timeoutCtxCancel := context.WithTimeout(ctx, time.Second*45)
- defer timeoutCtxCancel()
- err = testutil.WaitForBlocks(timeoutCtx, int(blocksAfterUpgrade), noble)
+ err = WaitForBlocksWithTimeout(ctx, time.Second*45, int(blocksAfterUpgrade), noble)
 require.NoError(t, err, "chain did not produce blocks after upgrade")

This refactoring improves code clarity and simplifies future maintenance.

Also applies to: 116-120, 123-128, 136-141, 210-215

e2e/utils.go (4)

Line range hint 118-122: Rename parameters nv and nf for clarity

The parameters nv and nf represent the number of validators and full nodes, respectively. Renaming them to numValidators and numFullNodes would improve code readability and maintainability.


Line range hint 118-122: Consider renaming version parameter to images

The parameter version is an array of ibc.DockerImage. Renaming it to images or dockerImages would make the code more intuitive and better reflect its purpose.


393-395: Update parameter names in NobleSpinUp function

In line with the previous suggestion, consider renaming the version parameter to images for consistency and clarity.


437-440: Consistency in parameter naming for NobleSpinUpIBC

Similarly, update the version parameter to images in the NobleSpinUpIBC function to maintain consistency across the codebase.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d6e1153 and 9ca4f70.

⛔ Files ignored due to path filters (3)
  • e2e/go.mod is excluded by !**/*.mod
  • e2e/go.sum is excluded by !**/*.sum, !**/*.sum
  • go.work.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (19)
  • Makefile (1 hunks)
  • app.go (4 hunks)
  • cmd/init.go (1 hunks)
  • cmd/nobled/main.go (1 hunks)
  • e2e/cctp_deposit_for_burn_test.go (1 hunks)
  • e2e/cctp_deposit_for_burn_with_caller_test.go (1 hunks)
  • e2e/cctp_receive_message_test.go (1 hunks)
  • e2e/cctp_receive_message_with_caller_test.go (1 hunks)
  • e2e/cctp_replace_deposit_for_burn_test.go (1 hunks)
  • e2e/cctp_roles_test.go (4 hunks)
  • e2e/conformance_test.go (1 hunks)
  • e2e/fiat_tf_test.go (21 hunks)
  • e2e/module_check_test.go (1 hunks)
  • e2e/upgrade_test.go (1 hunks)
  • e2e/upgrade_utils.go (1 hunks)
  • e2e/utils.go (8 hunks)
  • upgrade/testnet/constants.go (1 hunks)
  • upgrade/testnet/store.go (1 hunks)
  • upgrade/testnet/upgrade.go (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • cmd/init.go
  • cmd/nobled/main.go
  • e2e/fiat_tf_test.go
  • upgrade/testnet/constants.go
🧰 Additional context used
🪛 Gitleaks
e2e/upgrade_utils.go

38-38: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🔇 Additional comments (19)
e2e/conformance_test.go (1)

31-31: LGTM! Verify consistent usage across test files.

The addition of e2e.LocalImages parameter aligns with the PR's objective of modifying the upgrade handler and test environment setup.

Let's verify that this parameter is consistently used across all test files:

✅ Verification successful

All test files consistently use e2e.LocalImages parameter with NobleSpinUpIBC

The verification shows that all calls to NobleSpinUpIBC in the test files (fiat_tf_test.go and conformance_test.go) consistently use the e2e.LocalImages parameter, matching the function signature defined in utils.go. This confirms the change is properly implemented across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistent usage of e2e.LocalImages parameter in NobleSpinUpIBC calls
# Expected: All calls should use e2e.LocalImages parameter

# Search for NobleSpinUpIBC function calls
rg -A 2 "NobleSpinUpIBC\(" e2e/

Length of output: 928

e2e/module_check_test.go (1)

31-31: LGTM! The NobleSpinUp parameter update looks correct.

The addition of e2e.LocalImages parameter aligns with the changes across other test files.

upgrade/testnet/store.go (3)

1-14: LGTM: License header is properly formatted.

The Apache 2.0 license header is correctly formatted with up-to-date copyright information.


15-22: LGTM: Package and imports are well-organized.

The package name aligns with the directory structure, and imports are properly organized with clear aliases.


25-27: Verify completeness of module additions.

Let's verify that globalfee is the only module that needs to be added during this upgrade.

✅ Verification successful

Based on the search results, I can now generate a final response:

Confirmed: globalfee is the only module that needs to be added in this upgrade

The verification shows that globalfeetypes.ModuleName is the only new module being added in the store upgrades. The search results reveal:

  • The upgrade primarily focuses on migrating GlobalFee legacy params to the new standalone module
  • Other module references in the upgrade files are for existing modules (auth, bank, crisis, etc.) and their parameter migrations
  • No other new module implementations or additions were found in the upgrade process
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any other potential module additions in the upgrade
# by looking for module registration patterns and upgrade-related changes

# Look for module registration patterns
echo "Checking for module registrations..."
rg -A 5 "ModuleBasics.*Register|NewModule|modules\s*:=.*{" app/

# Look for upgrade-related changes mentioning modules
echo "Checking for upgrade-related module changes..."
rg -l "upgrade.*module|module.*upgrade" app/ upgrade/

Length of output: 558


Script:

#!/bin/bash
# Let's try a different approach to verify module additions

# Check for module-related changes in upgrade files
echo "Checking upgrade files for module changes..."
rg -A 5 "Module|store.*upgrade" upgrade/

# Look for any new module implementations or configurations
echo "Looking for new module implementations..."
fd -e go . | xargs rg "type Module struct|func New.*Module"

# Check for module initialization or setup
echo "Checking module initialization patterns..."
fd -e go . | xargs rg "ModuleName.*=|RegisterServices|RegisterModule"

Length of output: 6729

e2e/upgrade_test.go (1)

28-56: Verify testnet compatibility.

The PR objectives mention this is specifically for testnet. Let's ensure the test configuration aligns with testnet requirements.

Makefile (1)

90-90: LGTM! Improved build output visibility.

Removing the output redirection provides better visibility into the heighliner build process, which is helpful for debugging and monitoring the build progress.

e2e/cctp_roles_test.go (1)

Line range hint 37-134: LGTM! The test implementations are consistent and well-structured.

The changes to include e2e.LocalImages are consistently applied across all test functions. Each test follows a clear pattern:

  1. Setup with NobleSpinUp
  2. Create and fund test users
  3. Execute role update transactions
  4. Verify the changes through role queries
e2e/cctp_receive_message_test.go (1)

45-45: Verify consistency of NobleSpinUp usage across test files.

The change to NobleSpinUp appears to be part of a broader standardization effort.

Let's verify that this change has been consistently applied across all test files:

✅ Verification successful

NobleSpinUp usage is consistent across test files

All test files are using the standardized signature with e2e.LocalImages parameter. The only exception is in upgrade_utils.go which uses a genesisImage parameter, but this is expected as it's specifically for upgrade testing.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent usage of NobleSpinUp across test files
# Expected: All calls should use the new signature with e2e.LocalImages

# Search for all NobleSpinUp function calls
rg -U "NobleSpinUp\([^)]+\)" e2e/

Length of output: 2624

e2e/cctp_deposit_for_burn_with_caller_test.go (2)

41-41: LGTM: Using local images for test reproducibility.

The addition of e2e.LocalImages parameter ensures consistent test environment setup using local container images.


Line range hint 27-190: Enhance security validation in test scenarios.

Consider adding security-focused test cases:

  1. Validate behavior with malicious/malformed addresses
  2. Test for potential integer overflow scenarios in amount calculations
  3. Verify proper handling of cross-chain message tampering

These additions would help ensure the CCTP implementation is robust against security threats.

e2e/cctp_replace_deposit_for_burn_test.go (1)

47-47: Verify the impact of LocalImages parameter.

The addition of e2e.LocalImages parameter aligns with the PR objective of modifying the upgrade handler for testnet. However, we should verify that this change is consistently applied across all e2e tests.

✅ Verification successful

All e2e tests consistently use LocalImages parameter

Based on the search results, all instances of NobleSpinUp and NobleSpinUpIBC across the e2e test suite consistently use e2e.LocalImages as the version parameter. The change in cctp_replace_deposit_for_burn_test.go aligns with this standardization.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if all e2e tests use LocalImages parameter consistently
# Expected: All NobleSpinUp calls should use e2e.LocalImages

echo "Checking NobleSpinUp usage across e2e tests..."
rg -A 1 "NobleSpinUp" "e2e/"

Length of output: 5002

app.go (3)

37-37: LGTM!

The import statement has been correctly updated to use the testnet upgrade module.


296-302: LGTM!

The upgrade handler has been appropriately updated to use testnet.UpgradeName and testnet.CreateUpgradeHandler with the necessary parameters.


314-315: LGTM!

The store loader is correctly set for the testnet upgrade using testnet.CreateStoreLoader.

e2e/utils.go (4)

30-33: Verify the correctness of the import paths

Ensure that the import paths for the newly added modules are correct and point to the intended repositories. Specifically, confirm that the import path for florintypes (github.com/monerium/module-noble/v2/types) is accurate and consistent with the project's module structure.


42-45: Constants for Docker configurations added appropriately

The addition of ghcrRepo and containerUidGid constants enhances the configurability for Docker image handling.


48-54: Initialization of LocalImages is well-structured

The LocalImages variable is properly defined with the necessary fields for Docker image configuration.


107-110: New interface registrations enhance encoding support

Registering interfaces for halotypes, auratypes, florintypes, and authoritytypes in NobleEncoding expands the types supported by the encoding configuration.

e2e/upgrade_test.go Show resolved Hide resolved
e2e/upgrade_test.go Outdated Show resolved Hide resolved
e2e/cctp_roles_test.go Show resolved Hide resolved
upgrade/testnet/upgrade.go Show resolved Hide resolved
upgrade/testnet/upgrade.go Show resolved Hide resolved
e2e/upgrade_utils.go Outdated Show resolved Hide resolved
e2e/upgrade_utils.go Show resolved Hide resolved
e2e/upgrade_utils.go Show resolved Hide resolved
e2e/upgrade_utils.go Outdated Show resolved Hide resolved
e2e/upgrade_utils.go Show resolved Hide resolved
johnletey
johnletey previously approved these changes Nov 6, 2024
Copy link
Member

@johnletey johnletey left a comment

Choose a reason for hiding this comment

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

Incredible job here! @boojamya

e2e/upgrade_utils.go Outdated Show resolved Hide resolved
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: 1

🧹 Outside diff range and nitpick comments (3)
app.go (1)

Line range hint 303-322: Overall implementation looks solid.

The upgrade handler implementation is well-structured and follows a clean approach:

  1. Proper separation of upgrade logic into the testnet package
  2. Clear integration of the globalfee module
  3. Appropriate handling of store migrations

The changes align well with the PR objectives of modifying the upgrade handler for the testnet environment.

Consider documenting the upgrade process and any specific testnet considerations in the README or documentation to help other developers understand the upgrade flow.

e2e/upgrade_utils.go (2)

39-45: Add documentation for the ChainUpgrade struct

Providing documentation comments for exported types improves code readability and maintainability.

Consider adding comments to explain the purpose and usage of the ChainUpgrade struct and its fields. For example:

// ChainUpgrade represents an upgrade to be applied to the chain during testing.
type ChainUpgrade struct {
    Image       ibc.DockerImage // The Docker image to use for the upgrade
    UpgradeName string          // The name of the upgrade; if empty, a rolling upgrade is assumed
    Emergency   bool            // Indicates if the upgrade is an emergency
    PreUpgrade  func(t *testing.T, ctx context.Context, noble *cosmos.CosmosChain, authority ibc.Wallet) // Function to run before the upgrade
    PostUpgrade func(t *testing.T, ctx context.Context, noble *cosmos.CosmosChain, authority ibc.Wallet) // Function to run after the upgrade
}

81-88: Handle errors from node operations with detailed logging

In the emergency upgrade path, errors from noble.StopAllNodes(ctx) and noble.StartAllNodes(ctx) are checked using require.NoError, which will fail the test on error but may not provide sufficient context.

Consider adding detailed error handling or logging to provide more information in case of failures. For example:

err := noble.StopAllNodes(ctx)
- require.NoError(t, err, "could not stop nodes for emergency upgrade")
+ if err != nil {
+     t.Fatalf("Failed to stop all nodes for emergency upgrade: %v", err)
+ }

noble.UpgradeVersion(ctx, client, upgrade.Image.Repository, upgrade.Image.Version)

err = noble.StartAllNodes(ctx)
- require.NoError(t, err, "could not start nodes for emergency upgrade")
+ if err != nil {
+     t.Fatalf("Failed to start all nodes after emergency upgrade: %v", err)
+ }

This provides more detailed error messages, which can aid in debugging if the test fails.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0abd62a and 0ff7586.

⛔ Files ignored due to path filters (3)
  • e2e/go.mod is excluded by !**/*.mod
  • e2e/go.sum is excluded by !**/*.sum, !**/*.sum
  • go.work.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (2)
  • app.go (4 hunks)
  • e2e/upgrade_utils.go (1 hunks)
🔇 Additional comments (6)
app.go (3)

37-37: LGTM: Import statement correctly updated for testnet upgrade module.

The import statement is properly formatted and consistent with the module versioning scheme.


321-322: Verify store loader implementation.

The store loader configuration is properly integrated with the upgrade process. Let's verify the implementation of the CreateStoreLoader function.

#!/bin/bash
# Description: Verify the CreateStoreLoader function implementation

# Check the CreateStoreLoader function definition and usage
ast-grep --pattern 'func CreateStoreLoader($_) {
  $$$
}'

# Look for any store-related migrations or configurations
rg -p "CreateStoreLoader" upgrade/testnet/

303-307: Verify upgrade handler configuration and constants.

The upgrade handler is properly configured with the required keepers for the globalfee module integration. However, let's verify the upgrade name constant is properly defined.

✅ Verification successful

Let me try another search strategy to verify the upgrade handler configuration.


Upgrade handler configuration and constants are properly defined

The verification confirms:

  • The upgrade name constant UpgradeName is defined as "v8.0.0-rc.4" in upgrade/testnet/constants.go
  • The CreateUpgradeHandler function in upgrade/testnet/upgrade.go accepts all the required parameters:
    • ModuleManager
    • Configurator
    • InterfaceRegistry
    • GlobalFeeKeeper
    • ParamsKeeper
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the upgrade name constant is properly defined in the testnet package
# and that the CreateUpgradeHandler function accepts the correct parameters.

# Check the upgrade name constant definition
rg -p "UpgradeName.*=.*" upgrade/testnet/

# Verify CreateUpgradeHandler function signature
ast-grep --pattern 'func CreateUpgradeHandler($_) {
  $$$
}'

Length of output: 353


Script:

#!/bin/bash
# Search for UpgradeName constant definition
rg -p "var UpgradeName" upgrade/testnet/

# Search for CreateUpgradeHandler function definition with more context
rg -p "func CreateUpgradeHandler" -A 10 upgrade/testnet/

# Search for any upgrade-related constants
rg -p "const.*[Uu]pgrade" upgrade/testnet/

Length of output: 820

e2e/upgrade_utils.go (3)

90-91: Avoid deferring context cancellation inside loops to prevent resource leaks

Deferring timeoutCtxCancel() inside loops causes the deferred calls to accumulate, delaying their execution until the surrounding function returns. This can lead to resource leaks because the contexts remain active longer than necessary.

This issue was previously noted and is still applicable. Modify the code to call timeoutCtxCancel() immediately after it's no longer needed. For example:

At lines 90-91:

timeoutCtx, timeoutCtxCancel := context.WithTimeout(ctx, time.Second*45)
- defer timeoutCtxCancel()

err = testutil.WaitForBlocks(timeoutCtx, int(blocksAfterUpgrade), noble)
require.NoError(t, err, "chain did not produce blocks after emergency upgrade")
+ timeoutCtxCancel()

Repeat this pattern for all similar instances to ensure that contexts are properly canceled within the loops.

Also applies to: 114-116, 122-123, 135-136, 178-179, 209-210


173-174: 🛠️ Refactor suggestion

Update error message to match the performed action

The error message in require.NoError states "error submitting software upgrade tx," but the code is executing an upgrade plan query using ExecQuery.

Update the error message to accurately reflect the operation being performed:

stdout, stderr, err := noble.Validators[0].ExecQuery(ctx, "upgrade", "plan")
- require.NoError(t, err, "error submitting software upgrade tx")
+ require.NoError(t, err, "error executing 'upgrade plan' query")

Likely invalid or redundant comment.


145-146: Validate the calculated halt height

The halt height is calculated using haltHeight := height + haltHeightDelta. It's important to verify that haltHeight is appropriately set to prevent unintended chain behaviors.

To confirm that the calculated halt height is valid and does not conflict with the current chain parameters, you can run the following script:

This script retrieves the current height and calculates the expected halt height. It also searches the codebase for any occurrences of haltHeight to ensure it's used correctly.

✅ Verification successful

Let me analyze the code further to understand the context of haltHeight calculation.


The halt height calculation is correctly implemented

The code shows that haltHeightDelta is a well-defined constant set to 10 blocks, used in the context of upgrade testing. The calculation haltHeight := height + haltHeightDelta is appropriate as it:

  • Sets the upgrade height 10 blocks in the future from the current height
  • Is used consistently throughout the test framework for upgrade verification
  • Has corresponding validation checks to ensure the upgrade occurs at the correct height
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the calculated halt height is appropriate.

# Get the current chain height
current_height=$(noble height)

# Expected halt height based on the delta
expected_halt_height=$((current_height + 10))

echo "Current Height: $current_height"
echo "Expected Halt Height: $expected_halt_height"

# Optional: Check if halt_height is set correctly in the upgrade plan
grep -rnw '.' -e 'haltHeight' --include \*.go

Length of output: 752


Script:

#!/bin/bash
# Let's examine the full context of how haltHeight and haltHeightDelta are used
rg "haltHeightDelta" -B 5 -A 5 ./e2e/upgrade_utils.go

# Also check how this height is used in test scenarios
ast-grep --pattern 'func $_($t *testing.T, $$$) {
  $$$
  haltHeight := $$$
  $$$
}'

Length of output: 694

e2e/upgrade_utils.go Show resolved Hide resolved
@boojamya boojamya merged commit dd84043 into main Nov 6, 2024
37 checks passed
@boojamya boojamya deleted the dan/upgrade-globalfee branch November 6, 2024 22:33
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.

2 participants