Commit graph

5959 commits

Author SHA1 Message Date
Elias Rohrer
391da3f3b2
Use saturating_add when adding inflight HTLCs values
Previously this calculation could overflow, leading to panicking in `debug`.
2023-09-28 10:14:35 +02:00
Matt Corallo
7b4fb9da88
Merge pull request #2570 from valentinewallace/2023-08-router-fuzz-fail
Fix router fuzz failure
2023-09-27 20:40:32 +00:00
Valentine Wallace
f3857d0f53
get_route: fix path value contribution to include min htlc overpay
Previously, the fuzzer hit a debug panic because we wouldn't include the amount
overpaid to meet a last hop's min_htlc in the total collected paths value. We
now include this value and also penalize hops along the overpaying path to
ensure that it gets deprioritized in path selection.
2023-09-27 13:19:51 -04:00
Valentine Wallace
ea38b938bb
get_route: fix path_min for first_hop<>network_node candidates
Previously, we would add a first_hop<>network_node channel that did not have
enough contribution amount to cover the next channel's min htlc plus fees,
because we were storing the next hop as having a path_min that did not include
fees, and would add a connecting first_hop node that did not have enough
contribution amount, leading to a debug panic upon invalid path construction.
2023-09-27 13:19:51 -04:00
Valentine Wallace
d83295ff5c
get_route: fix path_min for first_hop<>blinded_hint candidates
See previous commit, but the bug where we would underestimate how much a first
hop candidate needed to be able to relay was also present in blinded paths.
2023-09-27 13:19:51 -04:00
Valentine Wallace
2aacbae67a
get_route: fix path_min when adding first_hop<>route_hint candidates
Previously, we would add a candidate hop to the list of potential hops even
though its available contribution wasn't sufficient to meet the next hop's
min_htlc. We'd subsequently build an invalid path using this hop and hit a
debug assertion.
2023-09-27 13:19:51 -04:00
Valentine Wallace
5263b07b55
get_route: fix outdated var name
Previously this variable was a bool, but has since been updated to be an
Option, so rename accordingly.
2023-09-27 13:19:51 -04:00
Valentine Wallace
29c67d5246
Pathfinding: ignore blinded route hints where we are the intro node
See tests, but the fuzzer found several panics from not fully ignoring these
hints.

We should support these route hints eventually, but it will involve some
reworking of the Path/BlindedTail structs.
2023-09-27 13:19:49 -04:00
Valentine Wallace
b16d6a1e11
Remove trailing whitespace in get_route
Because my text editor loves to do that.
2023-09-27 09:37:21 -04:00
Valentine Wallace
7632cfe517
Refuse to pathfind when provided our_node_id matches internal dummy pk
The fuzzer managed to hit this and it causes some invalid paths to be generated
internally.
2023-09-27 09:37:21 -04:00
Valentine Wallace
6cfb052d98
Pathfinding: log when we ignore one hop blinded route hints 2023-09-27 09:37:21 -04:00
Matt Corallo
0f87ee8883
Merge pull request #2601 from TheBlueMatt/2023-09-117-alpha2
Bump versions to 0.0.117-alpha2/invoice 0.25.0-alpha2
2023-09-27 03:51:12 +00:00
Matt Corallo
c8e1916b77
Merge pull request #2603 from TheBlueMatt/2023-09-default-route-limit
Set a default max_total_routing_fee_msat of 1% + 50sats
2023-09-27 03:47:16 +00:00
Matt Corallo
7d5f137946
Merge pull request #2602 from TheBlueMatt/2023-09-descriptor-hash
Derive `Hash` for `SpendableOutputDescriptor`
2023-09-27 03:47:09 +00:00
Matt Corallo
bf9144039c
Merge pull request #2359 from domZippilli/2023-06-monitor-updating-persister
Monitor updating persister
2023-09-27 03:46:39 +00:00
Dom Zippilli
0430d3379a Add MonitorUpdatingPersister
MonitorUpdatingPersister is an implementation of Persister that stores
ChannelMonitorUpdates separately from ChannelMonitors. Its RFC is
in #2545, at https://github.com/orgs/lightningdevkit/discussions/2545.

Co-Authored-By: Elias Rohrer <dev@tnull.de>
2023-09-26 16:30:07 -07:00
Matt Corallo
3e1e393f61
Merge pull request #2486 from wvanlint/batch_channel_opens
Batch funding for v1 channel establishments
2023-09-26 22:54:12 +00:00
Matt Corallo
0c31c6f162 Set a default max_total_routing_fee_msat of 1% + 50sats
When using the normal default constructors, we should have some
fee maximum to ensure our default behavior is safe. Here we pick
1% + 50 sats to ensure we're always willing to pay
reasonabl(y high) fees, but not anything too wild.
2023-09-26 22:03:59 +00:00
Matt Corallo
793a1bf679 Derive Debug and Display for Route 2023-09-26 21:59:48 +00:00
Matt Corallo
8a42d55508 Derive Hash for SpendableOutputDescriptor
This allows for easy descriptor de-duplication before building a
claiming transaction.
2023-09-26 20:41:49 +00:00
Willem Van Lint
82341991cb Batch funding for v1 channel establishments 2023-09-26 13:37:14 -07:00
Willem Van Lint
c55a507709 Rename finish_force_close_channel to finish_close_channel 2023-09-26 13:37:14 -07:00
Willem Van Lint
cd4b38dfd3 Always call finish_force_close_channel on closure
This is a step towards more unified closing of channels, and provides a
place where the per_peer_state lock is not held.
2023-09-26 13:37:14 -07:00
Matt Corallo
94140b91d8 Bump versions to 0.0.117-alpha2/invoice 0.25.0-alpha2 2023-09-26 20:21:08 +00:00
Matt Corallo
1ac53ed02b
Merge pull request #2417 from tnull/2023-07-max-total-fee
Add config option to set maximum total routing fee
2023-09-26 20:07:52 +00:00
Elias Rohrer
6765767cbc
Test max_total_routing_fee_msat handling when retrying overpaid paths
We setup an MPP scenario with two paths in which we need to overpay to
reach `htlc_minimum_msat`. We then fail the overpaid path and check that
on retry our `max_total_routing_fee_msat` only accounts for the path
fees, but not for the fees overpaid in the first attempt.
2023-09-26 20:12:31 +02:00
Elias Rohrer
7895943953
Check max_total_routing_fee is accounted for in test_threaded_payment_retries 2023-09-26 20:12:30 +02:00
Elias Rohrer
26b515c13c
Check max_total_routing_fee is reduced in mpp_retry test
We check that the `RouteParameters::max_total_routing_fee` field is reduced accordingly
to our previously used fees.
2023-09-26 20:12:30 +02:00
Elias Rohrer
649144d25f
Account for leftover fee budget when retrying via check_retry_payment 2023-09-26 20:12:30 +02:00
Matt Corallo
827b17c7df
Merge pull request #2597 from TheBlueMatt/2023-09-finish-force-close-deadlocks
Fix potential peer_state deadlocks in `finish_force_close_channel`
2023-09-26 16:36:16 +00:00
Elias Rohrer
ac57163895
Account for leftover fee budget when retrying PartialFailures 2023-09-26 09:44:05 +02:00
Elias Rohrer
b1a878fe81
Test we adhere to max_total_routing_fee_msat 2023-09-26 09:44:05 +02:00
Elias Rohrer
ca40d8a6fb
Consider RouteParameters::max_total_routing_fee_msat in get_route
We exclude any candidate hops if we find that using them would let the
aggregated path routing fees exceed `max_total_routing_fee_msat`.

Moreover, we return an error if the aggregated fees over all paths of
the selected route would surpass `max_total_routing_fee_msat`.
2023-09-26 09:44:05 +02:00
Elias Rohrer
d7e2ff6220
Introduce RouteParameters::max_total_routing_fee_msat
Currently, users have no means to upper-bound the total fees accruing
when finding a route. Here, we add a corresponding field to
`RouteParameters` which will be used to limit the candidate set during
path finding in the following commits.
2023-09-26 09:44:04 +02:00
Matt Corallo
20e1c27334 Provide some test coverage of shutdown msgs for unfunded chans
We have code to handle receiving `shutdown` messages on unfudned
channels. However, it had no test coverage, which we add here.
2023-09-26 00:38:17 +00:00
Matt Corallo
d6cd197adc Fix potential peer_state deadlocks in finish_force_close_channel
`ChannelManager::finish_force_close_channel` exists to do cleanups
which must happen without the `per_peer_state` mutex held. However,
because it lacked lock assertions, several changes snuck in
recently which resulted in it running with peer-state locks held,
risking a deadlock if some HTLCs need to be failed.
2023-09-26 00:38:17 +00:00
Matt Corallo
ce7463486e
Merge pull request #2583 from Evanfeenstra/pub-make-onion
Pub make onion
2023-09-25 17:08:41 +00:00
Matt Corallo
0e83e91d7a
Merge pull request #2576 from valentinewallace/2023-09-fix-outbound-bp-fail-ev
Fix `PaymentPathFailed::payment_failed_permanently` on blinded path fail
2023-09-25 16:56:03 +00:00
Matt Corallo
a87f381a51
Merge pull request #2594 from benthecarman/debug-monitor-update-id
Implement Debug for MonitorUpdateId
2023-09-25 16:00:04 +00:00
benthecarman
66821a9e72
Implement Debug for MonitorUpdateId 2023-09-24 00:34:27 -05:00
Valentine Wallace
6299f7d14f
Blame outbound channel on UPDATE onion failure with 0-len update
We've run into this several times in the wild, likely due to
https://github.com/ElementsProject/lightning/issues/6200 wherein a node on the
path will error with 0x1000 but not provide a channel update (a spec
violation).

Previously, we would blame the inbound edge even though the buggy peer wanted
us to blame the outbound edge. Since this issue seems to be recurring and our
blaming the inbound edge is causing us to punish innocent channels, trust the
peer that the outbound edge is the one to blame.
2023-09-22 15:56:28 -04:00
Valentine Wallace
9df61dc0b8
Fix PaymentPathFailed::payment_failed_permanently on blinded path fail
Previously this value would be incorrectly set to true because we wouldn't
account for blinded hops when determining if we were processing the last hop's
failure packet.
2023-09-22 15:56:23 -04:00
Valentine Wallace
5f5119fa3d
Correct DecodedOnionFailure when processing we-are-intro-node path
We don't support sending to paths where we are the intro node yet, but may as
well set the failure correctly now.
2023-09-22 15:56:23 -04:00
Valentine Wallace
9c41f129c0
DecodedOnionFailure::payment_retryable -> ::payment_failed_permanently
Our ultimate goal with this field is to set
PaymentPathFailed::payment_failed_permanently, so use this name rather than
flipping a bool back and forth across methods.
2023-09-22 15:56:23 -04:00
Valentine Wallace
61ab1f8513
Struct-ify onion util internal result type
Improves readability.
2023-09-22 15:56:18 -04:00
Valentine Wallace
9ade8eb23b
Rename onion util internal var
This variable is ultimately for setting
PaymentPathFailed::payment_failed_permanently, so use this name rather than
flipping a bool back and forth.
2023-09-22 15:56:07 -04:00
Elias Rohrer
a37a16a3ce
Merge pull request #2589 from ErikDeSmedt/reexport_route_hint_hop
Reexport RouteHintHop
2023-09-22 09:09:41 +02:00
Matt Corallo
7ea280e98b
Merge pull request #2592 from TheBlueMatt/2023-09-117-alpha
Update crate version numbers to 0.0.117-alpha1/invoice 0.25-alpha1
2023-09-21 23:20:17 +00:00
Matt Corallo
c91debba1a
Merge pull request #2590 from TheBlueMatt/2023-09-default-score-params
Use `Default::default()` to construct `()` as a test scoring param
2023-09-21 20:40:13 +00:00
Matt Corallo
e01b51db67 Update crate version numbers to 0.0.117-alpha1/invoice 0.25-alpha1 2023-09-21 20:27:12 +00:00