Skip to content

Commit 1129cfb

Browse files
authored
Merge pull request #486 from icon-project/fix/solana-tx-not-found
fix: retry solana tx
2 parents fd96158 + 6330f6d commit 1129cfb

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.22
44

55
require (
66
github.com/CosmWasm/wasmd v0.52.0
7+
github.com/avast/retry-go/v4 v4.6.0
78
github.com/cometbft/cometbft v0.38.10
89
github.com/coming-chat/go-sui/v2 v2.0.1
910
github.com/cosmos/cosmos-sdk v0.50.8
@@ -26,7 +27,6 @@ require (
2627
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d
2728
go.uber.org/zap v1.27.0
2829
golang.org/x/sync v0.7.0
29-
google.golang.org/grpc v1.64.0
3030
gopkg.in/yaml.v3 v3.0.1
3131

3232
)
@@ -128,6 +128,7 @@ require (
128128
golang.org/x/net v0.26.0 // indirect
129129
golang.org/x/time v0.5.0 // indirect
130130
google.golang.org/appengine v1.6.8 // indirect
131+
google.golang.org/grpc v1.64.0 // indirect
131132
google.golang.org/protobuf v1.34.1 // indirect
132133
gopkg.in/go-playground/validator.v9 v9.31.0 // indirect
133134
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
@@ -288,7 +289,7 @@ require (
288289
github.com/zondax/hid v0.9.2 // indirect
289290
github.com/zondax/ledger-go v0.14.3 // indirect
290291
go.etcd.io/bbolt v1.3.8 // indirect
291-
golang.org/x/crypto v0.25.0 // indirect
292+
golang.org/x/crypto v0.25.0
292293
golang.org/x/oauth2 v0.20.0 // indirect
293294
golang.org/x/sys v0.22.0 // indirect
294295
golang.org/x/term v0.22.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5
278278
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
279279
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
280280
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
281+
github.com/avast/retry-go/v4 v4.6.0 h1:K9xNA+KeB8HHc2aWFuLb25Offp+0iVRXEvFx8IinRJA=
282+
github.com/avast/retry-go/v4 v4.6.0/go.mod h1:gvWlPhBVsvBbLkVGDg/KwvBv0bEkCOLRRSHKIr2PyOE=
281283
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
282284
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
283285
github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=

relayer/chains/solana/client.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import (
77
"encoding/json"
88
"fmt"
99
"io"
10+
"time"
1011

12+
"github.com/avast/retry-go/v4"
1113
"github.com/gagliardetto/solana-go"
1214
solrpc "github.com/gagliardetto/solana-go/rpc"
1315
"github.com/near/borsh-go"
@@ -266,7 +268,18 @@ func (cl Client) GetTransaction(
266268
signature solana.Signature,
267269
opts *solrpc.GetTransactionOpts,
268270
) (*solrpc.GetTransactionResult, error) {
269-
return cl.rpc.GetTransaction(ctx, signature, opts)
271+
return retry.DoWithData(
272+
func() (*solrpc.GetTransactionResult, error) {
273+
return cl.rpc.GetTransaction(ctx, signature, opts)
274+
},
275+
retry.Attempts(10),
276+
retry.Delay(3*time.Second),
277+
retry.RetryIf(func(err error) bool {
278+
return err == solrpc.ErrNotFound
279+
}),
280+
retry.LastErrorOnly(true),
281+
retry.Context(ctx),
282+
)
270283
}
271284

272285
func (cl Client) GetRecentPriorityFee(

relayer/chains/solana/listener.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (p *Provider) listenByPolling(ctx context.Context, fromSignature string, bl
122122

123123
func (p *Provider) processTxSignature(ctx context.Context, sign solana.Signature, blockInfo chan *relayertypes.BlockInfo) (*solrpc.GetTransactionResult, error) {
124124
txVersion := uint64(0)
125-
timeoutCtx, cancel := context.WithTimeout(ctx, 20*time.Second)
125+
timeoutCtx, cancel := context.WithTimeout(ctx, 60*time.Second)
126126
defer cancel()
127127
txn, err := p.client.GetTransaction(timeoutCtx, sign, &solrpc.GetTransactionOpts{MaxSupportedTransactionVersion: &txVersion})
128128
if err != nil {

0 commit comments

Comments
 (0)