Commit graph

7426 commits

Author SHA1 Message Date
shaavan
42c096c491 Allow create_blinded_paths functions to accept MessageContext as input field
- Enabled `create_blinded_paths` to accept `MessageContext` TLVs as
  an input field.
- `MessageContext` is intended to be sent along with the `reply_path`
   to the counterparty.
- Added `MessageContext` in the `create_blinded_paths` flow, optionally
  appending it within the `reply_path`.
- Updated tests to verify the new feature.
2024-07-09 17:27:11 +05:30
shaavan
fbe9dfa938 Update handle_message to accept OffersContext data as an input field
1. Handling Offers Data:
   - Updated `handle_message` to accept `OffersContext` data as an input field.
   - If it is present, it will be utilized by the handler to
     abandon outbound payments that have failed for any reason.

2. Consistency in Custom Message Handling:
   - Updated `handle_custom_message` to accept optional custom data.
     for consistency.
   - Note: `custom_data` will remain unused in this PR.
2024-07-09 17:27:08 +05:30
shaavan
7f82cde861 Introduce MessageContext in ReceiveTlvs
1. New Enum for Enhanced Data Handling:
   - Introduced the `MessageContext` enum, which allows the node to include
     additional context data along with the `reply_path` sent to the counterparty.
   - The node anticipates receiving this data back for further processing.

2. Variants in MessageContext:
   - The `MessageContext` enum includes two variants: "Offers" and
     "Context"
   - One of the variants, `Offers`, holds the `payment_id`
     of the associated Outbound BOLT12 Payment.

3. Future Usage:
   - This enum will be utilized in a subsequent commit to abandon outbound
     payments that have failed to complete for various reasons.
2024-07-09 01:45:13 +05:30
shaavan
7e2fde7054 Remove path_id from Responder, and OnionMessageResponse struct
1. The path_id will be removed from the codebase in the following
   commits.
2024-07-09 01:44:14 +05:30
Matt Corallo
40283e7153
Merge pull request #3151 from alecchendev/2024-06-async-test-util-followup
Async signing test util follow ups
2024-07-08 11:28:16 -07:00
valentinewallace
bfc20f8f34
Merge pull request #3156 from valentinewallace/2024-07-b12-max-path-len
Set max path length when paying BOLT 12 invoices.
2024-07-08 12:45:20 -04:00
Valentine Wallace
678aac0f0f
Set max path length when paying BOLT 12 invoices. 2024-07-08 10:35:48 -04:00
Elias Rohrer
0c3196c52d
Merge pull request #3158 from dunxen/2024-07-excludemergesfrommutants
Skip incremental-mutants job for main
2024-07-08 10:06:43 +02:00
Duncan Dean
8400cfc0d8
Fix CI for unused PendingOnionMessage 2024-07-04 17:08:16 +02:00
Duncan Dean
b1d7829565
Skip incremental-mutants job for main
There is no diff when running against main, so we skip incremental-mutants.
Before this commit, we'd get `Error: Failed to parse diff: Line 1: Error while parsing:`
as the diff file was empty.
2024-07-04 15:48:08 +02:00
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
Elias Rohrer
669a4596a6
Merge pull request #3154 from TheBlueMatt/2024-06-message-flags
Fix spelling in comment
2024-07-03 03:15:37 -04: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
162b81fbb1 Use test_msg_exact in channl_update fuzz testing
Gossip messages should always use `test_msg_exact` to ensure they
round-trip during signature validation.
2024-07-01 23:46:34 +00: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
Matt Corallo
c64b8e4dd7
Merge pull request #2763 from dunxen/2023-11-mutation-testing
Introduce mutation testing
2024-07-01 10:40:17 -07:00
Duncan Dean
c42699d1af
Introduce basic incremental mutation testing
We introduce a CI job for mutation testing of PR diffs using cargo-mutants.
Missed cases do not trigger a fail of this job yet as we just introduce it
now for visibility. We may start enforcing stricter rules at a later stage.
2024-06-30 17:25:56 +02: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
valentinewallace
d43218ab8b
Merge pull request #3145 from valentinewallace/2024-06-AP-prefactor-followup
Followups to #3125
2024-06-26 10:19:22 -04: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
Valentine Wallace
07b4cb6265
Onion message fuzzer: update held_htlc_available handling
Fuzzers should always do more, not less. Post-merge feedback on
e8f154dd3c.
2024-06-25 15:51:05 -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
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