Skip to content

test: update tss address on connectors and custody contracts#2661

Merged
kingpinXD merged 33 commits intodevelopfrom
update-connectors
Aug 22, 2024
Merged

test: update tss address on connectors and custody contracts#2661
kingpinXD merged 33 commits intodevelopfrom
update-connectors

Conversation

@kingpinXD
Copy link
Member

@kingpinXD kingpinXD commented Aug 8, 2024

Description

  • Update Erc20Custody and Connector contract addresses after migration is is complete
  • Improve the TSS migration test to run the entire suite instead of just a few tests

Closes: #2443
#2444

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 structured testing workflows for "migrate" and "upgrade" scenarios in end-to-end tests.
    • Enhanced functionality for updating TSS addresses in Ethereum smart contracts.
  • Bug Fixes

    • Increased gas limit for transactions in the TestMessagePassingRevertFailExternalChains function, improving transaction execution success.
  • Documentation

    • Updated changelog to reflect recent changes in connector and ERC20 custody addresses for TSS migration tests.
  • Style

    • Minor formatting improvements across various test functions for better readability.
  • Chores

    • Increased default context timeout duration to enhance system robustness.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 8, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

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

Walkthrough

Walkthrough

This update introduces enhancements to the migration and testing functionalities within the codebase, particularly focusing on TSS (Threshold Signature Scheme) migrations. Key changes include improvements to environment variable management, restructuring of migration functions, updates to end-to-end (e2e) tests, and modifications to logging and error handling. Overall, the changes aim to refine the testing workflow, ensure accurate configuration, and bolster the robustness of the migration process.

Changes

Files Change Summary
Makefile, changelog.md Added environment variable for migration tests and updated changelog to reflect recent test modifications.
cmd/zetae2e/local/local.go, cmd/zetae2e/local/migration.go Renamed functions to reflect broader functionality and streamlined migration logic.
contrib/localnet/orchestrator/start-zetae2e.sh Enhanced script to handle e2e tests for "migrate" and "upgrade" modes with structured workflows.
e2e/e2etests/test_crosschain_swap.go, e2e/e2etests/test_message_passing_external_chains_revert_fail.go, e2e/e2etests/test_migrate_tss.go, e2e/e2etests/test_zrc20_swap.go Minor updates for logging, formatting, and adjustments to gas limits and UTXO handling within tests.
e2e/runner/update_contracts.go Introduced functions for updating TSS addresses in smart contracts, enhancing functionality.
e2e/utils/zetacore.go Increased the default context timeout for operations, improving robustness.
testutil/keeper/mocks/crosschain/observer.go Added mock functions to enhance testing capabilities related to foreign chains.
x/crosschain/keeper/msg_server_add_outbound_tracker.go Minor formatting change with no functional impact.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LocalNet
    participant MigrationService
    participant E2ETests
    participant SmartContract

    User->>LocalNet: Start e2e test in migrate mode
    LocalNet->>MigrationService: Check for deployed.yml
    alt Not Found
        MigrationService->>LocalNet: Execute setup command
        LocalNet-->>User: Setup successful
    end
    MigrationService->>E2ETests: Run pre-migration tests
    E2ETests-->>MigrationService: Tests successful
    MigrationService->>SmartContract: Update TSS addresses
    SmartContract->>MigrationService: Transaction receipt
    MigrationService->>E2ETests: Run post-migration tests
    E2ETests-->>LocalNet: Verify TSS address functionality
    LocalNet-->>User: E2E tests completed
Loading

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 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.

@codecov
Copy link

codecov bot commented Aug 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.91%. Comparing base (1d5cee1) to head (01587c2).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #2661   +/-   ##
========================================
  Coverage    66.90%   66.91%           
========================================
  Files          364      364           
  Lines        20458    20461    +3     
========================================
+ Hits         13688    13691    +3     
  Misses        6143     6143           
  Partials       627      627           
Files Coverage Δ
.../crosschain/keeper/msg_server_migrate_tss_funds.go 87.83% <100.00%> (+0.51%) ⬆️
x/crosschain/types/cmd_cctxs.go 97.48% <100.00%> (ø)

@kingpinXD kingpinXD marked this pull request as ready for review August 9, 2024 01:36
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, codebase verification and nitpick comments (3)
e2e/e2etests/test_crosschain_swap.go (1)

28-28: Improve logging readability.

The logging statement for the error message when creating a pair in the Uniswap factory has been reformatted for better readability. While this does not affect functionality, it enhances clarity in the logs.

-		r.Logger.Print("ℹ️ create pair error")
+		r.Logger.Print("ℹ️  create pair error")
contrib/localnet/orchestrator/start-zetae2e.sh (2)

98-127: Enhance error handling for migration mode.

In the "migrate" mode, consider adding more detailed error messages or logs to help diagnose issues if the setup or tests fail. This will improve the maintainability and debuggability of the script.

# Example: Enhance error logging
echo "e2e setup failed at $(date)" >&2

Line range hint 131-209:
Improve maintainability by consolidating repeated code.

The script contains repeated logic for setting up and running tests in both "migrate" and "upgrade" modes. Consider refactoring these sections into functions to improve maintainability and reduce duplication.

# Example: Define a function for e2e setup
function run_e2e_setup() {
  if [[ ! -f deployed.yml ]]; then
    zetae2e local $E2E_ARGS --setup-only --config config.yml --config-out deployed.yml --skip-header-proof
    if [ $? -ne 0 ]; then
      echo "e2e setup failed"
      exit 1
    fi
  else
    echo "skipping e2e setup because it has already been completed"
  fi
}

# Use the function in both modes
run_e2e_setup
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f78ff55 and 865f565.

Files selected for processing (13)
  • Makefile (1 hunks)
  • changelog.md (1 hunks)
  • cmd/zetae2e/local/local.go (3 hunks)
  • cmd/zetae2e/local/migration.go (1 hunks)
  • contrib/localnet/orchestrator/start-zetae2e.sh (3 hunks)
  • e2e/e2etests/test_crosschain_swap.go (4 hunks)
  • e2e/e2etests/test_message_passing_external_chains_revert_fail.go (2 hunks)
  • e2e/e2etests/test_migrate_tss.go (2 hunks)
  • e2e/e2etests/test_zrc20_swap.go (1 hunks)
  • e2e/runner/update_contracts.go (1 hunks)
  • e2e/utils/zetacore.go (1 hunks)
  • testutil/keeper/mocks/crosschain/observer.go (1 hunks)
  • x/crosschain/keeper/msg_server_add_outbound_tracker.go (1 hunks)
Files skipped from review due to trivial changes (4)
  • cmd/zetae2e/local/migration.go
  • e2e/e2etests/test_migrate_tss.go
  • e2e/e2etests/test_zrc20_swap.go
  • x/crosschain/keeper/msg_server_add_outbound_tracker.go
Additional context used
Path-based instructions (7)
e2e/runner/update_contracts.go (1)

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

e2e/e2etests/test_message_passing_external_chains_revert_fail.go (1)

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

e2e/e2etests/test_crosschain_swap.go (1)

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

e2e/utils/zetacore.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.

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

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

testutil/keeper/mocks/crosschain/observer.go (1)

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

Additional comments not posted (11)
e2e/runner/update_contracts.go (2)

11-25: Well-structured function with robust error handling.

The UpdateTssAddressForConnector function efficiently updates the TSS address, logs the transaction, and verifies the update. The use of require.NoError ensures that any errors are caught immediately, maintaining robustness.


27-40: Consistent and correct implementation.

The UpdateTssAddressForErc20custody function follows a pattern similar to UpdateTssAddressForConnector, ensuring consistency across updates. The error handling and logging are appropriately implemented.

e2e/e2etests/test_message_passing_external_chains_revert_fail.go (1)

43-43: Verify the increased DestinationGasLimit.

The DestinationGasLimit has been increased from 400,000 to 1,800,000. Ensure this change is intentional and aligns with the test's objectives, as it may affect transaction execution and cost.

e2e/e2etests/test_crosschain_swap.go (2)

18-19: Enhance test setup with local Bitcoin mining.

The addition of r.MineBlocksIfLocalBitcoin() at the start of the function ensures that local Bitcoin blocks are mined during the test, enhancing the setup for cross-chain scenarios. This change improves the reliability of the test environment.


146-147: Dynamic UTXO handling enhances flexibility.

The change to dynamically retrieve UTXOs using r.ListDeployerUTXOs() ensures that the most current state is utilized, enhancing the flexibility and accuracy of the test.

e2e/utils/zetacore.go (1)

23-23: Verify the impact of increased timeout duration.

The DefaultCctxTimeout has been increased from 4 * time.Minute to 6 * time.Minute. Ensure that this change aligns with the intended use cases and does not lead to unintended side effects, such as prolonged wait times in failure scenarios.

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

Line range hint 409-435:
Verify robustness and dependencies of TSS migration logic.

The migration logic has been streamlined, focusing on the TSS address update process. Ensure that all dependencies are correctly handled and that the migration process is robust against failures or interruptions.

Verification successful

Ensure Robust Error Handling in runTSSMigration Function

The runTSSMigration function relies on external services for critical operations such as fetching the last Zeta height and updating the keygen. Ensure that all potential errors from these services are properly handled and logged to maintain robustness in the TSS migration process. Consider implementing retry mechanisms or fallback strategies if necessary.

  • Location: cmd/zetae2e/local/local.go at lines where LastZetaHeight and UpdateKeygen are called.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the robustness and dependencies of the TSS migration logic.

# Test: Search for all usages and dependencies of `runTSSMigration`. Expect: Ensure all dependencies are correctly handled.
rg --type go 'runTSSMigration'

Length of output: 255


Script:

#!/bin/bash
# Description: Examine dependencies and error handling within the `runTSSMigration` function.

# Look for the implementation or definition of `LastZetaHeight` to understand its behavior and error handling.
ast-grep --lang go --pattern 'func LastZetaHeight($_, $_) $_ { $$$ }'

# Look for the implementation or definition of `UpdateKeygen` to understand its behavior and error handling.
ast-grep --lang go --pattern 'func UpdateKeygen($_) $_ { $$$ }'

Length of output: 137


Script:

#!/bin/bash
# Description: Search for the definitions or usages of `LastZetaHeight` and `UpdateKeygen` in the codebase.

# Search for any references to `LastZetaHeight` to find its definition or usage.
rg --type go 'LastZetaHeight'

# Search for any references to `UpdateKeygen` to find its definition or usage.
rg --type go 'UpdateKeygen'

Length of output: 22274

Makefile (1)

266-266: Environment variable addition is appropriate.

The addition of export LOCALNET_MODE=migrate in the start-tss-migration-test target is a suitable enhancement for configuring the local network mode during migration tests.

testutil/keeper/mocks/crosschain/observer.go (2)

607-625: Mock function GetSupportedForeignChains is well-implemented.

The function enhances testing flexibility by allowing the simulation of interactions related to supported foreign chains. It adheres to the existing pattern for mock functions.


627-645: Mock function GetSupportedForeignChainsByConsensus is well-implemented.

This function extends the mocking capabilities by incorporating consensus-based filtering, which is useful for more specific testing scenarios. It maintains consistency with other mock functions.

changelog.md (1)

16-19: Changelog entry is clear and informative.

The addition under the "Tests" section effectively documents the update of connector and ERC20 custody addresses in TSS migration e2e tests, enhancing the clarity of recent changes.

@gartnera gartnera added the TSS_MIGRATION_TESTS Run TSS migration tests label Aug 13, 2024
@kingpinXD kingpinXD removed the TSS_MIGRATION_TESTS Run TSS migration tests label Aug 19, 2024
@kingpinXD kingpinXD requested a review from lumtis August 19, 2024 22:38
@gartnera gartnera added the TSS_MIGRATION_TESTS Run TSS migration tests label Aug 20, 2024
@kingpinXD kingpinXD requested a review from a team as a code owner August 22, 2024 14:25
@github-actions github-actions bot added the ci Changes to CI pipeline or github actions label Aug 22, 2024
@kingpinXD kingpinXD enabled auto-merge August 22, 2024 14:56
@kingpinXD kingpinXD requested a review from lumtis August 22, 2024 14:56
@kingpinXD kingpinXD added this pull request to the merge queue Aug 22, 2024
Merged via the queue into develop with commit 1ad2bde Aug 22, 2024
@kingpinXD kingpinXD deleted the update-connectors branch August 22, 2024 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking:cli ci Changes to CI pipeline or github actions TSS_MIGRATION_TESTS Run TSS migration tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option to rerun entire test suite after TSS migration Add Connector and ERC20 custody contract update for TSS migration test

5 participants