Skip to content

Increase the chance of syncing success#1130

Merged
chedieck merged 2 commits into
PayButton:masterfrom
Fabcien:sync_bch
Jun 2, 2026
Merged

Increase the chance of syncing success#1130
chedieck merged 2 commits into
PayButton:masterfrom
Fabcien:sync_bch

Conversation

@Fabcien
Copy link
Copy Markdown
Collaborator

@Fabcien Fabcien commented May 29, 2026

  • The BCH syncing is the less resource intensive but also the most brittle as it only uses a single Chronik instance. To avoid restarting syncing of all eCash each time it fails, the first commit makes it start with BCH.
  • There already is a retry mechanism for fetching txs in some paths, but it's not generalized: the second commit apply the same logic to all Chronik calls.

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced reliability of blockchain service requests through automatic retry logic, reducing failures from transient network issues during data synchronization and transaction operations.
  • Tests

    • Added test coverage for retry mechanism behavior in both success and failure scenarios.

Review Change Stack

Fabcien added 2 commits May 29, 2026 15:35
Only fetchTxWithRetry has the feature currently, use the same approach for all calls. This will avoid spurious failures due to e.g. chronik switching instance.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a781716a-b50e-4d6d-83f0-0ad7ad4000ff

📥 Commits

Reviewing files that changed from the base of the PR and between 7d4e91d and d94da9b.

📒 Files selected for processing (3)
  • constants/index.ts
  • services/chronikService.ts
  • tests/unittests/chronikService.test.ts

📝 Walkthrough

Walkthrough

This PR adds a generic exponential backoff retry wrapper (chronikCallWithRetry) for Chronik RPC calls and applies it across multiple fetch methods. Configuration constants define retry count (3) and initial delay (1000 ms). Existing methods are refactored to use the unified helper, duplicated retry logic is removed, and a new paginated block transaction method is introduced.

Changes

Chronik Retry Resilience

Layer / File(s) Summary
Retry Configuration and Core Helper
constants/index.ts, services/chronikService.ts
Adds CHRONIK_TRIES and CHRONIK_RETRY_DELAY_MS constants and implements chronikCallWithRetry with exponential backoff for generic Chronik operation wrapping.
Refactor Existing Methods to Use Unified Retry
services/chronikService.ts
Updates getPaginatedTxs, getUtxos, getTransactionDetails to wrap calls with chronikCallWithRetry, and refactors fetchTxWithRetry to delegate to the unified helper.
Block Transaction Pagination and Sync Order
services/chronikService.ts
Adds getBlockTxsPage for paginated block transaction fetching and updates syncBlockTransactions to use it; swaps bitcoincash and ecash sync order in MultiBlockchainClient.syncMissedTransactions().
Chronik Retry Test Coverage
tests/unittests/chronikService.test.ts
Adds two test cases verifying chronikCallWithRetry retry-after-error and retry-exhaustion behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

enhancement (behind the scenes)

Suggested reviewers

  • chedieck
  • Klakurka

🐰 A hop, a skip, a retry grace—
Exponential backoff saves the race!
Chronik calls now dance with care,
Resilience blooming everywhere.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description clearly explains both commits and their purposes, but lacks required template sections like 'Related to #', 'Test plan', and structured formatting. Add issue reference, test plan section, and follow the repository's description template structure for better clarity and documentation.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly reflects the main objective of improving syncing resilience through retry logic and order optimization.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Klakurka Klakurka added the enhancement (behind the scenes) Stuff that users won't see label May 29, 2026
@Klakurka Klakurka added this to the Phase 3 milestone May 29, 2026
@Klakurka Klakurka requested a review from chedieck June 1, 2026 03:21
@chedieck chedieck merged commit 098b16b into PayButton:master Jun 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement (behind the scenes) Stuff that users won't see

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants