-
Notifications
You must be signed in to change notification settings - Fork 421
Fix SCID removal when an HTLC is pending from 0.1 before upgrading #4167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
TheBlueMatt
merged 8 commits into
lightningdevkit:main
from
TheBlueMatt:2025-10-upgrade-scid-timeout
Oct 27, 2025
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c418034
Remove previous holder HTLC data on splice locked when necessary
wpaulino f2ada1a
Fix legacy SCID pruning
wpaulino b84ad65
Test inflight HTLC forward and resolution after locked splice
wpaulino e95ebf8
Properly handle funding key rotation during splices
TheBlueMatt 491b694
Enforce that `ChanelSigner::pubkeys` is only called once
TheBlueMatt 0f4e6c2
Fix `generated_by_local` arg to build commmitment during splicing
TheBlueMatt d12c6a3
Correct spliced-stale SCID expiry for upgrades from pre-0.2 HTLC
TheBlueMatt 2c836b3
Add an upgrade test of splicing after upgrading from 0.1
TheBlueMatt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,9 @@ use crate::prelude::*; | |
| #[cfg(any(test, feature = "_test_utils"))] | ||
| use crate::sync::MutexGuard; | ||
| use crate::sync::{Arc, Mutex}; | ||
|
|
||
| use core::cmp; | ||
| use core::sync::atomic::{AtomicBool, Ordering}; | ||
|
|
||
| use bitcoin::hashes::Hash; | ||
| use bitcoin::sighash; | ||
|
|
@@ -68,13 +70,31 @@ pub const INITIAL_REVOKED_COMMITMENT_NUMBER: u64 = 1 << 48; | |
| /// | ||
| /// Note that before we do so we should ensure its serialization format has backwards- and | ||
| /// forwards-compatibility prefix/suffixes! | ||
| #[derive(Clone)] | ||
| pub struct TestChannelSigner { | ||
| pub inner: DynSigner, | ||
| /// Channel state used for policy enforcement | ||
| pub state: Arc<Mutex<EnforcementState>>, | ||
| pub disable_revocation_policy_check: bool, | ||
| pub disable_all_state_policy_checks: bool, | ||
| have_fetched_pubkeys: AtomicBool, | ||
| } | ||
|
|
||
| impl Clone for TestChannelSigner { | ||
| fn clone(&self) -> Self { | ||
| // Generally, a signer should only ever be cloned when a ChannelMonitor is cloned (which | ||
| // doesn't fetch the pubkeys at all). This isn't really a critical test, but if it | ||
| // it ever does fail we should make sure the clone is hapening in a sensible place. | ||
| assert!(!self.have_fetched_pubkeys.load(Ordering::Acquire)); | ||
| Self { | ||
| inner: self.inner.clone(), | ||
| state: Arc::clone(&self.state), | ||
| disable_revocation_policy_check: self.disable_revocation_policy_check, | ||
| disable_all_state_policy_checks: self.disable_all_state_policy_checks, | ||
| // In some tests we clone a `ChannelMonitor` multiple times, so have to initialize with | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so we* |
||
| // `!have_fetched_pubkeys` to ensure the above assertion passes. | ||
| have_fetched_pubkeys: AtomicBool::new(false), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
|
|
@@ -129,6 +149,7 @@ impl TestChannelSigner { | |
| state, | ||
| disable_revocation_policy_check: false, | ||
| disable_all_state_policy_checks: false, | ||
| have_fetched_pubkeys: AtomicBool::new(false), | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -141,7 +162,13 @@ impl TestChannelSigner { | |
| inner: DynSigner, state: Arc<Mutex<EnforcementState>>, | ||
| disable_revocation_policy_check: bool, disable_all_state_policy_checks: bool, | ||
| ) -> Self { | ||
| Self { inner, state, disable_revocation_policy_check, disable_all_state_policy_checks } | ||
| Self { | ||
| inner, | ||
| state, | ||
| disable_revocation_policy_check, | ||
| disable_all_state_policy_checks, | ||
| have_fetched_pubkeys: AtomicBool::new(false), | ||
| } | ||
| } | ||
|
|
||
| #[cfg(any(test, feature = "_test_utils"))] | ||
|
|
@@ -222,6 +249,7 @@ impl ChannelSigner for TestChannelSigner { | |
| } | ||
|
|
||
| fn pubkeys(&self, secp_ctx: &Secp256k1<secp256k1::All>) -> ChannelPublicKeys { | ||
| assert!(!self.have_fetched_pubkeys.swap(true, Ordering::AcqRel)); | ||
| self.inner.pubkeys(secp_ctx) | ||
| } | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.