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

refactor: use protocol contracts V2 with TON deposits #3439

Merged
merged 8 commits into from
Feb 19, 2025

Conversation

lumtis
Copy link
Member

@lumtis lumtis commented Jan 30, 2025

Description

Closes #2967

Summary by CodeRabbit

  • New Features

    • Introduced an advanced abort workflow with support for multiple confirmation counts.
    • Added enhancements to track cross-chain transactions and display additional chain details.
    • Rolled out new message types for inbound tracking and token name/symbol updates.
  • Refactor

    • Streamlined deposit processing by simplifying memo and transaction data handling.
  • Bug Fixes

    • Resolved issues causing test failures, duplicate event processing, and key signing spam.
  • Tests

    • Expanded simulation and end-to-end tests to verify the new functionalities.

Copy link
Contributor

coderabbitai bot commented Jan 30, 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

The pull request updates the changelog with new features such as support for an advanced abort workflow (including a new onAbort), a ConfirmationParams field, integration of a new ConfirmationMode enum, and additional commands and message types. It also refines TON deposit and call logic by simplifying memo construction and status checking, modifies memo methods in related gateway messages, and restructures TON inbound transaction data handling by introducing an inboundData struct. Corresponding adjustments were made in test assertions to reflect these changes.

Changes

Files Summary
changelog.md Updated changelog documenting new features (advanced abort workflow with onAbort, ConfirmationParams, ConfirmationMode enum, new commands like track-cctx, new message types such as MsgRemoveInboundTracker and MsgUpdateZRC20Name), significant refactoring in zetaclient, and inclusion of tests and protocol contracts V2 integration.
e2e/runner/ton.go Simplified the TONDepositAndCall method by eliminating the intermediate memo construction and using callData directly for filtering; now initializes expected status to CctxStatus_OutboundMined to ensure proper cross-chain transaction state.
pkg/contracts/ton/gateway_msg.go Modified Memo methods in both Deposit and DepositAndCall structs to remove recipient bytes; the Deposit now returns an empty byte slice, while DepositAndCall returns only CallData, thereby simplifying memo content.
zetaclient/chains/ton/observer/inbound.go Introduced a new inboundData struct to encapsulate deposit details; updated extractInboundData to return this struct; and modified voteInbound and voteDeposit to accept inboundData instead of individual parameters for enhanced clarity and cleaner code.
zetaclient/chains/ton/observer/inbound_test.go Adjusted test assertions for inbound transactions: for the "Deposit" and "Deposit and call" cases, validations now check that cctx.Message is an empty string or the hexadecimal representation of CallData, and cctx.Receiver matches the hexadecimal formatted deposit recipient; similar changes were made in the "TestInboundTracker" test case.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant R as E2ERunner
    participant T as TON Chain
    U->>R: Initiate TONDepositAndCall
    R->>T: Submit TON depositAndCall transaction
    T-->>R: Return transaction details (callData)
    R->>R: Filter: Compare callData with cctx.RelayedMessage
    R->>T: Wait for cctx status to be OutboundMined
Loading
sequenceDiagram
    participant T as TON Node
    participant O as Observer
    participant V as Vote System
    T->>O: Transmit inbound deposit transaction
    O->>O: Execute extractInboundData(tx) → inboundData
    O->>V: Call voteInbound(inboundData)
    V-->>O: Return vote result
Loading

Possibly related PRs

Suggested labels

breaking:proto, SOLANA_TESTS

Suggested reviewers

  • skosito
  • brewmaster012
  • swift1337
  • fbac

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

codecov bot commented Jan 30, 2025

Codecov Report

Attention: Patch coverage is 90.62500% with 3 lines in your changes missing coverage. Please review.

Project coverage is 64.63%. Comparing base (9092054) to head (0da9c92).
Report is 5 commits behind head on develop.

Files with missing lines Patch % Lines
zetaclient/chains/ton/observer/inbound.go 90.62% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3439      +/-   ##
===========================================
- Coverage    64.69%   64.63%   -0.07%     
===========================================
  Files          455      458       +3     
  Lines        31495    31839     +344     
===========================================
+ Hits         20377    20579     +202     
- Misses       10229    10355     +126     
- Partials       889      905      +16     
Files with missing lines Coverage Δ
zetaclient/chains/ton/observer/inbound.go 64.68% <90.62%> (+2.23%) ⬆️

... and 12 files with indirect coverage changes

@lumtis lumtis added TON_TESTS Runs TON E2E tests CONSENSUS_BREAKING_ACK Acknowledge a consensus breaking change UPGRADE_LIGHT_TESTS Run make start-upgrade-test-light UPGRADE_TESTS Run make start-upgrade-tests labels Jan 30, 2025
@lumtis lumtis marked this pull request as ready for review February 18, 2025 16:34
@lumtis lumtis requested a review from a team as a code owner February 18, 2025 16:34
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

🧹 Nitpick comments (1)
changelog.md (1)

16-16: Validate the New Changelog Entry for TON Deposits
The new changelog entry for PR 3439 is clear and concise. Please verify that the description sufficiently conveys that this refactor introduces protocol contracts V2 specifically for TON deposits, ensuring consistency with the style of other entries.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9092054 and db0615d.

📒 Files selected for processing (5)
  • changelog.md (1 hunks)
  • e2e/runner/ton.go (1 hunks)
  • pkg/contracts/ton/gateway_msg.go (2 hunks)
  • zetaclient/chains/ton/observer/inbound.go (3 hunks)
  • zetaclient/chains/ton/observer/inbound_test.go (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.go`: Review the Go code, point out issues relative to ...

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

  • pkg/contracts/ton/gateway_msg.go
  • zetaclient/chains/ton/observer/inbound_test.go
  • e2e/runner/ton.go
  • zetaclient/chains/ton/observer/inbound.go
🪛 GitHub Check: codecov/patch
zetaclient/chains/ton/observer/inbound.go

[warning] 221-221: zetaclient/chains/ton/observer/inbound.go#L221
Added line #L221 was not covered by tests


[warning] 233-233: zetaclient/chains/ton/observer/inbound.go#L233
Added line #L233 was not covered by tests


[warning] 243-243: zetaclient/chains/ton/observer/inbound.go#L243
Added line #L243 was not covered by tests

🔇 Additional comments (9)
e2e/runner/ton.go (1)

118-118: LGTM! Simplified filter logic.

The filter condition has been simplified to directly compare encoded call data, improving code clarity and consistency with the Memo() method changes.

pkg/contracts/ton/gateway_msg.go (2)

62-62: LGTM! Simplified memo structure.

Returning an empty byte slice simplifies the memo structure by removing unnecessary recipient bytes.


80-80: LGTM! Consistent memo handling.

The change to return only CallData aligns with the simplified memo structure and improves code clarity.

zetaclient/chains/ton/observer/inbound.go (3)

181-187: LGTM! Well-structured data encapsulation.

The inboundData struct effectively encapsulates TON inbound deposit data, improving code organization and reducing parameter passing.


216-244: Add test coverage for error paths.

The error paths in the extractInboundData function are not covered by tests. Consider adding test cases for:

  • Deposit parsing failure (line 221)
  • DepositAndCall parsing failure (line 233)
  • Unknown operation error (line 243)
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 221-221: zetaclient/chains/ton/observer/inbound.go#L221
Added line #L221 was not covered by tests


[warning] 233-233: zetaclient/chains/ton/observer/inbound.go#L233
Added line #L233 was not covered by tests


[warning] 243-243: zetaclient/chains/ton/observer/inbound.go#L243
Added line #L243 was not covered by tests


267-287: LGTM! Enhanced protocol V2 integration.

The changes effectively integrate protocol V2 features:

  • Proper handling of cross-chain calls
  • Safe confirmation mode
  • Structured inbound data usage
zetaclient/chains/ton/observer/inbound_test.go (3)

165-167: LGTM! Comprehensive test assertions.

The test assertions correctly validate:

  • Empty message for regular deposits
  • Proper receiver address format
  • Cross-chain call flag state

229-231: LGTM! Accurate test validations.

The test assertions correctly validate:

  • Hex-encoded call data
  • Proper receiver address format
  • Cross-chain call flag state

436-437: LGTM! Consistent test assertions.

The test assertions maintain consistency with the new memo structure and address format requirements.

Copy link
Contributor

@swift1337 swift1337 left a comment

Choose a reason for hiding this comment

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

Nice

Copy link
Contributor

@ws4charlie ws4charlie left a comment

Choose a reason for hiding this comment

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

looks good to me

@lumtis lumtis added this pull request to the merge queue Feb 19, 2025
Merged via the queue into develop with commit ab3e5e1 Feb 19, 2025
45 checks passed
@lumtis lumtis deleted the refactor/ton-contract-v2 branch February 19, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CONSENSUS_BREAKING_ACK Acknowledge a consensus breaking change TON_TESTS Runs TON E2E tests UPGRADE_LIGHT_TESTS Run make start-upgrade-test-light UPGRADE_TESTS Run make start-upgrade-tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support TON with Protocol contract v2 architecture
3 participants