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

fix(zetaclient): add zetaclient evm outbound tx index by nonce to supplement outtx tracker #2735

Merged
merged 21 commits into from
Sep 11, 2024

Conversation

brewmaster012
Copy link
Collaborator

@brewmaster012 brewmaster012 commented Aug 16, 2024

Description

Currently outbound tracker is susceptible to being filled by invalid hashes and missing entries.
Invalid hashes require manual cleanup by group proposal and missing entries require constant monitoring and filling in.

This PoC PR adds simple logic in zetaclient to index outtx from TSS address by nonce, therefore avoid relying solely on outtx tracker for discovery of outbound tx hashes on Ethereum.

Overhead (both memory and computation) added is minimal as it piggy backs on existing block by block scanner in inbound tx processing.

  • Created a separate method FilterTSSOutbound in outbound.go to filter outbounds in blocks.
  • Unit tests thru evm rpc mocks.
  • Manually tested in localnet E2E by disabling outbound tracker in Ethereum client.

Closes #2846

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

    • Enhanced outbound tracking for EVM chains, improving transaction confirmation and processing.
    • Improved observation capabilities for TSS-related transactions, now handling both incoming and outbound processes.
  • Bug Fixes

    • Resolved an issue with the outbound tracker that was blocking transaction confirmations on EVM chains.
  • Tests

    • Updated test cases to reflect changes in transaction observation methods, ensuring comprehensive coverage of outbound operations.

Copy link
Contributor

coderabbitai bot commented Aug 16, 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

The recent changes encompass the addition of a new entry in the changelog for version 19.0.0, detailing a fix for the outbound tracker affecting confirmation and processing on EVM chains. Furthermore, the Observer class in the zetaclient has been enhanced to include a method for handling both TSS gas asset reception and outbound transactions. Corresponding updates have been made to the associated test cases to reflect these modifications.

Changes

Files Change Summary
changelog.md Added a new entry for version 19.0.0 detailing a fix for the outbound tracker that impacts confirmation and processing on EVM chains.
zetaclient/chains/evm/observer/inbound.go, zetaclient/chains/evm/observer/inbound_test.go Renamed the ObserveTSSReceiveInBlock method to ObserveTSSReceiveInBlockAndOutbound, modifying its functionality to include handling of outbound transactions. Updated corresponding test cases to reflect this change.

Sequence Diagram(s)

sequenceDiagram
    participant Observer
    participant TransactionHandler
    participant EVMChain

    Observer->>EVMChain: ObserveTSSReceiveInBlockAndOutbound(blockNumber)
    EVMChain->>TransactionHandler: Check for confirmed transactions
    TransactionHandler-->>EVMChain: Confirmed transactions found
    EVMChain-->>Observer: Send transaction receipt
    Observer->>Observer: Process inbound and outbound transactions
Loading

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

Copy link

codecov bot commented Aug 19, 2024

Codecov Report

Attention: Patch coverage is 97.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 66.93%. Comparing base (cc7b347) to head (cf8f943).
Report is 3 commits behind head on develop.

Files with missing lines Patch % Lines
zetaclient/chains/evm/observer/inbound.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2735      +/-   ##
===========================================
+ Coverage    66.80%   66.93%   +0.13%     
===========================================
  Files          373      373              
  Lines        20993    21028      +35     
===========================================
+ Hits         14025    14076      +51     
+ Misses        6315     6288      -27     
- Partials       653      664      +11     
Files with missing lines Coverage Δ
zetaclient/chains/evm/observer/outbound.go 55.41% <100.00%> (+8.99%) ⬆️
zetaclient/chains/evm/signer/signer.go 47.48% <100.00%> (+0.33%) ⬆️
zetaclient/testutils/testdata.go 86.95% <100.00%> (+1.12%) ⬆️
zetaclient/chains/evm/observer/inbound.go 37.36% <0.00%> (-0.08%) ⬇️

@brewmaster012 brewmaster012 changed the title WIP: zetaclient evm outbound tx index by nonce to supplement outtx tracker fix(zetaclient): add zetaclient evm outbound tx index by nonce to supplement outtx tracker Aug 23, 2024
@brewmaster012 brewmaster012 marked this pull request as ready for review August 23, 2024 16:37
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: 1

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1ad2bde and 7c0c232.

Files selected for processing (3)
  • changelog.md (1 hunks)
  • zetaclient/chains/evm/observer/inbound.go (3 hunks)
  • zetaclient/chains/evm/observer/inbound_test.go (1 hunks)
Additional context used
Path-based instructions (2)
zetaclient/chains/evm/observer/inbound_test.go (1)

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

zetaclient/chains/evm/observer/inbound.go (1)

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

GitHub Check: codecov/patch
zetaclient/chains/evm/observer/inbound.go

[warning] 449-449: zetaclient/chains/evm/observer/inbound.go#L449
Added line #L449 was not covered by tests


[warning] 455-455: zetaclient/chains/evm/observer/inbound.go#L455
Added line #L455 was not covered by tests


[warning] 798-800: zetaclient/chains/evm/observer/inbound.go#L798-L800
Added lines #L798 - L800 were not covered by tests

Additional comments not posted (5)
zetaclient/chains/evm/observer/inbound_test.go (3)

484-484: Ensure comprehensive test coverage for ObserveTSSReceiveInBlockAndOutbound.

The test case verifies the successful observation of TSS receive in a block. Ensure that the new outbound functionality is adequately tested.

Consider adding specific test cases to cover outbound transaction scenarios.


489-489: Verify error handling for block retrieval.

The test case simulates an error in getting the block. Ensure that the error handling logic in ObserveTSSReceiveInBlockAndOutbound is robust.

Consider testing additional edge cases related to block retrieval errors.


496-496: Verify error handling for receipt retrieval.

The test case simulates an error in getting the receipt. Ensure that the error handling logic in ObserveTSSReceiveInBlockAndOutbound is robust.

Consider testing additional edge cases related to receipt retrieval errors.

zetaclient/chains/evm/observer/inbound.go (1)

Line range hint 773-802: Enhance test coverage for ObserveTSSReceiveInBlockAndOutbound.

The method now includes logic for handling outbound transactions. Ensure that this new functionality is adequately tested.

Consider adding test cases to cover scenarios where outbound transactions are processed.

Tools
GitHub Check: codecov/patch

[warning] 798-800: zetaclient/chains/evm/observer/inbound.go#L798-L800
Added lines #L798 - L800 were not covered by tests

changelog.md (1)

32-32: Ensure clarity and consistency in changelog entries.

The changelog entry for PR 2735 is clear and aligns with the PR objectives. It effectively communicates the fix for the outbound tracker issue on EVM chains by indexing outbound transactions locally in the zetaclient.

zetaclient/chains/evm/observer/inbound.go Outdated Show resolved Hide resolved
Co-authored-by: Charlie Chen <34498985+ws4charlie@users.noreply.github.com>
Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

I'm. sure to understand the change, we add new logic in TSS inbound observation. How does it concern outbound trackers?

Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

I see know the logic and idea. It would still be proper to define a new method like ObserveTSSOutbound, and calling this function in ObserveInbound. Ideally we should have this logic in outbound.go as it pertains to outbounds but the current state of the code doesn't allow it. ObserveInbound is fine as we iterate the blocks there.

I think the ObserveTSSReceiveInBlockAndOutbound naming is a bit confusing and the method is still called in ObserverTSSReceive which makes the control flow a bit more implicit.

Also ObserverTSSReceive will be removed in the future once we fully migrate to V2 contract and wind down v1 compatibility

Tested in localnet E2E by disabling outbound tracker in Ethereum client.

Is it possible to share the line you removed to disable the outbound trackers? Just wanted to do some checks as in the current code it seems we still rely on outbound trackers to watch the outbounds

@ws4charlie
Copy link
Contributor

ws4charlie commented Aug 30, 2024

I see know the logic and idea. It would still be proper to define a new method like ObserveTSSOutbound, and calling this function in ObserveInbound. Ideally we should have this logic in outbound.go as it pertains to outbounds but the current state of the code doesn't allow it. ObserveInbound is fine as we iterate the blocks there.

I think the ObserveTSSReceiveInBlockAndOutbound naming is a bit confusing and the method is still called in ObserverTSSReceive which makes the control flow a bit more implicit.

Also ObserverTSSReceive will be removed in the future once we fully migrate to V2 contract and wind down v1 compatibility

Tested in localnet E2E by disabling outbound tracker in Ethereum client.

Is it possible to share the line you removed to disable the outbound trackers? Just wanted to do some checks as in the current code it seems we still rely on outbound trackers to watch the outbounds

I think this PR was intended to be a supplement to (not to disable) outbound trackers. I think it is possible to minimize our reliance on outbound trackers in future and restrict its usage to only missed outbound (similar to inbound tracker). The new observation might look like:

  • New impl will scan block and filter outbound transactions and won't solely relay on trackers, this could completely remove the complexity of tracker reporters.
  • New impl will scan block by block sequentially and post vote sequentially. The current impl doesn't care the order by which the votes are posted.
  • New impl will need to scan quick enough to catch up external chain in order to not cause delay. The current impl doesn't need to catch up on blocks.

overall: we could switch to a block-scanning model to minimize reliance on outbound trackers while still keep them for scenarios similar to inbound trackers.

I created a issue open to discussion: #2805

@brewmaster012
Copy link
Collaborator Author

Is it possible to share the line you removed to disable the outbound trackers? Just wanted to do some checks as in the current code it seems we still rely on outbound trackers to watch the outbounds

image

i tested in localnet by disabling reporting to outbound tracker.

@brewmaster012
Copy link
Collaborator Author

Also ObserverTSSReceive will be removed in the future once we fully migrate to V2 contract and wind down v1 compatibility

then this function will just become ObserveOutbound
essentially a local indexer for all outbound txs. We can find a place for it that is more logical.

zetaclient/testutils/types/ethrpc.go Dismissed Show dismissed Hide dismissed
Copy link
Member

@lumtis lumtis 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

@ws4charlie ws4charlie added this pull request to the merge queue Sep 11, 2024
Merged via the queue into develop with commit 1929ff6 Sep 11, 2024
30 checks passed
@ws4charlie ws4charlie deleted the zetaclient-evm-index-by-nonce branch September 11, 2024 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

missing or invalid outbound tx tracker blocks outbound processing
5 participants