zeta-chain / node

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

feat: derive Bitcoin TSS address by chain ID; added more Signet static info in 'chains' package #2907

Closed ws4charlie closed 1 month ago

ws4charlie commented 1 month ago

Description

Closes: https://github.com/zeta-chain/node/issues/1397

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 The changes introduced in this pull request enhance the ZetaClient's support for multiple Bitcoin chains, specifically by adding functionality for deriving Bitcoin TSS addresses based on chain IDs. The updates include modifications across various files to streamline address retrieval, validation, and testing processes, ensuring better handling of Bitcoin Signet and other chains. Additionally, the configuration management has been adjusted to accommodate multiple Bitcoin chains, aligning with ongoing efforts to future-proof the system. ## Changes | Files | Change Summary | |-------------------------------------------------|-------------------------------------------------------------------------------------------------------------| | changelog.md | Updated to include new functionality for deriving Bitcoin TSS addresses and added static info for Signet. | | cmd/zetaclientd/start.go | Modified `start` function to filter supported Bitcoin chain IDs and update TSS address validation. | | pkg/chains/bitcoin.go | Added `BitcoinSignetParams` and updated functions to support Bitcoin Signet network. | | pkg/chains/bitcoin_test.go | Introduced new test cases for Bitcoin Signet network in existing test functions. | | zetaclient/chains/base/observer.go | Updated `OutboundID` method to retrieve Bitcoin address using chain ID as a parameter. | | zetaclient/chains/base/observer_test.go | Adjusted expected outbound ID construction in tests to include chain ID. | | zetaclient/chains/bitcoin/observer/inbound.go | Modified TSS address retrieval in `ObserveInbound` method to include chain ID. | | zetaclient/chains/bitcoin/observer/observer.go | Changed address retrieval logic in `FetchUTXOs` method to simplify and enhance error handling. | | zetaclient/chains/bitcoin/observer/outbound.go | Updated methods to include chain ID in TSS address retrieval for outbound processes. | | zetaclient/chains/bitcoin/signer/signer.go | Altered address retrieval in `AddWithdrawTxOutputs` to require chain ID. | | zetaclient/tss/tss_signer.go | Removed BitcoinChainID from TSS struct and updated methods to handle multiple chains. | | zetaclient/tss/tss_signer_test.go | Added new tests for validating Bitcoin addresses and TSS functionality. | ## Sequence Diagram(s) ```mermaid sequenceDiagram participant User participant ZetaClient participant Observer participant TSS User->>ZetaClient: Request Bitcoin TSS Address ZetaClient->>Observer: Retrieve Outbound ID Observer->>TSS: Get BTC Address with Chain ID TSS-->>Observer: Return BTC Address Observer-->>ZetaClient: Return Outbound ID ZetaClient-->>User: Provide Bitcoin TSS Address ``` ## Assessment against linked issues | Objective | Addressed | Explanation | |---------------------------------------------------------------------------|-----------|-----------------------------------------------| | Update ZetaClient config to support multiple Bitcoin chains (Issue #1397) | ✅ | | | Ensure proper handling of multiple Bitcoin chains in configuration | ✅ | | ## Possibly related issues - **#2889**: This issue discusses adding support for multiple BTC chains in ZetaClient config, which aligns with the changes made in this PR. ## Possibly related PRs - **#2883**: Adds static information for the Bitcoin Signet testnet, directly related to the updates in this PR. - **#2870**: Enhances configuration management to support multiple Bitcoin chains, aligning with the focus of this PR. - **#2895**: Introduces end-to-end tests for Bitcoin deposits, relevant to the transaction handling updates in this PR. ## Suggested labels `chain:bitcoin`, `SOLANA_TESTS` ## Suggested reviewers - fbac - kingpinXD - swift1337 - lumtis - brewmaster012 - skosito

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](https://discord.com/invite/GsXnASn26c) 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 79.16667% with 10 lines in your changes missing coverage. Please review.

Project coverage is 67.49%. Comparing base (3eba701) to head (3a111e0). Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
zetaclient/chains/bitcoin/observer/rpc_status.go 0.00% 4 Missing :warning:
zetaclient/chains/bitcoin/observer/observer.go 0.00% 3 Missing :warning:
zetaclient/chains/bitcoin/signer/signer.go 33.33% 1 Missing and 1 partial :warning:
zetaclient/chains/bitcoin/observer/inbound.go 0.00% 1 Missing :warning:
Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/zeta-chain/node/pull/2907/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/2907?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 #2907 +/- ## =========================================== + Coverage 67.27% 67.49% +0.21% =========================================== Files 380 380 Lines 21175 21169 -6 =========================================== + Hits 14245 14287 +42 + Misses 6264 6213 -51 - Partials 666 669 +3 ``` | [Files with missing lines](https://app.codecov.io/gh/zeta-chain/node/pull/2907?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/bitcoin.go](https://app.codecov.io/gh/zeta-chain/node/pull/2907?src=pr&el=tree&filepath=pkg%2Fchains%2Fbitcoin.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-cGtnL2NoYWlucy9iaXRjb2luLmdv) | `100.00% <100.00%> (ø)` | | | [x/observer/keeper/grpc\_query\_tss.go](https://app.codecov.io/gh/zeta-chain/node/pull/2907?src=pr&el=tree&filepath=x%2Fobserver%2Fkeeper%2Fgrpc_query_tss.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-eC9vYnNlcnZlci9rZWVwZXIvZ3JwY19xdWVyeV90c3MuZ28=) | `86.44% <100.00%> (ø)` | | | [zetaclient/chains/base/observer.go](https://app.codecov.io/gh/zeta-chain/node/pull/2907?src=pr&el=tree&filepath=zetaclient%2Fchains%2Fbase%2Fobserver.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-emV0YWNsaWVudC9jaGFpbnMvYmFzZS9vYnNlcnZlci5nbw==) | `87.61% <100.00%> (+0.42%)` | :arrow_up: | | [zetaclient/chains/bitcoin/observer/outbound.go](https://app.codecov.io/gh/zeta-chain/node/pull/2907?src=pr&el=tree&filepath=zetaclient%2Fchains%2Fbitcoin%2Fobserver%2Foutbound.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-emV0YWNsaWVudC9jaGFpbnMvYml0Y29pbi9vYnNlcnZlci9vdXRib3VuZC5nbw==) | `33.08% <100.00%> (ø)` | | | [zetaclient/tss/tss\_signer.go](https://app.codecov.io/gh/zeta-chain/node/pull/2907?src=pr&el=tree&filepath=zetaclient%2Ftss%2Ftss_signer.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-emV0YWNsaWVudC90c3MvdHNzX3NpZ25lci5nbw==) | `21.98% <100.00%> (+12.42%)` | :arrow_up: | | [zetaclient/chains/bitcoin/observer/inbound.go](https://app.codecov.io/gh/zeta-chain/node/pull/2907?src=pr&el=tree&filepath=zetaclient%2Fchains%2Fbitcoin%2Fobserver%2Finbound.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-emV0YWNsaWVudC9jaGFpbnMvYml0Y29pbi9vYnNlcnZlci9pbmJvdW5kLmdv) | `18.11% <0.00%> (ø)` | | | [zetaclient/chains/bitcoin/signer/signer.go](https://app.codecov.io/gh/zeta-chain/node/pull/2907?src=pr&el=tree&filepath=zetaclient%2Fchains%2Fbitcoin%2Fsigner%2Fsigner.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-emV0YWNsaWVudC9jaGFpbnMvYml0Y29pbi9zaWduZXIvc2lnbmVyLmdv) | `17.64% <33.33%> (-0.14%)` | :arrow_down: | | [zetaclient/chains/bitcoin/observer/observer.go](https://app.codecov.io/gh/zeta-chain/node/pull/2907?src=pr&el=tree&filepath=zetaclient%2Fchains%2Fbitcoin%2Fobserver%2Fobserver.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-emV0YWNsaWVudC9jaGFpbnMvYml0Y29pbi9vYnNlcnZlci9vYnNlcnZlci5nbw==) | `32.77% <0.00%> (+0.13%)` | :arrow_up: | | [zetaclient/chains/bitcoin/observer/rpc\_status.go](https://app.codecov.io/gh/zeta-chain/node/pull/2907?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%> (ø)` | |