Skip to content

Conversation

@TheBlueMatt
Copy link
Collaborator

When we see a funding transaction for one of our chanels reorg'd out, we worry that its possible we've been double-spent and immediately force-close the channel to avoid accepting any more HTLCs on it. This isn't ideal, but is mostly fine as most nodes require 6 confirmations and 6 block reorgs are exceedingly rare.

However, this isn't so okay for 0-conf channels - in that case we elected to trust the funder anyway, so reorgs shouldn't worry us. Still, to handle this correctly we needed to track the old SCID and ensure our logic is safe across an SCID change. Luckily, we did that work for splices, and can now take advantage of it here.

Fixes #3836.

@TheBlueMatt TheBlueMatt added this to the 0.3 milestone Nov 18, 2025
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Nov 18, 2025

👋 Thanks for assigning @tankyleo 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.

When we see a funding transaction for one of our chanels reorg'd
out, we worry that its possible we've been double-spent and
immediately force-close the channel to avoid accepting any more
HTLCs on it. This isn't ideal, but is mostly fine as most nodes
require 6 confirmations and 6 block reorgs are exceedingly rare.

However, this isn't so okay for 0-conf channels - in that case we
elected to trust the funder anyway, so reorgs shouldn't worry us.
Still, to handle this correctly we needed to track the old SCID and
ensure our logic is safe across an SCID change. Luckily, we did
that work for splices, and can now take advantage of it here.

Fixes lightningdevkit#3836.
@TheBlueMatt TheBlueMatt force-pushed the 2025-11-0conf-no-reorg-close branch from 83e1ae9 to b4f7fdf Compare November 18, 2025 17:21
wpaulino
wpaulino previously approved these changes Nov 18, 2025
@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.

@ldk-reviews-bot
Copy link

✅ Added second reviewer: @tankyleo

@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

❌ Patch coverage is 95.53073% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.34%. Comparing base (21110c8) to head (37d5a21).
⚠️ Report is 42 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/channel.rs 80.00% 3 Missing ⚠️
lightning/src/ln/functional_test_utils.rs 81.25% 0 Missing and 3 partials ⚠️
lightning/src/ln/priv_short_conf_tests.rs 98.63% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4231      +/-   ##
==========================================
+ Coverage   89.33%   89.34%   +0.01%     
==========================================
  Files         180      180              
  Lines      138353   139177     +824     
  Branches   138353   139177     +824     
==========================================
+ Hits       123598   124353     +755     
- Misses      12132    12200      +68     
- Partials     2623     2624       +1     
Flag Coverage Δ
fuzzing 34.99% <29.03%> (-0.92%) ⬇️
tests 88.71% <95.53%> (+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.

} else {
debug_assert!(false);
}
if self.context.minimum_depth(&self.funding).expect("set for a ready channel") > 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we also not want to force close for 1-conf minimum channels ? Zero-conf channels have min depth 0 iiuc

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mmm, yea, when i was writing the patch I was thinking we should also not FC for 1 confs but then thought better of it cause we'd need a channel-freeze option. Good catch.

@TheBlueMatt TheBlueMatt force-pushed the 2025-11-0conf-no-reorg-close branch from 51dde37 to faf6e00 Compare December 2, 2025 16:32
@TheBlueMatt TheBlueMatt requested a review from tankyleo December 2, 2025 16:32
@TheBlueMatt TheBlueMatt force-pushed the 2025-11-0conf-no-reorg-close branch 2 times, most recently from 9312dfb to 850aef5 Compare December 2, 2025 16:37
@TheBlueMatt TheBlueMatt force-pushed the 2025-11-0conf-no-reorg-close branch from 850aef5 to 37d5a21 Compare December 2, 2025 16:38
@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Copy link
Contributor

@tankyleo tankyleo left a comment

Choose a reason for hiding this comment

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

LGTM @TheBlueMatt good to squash thanks

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.

Keep 0conf channels live if funding gets reorg'd out

4 participants