Commit graph

5075 commits

Author SHA1 Message Date
Valentine Wallace
c8888e6d66
Test router: support expecting blinded payment paths. 2024-07-03 14:31:13 -04:00
Valentine Wallace
c239b1c899
Remove spurious commented out code line. 2024-07-03 14:28:20 -04:00
Alec Chen
3775edd7ee Allow sending RAA upon unblocking the signer 2024-07-02 19:11:44 -07:00
Matt Corallo
46ba6a8fbb Fix spelling in comment
From @valentinewallace at
https://github.com/lightningdevkit/rust-lightning/pull/3144#discussion_r1661404243
2024-07-02 22:18:17 +00:00
Matt Corallo
8d240cfe3e
Merge pull request #3144 from TheBlueMatt/2024-06-message-flags
(Re-)add handling for `ChannelUpdate::message_flags`
2024-07-02 15:16:59 -07:00
Matt Corallo
dc3f826123 (Re-)add handling for ChannelUpdate::message_flags
When the `htlc_maximum_msat` field was made mandatory in
`ChannelUpdate` (in b0e8b739b7) we
started ignoring the `message_flags` field entirely and always
writing `1`. The comment updates indicated that the `message_flags`
field was deprecated, but this is not true - only the
`htlc_maximum_msat` indicator bit was deprecated, requiring it to
be 1.

If a node creates a `channel_update` with `message_flags` bits set
other than the low bit, this will cause us to spuriously reject
the message with an invalid signature error as we will check the
message against the wrong hash.

With today's current spec this is totally fine - the only other bit
defined for `message_flags` is the `dont_forward` bit, which when
set indicates we shouldn't accept the message into our gossip store
anyway (though this may lead to spurious `warning` messages being
sent to peers). However, in the future this may mean we start
rejecting valid `channel_update`s if new bits are defiend.
2024-07-01 23:46:34 +00:00
Alec Chen
1ce5bbd47a Async signing test util follow ups
- Remove unused unavailable signers in TestKeysInterface
- Remove unnecessary display implementation for SignerOp
- Move set of test disabled signer ops to EnforcementState
- Add method to enable/disable all signer ops at once
2024-07-01 16:11:20 -07:00
Jeffrey Czyz
3ccf064160
Merge pull request #3129 from optout21/splicing-msgs-update
Update splice messages according to new spec draft
2024-06-27 14:39:26 -05:00
Elias Rohrer
b3223abbe1
Merge pull request #3147 from TheBlueMatt/2024-06-feerate-overflow
Handle feerates of `u32::MAX` without overflowing
2024-06-27 11:03:24 -04:00
dunxen
cb0849855b
Merge pull request #2989 from optout21/iatx-shared-output
Interactive TX negotiation tracks shared outputs
2024-06-27 10:37:39 +02:00
Matt Corallo
e8bc0c92ad Handle feerates of u32::MAX without overflowing
Though we generally shouldn't be seeing these, and the
`get_dust_buffer_feerate` implementation will still return
`u32::MAX` in spite of the overflow, we should handle the overflow
to avoid panic when `debug_assertions` are enabled.

Found by the `full_stack_target` fuzzer
2024-06-26 14:23:40 +00:00
Valentine Wallace
969578703d
Implement AsyncPaymentsMessageHandler for ChanMan and use everywhere
Dummy implementation for now. This avoids having to change a bunch of type
signatures in the future when we replace the dummy impl with a real one.
2024-06-25 16:40:35 -04:00
valentinewallace
88e1b56d66
Merge pull request #3125 from valentinewallace/2024-06-async-payments-prefactor
Async payments message encoding and prefactor
2024-06-24 12:06:17 -04:00
optout
43a6ee34d7
Update splice messages according to new spec draft 2024-06-24 13:05:45 +02:00
Valentine Wallace
5c7af8c6d3
Cfg-gate async payments module and public enum variants. 2024-06-20 14:24:09 -04:00
Valentine Wallace
f20bd3de9f
Remove unused imports in static_invoice.rs 2024-06-20 14:24:09 -04:00
Valentine Wallace
6553d15aad
Add OffersMessage variant for static invoices. 2024-06-20 14:24:09 -04:00
Valentine Wallace
691e10f01e
DRY responder instantiation for onion messages. 2024-06-20 14:24:08 -04:00
Valentine Wallace
e8f154dd3c
AsyncPaymentsMessageHandler trait for OnionMessenger
Add a trait for handling async payments messages to OnionMessenger. This allows
users to either provide their own custom handling for async payments messages
or rely on a version provided by LDK.
2024-06-20 14:24:03 -04:00
Matt Corallo
07d991c82f
Merge pull request #2966 from G8XSU/2647-distribute
Optimize ChannelMonitor persistence on block connections.
2024-06-20 09:51:54 -07:00
optout
80eb5cee10
Interactive TX negotiation tracks shared outputs 2024-06-20 17:28:56 +02:00
Matt Corallo
38285167b1
Merge pull request #3127 from wvanlint/non_strict_forwarding
Implement non-strict forwarding
2024-06-20 07:26:43 -07:00
Valentine Wallace
445ec8d508
Onion message payload for async payments
Async payments uses onion messages to indicate when HTLCs are held and
released. Add these types along with the necessary parsing and encoding.
2024-06-20 10:09:03 -04:00
Willem Van Lint
05e6252b20 Implement non-strict forwarding
This change implements non-strict forwarding, allowing the node to
forward an HTLC along a channel other than the one specified
by short_channel_id in the onion message, so long as the receiver has
the same node public key intended by short_channel_id
([BOLT](57ce4b1e05/04-onion-routing.md (non-strict-forwarding))).
This can improve payment reliability when there are multiple channels
with the same peer e.g. when outbound liquidity is replenished by
opening a new channel.

The implemented forwarding strategy now chooses the channel with the
lowest outbound liquidity that can forward an HTLC to maximize the
probability of being able to successfully forward a subsequent HTLC.

Fixes #1278.
2024-06-19 21:24:21 -07:00
Matt Corallo
a17a159c93 Store the source and destination node_counters in ChannelInfo
In the next commit, we'll use the new `node_counter`s to remove a
`HashMap` from the router, using a `Vec` to store all our per-node
information. In order to make finding entries in that `Vec` cheap,
here we store the source and destintaion `node_counter`s in
`ChannelInfo`, givind us the counters for both ends of a channel
without doing a second `HashMap` lookup.
2024-06-19 13:57:41 +00:00
Matt Corallo
6d714b8cbd Track a counter for each node in our network graph
These counters are simply a unique number describing each node.
They have no specific meaning, but start at 0 and count up, with
counters being reused after a node has been deleted.
2024-06-19 13:57:41 +00:00
Elias Rohrer
f45a840c47
Merge pull request #3132 from jkczyz/2024-06-bolt12-unannounced
Blinded paths with unannounced introduction nodes
2024-06-19 14:42:08 +02:00
G8XSU
bf28957f6d
Optimize ChannelMonitor persistence on block connections.
Currently, every block connection triggers the persistence of all
ChannelMonitors with an updated best_block. This approach poses
challenges for large node operators managing thousands of channels.
Furthermore, it leads to a thundering herd problem
(https://en.wikipedia.org/wiki/Thundering_herd_problem), overwhelming
the storage with simultaneous requests.

To address this issue, we now persist ChannelMonitors at a
regular cadence, spreading their persistence across blocks to
mitigate spikes in write operations.

Outcome: After doing this, Ldk's IO footprint should be reduced
by ~50 times. The processing time required to sync each block
will be significantly reduced, particularly for nodes with 1000s
of channels, as write latency plays a significant role in this process.
As a result, the Node/ChainMonitor will be blocked for a shorter
duration, leading to further efficiency gains.
2024-06-19 00:04:23 -07:00
Gursharan Singh
87fc324c71
Merge pull request #3126 from TheBlueMatt/2024-06-preimage-removal-blocked-by-claim-event
(Very) marginally expand `test_monitor_update_fail_claim`
2024-06-18 13:31:38 -07:00
Matt Corallo
68af6d0809 (Very) marginally expand test_monitor_update_fail_claim
For some reason I wasn't sure this happened yet, so making the
test for no-`PaymentClaimed`-event-before-preimage-on-disk explicit
is nice.
2024-06-18 17:59:12 +00:00
Matt Corallo
c39ff87f44
Merge pull request #3115 from alecchendev/2024-06-specific-async-sign
Refactor async signing test utils to toggle specific method availability
2024-06-18 08:33:43 -07:00
Jeffrey Czyz
c1eda4ba3d
Relax channel count check for unannounced nodes
When creating blinded paths, introduction nodes are limited to peers
with at least three channels to prevent easily guessing the recipient.
Relax this check when the recipient is unannounced since they won't be
in the NetworkGraph.
2024-06-18 09:26:29 -05:00
Jeffrey Czyz
642913c586
Advance self blinded payment paths
DefaultRouter will ignore blinded paths where the sender is the
introduction node. Similar to message paths, advance such paths by one
so that payments may be sent to them.
2024-06-18 09:26:29 -05:00
Jeffrey Czyz
55ba2aab41
Re-order imports 2024-06-18 09:26:29 -05:00
Jeffrey Czyz
79122d69d4
Rename variable 2024-06-18 09:26:29 -05:00
Jeffrey Czyz
b6fcd84a13
Add advance_path_by_one for blinded payment paths
Similar to blinded paths for onion messages, if given a blinded payment
path where we are the introduction node, the path must be advanced by
one in order to use it.
2024-06-18 09:26:28 -05:00
Jeffrey Czyz
efc4647c65
Don't modify path when advance_path_by_one errors
When using advance_path_by_one when we are the introduction node, any
error will result having the first hop of the input blinded path
removed. Instead, only remove the first hop on success. Otherwise, the
path will be invalid.
2024-06-18 09:26:28 -05:00
Jeffrey Czyz
3bf84204e3
Blinded payments to unannounced introduction node
When creating blinded paths for receiving onion payments, allow using
the recipient's only peer as the introduction node when the recipient is
unannounced. This allows for sending payments without going through an
intermediary, which is useful for testing or when only connected to an
LSP with an empty NetworkGraph.
2024-06-18 09:26:28 -05:00
Jeffrey Czyz
7d1745e721
BlindedPath with unannounced introduction node
When creating blinded paths for receiving onion messages, allow using
the recipient's only peer as the introduction node when the recipient is
unannounced. This allows for sending messages without going through an
intermediary, which is useful for testing or when only connected to an
LSP with an empty NetworkGraph.
2024-06-18 09:26:26 -05:00
Elias Rohrer
249886497e
Merge pull request #3130 from TheBlueMatt/2024-06-doc-fee-present
Document when `Events::PaymentSent::pending_fee_msat` is `Some`
2024-06-18 14:49:38 +02:00
Alec Chen
21eeca4add Remove global availability logic for testing async signing 2024-06-17 16:34:56 -07:00
Alec Chen
1fb2b8e0ff Refactor tests to use specific async signing ops 2024-06-17 16:32:07 -07:00
Alec Chen
e8939e26bc Allow toggling specific signing methods in test channel signer 2024-06-17 16:32:06 -07:00
G8XSU
1912d8df01
Start tracking chain_sync_monitor_persistences in TestPersister
It is helpful to assert that chain-sync did trigger a monitor
persist.
2024-06-17 12:50:04 -07:00
valentinewallace
737df0f46f
Merge pull request #3128 from TheBlueMatt/2024-06-no-claim-ret
Drop unused return value from `claim_funds_from_hop`
2024-06-17 10:13:04 -04:00
Matt Corallo
f2005ba79d Document when Events::PaymentSent::pending_fee_msat is Some 2024-06-17 13:54:20 +00:00
Matt Corallo
fea6393083 Drop unused return value from claim_funds_from_hop 2024-06-16 14:15:07 +00:00
Duncan Dean
0881b24895
Move accept_channel checks into ChannelContext::do_accept_channel_checks
This is done ahead of getting the dual-funding implementation to reduce
refactoring noise there.
2024-06-14 10:52:32 +02:00
Valentine Wallace
66df329236
ser_macros: support messages with no fields 2024-06-13 12:20:43 -04:00
Elias Rohrer
3ec0dcdac1
Merge pull request #3078 from jkczyz/2024-05-invoice-event
Asynchronous `Bolt12Invoice` payment
2024-06-13 08:25:59 +02:00