Skip to content

Commit

Permalink
Merge branch 'main' of github.com:icon-project/centralized-relay
Browse files Browse the repository at this point in the history
  • Loading branch information
debendraoli committed Dec 2, 2024
2 parents 749b60f + c0fe7c0 commit bab9637
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
14 changes: 10 additions & 4 deletions relayer/chains/solana/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -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()),
Expand Down
1 change: 1 addition & 0 deletions relayer/chains/solana/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,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)))
Expand Down
5 changes: 3 additions & 2 deletions relayer/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit bab9637

Please sign in to comment.