From 2ad833a8a04dbc603bd8df91167e3a07da3ef035 Mon Sep 17 00:00:00 2001 From: Ljubisa Gacevic Date: Fri, 30 Jan 2026 13:55:17 +0100 Subject: [PATCH 1/2] fix(chain): add retry logic for transient RPC connection errors --- pkg/node/chain.go | 76 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/pkg/node/chain.go b/pkg/node/chain.go index 78fc0a5448d..d86aac883c7 100644 --- a/pkg/node/chain.go +++ b/pkg/node/chain.go @@ -9,8 +9,11 @@ import ( "encoding/hex" "errors" "fmt" + "io" "math/big" + "net/http" "strings" + "syscall" "time" "github.com/ethereum/go-ethereum/common" @@ -37,8 +40,79 @@ const ( maxDelay = 1 * time.Minute cancellationDepth = 12 additionalConfirmations = 2 + maxRetries = 3 + retryBackoff = 100 * time.Millisecond ) +// retryRoundTripper implements http.RoundTripper with retry logic for transient network errors. +type retryRoundTripper struct { + transport http.RoundTripper + maxRetries int + backoff time.Duration +} + +// RoundTrip executes a single HTTP transaction, returning a Response for the Request. +// It retries on transient errors like EOF, connection reset, and connection refused. +func (r *retryRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { + var lastErr error + + for attempt := 0; attempt <= r.maxRetries; attempt++ { + if attempt > 0 { + backoffDuration := min(r.backoff*time.Duration(1< Date: Fri, 30 Jan 2026 16:25:49 +0100 Subject: [PATCH 2/2] fix(node): add retry logic for blockchain RPC transient errors --- pkg/node/chain.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/node/chain.go b/pkg/node/chain.go index d86aac883c7..d72709435ab 100644 --- a/pkg/node/chain.go +++ b/pkg/node/chain.go @@ -60,6 +60,15 @@ func (r *retryRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) if attempt > 0 { backoffDuration := min(r.backoff*time.Duration(1<