From 6d9daed6fe31cbe6f80df0170c30ea9a43c1dba2 Mon Sep 17 00:00:00 2001 From: aman035 Date: Tue, 14 Apr 2026 13:51:16 +0530 Subject: [PATCH] fix: rpc retry logic --- go.mod | 2 -- go.sum | 2 -- universalClient/chains/evm/rpc_client.go | 4 ++-- universalClient/chains/svm/rpc_client.go | 4 ++-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 8b4accce..b46171bb 100755 --- a/go.mod +++ b/go.mod @@ -66,7 +66,6 @@ require ( github.com/cosmos/ibc-apps/modules/rate-limiting/v10 v10.1.0 github.com/cosmos/ibc-go/modules/capability v1.0.1 github.com/cosmos/ibc-go/v10 v10.4.0 - github.com/decred/base58 v1.0.6 github.com/ethereum/go-ethereum v1.15.11 github.com/gagliardetto/solana-go v1.13.0 github.com/golang/mock v1.6.0 @@ -228,7 +227,6 @@ require ( github.com/danieljoos/wincred v1.2.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/deckarep/golang-set v1.8.0 // indirect - github.com/decred/dcrd/crypto/blake256 v1.1.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect github.com/desertbit/timer v1.0.1 // indirect github.com/dgraph-io/badger/v4 v4.6.0 // indirect diff --git a/go.sum b/go.sum index fda4900f..48050699 100755 --- a/go.sum +++ b/go.sum @@ -940,8 +940,6 @@ github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= -github.com/decred/base58 v1.0.6 h1:NXndBcO+ubGZORV3EulvqeBcMuQM7doqVGa7pBhMOs4= -github.com/decred/base58 v1.0.6/go.mod h1:KR7Oh9njDPXTagD4P67KJZwroL8jT653u8CffkYqhcQ= github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/crypto/blake256 v1.1.0 h1:zPMNGQCm0g4QTY27fOCorQW7EryeQ/U0x++OzVrdms8= github.com/decred/dcrd/crypto/blake256 v1.1.0/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= diff --git a/universalClient/chains/evm/rpc_client.go b/universalClient/chains/evm/rpc_client.go index 2c486500..13e60ee6 100644 --- a/universalClient/chains/evm/rpc_client.go +++ b/universalClient/chains/evm/rpc_client.go @@ -94,6 +94,7 @@ func (rc *RPCClient) executeWithFailover(ctx context.Context, operation string, } maxAttempts := len(clients) + startIndex := atomic.AddUint64(&rc.index, 1) - 1 var lastErr error for attempt := 0; attempt < maxAttempts; attempt++ { if ctx != nil { @@ -104,8 +105,7 @@ func (rc *RPCClient) executeWithFailover(ctx context.Context, operation string, } } - index := atomic.AddUint64(&rc.index, 1) - 1 - client := clients[index%uint64(len(clients))] + client := clients[(startIndex+uint64(attempt))%uint64(len(clients))] if client == nil { continue diff --git a/universalClient/chains/svm/rpc_client.go b/universalClient/chains/svm/rpc_client.go index 89777cd1..4fe0e92f 100644 --- a/universalClient/chains/svm/rpc_client.go +++ b/universalClient/chains/svm/rpc_client.go @@ -110,6 +110,7 @@ func (rc *RPCClient) executeWithFailover(ctx context.Context, operation string, } maxAttempts := len(clients) + startIndex := atomic.AddUint64(&rc.index, 1) - 1 for attempt := 0; attempt < maxAttempts; attempt++ { if ctx != nil { select { @@ -119,8 +120,7 @@ func (rc *RPCClient) executeWithFailover(ctx context.Context, operation string, } } - index := atomic.AddUint64(&rc.index, 1) - 1 - client := clients[index%uint64(len(clients))] + client := clients[(startIndex+uint64(attempt))%uint64(len(clients))] if client == nil { continue