Commit graph

7440 commits

Author SHA1 Message Date
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
Elias Rohrer
321f2a8b4a
Merge pull request #3135 from tnull/2024-06-rustfmt-rgs
Run `rustfmt` on `lightning-rapid-gossip-sync`
2024-06-20 13:46:06 +02:00
Elias Rohrer
8be13f684f
rustfmt: Drop benches/src/bench.rs from excluded files 2024-06-20 10:59:21 +02:00
Elias Rohrer
945fb5b3c9
rustfmt: Run on lightning-rapid-gossip-sync/src/lib.rs 2024-06-20 10:55:49 +02:00
Elias Rohrer
6e81e1240b
rustfmt: Run on lightning-rapid-gossip-sync/src/processing.rs 2024-06-20 10:55:08 +02:00
Elias Rohrer
1856fd3d64
rustfmt: Prepare lightning-rapid-gossip-sync/src/processing.rs 2024-06-20 10:53:29 +02: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
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
Elias Rohrer
baefe5ac93
Merge pull request #3123 from dunxen/2024-06-channelrefactor
Move accept_channel checks into `ChannelContext::do_accept_channel_checks`
2024-06-17 09:23:18 +02: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
Matt Corallo
07f33800a1
Merge pull request #3102 from tnull/2024-06-rustfmt-fuzz
`rustfmt`: Reformat the `fuzz` dir
2024-06-13 06:56:33 -07:00
Elias Rohrer
cc9fc650b8
Merge pull request #3098 from arik-so/arik/gossip-v2-parsing
Parse v2 gossip
2024-06-13 08:48:06 +02: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
Arik Sosman
ab0c35fccc
Update documentation. 2024-06-12 18:35:19 -07:00
Arik Sosman
bfc959259b
Parse v2 gossip. 2024-06-12 18:35:19 -07:00
Jeffrey Czyz
97c1d656ee
Add pays_bolt12_invoice_asynchronously test 2024-06-12 19:39:49 -05:00
Jeffrey Czyz
65efd92c4a
Expose send_payment_for_bolt12_invoice
UserConfig::manually_handle_bolt12_invoices allows deferring payment of
BOLT12 invoices by generating Event::InvoiceReceived. Expose
ChannelManager::send_payment_for_bolt12_invoice to allow users to pay
the Bolt12Invoice included in the event. While the event contains the
PaymentId for reference, that parameter is now removed from the method
in favor of extracting the PaymentId from the invoice's payer_metadata.
2024-06-12 19:38:22 -05:00
Jeffrey Czyz
232959cd27
Reformat and tick config docs 2024-06-12 19:38:21 -05:00
Jeffrey Czyz
a9dcfaf952
Add UserConfig::manually_handle_bolt12_invoices
BOLT12 invoices are automatically paid once they have been verified.
Users may want to manually pay them by first performing additional
checks. Add a manually_handle_bolt12_invoices configuration option that
when set generates an Event::InvoiceReceived instead of paying the
invoice.
2024-06-12 19:38:16 -05:00
Matt Corallo
f267ffe2fc
Merge pull request #3082 from valentinewallace/2024-04-bolt12-keysend-invoice
BOLT 12 static invoice encoding and building
2024-06-12 15:17:48 -07:00
Matt Corallo
08c566ccfb
Merge pull request #3103 from TheBlueMatt/2024-06-real-bench
Use a real (probing-generated) scorer in benchmarks
2024-06-12 15:17:25 -07:00
Valentine Wallace
bafe4ed218
Static invoice parsing tests 2024-06-12 16:42:29 -04:00
Valentine Wallace
7970de47a6
Static invoice building tests 2024-06-12 16:42:29 -04:00
Valentine Wallace
1e58066868
Builder for creating static invoices from offers
Add a builder for creating static invoices for an offer. Building produces a
semantically valid static invoice for the offer, which can then be signed with
the key associated with the offer's signing pubkey.
2024-06-12 16:42:27 -04:00
Jeffrey Czyz
4666c33c0f
Add an InvoiceReceived event
Some users may want to handle a Bolt12Invoice asynchronously, either in
a different process or by first performing additional verification
before paying the invoice. Add an InvoiceReceived event to facilitate
this.
2024-06-12 15:24:08 -05:00
Elias Rohrer
4e9ce52c72
rustfmt: fuzz/src/full_stack.rs 2024-06-12 21:53:32 +02:00
Elias Rohrer
945cb77247
Prepare fuzz/src/full_stack.rs for rustfmt 2024-06-12 21:53:32 +02:00
Elias Rohrer
0583f643b9
rustfmt: fuzz/src/chanmon_consistency.rs 2024-06-12 21:53:30 +02:00