Skip to content

feat(cbf): add auto-restart with exponential backoff#10

Merged
febyeji merged 5 commits intoadd-cbf-chain-sourcefrom
add-cbf-auto-restart
Apr 6, 2026
Merged

feat(cbf): add auto-restart with exponential backoff#10
febyeji merged 5 commits intoadd-cbf-chain-sourcefrom
add-cbf-auto-restart

Conversation

@febyeji
Copy link
Copy Markdown
Owner

@febyeji febyeji commented Apr 6, 2026

Summary

  • Extract build_cbf_node helper and thread Arc to enable node rebuilding without &self
  • Auto-restart bip157 node on failure (e.g. NoReachablePeers from kyoto#558) with exponential backoff (500ms
    base, max 5 retries)
  • Add is_running() liveness check in requester() for immediate failure signal
  • Clean up scan state on filter scan failure
  • Add per-block-fetch timeout using per_request_timeout_secs config (kyoto#556)
    EOF
    gh pr create --repo febyeji/ldk-node --base add-cbf-chain-source --head add-cbf-auto-restart --title
    "feat(cbf): add auto-restart with exponential backoff" --body-file /tmp/pr-body.txt

febyeji added 5 commits April 6, 2026 11:17
Preparation for auto-restart: extract bip157 node build logic into a
reusable helper method, add chain_state() from wallet checkpoint to avoid
genesis re-sync, and thread Arc<Wallet> through start().

AI: claude
When node.run() exits (e.g. NoReachablePeers from kyoto lightningdevkit#558), the
background task rebuilds the node, swaps the requester, and respawns
channel processing tasks, up to MAX_RESTART_RETRIES (5) attempts with
doubling backoff starting at 500ms.

- Change cbf_runtime_status from Mutex<> to Arc<Mutex<>> so it can be
  shared with the async restart loop
- Extract build_cbf_node_static() that takes explicit params instead of
  &self, enabling calls from 'static async blocks
- Move all task spawning (info/warn/event + node.run) into a single
  restart loop inside spawn_background_task

AI: claude
requester() now checks is_running() to give callers an immediate failure
signal instead of waiting for SendError to propagate through the channel.
Extract cleanup_scan_state() helper and call it on error paths in
run_filter_scan() to prevent stale watched_scripts, matched_block_hashes,
and filter_skip_height from leaking between scans.
Wrap individual get_block() calls in tokio::time::timeout using the
existing per_request_timeout_secs config. Previously only the overall sync
had a timeout; individual block fetches could hang indefinitely (kyoto lightningdevkit#556).
@febyeji febyeji merged commit 22cb2c2 into add-cbf-chain-source Apr 6, 2026
37 of 38 checks passed
febyeji added a commit that referenced this pull request Apr 7, 2026
  add auto-restart with exponential backoff (#10)

* refactor(cbf): extract build_cbf_node helper and add wallet reference
* feat(cbf): auto-restart bip157 node with exponential backoff
* feat(cbf): add liveness check before returning requester
* fix(cbf): clean up scan state on filter scan failure
* fix(cbf): add per-block-fetch timeout to wallet sync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant