zeta-chain / node

ZetaChainโ€™s blockchain node and an observer validator client
https://zetachain.com
MIT License
168 stars 108 forks source link

feat(ton): TON observer ๐Ÿ’Ž #2896

Closed swift1337 closed 1 month ago

swift1337 commented 1 month ago

Description

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

Closes #2808, #2757

Unit tests

E2E tests

Transaction Parsing

TON tools

Zetacore

Misc

How Has This Been Tested?

Summary by CodeRabbit

coderabbitai[bot] commented 1 month ago

[!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 - **#2795**: Adds support for restricted addresses in Solana, related to the main PR's enhancements in Solana functionality. - **#2861**: Introduces event emissions from staking precompiles, aligning with the main PR's focus on staking functionalities. - **#2907**: Adds functionality for deriving Bitcoin TSS addresses by chain ID, relevant to updates regarding Bitcoin chain support. - **#2919**: Adds a sender to the revert context, related to enhancements in context management and smart contract functionality. ## 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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
๐Ÿชง Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit , 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](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 49.14040% with 355 lines in your changes missing coverage. Please review.

Project coverage is 66.09%. Comparing base (1470fdc) to head (906e8e9). Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
zetaclient/chains/ton/liteapi/client.go 13.40% 84 Missing :warning:
zetaclient/chains/ton/observer/inbound.go 59.72% 49 Missing and 9 partials :warning:
pkg/contracts/ton/gateway.go 60.97% 29 Missing and 19 partials :warning:
zetaclient/orchestrator/bootstrap.go 54.16% 16 Missing and 6 partials :warning:
pkg/contracts/ton/gateway_send.go 0.00% 19 Missing :warning:
pkg/contracts/ton/tlb.go 59.37% 9 Missing and 4 partials :warning:
zetaclient/chains/evm/observer/inbound.go 7.14% 13 Missing :warning:
pkg/contracts/ton/gateway_op.go 69.23% 10 Missing and 2 partials :warning:
zetaclient/chains/ton/observer/observer.go 45.45% 12 Missing :warning:
zetaclient/chains/base/observer.go 66.66% 11 Missing :warning:
... and 21 more
Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/zeta-chain/node/pull/2896/graphs/tree.svg?width=650&height=150&src=pr&token=JABAIMO8MP&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain)](https://app.codecov.io/gh/zeta-chain/node/pull/2896?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain) ```diff @@ Coverage Diff @@ ## develop #2896 +/- ## =========================================== - Coverage 66.40% 66.09% -0.32% =========================================== Files 389 397 +8 Lines 21777 22332 +555 =========================================== + Hits 14462 14760 +298 - Misses 6587 6804 +217 - Partials 728 768 +40 ``` | [Files with missing lines](https://app.codecov.io/gh/zeta-chain/node/pull/2896?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain) | Coverage ฮ” | | |---|---|---| | [pkg/chains/chains.go](https://app.codecov.io/gh/zeta-chain/node/pull/2896?src=pr&el=tree&filepath=pkg%2Fchains%2Fchains.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-cGtnL2NoYWlucy9jaGFpbnMuZ28=) | `100.00% <100.00%> (+6.25%)` | :arrow_up: | | [x/crosschain/keeper/evm\_deposit.go](https://app.codecov.io/gh/zeta-chain/node/pull/2896?src=pr&el=tree&filepath=x%2Fcrosschain%2Fkeeper%2Fevm_deposit.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-eC9jcm9zc2NoYWluL2tlZXBlci9ldm1fZGVwb3NpdC5nbw==) | `86.95% <100.00%> (รธ)` | | | [x/observer/keeper/msg\_server\_vote\_blame.go](https://app.codecov.io/gh/zeta-chain/node/pull/2896?src=pr&el=tree&filepath=x%2Fobserver%2Fkeeper%2Fmsg_server_vote_blame.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-eC9vYnNlcnZlci9rZWVwZXIvbXNnX3NlcnZlcl92b3RlX2JsYW1lLmdv) | `100.00% <100.00%> (รธ)` | | | [zetaclient/config/config\_chain.go](https://app.codecov.io/gh/zeta-chain/node/pull/2896?src=pr&el=tree&filepath=zetaclient%2Fconfig%2Fconfig_chain.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-emV0YWNsaWVudC9jb25maWcvY29uZmlnX2NoYWluLmdv) | `100.00% <100.00%> (รธ)` | | | [zetaclient/chains/bitcoin/observer/rpc\_status.go](https://app.codecov.io/gh/zeta-chain/node/pull/2896?src=pr&el=tree&filepath=zetaclient%2Fchains%2Fbitcoin%2Fobserver%2Frpc_status.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-emV0YWNsaWVudC9jaGFpbnMvYml0Y29pbi9vYnNlcnZlci9ycGNfc3RhdHVzLmdv) | `0.00% <0.00%> (รธ)` | | | [zetaclient/chains/evm/observer/rpc\_status.go](https://app.codecov.io/gh/zeta-chain/node/pull/2896?src=pr&el=tree&filepath=zetaclient%2Fchains%2Fevm%2Fobserver%2Frpc_status.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-emV0YWNsaWVudC9jaGFpbnMvZXZtL29ic2VydmVyL3JwY19zdGF0dXMuZ28=) | `0.00% <0.00%> (รธ)` | | | [zetaclient/chains/solana/observer/inbound.go](https://app.codecov.io/gh/zeta-chain/node/pull/2896?src=pr&el=tree&filepath=zetaclient%2Fchains%2Fsolana%2Fobserver%2Finbound.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-emV0YWNsaWVudC9jaGFpbnMvc29sYW5hL29ic2VydmVyL2luYm91bmQuZ28=) | `41.39% <0.00%> (รธ)` | | | [zetaclient/chains/solana/observer/observer.go](https://app.codecov.io/gh/zeta-chain/node/pull/2896?src=pr&el=tree&filepath=zetaclient%2Fchains%2Fsolana%2Fobserver%2Fobserver.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-emV0YWNsaWVudC9jaGFpbnMvc29sYW5hL29ic2VydmVyL29ic2VydmVyLmdv) | `46.42% <0.00%> (+5.80%)` | :arrow_up: | | [zetaclient/chains/solana/observer/rpc\_status.go](https://app.codecov.io/gh/zeta-chain/node/pull/2896?src=pr&el=tree&filepath=zetaclient%2Fchains%2Fsolana%2Fobserver%2Frpc_status.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-emV0YWNsaWVudC9jaGFpbnMvc29sYW5hL29ic2VydmVyL3JwY19zdGF0dXMuZ28=) | `0.00% <0.00%> (รธ)` | | | [pkg/contracts/ton/gateway\_tx.go](https://app.codecov.io/gh/zeta-chain/node/pull/2896?src=pr&el=tree&filepath=pkg%2Fcontracts%2Fton%2Fgateway_tx.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-cGtnL2NvbnRyYWN0cy90b24vZ2F0ZXdheV90eC5nbw==) | `87.50% <87.50%> (รธ)` | | | ... and [25 more](https://app.codecov.io/gh/zeta-chain/node/pull/2896?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain) | |
github-actions[bot] commented 1 month ago

!!!WARNING!!! nosec detected in the following files: pkg/contracts/ton/gateway.go

Be very careful about using #nosec in code. It can be a quick way to suppress security warnings and move forward with development, it should be employed with caution. Suppressing warnings with #nosec can hide potentially serious vulnerabilities. Only use #nosec when you're absolutely certain that the security issue is either a false positive or has been mitigated in another way.

Only suppress a single rule (or a specific set of rules) within a section of code, while continuing to scan for other problems. To do this, you can list the rule(s) to be suppressed within the #nosec annotation, e.g: / #nosec G401 / or //#nosec G201 G202 G203 Broad #nosec annotations should be avoided, as they can hide other vulnerabilities. The CI will block you from merging this PR until you remove #nosec annotations that do not target specific rules.

Pay extra attention to the way #nosec is being used in the files listed above.