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(ton): TON observer 💎 #2896

Merged
merged 42 commits into from
Oct 9, 2024
Merged

feat(ton): TON observer 💎 #2896

merged 42 commits into from
Oct 9, 2024

Conversation

swift1337
Copy link
Contributor

@swift1337 swift1337 commented Sep 18, 2024

Description

This PR adds TON observer with all necessary dependencies. It does NOT cover gas economics

Closes #2808, #2757

Unit tests

  • Donate
  • Deposit
  • Deposit and Call

E2E tests

  • Add TON as ZRC20
  • Add TON chain
  • Add TON chain params admin vote on the fly
  • Deposit
  • Deposit and Call

Transaction Parsing

  • Donation
  • Deposit
  • DepositAndCall

TON tools

  • Add TON scraper - a tool for storing transactions locally for further testing
  • Implement TON liteapi wrapper
    • client.GetFirstTransaction()
    • client.GetTransactionsUntil()
  • Gateway wrapper for parsing and filtering transactions

Zetacore

  • Add TON chain params, consensus, VM, network type, ...

Misc

  • utils: improve pkg/ticker package. Stop ticker by external sig chan
  • observers: reuse Stop(), ChainParams(), Chain(), SetChainParam() from base observer
  • mocks for lite api
  • sample data for unit 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

    • Support for stateful precompiled contracts and staking precompiled contracts.
    • Enhanced Bitcoin chain support with static information for various testnets.
    • Integration of authenticated calls and restricted addresses in Solana.
    • New TON ZRC20 address handling and testing capabilities.
  • Bug Fixes

    • Resolved issues preventing operators from voting on discarded keygen ballots and ensuring outbound tracker functionality.
  • Tests

    • Expanded end-to-end testing for TON deposits and contract interactions.
    • Added new test cases for TON blockchain functionalities.
  • Documentation

    • Updated OpenAPI specifications with new consensus algorithms and network definitions.

@swift1337 swift1337 self-assigned this Sep 18, 2024
Copy link
Contributor

coderabbitai bot commented Sep 18, 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
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces a series of enhancements and modifications to the ZetaChain node, focusing on the integration of stateful precompiled contracts, support for various blockchain functionalities, and improvements in testing frameworks. Key changes include the addition of a new RPC package, enhancements to Bitcoin chain support, and the introduction of new test cases for the TON blockchain. Refactoring efforts address code quality, while the changelog documents significant updates across multiple versions, reflecting a comprehensive improvement in functionality and structure.

Changes

File Path Change Summary
changelog.md Updated to include new features, refactoring, tests, and fixes; notable additions for stateful precompiled contracts, staking, and Bitcoin support.
cmd/zetae2e/config/config.go Added export of TONZRC20Addr in ExportContractsFromRunner function.
cmd/zetae2e/config/contracts.go Introduced handling for TONZRC20Addr in setContractsFromConfig function.
cmd/zetae2e/local/local.go Added new test case e2etests.TestTONDepositAndCallName for the TON blockchain.
cmd/zetae2e/local/ton.go Updated tonTestRoutine to include ZetaTxServer parameter in initTestRunner.
docs/openapi/openapi.swagger.yaml Modified definitions section to include new values for consensus, network, and VM types.
e2e/config/config.go Added TONZRC20Addr field to ZEVM struct.
e2e/e2etests/e2etests.go Introduced new constants and updated existing ones for TON deposit tests.
e2e/e2etests/helpers.go Added parseUint function for string to math.Uint conversion.
e2e/e2etests/test_ton_deposit.go Updated TestTONDeposit function signature and logic for deposit testing.
e2e/e2etests/test_ton_deposit_and_call.go Introduced TestTONDepositAndCall function for deposit and call functionality in tests.
e2e/runner/runner.go Added fields TONZRC20Addr and TONZRC20 to E2ERunner struct for TON integration.

Assessment against linked issues

Objective Addressed Explanation
Implement deposit functionality
Implement deposit_and_call functionality
Implement donate functionality No changes related to donation functionality were made.
Handle unknown incoming transactions Unclear if changes address this objective directly.
Handle invalid transactions No changes related to invalid transaction handling were made.

Possibly related PRs

Suggested labels

E2E

Suggested reviewers

  • fbac
  • kingpinXD
  • swift1337
  • lumtis
  • skosito
  • brewmaster012
  • gartnera

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.

@swift1337 swift1337 added the TON_TESTS Runs TON E2E tests label Sep 18, 2024
@swift1337 swift1337 changed the title feat(ton): TON observer 💎 feat(ton): TON observer 💎 [WIP] Sep 18, 2024
pkg/ticker/ticker.go Outdated Show resolved Hide resolved
@swift1337 swift1337 added this pull request to the merge queue Oct 9, 2024
github-merge-queue bot pushed a commit that referenced this pull request Oct 9, 2024
* Use chainParams from base observer

* Improve base observer Start() semantics

* Add pkg/ticker options

* Add TON to pkg/chains & protos

* Add liteapi wrapper client; locate first tx

* Add TON tx scraper

* Add client.GetTransactionsUntil

* Gateway WIP

* Implement Gateway inbound tx parsing

* Add Gateway tx filtration

* Add GetBlockHeader cache; Add masterchain seqno. Implement watchInbound

* Improve ton contracts pkg

* Add IsTONChain()

* Refactor Gateway package

* Implement samples for TON

* Add liteClient mocks

* Add unit tests for inbound TON observer

* Localnet: add TON ZRC20

* Wire the TON observer into the orchestrator

* Add TON chain params of the fly!

* TON deposits E2E wip

* Fix bugs during cctx;

* TON Deposits E2E 🫡✅

* TON Deposit And Call E2E

* Merge fixes

* Update changelog

* gosec

* Improve testing

* Simplify ticker.Stop(). Leverage ctx.cancel()

* Simplify E2E

* Simplify liteapi semantics

* Fix comments

* Update zetaclient/chains/base/observer.go

Co-authored-by: Francisco de Borja Aranda Castillejo <[email protected]>

* Add gw explanatory comments; address PR comments

* Apply fixes for AI suggestions

---------

Co-authored-by: Francisco de Borja Aranda Castillejo <[email protected]>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 9, 2024
@swift1337 swift1337 added the UPGRADE_LIGHT_TESTS Run make start-upgrade-test-light label Oct 9, 2024
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

@swift1337 swift1337 enabled auto-merge October 9, 2024 17:06
@swift1337 swift1337 added this pull request to the merge queue Oct 9, 2024
Merged via the queue into develop with commit b20c3f1 Oct 9, 2024
35 of 36 checks passed
@swift1337 swift1337 deleted the feat/ton-observer branch October 9, 2024 17:46
@coderabbitai coderabbitai bot mentioned this pull request Oct 17, 2024
5 tasks
@coderabbitai coderabbitai bot mentioned this pull request Dec 11, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TON Observer E2E test-cases
6 participants