Skip to content

fix: allow evm chain stuck outbound replacement by using latest nonce#3956

Merged
ws4charlie merged 4 commits intodevelopfrom
allow-evm-outbound-tx-replacement
Jun 6, 2025
Merged

fix: allow evm chain stuck outbound replacement by using latest nonce#3956
ws4charlie merged 4 commits intodevelopfrom
allow-evm-outbound-tx-replacement

Conversation

@ws4charlie
Copy link
Contributor

@ws4charlie ws4charlie commented Jun 4, 2025

Description

This PR is to backport the v31 fix: #3955

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

  • Bug Fixes

    • Improved transaction replacement for EVM chains by using the latest finalized nonce during pre-broadcast checks, allowing pending transactions to be replaced more reliably.
  • Documentation

    • Updated changelog with details of the nonce handling fix for EVM transaction replacement.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 4, 2025

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 update the logic for retrieving the transaction nonce in EVM signing operations from using the pending nonce to the latest finalized nonce. This adjustment affects the broadcast method, associated tests, and test utilities. The changelog documents this fix, clarifying its intent to enable transaction replacement.

Changes

File(s) Change Summary
changelog.md Added a changelog entry under "UNRELEASED" describing the nonce handling fix (PR #3956).
zetaclient/chains/evm/signer/signer.go Replaced PendingNonceAt with NonceAt for nonce retrieval; updated variable names, comments, and logs accordingly.
zetaclient/chains/evm/signer/signer_test.go Updated tests to use MockNonceAt instead of MockPendingNonceAt; adjusted comments.
zetaclient/testutils/testrpc/rpc_evm.go Renamed MockPendingNonceAt to MockNonceAt in the EVMServer struct.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Signer
    participant EVMNode

    Client->>Signer: Request to broadcast transaction
    Signer->>EVMNode: Query latest finalized nonce (NonceAt)
    EVMNode-->>Signer: Return latest nonce
    Signer->>Signer: Compare transaction nonce with latest nonce
    alt If transaction nonce < latest nonce
        Signer->>Client: Skip broadcast (already processed)
    else If transaction nonce >= latest nonce
        Signer->>EVMNode: Broadcast transaction
        EVMNode-->>Signer: Broadcast result
        Signer->>Client: Return result
    end
Loading

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

@ws4charlie ws4charlie added chain:evm zetaclient Issues related to ZetaClient labels Jun 4, 2025
@ws4charlie ws4charlie marked this pull request as ready for review June 4, 2025 18:15
@ws4charlie ws4charlie requested a review from a team as a code owner June 4, 2025 18:15
@codecov
Copy link

codecov bot commented Jun 4, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 64.11%. Comparing base (1114f6d) to head (1b4cb00).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
zetaclient/chains/evm/signer/signer.go 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #3956   +/-   ##
========================================
  Coverage    64.11%   64.11%           
========================================
  Files          474      474           
  Lines        34842    34842           
========================================
  Hits         22340    22340           
  Misses       11477    11477           
  Partials      1025     1025           
Files with missing lines Coverage Δ
zetaclient/chains/evm/signer/signer.go 43.28% <50.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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: 0

🧹 Nitpick comments (1)
zetaclient/chains/evm/signer/signer.go (1)

495-498: Address test coverage gap for new logging.

The logic and variable renaming are correct, but the new log statement on line 497 lacks test coverage as indicated by static analysis.

Consider adding a test case that covers the scenario where latestNonce > nonce to ensure the new log message is tested:

func TestBroadcastOutbound_SkipLowNonce(t *testing.T) {
    // Setup test with latestNonce > cctx.nonce
    // Verify log message is generated correctly
}
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 497-497: zetaclient/chains/evm/signer/signer.go#L497
Added line #L497 was not covered by tests

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 99a50da and 3bf7760.

📒 Files selected for processing (4)
  • changelog.md (1 hunks)
  • zetaclient/chains/evm/signer/signer.go (1 hunks)
  • zetaclient/chains/evm/signer/signer_test.go (2 hunks)
  • zetaclient/testutils/testrpc/rpc_evm.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.go`: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

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

  • zetaclient/testutils/testrpc/rpc_evm.go
  • zetaclient/chains/evm/signer/signer_test.go
  • zetaclient/chains/evm/signer/signer.go
🪛 GitHub Check: codecov/patch
zetaclient/chains/evm/signer/signer.go

[warning] 497-497: zetaclient/chains/evm/signer/signer.go#L497
Added line #L497 was not covered by tests

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: start-e2e-test / e2e
🔇 Additional comments (5)
zetaclient/testutils/testrpc/rpc_evm.go (1)

39-39: LGTM: Test utility properly updated to reflect nonce method change.

The method rename from MockPendingNonceAt to MockNonceAt correctly aligns with the main signer implementation changes while preserving the mock functionality.

zetaclient/chains/evm/signer/signer_test.go (2)

152-154: LGTM: Test comments and mock calls correctly updated.

The changes properly reflect the transition from pending nonce to finalized nonce retrieval, maintaining test consistency with the main implementation.


178-179: LGTM: Mock setup properly updated for nonce retrieval change.

The test correctly uses MockNonceAt to align with the updated nonce retrieval logic in the main signer implementation.

changelog.md (1)

12-12: LGTM: Changelog properly documents the EVM transaction replacement fix.

The entry clearly explains the purpose of using the latest nonce for pre-broadcast checks to enable transaction replacement capability.

zetaclient/chains/evm/signer/signer.go (1)

487-491: LGTM: Core nonce retrieval logic correctly updated.

The change from PendingNonceAt to NonceAt with nil block parameter properly implements the finalized nonce strategy, enabling replacement of stuck pending transactions.

@lumtis lumtis changed the title fix(backport/v31): allow evm chain stuck outbound replacement by using latest nonce fix: allow evm chain stuck outbound replacement by using latest nonce Jun 5, 2025
Copy link
Contributor

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

This PR is to backport the v31 fix: #3955

Again, the backport is the PR to v31, this is the regular fix PR

@ws4charlie ws4charlie enabled auto-merge June 6, 2025 16:24
@ws4charlie ws4charlie added this pull request to the merge queue Jun 6, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Jun 6, 2025
@ws4charlie ws4charlie enabled auto-merge June 6, 2025 16:44
@ws4charlie ws4charlie added this pull request to the merge queue Jun 6, 2025
Merged via the queue into develop with commit 7e70780 Jun 6, 2025
46 of 47 checks passed
@ws4charlie ws4charlie deleted the allow-evm-outbound-tx-replacement branch June 6, 2025 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chain:evm zetaclient Issues related to ZetaClient

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants