Commit graph

4910 commits

Author SHA1 Message Date
Elias Rohrer
5e3056e988
Merge pull request #3113 from TheBlueMatt/2024-04-async-monitor-fuzz
Fuzz reloading with a stale monitor in chanmon_consistency
2024-06-12 19:20:28 +02:00
Matt Corallo
920d96edb6 Unblock channels awaiting monitor update based on ChanMan queue
When we have `ChannelMonitorUpdate`s which are completing both
synchronously and asynchronously, we need to consider a channel as
unblocked based on the `ChannelManager` monitor update queue,
rather than by checking the `update_id`s.

Consider the case where a channel is updated, leading to a
`ChannelMonitorUpdate` which completes asynchronously. The update
completes, but prior to the `ChannelManager` receiving the
`MonitorEvent::Completed` it generates a further
`ChannelMonitorUpdate`. This second update completes synchronously.
As a result, when the `MonitorEvent` is processed, the event's
`monitor_update_id` is the first update, but there are no updates
queued and the channel should be free to return to be unblocked.

Here we fix this by looking only at the `ChannelManager` update
queue, rather than the update_id of the `MonitorEvent`.

While we don't anticipate many users having both synchronous and
asynchronous persists in the same application, there isn't much
cost to supporting it, which we do here.

Found by the chanmon_consistency target.
2024-06-12 15:32:33 +00:00
Valentine Wallace
3cfb24d265
InvoiceTlvStream{Ref}: add message_paths field
Will be used in static invoices. Also test that we'll fail to decode if these
paths are included in single-use BOLT 12 invoices.
2024-06-12 11:27:08 -04:00
Matt Corallo
64336faa75 Clarify Display text for ClosureReason::HolderForceClosed some
... to make it clear that we elected not to broadcast, rather than
failed to broadcast.
2024-06-11 19:01:13 +00:00
Matt Corallo
b8cdde8af6
Merge pull request #3107 from mhrheaume/mhr/closure_reason_abandoned
Updated `ClosureReason::HolderForceClosed` with whether txn was broadcasted.
2024-06-11 11:55:11 -07:00
Valentine Wallace
922fd601d2
Use ? instead of matching in BOLT 12 invoice parsing.
Minor cleanup to be more concise.
2024-06-11 14:55:09 -04:00
Valentine Wallace
f6bd1ebfc5
BOLT 12 invoice: extract helper for invoice signing pubkey checks
Will be useful for static invoices.
2024-06-11 14:55:06 -04:00
Valentine Wallace
b073711738
BOLT 12 invoice: expose common helper methods and fields
Useful for static invoice support.
2024-06-11 14:55:06 -04:00
Valentine Wallace
bbc15f56e9
Genericize BOLT 12 invoice{_builder} common macro docs over invoice type
Will be useful so the docs generated work for static invoices.
2024-06-11 14:55:02 -04:00
Jeffrey Czyz
4c297c9a3a
Implement Readable for Responder
A future InvoiceReceived event will include a Responder. Since Event
implements Readable, so must Responder.
2024-06-11 11:05:32 -05:00
Jeffrey Czyz
bfdfb9da27
Implement Readable for Bolt12Invoice
A future InvoiceReceived event will include a Bolt12Invoice. Since Event
implements Readable, so must Bolt12Invoice.
2024-06-11 11:05:32 -05:00
Jeffrey Czyz
3edbe76317
Re-order imports in events module 2024-06-11 11:05:32 -05:00
Jeffrey Czyz
1173e06f38
Clean up invoice handling result logic 2024-06-11 11:05:32 -05:00
Jeffrey Czyz
bccdf0d8e7
Use implicit returns from match expressions 2024-06-11 11:05:32 -05:00
Matt Corallo
a6664010fd
Merge pull request #3037 from TheBlueMatt/2024-05-close-on-stale-fees
Force-close channels if their feerate gets stale without any update
2024-06-11 07:20:00 -07:00
valentinewallace
f2237a78ff
Merge pull request #3086 from alecchendev/2024-05-holder-commitment
Add `HolderCommitmentPoint` struct to track commitment points
2024-06-10 18:30:09 -04:00
Alec Chen
cf545b4697 Get per commitment point everywhere else with HolderCommitmentPoint
This includes when building TxCreationKeys, as well as for open_channel
and accept_channel messages. Note: this is only for places where we are
retrieving the current per commitment point, which excludes
channel_reestablish.
2024-06-10 13:06:58 -07:00
Alec Chen
d189cf0e82 Get per commitment point for channel ready using HolderCommitmentPoint 2024-06-10 13:06:58 -07:00
Matthew Rheaume
808d814a76 Updated ClosureReason::HolderForceClosed with broadcasted txn. 2024-06-10 12:09:24 -07:00
Alec Chen
7a115d79ab Use HolderCommitmentPoint for commitment number 2024-06-10 10:39:47 -07:00
Alec Chen
c08aa349f5 Add HolderCommitmentPoint struct to ChannelContext 2024-06-10 10:39:47 -07:00
Matt Corallo
17b77e0bcf Add a test of stale-feerate-force-closure behavior 2024-06-10 15:17:58 +00:00
Matt Corallo
5a1cc288b7 Force-close channels if their feerate gets stale without any update
For quite some time, LDK has force-closed channels if the peer
sends us a feerate update which is below our `FeeEstimator`'s
concept of a channel lower-bound. This is intended to ensure that
channel feerates are always sufficient to get our commitment
transaction confirmed on-chain if we do need to force-close.

However, we've never checked our channel feerate regularly - if a
peer is offline (or just uninterested in updating the channel
feerate) and the prevailing feerates on-chain go up, we'll simply
ignore it and allow our commitment transaction to sit around with a
feerate too low to get confirmed.

Here we rectify this oversight by force-closing channels with stale
feerates, checking after each block. However, because fee
estimators are often buggy and force-closures piss off users, we
only do so rather conservatively. Specifically, we only force-close
if a channel's feerate is below the minimum `FeeEstimator`-provided
minimum across the last day.

Further, because fee estimators are often especially buggy on
startup (and because peers haven't had a chance to update the
channel feerates yet), we don't force-close channels until we have
a full day of feerate lower-bound history.

This should reduce the incidence of force-closures substantially,
but it is expected this will still increase force-closures somewhat
substantially depending on the users' `FeeEstimator`.

Fixes #993
2024-06-10 15:17:58 +00:00
Matt Corallo
88c291a9bc Add a new ClosureReason::PeerFeerateTooLow
Closure due to feerate disagreements are a specific closure reason
which admins can understand and tune their config (in the form of
their `FeeEstimator`) to avoid, so having a separate
`ClosureReason` for it is useful.
2024-06-10 15:12:28 +00:00
Matt Corallo
93011c377c Allow ChannelError to specify the ClosureReason
This will allow us to add more granular failure reasons when
returning the general `ChannelError::Close`.
2024-06-10 15:12:28 +00:00
Matt Corallo
3e09d9937e Use ChannelError::close constructor when building a close variant
In the next commit we'll add a second field to
`ChannelError::Close` so here we prep by converting existing calls
to the constructor function, which is almost a full-file sed.
2024-06-10 15:12:27 +00:00
Matt Corallo
73bc0f61b9 Add ChannelError::close constructor 2024-06-10 15:12:02 +00:00
Matt Corallo
8ca3259bfa
Merge pull request #3083 from valentinewallace/2024-05-ignore-onion-err-chan-upd
Ignore channel updates in onion errors
2024-06-07 12:25:46 -07:00
valentinewallace
88124a901a
Merge pull request #3080 from jkczyz/2024-05-compact-blinded-path-creation-trait
Optional compact blinded path creation
2024-06-07 14:32:24 -04:00
Arik
1e49c4a671
Merge pull request #3096 from alecchendev/2024-06-drop-one-signer-call
Cache commitment point on ExternalHTLCClaim to drop a signer call
2024-06-07 09:26:39 -07:00
John Cantrell
602921cf37
add peer_(dis)connected to custom message handler 2024-06-07 10:10:01 -04:00
Jeffrey Czyz
c17a026b07
Clarify docs regarding one-hop blinded paths
The docs assumed ChannelManager is parameterized by DefaultRouter, which
may not be the case. Clarify the behavior is specific to using
DefaultRouter.
2024-06-05 17:52:30 -05:00
Jeffrey Czyz
7db6616e52
Exclude disconnected peers from BlindedPath
When calling MessageRouter::create_blinded_path, ChannelManager was
including disconnected peers. Filter peers such that only connected ones
are included. Otherwise, the resulting BlindedPath may not work.
2024-06-05 17:52:30 -05:00
Jeffrey Czyz
15fa0d8f20
Fix functional_test_utils::reconnect_nodes
When reconnecting nodes, make sure to notify OnionMessenger that the
nodes are now connected.
2024-06-05 17:52:30 -05:00
Jeffrey Czyz
8012c2b213
Use compact blinded paths for short-lived offers
When an offer is short-lived, the likelihood of a channel used in a
compact blinded path going away is low. Require passing the absolute
expiry of an offer to ChannelManager::create_offer_builder so that it
can be used to determine whether or not compact blinded path should be
used.

Use the same criteria for creating blinded paths for refunds as well.
2024-06-05 17:52:30 -05:00
Jeffrey Czyz
411b9b43f6
Don't use compact blinded paths for reply paths
There's no need to save space when creating reply paths since they are
part of onion messages rather than in QR codes. Use normal blinded paths
for these instead as they are less likely to become invalid in case of
channel closure.
2024-06-05 17:52:30 -05:00
Jeffrey Czyz
5326171885
Refactor MessageRouter::create_blinded_paths
Using compact blinded paths isn't always necessary or desirable. For
instance, reply paths are communicated via onion messages where space
isn't a premium unlike in QR codes. Additionally, long-lived paths could
become invalid if the channel associated with the SCID is closed.
Refactor MessageRouter::create_blinded_paths into two methods: one for
compact blinded paths and one for normal blinded paths.
2024-06-05 17:52:30 -05:00
Jeffrey Czyz
defc54096d
Move DefaultMessageRouter::create_blinded_paths
An upcoming change to the MessageRouter trait will require reusing
DefaultMessageRouter::create_blinded_paths. Move the code to a utility
function so facilitate this.
2024-06-05 17:04:14 -05:00
Matt Corallo
2701bc512a
Merge pull request #3072 from arik-so/arik/gossip-v2-parsing
Reintroduce addresses to NodeAnnouncementInfo.
2024-06-05 14:39:21 -07:00
Alec Chen
4c1638c55e Cache commitment point on ExternalHTLCClaim to drop a signer call 2024-06-05 16:10:12 -05:00
Arik Sosman
db489baee2
Reintroduce addresses to NodeAnnouncementInfo. 2024-06-05 09:48:59 -07:00
Matt Corallo
e5b74026a0
Merge pull request #3091 from TheBlueMatt/2024-06-channel_state_ser
Move serialization of `channel_state` fields to `channel_state.rs`
2024-06-04 16:31:34 -07:00
Matt Corallo
8880b552cc
Merge pull request #3081 from G8XSU/2024-05-08-claimable-persist-3049-outputs
Watch all outputs irrespective of claimable outpoints
2024-06-04 14:02:41 -07:00
Valentine Wallace
7417406676
Move common BOLT 12 accessor methods to new macro.
Will be useful when we support static BOLT 12 invoices.
2024-06-04 16:29:34 -04:00
Valentine Wallace
45d7d2d95e
Move common BOLT 12 invoice builder setters to new macro.
Will be useful when we later add support for static BOLT 12 invoices.
2024-06-04 16:29:33 -04:00
Valentine Wallace
f18b490d87
Remove redundant checks in BOLT 12 invoice tests. 2024-06-04 16:25:18 -04:00
Matt Corallo
64e5dc4933 Fromat moved code in channel_state.rs 2024-06-04 19:33:00 +00:00
Matt Corallo
dff697d1a5 Move serialization of channel_state fields to channel_state.rs
1f616c0058 moved a handful of structs
to the new `channel_state.rs` but forgot to move their
serialization logic with them, which is corrected here.
2024-06-04 19:33:00 +00:00
Matt Corallo
3cd1cb5946
Merge pull request #3060 from TheBlueMatt/2024-05-parallel-async-om-events
Add a parallel async event handler to OnionMessenger and pass it directly to BackgroundProcessor
2024-06-04 12:10:43 -07:00
Matt Corallo
96fe1855a7
Merge pull request #3088 from alecchendev/2024-06-fc-no-disconnect
Don't disconnect on manual force closes
2024-06-04 08:47:22 -07:00