Skip to content

Conversation

Prabhat1308
Copy link
Contributor

fixes #3915
adds test for #2119

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Aug 16, 2025

👋 Thanks for assigning @wpaulino as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@Prabhat1308 Prabhat1308 force-pushed the pv/update_WatchedOutput branch from 24667d6 to a2bd207 Compare August 17, 2025 13:00
Copy link

codecov bot commented Aug 17, 2025

Codecov Report

❌ Patch coverage is 90.69767% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.68%. Comparing base (ac8f897) to head (a2bd207).

Files with missing lines Patch % Lines
lightning/src/chain/chainmonitor.rs 33.33% 2 Missing ⚠️
lightning/src/ln/monitor_tests.rs 94.59% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4016      +/-   ##
==========================================
- Coverage   88.85%   88.68%   -0.17%     
==========================================
  Files         175      174       -1     
  Lines      127710   127633      -77     
  Branches   127710   127633      -77     
==========================================
- Hits       113478   113197     -281     
- Misses      11675    11957     +282     
+ Partials     2557     2479      -78     
Flag Coverage Δ
fuzzing ?
tests 88.68% <90.69%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tnull tnull requested review from tnull and removed request for joostjager August 18, 2025 07:06
Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, note that the original comment linked on #3915 was regarding ChainMonitor, not the places you're changing here. I also don't think we can just always plug-in the current block hash, but (depending on the context) rather need to track the earliest block hash where the respective output spent could have happened.

use std::ops::Deref;

// Custom test filter to capture full WatchedOutput instances
struct TestFilter {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than creating a new test util, you should be able to reuse crate::util::test_utils::TestChainSource.

#[test]

fn test_watched_output_block_hash_persistence_after_restart() {
use crate::chain::WatchedOutput;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move any imports to the module-level.

@@ -3298,3 +3298,80 @@ fn test_claim_event_never_handled() {
// `ChannelMonitorUpdate`.
check_added_monitors(&nodes[1], 2);
}

#[test]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Stray whitespace.

@@ -1212,7 +1213,8 @@ where
);
chain_source.register_tx(&funding_outpoint.txid, &funding_script);
chain_source.register_output(WatchedOutput {
block_hash: None,
block_hash: Some(current_block_hash),
// block_hash: None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the commented-out lines here and below.

mine_transactions(&nodes[1], &[]);
}

let expected_block_hash = nodes[1].best_block_hash();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expected block hash should be earliest hash the given output could potentially appear in. That means it would need to be the earliest block hash here i.e., the hash even before mining any additional blocks, no?

@ldk-reviews-bot
Copy link

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

@tnull tnull requested a review from wpaulino August 18, 2025 10:28
@@ -2002,7 +2003,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
let outpoint = OutPoint { txid: *txid, index: *index as u16 };
log_trace!(logger, "Registering outpoint {} with the filter to monitor spend", outpoint);
filter.register_output(WatchedOutput {
block_hash: None,
block_hash: Some(current_block_hash),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're interested in the spend of an output, ideally this block hash is for the block the output was created in, or if it has not been created yet, the current block hash. This means we'll need to store it so we can reuse it here when this gets called on startup.

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.

Set WatchedOutput::block_hash to Some
4 participants