← Back to Pull requests

feat(relayer): additional evm tx submission reliability mechanisms #1560

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Oct 15, 2026 00:22 UTC
Author

<!-- SPDX-License-Identifier: Apache-2.0 -->

<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
v ✰ Thanks for creating a PR! ✰
v Before smashing the submit button please review the checkboxes.
v If a checkbox is n/a - please still include it but + a little note why
v Also: make sure that you are familiar with the contribution guidelines: https://github.com/cosmos/.github/blob/main/CONTRIBUTING.md
v Failure to do this can result in your PR getting closed without further discussion (we receive a lot of PRs, and it takes a lot of time to respond to everyone who doesn't read this)
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -->

Description

<!-- Add a description of the changes that this PR introduces and the files that
are the most critical to review.
-->

While transaction submission currently has a timeout based retry mechanism, it is missing mitigations for several reliability issues. This pr addresses the following gaps:

  • Replacing stuck transactions - Transaction nonces on evm chains must be used sequentially. If there is an issue preventing a pending transaction from landing, it will block any subsequent pending transactions with greater nonces. A transaction can get stuck for a variety of reasons. For example, an rpc node can accept it but the network can fail to mine it if it is underpriced. To address this issue, this PR introduces a recovery mechanism where the relayer monitors the lowest unmined nonce and how long it is pending in the mempool. If it exceeds some threshold, the lowest unmined nonce gets reused when creating a new transaction such that it replaces the stuck transaction with the same nonce. Note that it only does this for the lowest pending nonce rather than all pending transactions.

  • Fee escalation - When replacing a transaction, the network requires that the replacement has a 20% higher fee. Transaction replacement may be required by the mechanism described above or it may be required if the relayer key is used to submit a transaction that is underpriced out-of-process. To satisfy the network requirements on the replacement tx fees, this pr introduces a fee escalation mechanism on tx submission.

  • Nonce selection - Concurrent requests to the node for the current transaction nonce can result in multiple workers using the same transaction nonce if the requests are made near the same time or if the node is lagging. This can create situations where the node rejects a redundant nonce wasting the resources expended in building that transaction or worse the node accepts multiple transactions with the same nonce while the network only mines one of them. To address this, this PR introduces logic into the evm TxSubmitter that tracks the last nonce used in local state and takes that value into account when selecting a new nonce.
  • Alternative Implementations Considered


    Similar EVM based relayers have more complex transaction replacement and fee escalation mechanisms where they persist the original transaction in the database and have separate worker threads reprice and resubmit the original transaction if it stalls for too long. This is the direction I initially went with but it increased the complexity excessively. It required logic tracking the lifecycle of a transaction and persisting that state to the database. There were multiple tricky edge cases introduced around reconciling database state with chain state in a robust way. The choice that makes this complexity largely unnecessary in our implementation is that we do not try and reprice a previously submitted transaction if it stalls for too long, we just reclaim the nonce it used for the next transaction the TxSubmitter receives which may not have any overlap in the packets it relays with the original transaction.

    The tradeoff is that this relies on the caller to monitor transactions they've previously submitted and resubmit any transactions that get dropped or replaced. Thankfully the relayer already did this. This is probably not ideal separation of concerns as retry logic is something the TxSubmitter should own but currently is a responsibility of the caller. Solving this with the alternative design was considered to be not worth the complexity introduced, but it can be considered in the larger relayer redesign which we are deferring for now.

    ---

    Before we can merge this PR, please make sure that all the following items have been
    checked off. If any of the checklist items are not applicable, please leave them but
    write a little note why.

  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.

  • Include changelog entry when appropriate (e.g. chores should be omitted from changelog).

  • Wrote unit and e2e tests if relevant.

  • Updated documentation (docs/) if anything is changed.

  • Added godoc comments if relevant.

  • Self-reviewed Files changed in the GitHub PR explorer.

  • Provide a conventional commit message to follow the repository standards.

  • <!-- This repository uses conventional commits, and the PR title is validated by the PR Lint workflow.
    Example commit messages:
    fix(cli): reconcile deployment config without losing custom settings
    feat(relayer): add metrics
    chore(deps): bump go.opentelemetry.io/otel
    ci: update golangci-lint
    docs: cli walkthrough updates
    feat(e2e): add e2e dump
    feat(api)!: this is an api breaking feature
    -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: dhfang Review duration: 1805m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.52) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #1560"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 29.7% · Safe to merge
    29.7%
    Repository