← Back to Pull requests

fix(relayer): stop a dispatch race from relaying finished packets twice #1545

Merged
gjermundgaraba merged 4 files (113 lines) on Oct 28, 2026 00:19 UTC
View on GitHub
gjermundgaraba gjermundgaraba commented on Oct 12, 2026 15:15 UTC
Author

Summary

Fixes a race in the relayer's dispatcher between reading the packet list and pushing each packet into its pipeline.

Each tick, the dispatcher reads the dispatchable packets (dispatcher.go), then pushes each one into its route's pipeline. The pipeline's deduper rejects a push only while the same packet is still in flight. If a packet's transfer leaves the pipeline after the read but before the push, the deduper lets the push through, and the packet goes round the pipeline again from data read before its first run finished. The second run:

  • searched both chains again for receive and acknowledgement transactions already relayed;

  • completed the packet a second time;

  • could overwrite the packet's terminal status with an in-progress one, so the Packets API reported succeeded packets as pending again.
  • The fix closes the window. The deduper now keeps a packet claimed after its transfer leaves the pipeline, until Release, which the dispatcher calls once per tick, before reading. A packet is pushed again only from a read made after its previous run ended, which is the next tick, as before.

    Evidence

    Anvil bursts of 3000 IFT transfers (1500 per direction) from the e2e load test, with the relayer on main (before) and with this change (after):

    | | before | after (two runs) |
    |---|---|---|
    | Transfer complete log lines | 4019 | 3000, 3000 |
    | "Packet already received on destination chain" lookups | 442 | 0, 0 |
    | "Packet commitment gone from source chain" lookups | 191 | 0, 0 |
    | Succeeded packets later listed as pending | 28 | 0, 0 |

    About a third of the packets were relayed through the pipeline twice.

    Test plan

  • New tests fail without the fix and pass with it: a packet whose transfer leaves between the read and the push is skipped, then pushed on the next read; the deduper rejects a transfer that left until Release.

  • go test ./... and go test -race ./internal/relay/... in cli/

  • golangci-lint run ./... in cli/
  • 🤖 Generated with Claude Code

    Diff: 113 lines (+106 / -7) across 4 files Reviewer: None requested Review duration: 22143m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.48) × (1 − Review Confidence (0.58)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 113 lines diff across 4 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.47 · 1 substantive comment(s)
    0.47
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 10%
    58%
    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.283
    No Reviewer Assigned no_reviewer_assigned
    0.120
    Real PR Conversation Timeline
    1 item
    "Review active on #1545"
    general weight: 0.35
    Reviewers
    None requested
    Assignees
    gjermundgaraba gjermundgaraba
    Labels
    risk: low confidence: 58.5% 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: 47.7% (MEDIUM) · Higher = larger blast radius
    47.7%
    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: 58.5% · Lower = rushed or shallow review
    58.5%
    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: 19.8% · Safe to merge
    19.8%
    Repository