From 89960703d59084b8519e87a88b98ee2194fff941 Mon Sep 17 00:00:00 2001 From: sherpalden Date: Mon, 2 Dec 2024 14:39:03 +0545 Subject: [PATCH 1/3] fix: add logs for solana tx & reduce retry & implement context timeout --- relayer/chains/solana/listener.go | 14 ++++++++++---- relayer/chains/solana/tx.go | 3 +++ relayer/types/types.go | 5 +++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/relayer/chains/solana/listener.go b/relayer/chains/solana/listener.go index 75eeac4e..e3333047 100644 --- a/relayer/chains/solana/listener.go +++ b/relayer/chains/solana/listener.go @@ -85,7 +85,7 @@ func (p *Provider) listenByPolling(ctx context.Context, fromSignature string, bl //start processing from last index i.e oldest signature for i := len(txSigns) - 1; i >= 0; i-- { sign := txSigns[i].Signature - time.Sleep(1 * time.Second) + time.Sleep(500 * time.Millisecond) if err := p.processTxSignature(ctx, sign, blockInfo); err != nil { p.log.Error("failed to process tx signature", zap.String("signature", sign.String()), zap.Error(err)) } @@ -96,7 +96,9 @@ func (p *Provider) listenByPolling(ctx context.Context, fromSignature string, bl func (p *Provider) processTxSignature(ctx context.Context, sign solana.Signature, blockInfo chan *relayertypes.BlockInfo) error { txVersion := uint64(0) - txn, err := p.client.GetTransaction(ctx, sign, &solrpc.GetTransactionOpts{MaxSupportedTransactionVersion: &txVersion}) + timeoutCtx, cancel := context.WithTimeout(ctx, 20*time.Second) + defer cancel() + txn, err := p.client.GetTransaction(timeoutCtx, sign, &solrpc.GetTransactionOpts{MaxSupportedTransactionVersion: &txVersion}) if err != nil { return fmt.Errorf("failed to get txn with sign %s: %w", sign, err) } @@ -271,18 +273,22 @@ func (p *Provider) getSignatures(ctx context.Context, fromSignature string) ([]* case <-ctx.Done(): return nil, ctx.Err() case <-ticker.C: - txSigns, err := p.client.GetSignaturesForAddress(context.Background(), progId, opts) + timeoutCtx, cancel := context.WithTimeout(ctx, 20*time.Second) + defer cancel() + txSigns, err := p.client.GetSignaturesForAddress(timeoutCtx, progId, opts) if err != nil { p.log.Error("failed to get signatures for address", zap.String("account", progId.String()), zap.String("before", opts.Before.String()), zap.String("until", opts.Until.String()), + zap.Error(err), ) break } - p.log.Debug("signature query successful", + p.log.Info("signature query successful", zap.Int("received-count", len(txSigns)), + zap.Any("tx-signatures", txSigns), zap.String("account", progId.String()), zap.String("before", opts.Before.String()), zap.String("until", opts.Until.String()), diff --git a/relayer/chains/solana/tx.go b/relayer/chains/solana/tx.go index 0983983a..485c8916 100644 --- a/relayer/chains/solana/tx.go +++ b/relayer/chains/solana/tx.go @@ -35,6 +35,8 @@ func (p *Provider) Route(ctx context.Context, message *relayertypes.Message, cal zap.String("data", hex.EncodeToString(message.Data)), ) + return nil + instructions, signers, err := p.makeCallInstructions(message) if err != nil { return fmt.Errorf("failed to create call instructions: %w", err) @@ -1095,6 +1097,7 @@ func (p *Provider) MessageReceived(ctx context.Context, key *relayertypes.Messag default: return true, fmt.Errorf("unknown event type") case relayerevents.CallMessage, relayerevents.RollbackMessage: + time.Sleep(2 * time.Second) return false, nil case relayerevents.EmitMessage: receiptAc, err := p.pdaRegistry.ConnReceipt.GetAddress(key.Sn.FillBytes(make([]byte, 16))) diff --git a/relayer/types/types.go b/relayer/types/types.go index 9d03928a..872dbc0c 100644 --- a/relayer/types/types.go +++ b/relayer/types/types.go @@ -16,7 +16,7 @@ var ( XcallContract = "xcall" ConnectionContract = "connection" SupportedContracts = []string{XcallContract, ConnectionContract} - RetryInterval = 3*time.Second + RouteDuration + RetryInterval = 2*time.Second + RouteDuration DefaultCoinDecimals = 18 ) @@ -106,7 +106,8 @@ func (r *RouteMessage) GetRetry() uint8 { // ResetLastTry resets the last try time to the current time plus the retry interval func (r *RouteMessage) AddNextTry() { - r.LastTry = time.Now().Add(RetryInterval * time.Duration(math.Pow(2, float64(r.Retry)))) // exponential backoff + pf := r.Retry - 1 + r.LastTry = time.Now().Add(RetryInterval * time.Duration(math.Pow(2, float64(pf)))) // exponential backoff } func (r *RouteMessage) IsProcessing() bool { From bdda502c1a4946ba608d6a593441d52507f9f0b8 Mon Sep 17 00:00:00 2001 From: sherpalden Date: Mon, 2 Dec 2024 14:41:43 +0545 Subject: [PATCH 2/3] fix: remove wrong code --- relayer/chains/solana/tx.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/relayer/chains/solana/tx.go b/relayer/chains/solana/tx.go index 485c8916..197f3bd4 100644 --- a/relayer/chains/solana/tx.go +++ b/relayer/chains/solana/tx.go @@ -35,8 +35,6 @@ func (p *Provider) Route(ctx context.Context, message *relayertypes.Message, cal zap.String("data", hex.EncodeToString(message.Data)), ) - return nil - instructions, signers, err := p.makeCallInstructions(message) if err != nil { return fmt.Errorf("failed to create call instructions: %w", err) From f0630361396c30732deda9a2d00d016bf5f71120 Mon Sep 17 00:00:00 2001 From: bcsainju <157450414+bcsainju@users.noreply.github.com> Date: Mon, 2 Dec 2024 14:50:34 +0545 Subject: [PATCH 3/3] Update ref_name in release.yml --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3331be3a..f8964c2c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -51,10 +51,10 @@ jobs: platforms: linux/amd64,linux/arm64 push: true build-args: | - - RELAYER_VERSION=${{ github.ref }} + - RELAYER_VERSION=${{ github.ref_name }} tags: | iconcommunity/centralized-relay:latest - iconcommunity/centralized-relay:${{ github.ref }} + iconcommunity/centralized-relay:${{ github.ref_name }} - name: Install cosign uses: sigstore/cosign-installer@v3 @@ -65,4 +65,4 @@ jobs: COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }} run: | cosign sign --key env://COSIGN_PRIVATE_KEY iconcommunity/centralized-relay:latest - cosign sign --key env://COSIGN_PRIVATE_KEY iconcommunity/centralized-relay:${{ github.ref }} + cosign sign --key env://COSIGN_PRIVATE_KEY iconcommunity/centralized-relay:${{ github.ref_name }}