zeta-chain / node

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

feat: integrate authenticated calls smart contract functionality into protocol #2904

Closed skosito closed 1 month ago

skosito commented 1 month ago

Description

Integrates this https://github.com/zeta-chain/protocol-contracts/issues/344 into protocol, this PR should be merged after smart contract changes are merged, but this is ready for first pass.

Also e2e tests to call zevm->evm, using call and withdrawAndCall and authenticated sender, with checking if sender is properly forwarded, so destination contract can use it as authentication.

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
:memo: Walkthrough
:memo: Walkthrough
:memo: Walkthrough ## Walkthrough The pull request introduces significant enhancements to the testing framework for the V2 smart contract functionality within the application. It adds multiple new test cases focused on authenticated calls for both ETH and ZEVM transactions, expands the capabilities of the `E2ERunner` struct, and modifies several related files to accommodate these changes. Additionally, the contract's ABI and implementation files are updated to support new functionalities related to message handling and sender validation. ## Changes | File Path | Change Summary | |----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `cmd/zetae2e/local/v2.go` | Added new test cases to `startV2Tests` for ETH and ZEVM authenticated calls. | | `e2e/e2etests/e2etests.go` | Introduced new tests for ETH withdrawals and ZEVM calls, expanding the existing test suite. | | `e2e/e2etests/test_v2_eth_withdraw_and_authenticated_call.go` | Added a test function to validate ETH withdrawal and authenticated calls. | | `e2e/e2etests/test_v2_eth_withdraw_and_authenticated_call_through_contract.go` | Implemented a test for ETH withdrawal through a contract, including success and failure scenarios. | | `e2e/e2etests/test_v2_zevm_to_evm_authenticated_call.go` | Added a test for authenticated calls from ZEVM to EVM, validating sender and message handling. | | `e2e/e2etests/test_v2_zevm_to_evm_authenticated_call_through_contract.go` | Created a test for authenticated calls through a contract, checking sender validation and revert scenarios. | | `e2e/e2etests/test_v2_zevm_to_evm_call.go` | Updated comments to reflect changes in terminology from "withdraw" to "call." | | `e2e/runner/v2_zevm.go` | Added new methods for authenticated ETH withdrawals and calls, enhancing the `E2ERunner` functionality. | | `go.mod` | Updated dependency versions and added new dependencies related to the project. | | `pkg/contracts/testdappv2/TestDAppV2.abi` | Expanded the contract's ABI with new functions for message handling and sender validation. | | `pkg/contracts/testdappv2/TestDAppV2.go` | Introduced new methods and structures for managing message contexts and expected senders. | | `pkg/contracts/testgatewayzevmcaller/TestGatewayZEVMCaller.abi` | Added ABI definitions for new contract functions related to gateway interactions. | | `pkg/contracts/testgatewayzevmcaller/TestGatewayZEVMCaller.go` | Provided Go bindings for the new contract, enabling interactions with the gateway. | | `proto/zetachain/zetacore/crosschain/cross_chain_tx.proto` | Added a new boolean field `is_arbitrary_call` to the `OutboundParams` message. | | `x/crosschain/types/message_vote_inbound.go` | Updated the `NewMsgVoteInbound` function to include a new boolean parameter for message handling. | | `zetaclient/chains/evm/signer/v2_sign.go` | Modified the `signGatewayExecute` function to handle different scenarios based on the `IsArbitraryCall` property. | ## Possibly related PRs - **#2735**: Addresses issues with the outbound transaction tracker in the `zetaclient`, potentially related to transaction handling improvements. - **#2864**: Enhances the `E2ERunner` struct, directly connected to the testing framework improvements in this PR. - **#2874**: Improves the testing framework for precompiled contracts, relevant to the expanded test coverage in this PR. - **#2891**: Focuses on initializing liquidity caps in tests, aligning with the goal of expanding test coverage in this PR. - **#2895**: Introduces a new e2e test for Bitcoin deposits and calls, directly related to the new test cases added in this PR. ## Suggested labels `E2E`, `V2_MIGRATION_TESTS`, `ADMIN_TESTS` ## Suggested reviewers - kingpinXD - fbac - swift1337 - lumtis - brewmaster012 - ws4charlie

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 25.71429% with 130 lines in your changes missing coverage. Please review.

Project coverage is 67.14%. Comparing base (2892114) to head (e8b32f2).

Files with missing lines Patch % Lines
...g/contracts/gatewayzevmcaller/GatewayZEVMCaller.go 0.00% 71 Missing :warning:
pkg/contracts/testdappv2/TestDAppV2.go 0.00% 34 Missing :warning:
zetaclient/chains/evm/signer/v2_sign.go 0.00% 12 Missing :warning:
x/crosschain/keeper/v2_zevm_inbound.go 0.00% 8 Missing :warning:
zetaclient/chains/evm/observer/v2_inbound.go 0.00% 2 Missing :warning:
x/crosschain/keeper/evm_hooks.go 66.66% 0 Missing and 1 partial :warning:
zetaclient/chains/bitcoin/signer/signer.go 0.00% 1 Missing :warning:
zetaclient/chains/evm/signer/v2_signer.go 0.00% 1 Missing :warning:
Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/zeta-chain/node/pull/2904/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/2904?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 #2904 +/- ## =========================================== - Coverage 67.49% 67.14% -0.36% =========================================== Files 380 381 +1 Lines 21170 21300 +130 =========================================== + Hits 14288 14301 +13 - Misses 6213 6330 +117 Partials 669 669 ``` | [Files with missing lines](https://app.codecov.io/gh/zeta-chain/node/pull/2904?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain) | Coverage Δ | | |---|---|---| | [x/crosschain/keeper/abci.go](https://app.codecov.io/gh/zeta-chain/node/pull/2904?src=pr&el=tree&filepath=x%2Fcrosschain%2Fkeeper%2Fabci.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-eC9jcm9zc2NoYWluL2tlZXBlci9hYmNpLmdv) | `75.58% <100.00%> (ø)` | | | [...hain/keeper/cctx\_orchestrator\_validate\_outbound.go](https://app.codecov.io/gh/zeta-chain/node/pull/2904?src=pr&el=tree&filepath=x%2Fcrosschain%2Fkeeper%2Fcctx_orchestrator_validate_outbound.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-eC9jcm9zc2NoYWluL2tlZXBlci9jY3R4X29yY2hlc3RyYXRvcl92YWxpZGF0ZV9vdXRib3VuZC5nbw==) | `72.98% <100.00%> (ø)` | | | [x/crosschain/keeper/gas\_payment.go](https://app.codecov.io/gh/zeta-chain/node/pull/2904?src=pr&el=tree&filepath=x%2Fcrosschain%2Fkeeper%2Fgas_payment.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-eC9jcm9zc2NoYWluL2tlZXBlci9nYXNfcGF5bWVudC5nbw==) | `77.29% <100.00%> (ø)` | | | [x/crosschain/types/cctx.go](https://app.codecov.io/gh/zeta-chain/node/pull/2904?src=pr&el=tree&filepath=x%2Fcrosschain%2Ftypes%2Fcctx.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-eC9jcm9zc2NoYWluL3R5cGVzL2NjdHguZ28=) | `92.30% <100.00%> (+0.25%)` | :arrow_up: | | [x/crosschain/types/cmd\_cctxs.go](https://app.codecov.io/gh/zeta-chain/node/pull/2904?src=pr&el=tree&filepath=x%2Fcrosschain%2Ftypes%2Fcmd_cctxs.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-eC9jcm9zc2NoYWluL3R5cGVzL2NtZF9jY3R4cy5nbw==) | `97.51% <100.00%> (+0.03%)` | :arrow_up: | | [x/crosschain/types/message\_vote\_inbound.go](https://app.codecov.io/gh/zeta-chain/node/pull/2904?src=pr&el=tree&filepath=x%2Fcrosschain%2Ftypes%2Fmessage_vote_inbound.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-eC9jcm9zc2NoYWluL3R5cGVzL21lc3NhZ2Vfdm90ZV9pbmJvdW5kLmdv) | `100.00% <100.00%> (ø)` | | | [zetaclient/chains/evm/signer/gas.go](https://app.codecov.io/gh/zeta-chain/node/pull/2904?src=pr&el=tree&filepath=zetaclient%2Fchains%2Fevm%2Fsigner%2Fgas.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-emV0YWNsaWVudC9jaGFpbnMvZXZtL3NpZ25lci9nYXMuZ28=) | `83.05% <100.00%> (ø)` | | | [zetaclient/chains/evm/signer/outbound\_data.go](https://app.codecov.io/gh/zeta-chain/node/pull/2904?src=pr&el=tree&filepath=zetaclient%2Fchains%2Fevm%2Fsigner%2Foutbound_data.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-emV0YWNsaWVudC9jaGFpbnMvZXZtL3NpZ25lci9vdXRib3VuZF9kYXRhLmdv) | `75.28% <100.00%> (ø)` | | | [zetaclient/zetacore/tx.go](https://app.codecov.io/gh/zeta-chain/node/pull/2904?src=pr&el=tree&filepath=zetaclient%2Fzetacore%2Ftx.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-emV0YWNsaWVudC96ZXRhY29yZS90eC5nbw==) | `86.00% <100.00%> (+0.28%)` | :arrow_up: | | [x/crosschain/keeper/evm\_hooks.go](https://app.codecov.io/gh/zeta-chain/node/pull/2904?src=pr&el=tree&filepath=x%2Fcrosschain%2Fkeeper%2Fevm_hooks.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain#diff-eC9jcm9zc2NoYWluL2tlZXBlci9ldm1faG9va3MuZ28=) | `84.57% <66.66%> (+0.15%)` | :arrow_up: | | ... and [7 more](https://app.codecov.io/gh/zeta-chain/node/pull/2904?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeta-chain) | |
lumtis commented 1 month ago

Upgrade test likely to fail because of https://github.com/zeta-chain/node/issues/2921

I think it should be trivial I will also have a look

skosito commented 1 month ago

Upgrade test likely to fail because of #2921

I think it should be trivial I will also have a look

fixed