Skip to content

Commit

Permalink
Merge pull request #486 from icon-project/fix/solana-tx-not-found
Browse files Browse the repository at this point in the history
fix: retry solana tx
  • Loading branch information
sherpalden authored Feb 11, 2025
2 parents fd96158 + 6330f6d commit 1129cfb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.22

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

)
Expand Down Expand Up @@ -128,6 +128,7 @@ require (
golang.org/x/net v0.26.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/grpc v1.64.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/go-playground/validator.v9 v9.31.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
Expand Down Expand Up @@ -288,7 +289,7 @@ require (
github.com/zondax/hid v0.9.2 // indirect
github.com/zondax/ledger-go v0.14.3 // indirect
go.etcd.io/bbolt v1.3.8 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/crypto v0.25.0
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
github.com/avast/retry-go/v4 v4.6.0 h1:K9xNA+KeB8HHc2aWFuLb25Offp+0iVRXEvFx8IinRJA=
github.com/avast/retry-go/v4 v4.6.0/go.mod h1:gvWlPhBVsvBbLkVGDg/KwvBv0bEkCOLRRSHKIr2PyOE=
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
Expand Down
15 changes: 14 additions & 1 deletion relayer/chains/solana/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"encoding/json"
"fmt"
"io"
"time"

"github.com/avast/retry-go/v4"
"github.com/gagliardetto/solana-go"
solrpc "github.com/gagliardetto/solana-go/rpc"
"github.com/near/borsh-go"
Expand Down Expand Up @@ -266,7 +268,18 @@ func (cl Client) GetTransaction(
signature solana.Signature,
opts *solrpc.GetTransactionOpts,
) (*solrpc.GetTransactionResult, error) {
return cl.rpc.GetTransaction(ctx, signature, opts)
return retry.DoWithData(
func() (*solrpc.GetTransactionResult, error) {
return cl.rpc.GetTransaction(ctx, signature, opts)
},
retry.Attempts(10),
retry.Delay(3*time.Second),
retry.RetryIf(func(err error) bool {
return err == solrpc.ErrNotFound
}),
retry.LastErrorOnly(true),
retry.Context(ctx),
)
}

func (cl Client) GetRecentPriorityFee(
Expand Down
2 changes: 1 addition & 1 deletion relayer/chains/solana/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (p *Provider) listenByPolling(ctx context.Context, fromSignature string, bl

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

0 comments on commit 1129cfb

Please sign in to comment.