Make bitcoind optional: add transaction-sync as an alternative chain backend#126
Make bitcoind optional: add transaction-sync as an alternative chain backend#126bitwalt wants to merge 1 commit into
Conversation
0e5ad71 to
9500239
Compare
zoedberg
left a comment
There was a problem hiding this comment.
Please check my comment #125 (comment), I explained why we should not replace the block-sync with the transaction-sync but add it instead as an alternative sync mode. Please update this PR accordingly
|
Hi @bitwalt, here #125 (comment) you said you agreed in updating this PR to add this as an alternative sync mode. Are you still willing to complete this PR? |
|
Hi Zoe, sure I'll try to complete this |
…backend Adds `lightning-transaction-sync` (electrum/esplora) as an alternative to the existing `lightning-block-sync` (bitcoind) chain backend, rather than replacing it (addresses the review on RGB-Tools#126 / RGB-Tools#125). The sync mode is selected explicitly at unlock time via a new `sync_mode` tag on the unlock request: - `block_sync` (default): consume full blocks from a trusted/local bitcoind over JSON-RPC. The bitcoind RPC parameters now live inside this variant, so they are required exactly when this mode is selected and rejected otherwise, with no manual "all or none" validation. - `transaction_sync`: sync through the configured electrum/esplora `indexer_url` only; no bitcoind required. Each backend is gated behind a Cargo feature (`block-sync`, `transaction-sync`), both enabled by default, so a user can build with only the sync dependency they need. A single mode is still fully functional on its own. LDK is wired against trait objects for the fee estimator, broadcaster and gossip UTXO lookup so one set of type aliases serves both backends. Because `lightning-block-sync`'s `GossipVerifier` requires the `P2PGossipSync` to be typed with `Arc<Self>`, a `BlockSyncGossipVerifier` provides the block-sync gossip UTXO lookup against the shared trait-object gossip sync. Adds an integration test for the transaction-sync backend: two nodes are unlocked in transaction-sync mode, an RGB asset channel is opened, a node is restarted (re-establishing the channel after syncing via the indexer) and the channel is cooperatively closed. Closes RGB-Tools#125 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
9500239 to
536b29f
Compare
|
Thanks @zoedberg — I've reworked the PR along the lines you suggested. Rather than replacing block-sync, it now keeps
Both are behind Cargo features ( I added the integration test you described (unlock 2 nodes, open a channel, restart a node, close the channel) exercising the transaction-sync path, and the existing block-sync tests still pass. Two notes for review:
|
Implements #125.
Reworked per @zoedberg's review: instead of replacing
lightning-block-syncwithlightning-transaction-sync, this adds transaction-sync as an alternative chain backend and keeps block-sync intact. The sync mode is chosen explicitly at unlock time.Sync modes
The
/unlockpayload gains async_modetag:block_sync(default): consume full blocks from a trusted/local bitcoind over JSON-RPC (lightning-block-sync). Thebitcoind_rpc_*parameters live inside this variant, so they are required exactly when this mode is selected and rejected otherwise — no manual "all or none" validation. This is the more trust-minimized / local-first option.transaction_sync: sync through the configured electrum/esploraindexer_url(lightning-transaction-sync). No bitcoind required — lighter to deploy for indexer-based setups.Cargo features
Each backend is gated behind a feature (
block-sync,transaction-sync), both enabled by default, so a user who wants only one sync type can build with only the dependency they need. Both single-feature builds compile cleanly, and requesting a mode that wasn't compiled in returns a clear error.Implementation notes
lightning-block-sync'sGossipVerifierrequires theP2PGossipSyncto be typed withArc<Self>, a smallBlockSyncGossipVerifierprovides the block-sync gossip UTXO lookup against the shared trait-object gossip sync (mirroring the transaction-syncIndexerGossipVerifier).Tests
Adds an integration test for the transaction-sync backend (as suggested): two nodes are unlocked in transaction-sync mode, an RGB asset channel is opened, a node is restarted (re-establishing the channel after syncing via the indexer) and the channel is cooperatively closed. The existing block-sync tests continue to pass unchanged.