← Back to Pull requests

fix(cli): reuse connections to EVM nodes under concurrent calls #1547

Merged
gjermundgaraba merged 2 files (84 lines) on Oct 15, 2026 19:51 UTC
View on GitHub
gjermundgaraba gjermundgaraba commented on Oct 12, 2026 16:37 UTC
Author

Summary

The relayer and attestors dial EVM nodes with go-ethereum's default HTTP client, which keeps only two idle connections per host. Every concurrent call beyond two opens and closes its own connection, so a relayer under load leaves the host's local ports in TIME_WAIT until new connections fail with "can't assign requested address". A sustained Besu load run logged 21,570 such errors from the relayer and starved the whole machine of ports.

Dial now shares one HTTP transport that keeps up to 256 idle connections per node.

Test plan

  • go test ./internal/chains/evm/ in cli/, including a test that concurrent calls reuse connections

  • golangci-lint run ./internal/chains/evm/...
  • 🤖 Generated with Claude Code

    Diff: 84 lines (+83 / -1) across 2 files Reviewer: swift1337 Review duration: 4514m
    All Vouch review confidence checks passed
    Residual risk 0.06 = Change Risk (0.36) × (1 − Review Confidence (0.83)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 84 lines diff across 2 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.77 · 4 substantive comment(s)
    0.77
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    83%
    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.266
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    6 items
    github-actions[bot] github-actions[bot] commented on Oct 12, 2026 16:39 UTC
    Bot

    <!-- dependency-review:govulncheck -->

    Vulnerable dependencies

    1 advisory across 1 library need attention, 2 accepted.

    :rotating_light: Needs attention

    github.com/cosmos/evm

    In use: v0.7.3 — reached from e2e

    | Advisory | CVE | Fixed in | Summary |
    |---|---|---|---|
    | GO-2025-3684 | — | no fix yet | Cosmos EVM Allows Partial Precompile State Writes in github.com/cosmos/evm |

    Run make vulncheck for the call paths. Either upgrade the library, or add the
    advisory to .govulncheck-ignore with a reason if no fix exists yet.

    Accepted

    Listed in .govulncheck-ignore with a reason.

    github.com/pion/dtls/v2

    In use: v2.2.12 — reached from cli

    | Advisory | CVE | Fixed in | Summary |
    |---|---|---|---|
    | GO-2026-4479 | CVE-2026-26014 | no fix yet | Usage of random nonce generation with AES GCM ciphers risks leaking the authentication key in github.com/pion/dtls |

    golang.org/x/crypto

    In use: v0.57.0 — reached from cli, e2e

    | Advisory | CVE | Fixed in | Summary |
    |---|---|---|---|
    | GO-2026-5932 | — | no fix yet | The golang.org/x/crypto/openpgp package is unmaintained, unsafe by design, and has known security issues |

    <sub>From make vulncheck-json on this run: logs.</sub>

    greptile-apps[bot] greptile-apps[bot] commented on Oct 12, 2026 20:09 UTC
    Bot

    <!-- greptile_summary -->

    <h2><a href="https://app.greptile.com/api/retrigger?id=79376228"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a>Confidence Score: 4/5</h2>

    [Medium impact] Changes how the CLI connects to blockchain nodes\.

    The PR appears safe to merge, with a non-blocking improvement needed to keep the new test from stalling after a failed request.

    <h2>Findings</h2>

    1. <img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top">&nbsp;Failed requests stall the test <a href="https://github.com/cosmos/ibc/pull/1547#discussion_r4251918269">▶</a>

    <h3>Summary</h3>

    Dial now gives EVM HTTP clients one shared transport.

  • EVM HTTP calls reuse connections during concurrent traffic.
  • <details><summary><h3>Diagram</h3></summary>

    %%{init: {'theme': 'neutral'}}%%
    flowchart LR
      A[Chain HTTP client] --> T[Shared HTTP transport]
      B[Transaction HTTP client] --> T
      T --> P[Up to 256 idle connections per host]
      P --> N[EVM node]
    

    </details>

    <!-- greptile_confidence_score:4 -->

    <sub>Reviews (1) · Last reviewed commit: "fix(cli): reuse connections to EVM nodes..." · Reviewed by Greptile</sub>

    greptile-apps[bot] greptile-apps[bot] commented on code on Oct 12, 2026 20:10 UTC
    Code Review
    cli/internal/chains/evm/dial_test.go:1
    @@ -0,0 +1,66 @@
    +// SPDX-License-Identifier: Apache-2.0
    +
    +package evm
    +
    +import (
    +	"encoding/json"
    +	"net"
    +	"net/http"
    +	"net/http/httptest"
    +	"sync"
    +	"sync/atomic"
    +	"testing"
    +
    +	"github.com/ethereum/go-ethereum/common"
    +	"github.com/stretchr/testify/assert"
    +	"github.com/stretchr/testify/require"
    +)
    +
    +func TestDialReusesConnectionsUnderConcurrency(t *testing.T) {
    +	// ARRANGE
    +	const concurrency = 20
    +	var opened atomic.Int64
    +	var inFlight sync.WaitGroup
    +	srv := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
    +		var req struct {
    +			ID json.RawMessage `json:"id"`
    +		}
    +		if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
    +			http.Error(w, err.Error(), http.StatusBadRequest)
    +			return
    +		}
    +		// Hold every request until the whole round is in flight, so each
    +		// needs its own connection.
    +		inFlight.Done()
    +		inFlight.Wait()

    <a href="#"><img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"></a> Failed requests stall the test

    If a request fails before reaching inFlight.Done(), the remaining handlers wait forever for all 20 requests. t.Context() has no deadline, and calls.Wait() prevents cleanup from starting. This can delay CI until the whole test run times out.

    Give requests a deadline and let handlers leave the barrier when the round fails or times out. A request deadline alone would still leave srv.Close() waiting for the blocked handlers.

    swift1337 swift1337 approved these changes on Oct 15, 2026 19:35 UTC
    Approved Reviewer

    Approved these changes.

    linear-code[bot] linear-code[bot] commented on Oct 15, 2026 22:41 UTC
    Bot
    Reviewers
    Assignees
    gjermundgaraba gjermundgaraba
    Labels
    risk: low confidence: 83.3% 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: 36% (MEDIUM) · Higher = larger blast radius
    36%
    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: 83.3% · Lower = rushed or shallow review
    83.3%
    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: 6% · Safe to merge
    6%
    Repository