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: fix admin e2e tests and bump protocol contracts #3006

Merged
merged 5 commits into from
Oct 15, 2024

Conversation

skosito
Copy link
Contributor

@skosito skosito commented Oct 15, 2024

Description

  • fix admin tests with latest protocol contracts
  • update erc20 custody on upgrade tests

How Has This Been Tested?

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Summary by CodeRabbit

  • New Features

    • Introduced a new command-line flag for contract upgrades, enhancing clarity in upgrade processes.
    • Added a function for upgrading the ERC20Custody contract.
  • Bug Fixes

    • Updated command-line arguments and method names to improve functionality and consistency.
  • Chores

    • Updated dependencies and Go module version to ensure compatibility and address previous issues.

@skosito skosito added ADMIN_TESTS Run make start-admin-tests UPGRADE_LIGHT_TESTS Run make start-upgrade-test-light no-changelog Skip changelog CI check labels Oct 15, 2024
@skosito skosito added TSS_MIGRATION_TESTS Run TSS migration tests V2_TESTS Run make start-v2-test labels Oct 15, 2024
@skosito skosito changed the title fix: admin e2e tests fix: fix admin e2e tests and bump protocol contracts Oct 15, 2024
@skosito skosito marked this pull request as ready for review October 15, 2024 10:55
Copy link
Contributor

coderabbitai bot commented Oct 15, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request involve renaming command-line flags and updating functionalities related to contract upgrades across multiple files. Key modifications include renaming the flagUpgradeGateways to flagUpgradeContracts, altering the corresponding method calls, and updating related scripts. Additionally, new methods for upgrading contracts have been introduced, and several dependencies have been updated to ensure compatibility with the latest Go version and address previous issues.

Changes

File Path Change Summary
cmd/zetae2e/local/local.go Renamed flagUpgradeGateways to flagUpgradeContracts and updated localE2ETest to call deployerRunner.UpgradeContracts().
contrib/localnet/orchestrator/start-zetae2e.sh Replaced --upgrade-gateways with --upgrade-contracts in two instances.
e2e/runner/v2_upgrade.go Renamed UpgradeGateways method to UpgradeContracts and added UpgradeERC20Custody method.
e2e/runner/v2_setup_evm.go Renamed several variables for clarity regarding proxy contracts: proxyAddress to gatewayProxyAddress, txProxy to gatewayProxyTx, etc.
go.mod Updated Go version from 1.22.2 to 1.22.5, added new dependencies, and replaced several existing ones to ensure compatibility.

Possibly related PRs

Suggested labels

UPGRADE_TESTS

Suggested reviewers

  • fbac
  • swift1337
  • kingpinXD
  • ws4charlie
  • brewmaster012
  • lumtis

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.

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

🧹 Outside diff range and nitpick comments (8)
e2e/runner/v2_upgrade.go (2)

13-18: Function renaming and addition of ERC20Custody upgrade are appropriate.

The renaming of UpgradeGateways to UpgradeContracts accurately reflects the broader scope of contract upgrades. The addition of r.UpgradeERC20Custody() is consistent with the function's purpose.

Consider updating the function comment to be more specific:

// UpgradeContracts upgrades the GatewayZEVM, GatewayEVM, and ERC20Custody contracts
// It deploys new contract implementations with the current imported artifacts and upgrades the contracts

59-76: Addition of UpgradeERC20Custody function is appropriate and well-implemented.

The new UpgradeERC20Custody function correctly implements the upgrade process for the ERC20Custody contract, following the established pattern of other upgrade functions. It includes proper error handling and transaction receipt verification.

For consistency with other upgrade functions, consider renaming the function to UpgradeERC20CustodyEVM:

func (r *E2ERunner) UpgradeERC20CustodyEVM() {
    // ... (rest of the function remains the same)
}

Also, update the call in the UpgradeContracts function accordingly:

func (r *E2ERunner) UpgradeContracts() {
    r.UpgradeGatewayZEVM()
    r.UpgradeGatewayEVM()
    r.UpgradeERC20CustodyEVM()
}
e2e/runner/v2_setup_evm.go (4)

51-52: Approve changes with minor suggestion for consistency

The variable renaming improves code clarity. However, for consistency, consider updating the variable name gatewayEVMAddr to gatewayImplAddr to clearly distinguish it from the proxy address.

- gatewayEVMAddr, txGateway, _, err := gatewayevm.DeployGatewayEVM(r.EVMAuth, r.EVMClient)
+ gatewayImplAddr, txGateway, _, err := gatewayevm.DeployGatewayEVM(r.EVMAuth, r.EVMClient)

Also applies to: 60-61


72-77: Approve changes with suggestion for improved error handling

The updates to the initializer data packing for the ERC20Custody contract are correct and align with the contract's requirements. However, consider adding error checking for the ABI packing operation.

 initializerData, err = erc20CustodyABI.Pack("initialize", r.GatewayEVMAddr, r.TSSAddress, r.Account.EVMAddress())
-require.NoError(r, err)
+if err != nil {
+    return fmt.Errorf("failed to pack initializer data for ERC20Custody: %w", err)
+}

79-84: Approve changes with suggestion for improved error handling

The updates to the ERC20Custody proxy contract deployment logic, including the new variable names, enhance code clarity. Consider adding more robust error handling for the contract instantiation.

 r.ERC20CustodyV2, err = erc20custodyv2.NewERC20Custody(erc20CustodyProxyAddress, r.EVMClient)
-require.NoError(r, err)
+if err != nil {
+    return fmt.Errorf("failed to instantiate ERC20CustodyV2 contract: %w", err)
+}

Also applies to: 88-90


93-93: Approve changes with suggestion for logging consistency

The updates to the logging statement and transaction receipt checks are consistent with the earlier variable renaming. For improved logging consistency, consider updating the ERC20CustodyV2 log message to use the proxy address.

 r.Logger.Info(
     "ERC20CustodyV2 contract address: %s, tx hash: %s",
-    erc20CustodyAddr.Hex(),
+    erc20CustodyProxyAddress.Hex(),
     txCustody.Hash().Hex(),
 )

Also applies to: 113-114

cmd/zetae2e/local/local.go (2)

49-49: Approve flag renaming with a minor suggestion.

The renaming of flagUpgradeGateways to flagUpgradeContracts accurately reflects the shift in functionality. This change enhances code clarity and maintainability.

Consider updating the flag description to provide more context:

-	flagUpgradeContracts  = "upgrade-contracts"
+	flagUpgradeContracts  = "upgrade-contracts" // Set to true to upgrade contracts during setup for ZEVM and EVM

117-117: Approve changes in localE2ETest with a suggestion for error handling.

The modifications in the localE2ETest function are consistent with the flag renaming. The upgrade logic has been correctly adjusted to use UpgradeContracts() instead of UpgradeGateways().

Consider adding error handling for the UpgradeContracts() call:

 	if upgradeContracts {
-		deployerRunner.UpgradeContracts()
+		if err := deployerRunner.UpgradeContracts(); err != nil {
+			logger.Print("❌ Failed to upgrade contracts: %v", err)
+			os.Exit(1)
+		}
 	}

This addition would ensure that any errors during the contract upgrade process are properly logged and handled.

Also applies to: 416-419

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 09e8c3a and 49a70a0.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (5)
  • cmd/zetae2e/local/local.go (4 hunks)
  • contrib/localnet/orchestrator/start-zetae2e.sh (1 hunks)
  • e2e/runner/v2_setup_evm.go (2 hunks)
  • e2e/runner/v2_upgrade.go (2 hunks)
  • go.mod (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
cmd/zetae2e/local/local.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

contrib/localnet/orchestrator/start-zetae2e.sh (1)

Pattern **/*.sh: Review the shell scripts, point out issues relative to security, performance, and maintainability.

e2e/runner/v2_setup_evm.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

e2e/runner/v2_upgrade.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

🔇 Additional comments (12)
e2e/runner/v2_upgrade.go (2)

6-6: Import addition is appropriate.

The addition of the erc20custody.sol import is consistent with the existing import pattern and is necessary for the new UpgradeERC20Custody function.


Line range hint 1-76: Overall file structure and consistency are maintained.

The changes to this file, including the addition of the UpgradeERC20Custody function and the renaming of UpgradeGateways to UpgradeContracts, maintain the overall structure and consistency of the file. Error handling and logging patterns are consistent across all upgrade functions.

e2e/runner/v2_setup_evm.go (1)

65-69: Approve changes for improved clarity

The updates to the ERC20Custody contract deployment logic, including the variable renaming, enhance code readability while maintaining the original functionality.

contrib/localnet/orchestrator/start-zetae2e.sh (4)

Line range hint 1-124: The initial setup and structure are well-organized and comprehensive.

The script demonstrates good practices in shell scripting, including:

  • Proper shebang and shellcheck disable
  • Well-defined functions for version retrieval and config reading
  • Comprehensive setup for funding various accounts on the local Ethereum network

These elements contribute to a robust foundation for the end-to-end testing process.


Line range hint 1-301: Summary of changes and recommendations for start-zetae2e.sh

The primary modification in this script is the transition from gateway upgrades to contract upgrades. This change, while seemingly straightforward, may have significant implications for the testing process and potentially the broader system.

Key points and recommendations:

  1. The change from --upgrade-gateways to --upgrade-contracts has been consistently applied in the upgrade mode section.
  2. The TSS migration mode remains unchanged, but its compatibility with the new contract upgrade process should be verified.
  3. It's crucial to ensure that all dependent systems and documentation are updated to reflect this change in the upgrade process.
  4. Consider adding comments to explain the rationale behind this change and its expected impact on the testing process.
  5. A thorough testing of the new contract upgrade process is recommended to ensure it behaves as expected and doesn't introduce any regressions.

To ensure a smooth transition, please verify the following:

  1. The zetae2e command correctly handles the new --upgrade-contracts flag.
  2. All relevant documentation has been updated to reflect this change.
  3. Any CI/CD pipelines or automated tests that rely on this script have been adjusted accordingly.

These verifications will help maintain the integrity of the testing process and ensure that the change is fully integrated into the existing infrastructure.


261-263: 🛠️ Refactor suggestion

Ensure consistency and understand implications of switching to contract upgrades.

The script has been modified to use --upgrade-contracts instead of --upgrade-gateways. This change suggests a shift in the upgrade process from focusing on gateways to contracts.

While the modification has been applied consistently in both scenarios (upgrade height < 100 and >= 100), it's crucial to verify the following:

  1. The zetae2e command supports this new flag and behaves as expected.
  2. The implications of upgrading contracts instead of gateways are fully understood and documented.
  3. Any dependent systems or scripts that may rely on the previous gateway upgrade process have been updated accordingly.

To ensure the change has been applied consistently throughout the codebase, please run the following command:

#!/bin/bash
# Check for any remaining instances of gateway upgrades
grep -R "upgrade.*gateway" .

# Verify the usage of the new contract upgrade flag
grep -R "upgrade.*contract" .

Consider adding a comment explaining the rationale behind this change and its expected impact on the testing process. This will help future maintainers understand the context of this modification.


Line range hint 126-165: Verify TSS migration mode compatibility with contract upgrades.

The TSS migration mode remains unchanged in this update. While this suggests that it may not be directly affected by the switch from gateway upgrades to contract upgrades, it's crucial to ensure its continued compatibility with the new upgrade process.

Please confirm that the TSS migration process is still valid and compatible with the new contract upgrade mechanism. Consider running the following commands to verify:

cmd/zetae2e/local/local.go (1)

87-87: Flag registration updated correctly.

The flag registration has been properly updated to use flagUpgradeContracts, maintaining consistency with the earlier renaming. The description accurately conveys the flag's purpose.

go.mod (4)

Line range hint 366-385: Clarify the necessity of replace directives and document their purpose.

The addition and modification of several replace directives, particularly those pointing to ZetaChain maintained forks, raises some concerns:

  1. While replace directives can be useful for using forked versions or specific commits, they can make the project harder to maintain and upgrade in the future.
  2. It's important to understand the specific reasons for each replacement and whether there's a plan to contribute these changes back to the original repositories.

Please provide clarification on the following:

  1. The specific reasons for each replacement, especially those pointing to ZetaChain forks.
  2. Any plans to contribute the changes in these forks back to the original repositories.
  3. The potential impact of these replacements on the project's maintainability and future upgrades.

Additionally, consider documenting the purpose and necessity of these replacements in the project's documentation to aid future maintenance decisions.

To assist in understanding the impact of these replacements, please run the following script:

#!/bin/bash
# Description: Find usage of replaced packages in the codebase

for package in $(grep "^replace" go.mod | awk '{print $2}'); do
  echo "Usage of $package:"
  rg --type go "$package" -A 5
done

62-62: Clarify the purpose of new dependencies and document their usage.

The addition of new dependencies (github.com/bnb-chain/tss-lib, github.com/showa-93/go-mask, and github.com/tonkeeper/tongo) may introduce new functionality, but it also increases the complexity of the project. Please provide clarification on the following:

  1. The specific use case for each new dependency in the project.
  2. Why these particular libraries were chosen over potential alternatives.
  3. Any potential impact on the project's performance or security.

Additionally, consider documenting the purpose and usage of these dependencies in the project's documentation to aid future maintenance.

To assist in understanding the usage of these new dependencies, please run the following script:

Also applies to: 353-357

✅ Verification successful

New dependencies are actively utilized within the codebase.

The dependencies github.com/bnb-chain/tss-lib, github.com/showa-93/go-mask, and github.com/tonkeeper/tongo are extensively used across multiple components, including but not limited to:

  • github.com/bnb-chain/tss-lib

    • zetaclient/tss/tss_signer.go
    • cmd/zetaclientd/main.go
    • cmd/zetaclientd/gen_pre_params.go
  • github.com/showa-93/go-mask

    • zetaclient/config/types.go
  • github.com/tonkeeper/tongo

    • Various files within zetaclient/testutils/mocks/, zetaclient/orchestrator/, zetaclient/chains/ton/observer/, and others.

This widespread integration confirms that the new dependencies are necessary for the project's functionality and complexity is justified.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find usage of new dependencies in the codebase

echo "Usage of github.com/bnb-chain/tss-lib:"
rg --type go "github.com/bnb-chain/tss-lib" -A 5

echo "Usage of github.com/showa-93/go-mask:"
rg --type go "github.com/showa-93/go-mask" -A 5

echo "Usage of github.com/tonkeeper/tongo:"
rg --type go "github.com/tonkeeper/tongo" -A 5

Length of output: 675


Script:

#!/bin/bash
# Description: Find usage of new dependencies in the codebase

echo "Usage of github.com/bnb-chain/tss-lib:"
rg --type go "github\\.com/bnb-chain/tss-lib" -A 5

echo "Usage of github.com/showa-93/go-mask:"
rg --type go "github\\.com/showa-93/go-mask" -A 5

echo "Usage of github.com/tonkeeper/tongo:"
rg --type go "github\\.com/tonkeeper/tongo" -A 5

Length of output: 13501


Line range hint 3-5: Approve Go version update with compatibility verification.

The update to Go 1.22.5 is a positive change, incorporating the latest language features and bug fixes. However, it is crucial to ensure that all dependencies and the codebase are compatible with this version.

To verify compatibility, please run the following script:


62-62: Approve dependency update with breaking changes verification.

The update of github.com/zeta-chain/protocol-contracts to version v1.0.2-athens3.0.20241014093550-f7f6d9fd971a is noted. While updating dependencies is generally beneficial for bug fixes and new features, it's crucial to verify that this update doesn't introduce any breaking changes.

To check for potential breaking changes, please run the following script:

cmd/zetae2e/local/local.go Show resolved Hide resolved
@skosito skosito linked an issue Oct 15, 2024 that may be closed by this pull request
cmd/zetae2e/local/local.go Outdated Show resolved Hide resolved
cmd/zetae2e/local/local.go Outdated Show resolved Hide resolved
@skosito skosito enabled auto-merge October 15, 2024 14:54
@skosito skosito removed UPGRADE_LIGHT_TESTS Run make start-upgrade-test-light ADMIN_TESTS Run make start-admin-tests TSS_MIGRATION_TESTS Run TSS migration tests V2_TESTS Run make start-v2-test labels Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking:cli no-changelog Skip changelog CI check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

V2 ERC20 Custody contract pause is incompatible with V1
3 participants