Uh oh!
There was an error while loading. Please reload this page.
Add electrum support to lightning-transaction-sync - #2685
Conversation
eadc4ba to
dfcc2f5CompareCodecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@## main #2685 +/- ##
==========================================
- Coverage 88.55% 88.53% -0.02%
==========================================
Files 113 113 Lines 89323 89334 +11 Branches 89323 89334 +11 ==========================================
- Hits 79097 79090 -7 - Misses 7860 7875 +15 - Partials 2366 2369 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
c684ae0 to
75ad902Comparetnull
commented
Oct 30, 2023
Did some further cleanup, should be ready for review now. |
75ad902 to
e38abe0Compare
jkczyz
left a comment
There was a problem hiding this comment.
Still have a bit to get through
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
e38abe0 to
74cafd3CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
74cafd3 to
5ba1c45Compare
jkczyz
left a comment
There was a problem hiding this comment.
Mostly looks good. Feel free to squash fixups. Will take a final pass after.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
5ba1c45 to
ce31cf2Comparetnull
commented
Nov 8, 2023
Squashed previous fixups and addressed the pending comments. |
jkczyz
left a comment
There was a problem hiding this comment.
LGTM after a couple minor comments
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
ce31cf2 to
d9f6d41Comparetnull
commented
Nov 10, 2023
Squashed fixups and included the following changes: diff --git a/lightning-transaction-sync/src/electrum.rs b/lightning-transaction-sync/src/electrum.rs
index a37d017fd..a002fc8e2 100644
--- a/lightning-transaction-sync/src/electrum.rs+++ b/lightning-transaction-sync/src/electrum.rs@@ -320,13 +320,13 @@ where
if let Some(history) = script_history.iter()
.filter(|h| h.tx_hash == txid).max_by_key(|x| x.height)
- {- let prob_conf_height = history.height;- let block_header = self.client.block_header(- prob_conf_height as usize)?;- if block_header.block_hash() == block_hash {- // Skip if the tx is still confirmed in the block in question.- continue;- }+ {+ let prob_conf_height = history.height;+ let block_header = self.client.block_header(+ prob_conf_height as usize)?;+ if block_header.block_hash() == block_hash {+ // Skip if the tx is still confirmed in the block in question.+ continue;
}
+ }
}
}
@@ -404,11 +404,6 @@ where
for mut bytes in merkle_res.merkle {
bytes.reverse();
- let next_hash = Sha256d::from_slice(&bytes).map_err(|_| {- log_error!(self.logger,- "Failed due to the server sending us bogus transaction data. This should not happen. Please verify server integrity."- );- InternalError::Failed- })?;-+ // unwrap() safety: `bytes` has len 32 so `from_slice` can never fail.+ let next_hash = Sha256d::from_slice(&bytes).unwrap();
let (left, right) = if index % 2 == 0 {
(cur, next_hash) |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
d9f6d41 to
e14f83eComparetnull
commented
Nov 15, 2023
Moved logging and updating > git diff-tree -U2 a48cf50b8 d609b5d37diff --git a/lightning-transaction-sync/src/electrum.rs b/lightning-transaction-sync/src/electrum.rs
index 9d39ed87b..4dbd53609 100644
--- a/lightning-transaction-sync/src/electrum.rs+++ b/lightning-transaction-sync/src/electrum.rs@@ -113,7 +113,9 @@ where
// Double-check the tip hash. If it changed, a reorg happened since
// we started syncing and we need to restart last-minute.
- if self.check_has_chain_moved(&mut sync_state, &mut tip_header,- &mut tip_height)?+ if self.check_update_tip(&mut tip_header, &mut tip_height)?
{
+ log_debug!(self.logger,+ "Encountered inconsistency during transaction sync, restarting.");+ sync_state.pending_sync = true;
continue;
}
@@ -145,7 +147,9 @@ where
// Double-check the tip hash. If it changed, a reorg happened since
// we started syncing and we need to restart last-minute.
- if self.check_has_chain_moved(&mut sync_state, &mut tip_header,- &mut tip_height)?+ if self.check_update_tip(&mut tip_header, &mut tip_height)?
{
+ log_debug!(self.logger,+ "Encountered inconsistency during transaction sync, restarting.");+ sync_state.pending_sync = true;
continue;
}
@@ -186,5 +190,7 @@ where
}
- fn check_has_chain_moved(&self, sync_state: &mut SyncState, cur_tip_header: &mut BlockHeader, cur_tip_height: &mut u32) -> Result<bool, InternalError> {+ fn check_update_tip(&self, cur_tip_header: &mut BlockHeader, cur_tip_height: &mut u32)+ -> Result<bool, InternalError>+ {
let check_notification = self.client.block_headers_subscribe()?;
let check_tip_hash = check_notification.header.block_hash();
@@ -203,8 +209,4 @@ where
*cur_tip_header = check_notification.header;
*cur_tip_height = check_notification.height as u32;
- log_debug!(self.logger,- "Encountered inconsistency during transaction sync, restarting.");- sync_state.pending_sync = true;-
Ok(true)
} else { |
Uh oh!
There was an error while loading. Please reload this page.
85c0d77 to
c8dca25Comparetnull
commented
Nov 16, 2023
Now included two more commits that set |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
c8dca25 to
36ade54Comparetnull
commented
Nov 22, 2023
TheBlueMatt
left a comment
There was a problem hiding this comment.
Should be good to go. I dunno if @jkczyz had any other thoughts, though.
We previously included the block hash, but it's also useful to include the height under which we expect the respective transaction to be confirmed.
We give some more information while reducing the log levels to make the logging less spammy. We also convert one safe-to-unwrap case from returning an error to unwrapping the value.
In particular, we now test `register_output` functionality, too.
36ade54 to
c2e81fbComparetnull
commented
Nov 23, 2023
Rebased on main after #2740 landed. |
Now that we upgraded `esplora-client` to 0.6 we can use `async-https-rustls` instead of manually overriding the `reqwest` dependency.
tnull
commented
Nov 24, 2023
Introduced a small follow-up commit to the rebase. As we've now upgraded to use |
Closes#2010.
This PR implements an
ElectrumSyncClientthat allows syncing LDK via theConfirm/Filterinterfaces based on BDK'selectrum-clientcrate.We furthermore improve the logging in
EsploraSyncClientandElectrumSyncClient, and extend our test coverage.Currently in draft as I want to do some further cleanup and experimentation.