Skip to content

feat: add support for deposits using the v2 connector contract #3990

Merged
kingpinXD merged 57 commits intodevelopfrom
connector-v2-migration-deposit
Jul 9, 2025
Merged

feat: add support for deposits using the v2 connector contract #3990
kingpinXD merged 57 commits intodevelopfrom
connector-v2-migration-deposit

Conversation

@kingpinXD
Copy link
Member

@kingpinXD kingpinXD commented Jun 19, 2025

Description

Partially closses #3947
The withdraw tests will be added in a separate PR to make the review easier

This PR

  • Adds support for deposit and depositAndCall using the new connector contract
  • Add e2e tests to test this functionality

The PR is ready to be reviewed; however, unit test coverage for some of the functions will be added soon

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

    • Added comprehensive support for ZETA token deposits, withdrawals, and aborts in protocol V2, including new end-to-end tests for ZETA workflows.
    • Enabled ZETA token handling in deposit-and-call, revert, and abort scenarios across smart contracts and cross-chain transactions.
    • Introduced new account configuration for ZETA testing and updated related funding scripts.
  • Improvements

    • Enhanced outbound event parsing and voting to support both legacy and native connector contracts.
    • Improved contract ABIs to allow payable functions for ZETA-related operations.
    • Refined test coverage and configuration for ZETA token scenarios.
  • Bug Fixes

    • Corrected and expanded outbound type detection for ZETA transactions.
  • Chores

    • Updated dependencies and improved code formatting and documentation.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 19, 2025

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 set of changes introduces comprehensive support for ZETA token operations within the protocol, including deposit, call, revert, and abort flows in both the core and E2E testing infrastructure. The update refactors deposit logic by coin type, enhances connector contract handling, and extends outbound event parsing and signing to accommodate ZETA-specific scenarios. Multiple new E2E tests and contract modifications ensure robust coverage and validation of these flows.

Changes

File(s) / Path(s) Change Summary
Makefile Updated connector migration test target message and flags.
cmd/zetae2e/config/contracts.go, x/crosschain/keeper/cctx_orchestrator_validate_outbound.go, x/fungible/keeper/gas_coin_and_pool_test.go Minor formatting (blank lines), no logic changes.
cmd/zetae2e/config/local.yml, cmd/zetae2e/config/localnet.yml Added user_zeta account entry with addresses and private key.
cmd/zetae2e/local/evm.go Added Zeta token workflow to EVM tests, including funding and test routines.
cmd/zetae2e/local/local.go Updated protocol contract update logic to accept testLegacy flag; removed redundant block.
contrib/localnet/orchestrator/start-zetae2e.sh Added funding step for user_zeta EVM address.
e2e/config/config.go Added UserZeta to AdditionalAccounts, updated slice and key generation methods.
e2e/contracts/testabort/TestAbort.* Made onAbort function payable in ABI, Go bindings, and Solidity contract.
e2e/contracts/testdappv2/TestDAppV2.* Made onCall function payable in ABI, Go bindings, and Solidity contract.
e2e/e2etests/e2etests.go Added and registered multiple new ZETA deposit and call E2E tests.
e2e/e2etests/test_migrate_connector_funds.go Removed unused updateChainParams function.
e2e/e2etests/test_zeta_deposit.go Refactored to use explicit receiver address and balance assertions.
e2e/e2etests/test_zeta_deposit_and_call.go, e2e/e2etests/test_zeta_deposit_and_call_revert.go, e2e/e2etests/test_zeta_deposit_and_call_revert_with_call.go, e2e/e2etests/test_zeta_deposit_revert_and_abort.go Added new E2E tests for ZETA deposit, call, revert, and abort scenarios.
e2e/runner/accounting.go Updated ZETA TSS balance check to sum balances from legacy and new connectors.
e2e/runner/evm.go Added methods for ZETA deposit-and-call and ZETA token transfer on EVM.
e2e/runner/runner.go Improved contract address log formatting; added ZetaAddress() method.
e2e/runner/setup_evm.go Re-enabled connector setting in gateway contract.
e2e/runner/setup_zevm.go Updated protocol contract update method to accept testLegacy flag.
go.mod Updated protocol-contracts dependency; downgraded go-tss.
x/crosschain/keeper/evm_deposit.go Refactored ZETA coin deposit logic to distinguish V1 and V2 flows.
x/fungible/keeper/deposits.go Refactored deposit logic by coin type; enabled ZETA deposit/abort in V2; modularized handling.
x/fungible/keeper/deposits_test.go Added/modified tests for ZETA coin type deposit and abort scenarios.
x/fungible/keeper/evm.go Added DepositZeta method for ZETA token deposit via EVM.
x/fungible/keeper/evm_gateway.go Added DepositAndCallZeta method; fixed method name in revert call.
zetaclient/chains/evm/common/cctx.go Added new outbound types for ZETA; updated parsing logic.
zetaclient/chains/evm/common/cctx_test.go Added/updated test cases for new outbound types and scenarios.
zetaclient/chains/evm/common/constant.go Added constant for Zeta connector withdraw event topics.
zetaclient/chains/evm/observer/inbound.go Switched to using legacy connector contract in inbound processing.
zetaclient/chains/evm/observer/observer.go Separated legacy and native connector contract retrieval methods.
zetaclient/chains/evm/observer/outbound.go Extended outbound logic to handle both legacy and native connectors; updated function signatures.
zetaclient/chains/evm/observer/v2_inbound.go Centralized coin type determination logic; added ZETA recognition.
zetaclient/chains/evm/observer/v2_inbound_test.go Added tests for coin type determination function.
zetaclient/chains/evm/observer/v2_outbound.go Added ZETA custody withdraw event parsing and handling; updated event parser.
zetaclient/chains/evm/signer/v2_sign.go Added ZETA connector withdraw and revert signing methods.
zetaclient/chains/evm/signer/v2_signer.go Integrated ZETA withdraw/revert signing into outbound signing logic.
zetaclient/zetacore/client_test.go Cleaned up duplicate imports.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant E2ERunner
    participant GatewayEVM
    participant ZetaConnectorNative
    participant ZEVM
    participant Observer
    participant Signer

    User->>E2ERunner: Initiate ZETA deposit and call
    E2ERunner->>GatewayEVM: DepositAndCall0 (ZETA, receiver, amount, payload, revertOpts)
    GatewayEVM->>ZetaConnectorNative: depositAndCall (amount, target, message)
    ZetaConnectorNative->>ZEVM: Mint ZETA, execute contract call
    ZEVM-->>ZetaConnectorNative: Execution result (success/revert/abort)
    ZetaConnectorNative-->>GatewayEVM: Event logs (Withdrawn, Reverted, Aborted)
    Observer->>ZetaConnectorNative: Parse event logs for outbound status
    Observer->>Signer: Sign outbound/revert transaction if confirmed
    Signer->>ZetaConnectorNative: Submit signed transaction
    ZetaConnectorNative-->>ZEVM: Finalize token transfer or revert/abort handling
Loading

Possibly related PRs

  • zeta-chain/node#2661: Updates TSS addresses on connectors and custody contracts, refactors migration test routines; both PRs involve connector migration testing.
  • zeta-chain/node#3976: Adds an end-to-end test for connector fund migration and integrates it into the test workflow and Makefile; both PRs modify E2E test infrastructure for connector migration.
  • zeta-chain/node#3321: Fixes revert handling for invalid withdraws in crosschain call processing; shares concerns with ZETA token support and revert logic.

Suggested labels

zetaclient, zetacore, chain:bitcoin, ADMIN_TESTS

Suggested reviewers

  • lumtis
  • swift1337
  • ws4charlie

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

@github-actions github-actions bot added ci Changes to CI pipeline or github actions breaking:cli labels Jun 19, 2025
@kingpinXD kingpinXD changed the base branch from develop to connector-v2-migration-contract-only June 19, 2025 04:14
@kingpinXD kingpinXD added this pull request to the merge queue Jul 8, 2025
@github-actions github-actions bot added the MERGE_FAILED Merge Queue CI failed label Jul 8, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 8, 2025
@kingpinXD kingpinXD added this pull request to the merge queue Jul 8, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 8, 2025
@kingpinXD kingpinXD added the ADMIN_UPGRADE_TESTS Run make start-upgrade-test-admin label Jul 9, 2025
@kingpinXD kingpinXD enabled auto-merge July 9, 2025 06:00
@kingpinXD kingpinXD added this pull request to the merge queue Jul 9, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jul 9, 2025
* update go mod

* add a new message for migrating funds

* add migrate funds to e2e

* rebase from develop

* add v2 e2e test to check flow

* add zeta gateway deposit to zetaclient

* add github workflow

* update comments

* fix code formating

* fix code formating

* fix code formating

* fix unit tests

* fix unit tests

* revert to old command to start e2e test

* remove message for migration and refactor to using contract directly

* add changelog

* generate files after removing new message

* update generated files

* update generated files

* update go mod

* update deposit

* add unit tests

* add unit tests

* generate files

* generate files

* undo changes based on develop

* update deposit and revert smart contract call

* rename zeta deposit test file

* rename zeta deposit test file

* add abort and revert tests

* add TestZetaDepositAndCallNoMessage

* add TestZetaDepositAndCallNoMessage

* remove payable from TestAbort contract

* rename to LegacyZETADepositAndCallContract

* improve unit test coverage

* fix unit tests

* add some delay in TestZetacore_SubscribeNewBlocks

* update comment for handling zeta token zrc20

* resolve comments

* rebase develop

* refactor to errors.Wrap for all instances of fmt.Errorf

* update zeta tests minimum version

* refactor TestCrosschainSwap

* refactor TestCrosschainSwap

* fix admin upgrade e2e
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 9, 2025
@kingpinXD kingpinXD enabled auto-merge July 9, 2025 17:14
@kingpinXD kingpinXD added this pull request to the merge queue Jul 9, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 9, 2025
@kingpinXD kingpinXD enabled auto-merge July 9, 2025 20:05
@kingpinXD kingpinXD added this pull request to the merge queue Jul 9, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 9, 2025
@kingpinXD kingpinXD added this pull request to the merge queue Jul 9, 2025
Merged via the queue into develop with commit c5675d4 Jul 9, 2025
47 of 48 checks passed
@kingpinXD kingpinXD deleted the connector-v2-migration-deposit branch July 9, 2025 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ADMIN_UPGRADE_TESTS Run make start-upgrade-test-admin breaking:cli LEGACY_TESTS Run make start-legacy-test MERGE_FAILED Merge Queue CI failed UPGRADE_TESTS Run make start-upgrade-tests V2_CONNECTOR_MIGRATION_TESTS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants