Skip to content

fix(backend): distributed-lock fencing, metrics on RPC failure, webhook retry consolidation, yield history tests#1292

Open
dikachim060-wq wants to merge 4 commits into
LabsCrypt:mainfrom
dikachim060-wq:fix/remitlend-backend-batch
Open

fix(backend): distributed-lock fencing, metrics on RPC failure, webhook retry consolidation, yield history tests#1292
dikachim060-wq wants to merge 4 commits into
LabsCrypt:mainfrom
dikachim060-wq:fix/remitlend-backend-batch

Conversation

@dikachim060-wq

Copy link
Copy Markdown

Note: this contribution was authored with AI assistance (Claude Code).

Summary

This batch PR addresses four backend issues assigned in Wave 6: atomic distributed-lock release, suppressing false-healthy metrics on RPC failure, wiring the correct webhook retry implementation, and adding missing test coverage for yield history share/cost-basis logic.

closes #1163
closes #1201
closes #1167
closes #1171

Changes

Test plan


Not built/tested locally (dependencies not installed in the Wave workspace); relying on CI for compilation and full test-suite validation.

dikachim060-wq and others added 4 commits June 29, 2026 10:24
…for lock release (LabsCrypt#1163)

acquireLock now stores the unique token it set in Redis as a private
instance variable. releaseLock calls a new cacheService.deleteIfEqual
that evaluates a Lua compare-and-delete atomically, so a run that
outlives the 10-minute LOCK_TTL cannot delete a lock acquired by a
subsequent instance.

Co-Authored-By: Claude <noreply@anthropic.com>
…nt false-healthy readings (LabsCrypt#1201)

getLatestLedgerSequence now returns null instead of 0 on error, and
increments a new indexer_rpc_fetch_errors_total counter. pollOnce skips
recordIndexerLedgers when the tip is null, so an RPC outage no longer
resets indexer_lag_ledgers to 0 and silently defeats the behind-chain-tip alert.

Co-Authored-By: Claude <noreply@anthropic.com>
…s and XDR share-decoding (LabsCrypt#1171)

Adds three tests:
- Withdraw with value=null verifying cost-basis is reduced proportionally
  (shareRatio = withdrawn/total shares, costBasis *= 1 - shareRatio)
- Deposit + Withdraw with a non-null base64 XDR ScVec value asserting
  shares are decoded and BigInt values converted via the parseDepositWithdrawAmounts path
- EmergencyWithdraw encoded in XDR following the same cost-basis path

Co-Authored-By: Claude <noreply@anthropic.com>
…ocessor as the live retry path (LabsCrypt#1167)

startWebhookRetryProcessor (which drives WebhookService.processRetries)
is now wired in index.ts in place of startWebhookRetryScheduler.
This makes the retry schedule single-sourced through processRetries,
which respects the next_retry_at timestamps stored by sendToWebhook
(RETRY_DELAYS_MS: 5m/15m/45m, MAX_RETRY_ATTEMPTS=4).
The old scheduler's independent BACKOFF=[60,300,1800]s that ignored
next_retry_at is no longer the live path.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment