Commit graph

2883 commits

Author SHA1 Message Date
Jeffrey Czyz
57f0822f5a
Simplify prefers_shorter_route_with_higher_fees
In order to make the scoring tests easier to read, only check the
relevant RouteHop fields. The remaining fields are tested elsewhere.
Expand the test to show the path used without scoring.
2021-10-18 18:32:34 -05:00
Matt Corallo
001bc7113a
Merge pull request #1121 from TheBlueMatt/2021-10-return-temp-id
Expose temporary channel ID and user channel ID pre-funding
2021-10-16 02:15:07 +00:00
Matt Corallo
2398f1746d
Merge pull request #1124 from jkczyz/2021-10-default-channel-scoring
Add channel scoring to get_route
2021-10-16 01:58:15 +00:00
Matt Corallo
bb7ef6c290 Rename create_channel param to user_channel_id to standardize it 2021-10-16 00:27:04 +00:00
Matt Corallo
a5de1aeb12
Merge pull request #1123 from tnull/fix_video_url
Fixed 'Advancing Bitcoin' video URL.
2021-10-15 22:07:34 +00:00
Jeffrey Czyz
e15a18a503
Add channel scoring to get_route
Failed payments may be retried, but calling get_route may return a Route
with the same failing path. Add a routing::Score trait used to
parameterize get_route, which it calls to determine how much a channel
should be penalized in terms of msats willing to pay to avoid the
channel.

Also, add a Scorer struct that implements routing::Score with a constant
constant penalty. Subsequent changes will allow for more robust scoring
by feeding back payment path success and failure to the scorer via event
handling.
2021-10-15 15:29:49 -05:00
Elias Rohrer
8549b52582 Fixed 'Advancing Bitcoin' video URL. 2021-10-14 10:35:12 +02:00
Matt Corallo
dda86a0cf2
Merge pull request #1112 from TheBlueMatt/2021-10-mon-refactors
Hide internals of ChainMonitor behind getter
2021-10-14 01:45:20 +00:00
Matt Corallo
1464671ae8 Use Persister to return errors in fuzzers not chain::Watch 2021-10-14 00:19:43 +00:00
Matt Corallo
c396dc6ee5 Use Persister to return errors in tests not chain::Watch
As ChainMonitor will need to see those errors in a coming PR,
we need to return errors via Persister so that our ChainMonitor
chain::Watch implementation sees them.
2021-10-14 00:19:42 +00:00
Matt Corallo
1b6a7c1314 Handle Persister returning TemporaryFailure for new channels
Previously, if a Persister returned a TemporaryFailure error when
we tried to persist a new channel, the ChainMonitor wouldn't track
the new ChannelMonitor at all, generating a PermanentFailure later
when the updating is restored.

This fixes that by correctly storing the ChannelMonitor on
TemporaryFailures, allowing later update restoration to happen
normally.

This is (indirectly) tested in the next commit where we use
Persister to return all monitor-update errors.
2021-10-14 00:19:12 +00:00
Matt Corallo
49dbabff27 Simplify channelmonitor tests which use chain::Watch and Persister
test_simple_monitor_permanent_update_fail and
test_simple_monitor_temporary_update_fail both have a mode where
they use either chain::Watch or persister to return errors.

As we won't be doing any returns directly from the chain::Watch
wrapper in a coming commit, the chain::Watch-return form of the
test will no longer make sense.
2021-10-14 00:19:12 +00:00
Matt Corallo
79541b11e8 Make ChainMonitor::monitors private and expose monitor via getter
Exposing a `RwLock<HashMap<>>` directly was always a bit strange,
and in upcoming changes we'd like to change the internal
datastructure in `ChainMonitor`.

Further, the use of `RwLock` and `HashMap` meant we weren't able
to expose the ChannelMonitors themselves to users in bindings,
leaving a bindings/rust API gap.

Thus, we take this opportunity go expose ChannelMonitors directly
via a wrapper, hiding the internals of `ChainMonitor` behind
getters. We also update tests to use the new API.
2021-10-14 00:17:31 +00:00
Matt Corallo
6a7c48b60d Move ChannelMonitorUpdateErr to chain as it is a chain::Watch val 2021-10-14 00:16:50 +00:00
Matt Corallo
0dfb24e661 Move Persist trait to chainmonitor as that's the only reference 2021-10-14 00:16:50 +00:00
Matt Corallo
da498d7974
Merge pull request #1120 from jkczyz/2021-10-test-refactors
Pre-scoring test clean-ups
2021-10-14 00:16:27 +00:00
Jeffrey Czyz
d4ec090bb8
Move mpp_failure test to payment_tests.rs 2021-10-13 18:37:05 -05:00
Jeffrey Czyz
0a5ccd1f13
Replace get_route with get_route_and_payment_hash
The interface for get_route will change to take a scorer. Using
get_route_and_payment_hash whenever possible allows for keeping the
scorer inside get_route_and_payment_hash rather than at every call site.

Replace get_route with get_route_and_payment_hash wherever possible.
Additionally, update get_route_and_payment_hash to use the known invoice
features and the sending node's logger.
2021-10-13 18:37:01 -05:00
Matt Corallo
9a5c9b3680 Include the user channel id counter in Event::ChannelClosed
This makes it more practical for users to track channels using
their own IDs, especially across funding.
2021-10-13 21:44:58 +00:00
Matt Corallo
be82239181 Return the temporary channel id in success from create_channel
This makes it more practical for users to track channels prior to
funding, especially if the channel fails because the peer rejects
it for a parameter mismatch.
2021-10-13 21:44:58 +00:00
Matt Corallo
2144166bc6
Merge pull request #1115 from TheBlueMatt/2021-10-expose-addr-vec
Expose ReadOnlyNetworkGraph::get_addresses to C by cloning result
2021-10-13 16:54:09 +00:00
Jeffrey Czyz
3fc035267c
Fix unused variable warnings in fuzzer 2021-10-13 10:26:32 -05:00
Jeffrey Czyz
d7c8c8c572
Speed up test_timer_tick_called 2021-10-13 10:25:18 -05:00
Matt Corallo
d2b7f6cc08 Expose ReadOnlyNetworkGraph::get_addresses to C by cloning result
We cannot expose ReadOnlyNetworkGraph::get_addresses as is in C as
it returns a list of references to an enum, which the bindings
dont support. Instead, we simply clone the result so that it
doesn't contain references.
2021-10-13 01:18:43 +00:00
Matt Corallo
fe8c10db95
Merge pull request #1077 from jkczyz/2021-09-failing-route-hop
Include short channel id in PaymentPathFailed
2021-10-13 01:13:41 +00:00
Jeffrey Czyz
202acd9e16
Add failing short channel id to PaymentPathFailed
This will be useful for scoring channels when a payment fails.
2021-10-12 18:40:06 -05:00
Matt Corallo
5a356cad69
Merge pull request #1116 from TheBlueMatt/2021-10-test-local-chan-routing
Use local channel state when constructing routes in test macro  + Fix compile-warning
2021-10-12 18:29:05 +00:00
Matt Corallo
00ffa4397d Fix loop label shadowing warning 2021-10-12 02:29:56 +00:00
Matt Corallo
74a9be6956 Use local channel state when constructing routes in test macro
This is a bit more realistic and needed to route over non-public
channels.
2021-10-12 02:29:01 +00:00
Jeffrey Czyz
1e2ca5233b
Clean up fee_insufficient computation 2021-10-11 13:47:04 -05:00
Matt Corallo
d66574803e
Merge pull request #1098 from 1nF0rmed/2021-09-adds-discard-funding-event
Add Event::DiscardFunding generation
2021-10-09 17:17:55 +00:00
1nF0rmed
1955008d6d Adds DiscardFunding event
During the event of a channel close, if the funding transaction
is yet to be broadcasted then a DiscardFunding event is issued
along with the ChannelClose event.
2021-10-09 16:43:50 +05:30
Matt Corallo
843d25d750
Merge pull request #1107 from dunxen/2021-10-swap-pubkey-for-bytearray
Replace PublicKey with [u8; 33] in NetworkGraph
2021-10-08 21:02:53 +00:00
Matt Corallo
e635db0da3
Merge pull request #1062 from galderz/t_payment_hash_999 2021-10-08 20:49:19 +00:00
Duncan Dean
fce631ca21
Replace PublicKey with [u8; 33] in NetworkGraph 2021-10-08 18:37:55 +02:00
Galder Zamarreño
204bfd260c Add payment_hash to PaymentSent #999 2021-10-08 06:53:10 +02:00
Matt Corallo
6582aaebae
Merge pull request #1109 from TheBlueMatt/2021-10-init-fail-payment-retry-leak
Move pending payment tracking to after the new HTLC flies
2021-10-07 23:14:06 +00:00
Matt Corallo
a58c617c42 Correct error returned when retry_payment doesn't have a payment 2021-10-07 22:27:58 +00:00
Matt Corallo
928bfb12d2 Move pending payment tracking to after the new HTLC flies
If we attempt to send a payment, but the HTLC cannot be send due to
local channel limits, we'll provide the user an error but end up
with an entry in our pending payment map. This will result in a
memory leak as we'll never reclaim the pending payment map entry.
2021-10-07 22:27:58 +00:00
Jeffrey Czyz
f5abc93978
Pass hop index in construct_onion_keys_callback
This simplifies failing route hop calculation, which will be useful for
later identifying the failing hop for PaymentFailed events.
2021-10-06 23:31:59 -05:00
Jeffrey Czyz
42bb0af11d
Remove special case for onion error expiry_too_far
With channel scoring and payment retries, it is no longer necessary to
have expiry_too_far imply a payment failure.
2021-10-06 23:31:27 -05:00
Matt Corallo
ab0739e3ea
Merge pull request #1079 from TheBlueMatt/2021-09-stale-docs
Update Event::PaymentReceived docs since we require payment secret
2021-10-05 23:16:20 +00:00
Matt Corallo
7478207d5c Update Event::PaymentReceived docs since we require payment secret
Users no longer need to verify the amounts of received payments as
the payment secret will protect us against the probing attacks such
verification was intended to fix.
2021-10-05 22:35:04 +00:00
Matt Corallo
bb4ff74da1 Move tests of payment retries into a new module 2021-10-05 19:26:45 +00:00
Matt Corallo
17d75a845a
Merge pull request #1100 from TheBlueMatt/2021-09-multihop-route-hint-fix
Consider many first-hop paths to the same counterparty in routing
2021-10-05 18:43:39 +00:00
Matt Corallo
7aa2caccd8
Merge pull request #1096 from valentinewallace/2021-09-mpp-retries 2021-09-30 01:19:04 +00:00
Valentine Wallace
3e6297a664
Expire outbound payments after 3 blocks if no parts are pending 2021-09-29 20:25:42 -04:00
Valentine Wallace
207479f32f
Don't remove failed payments when all paths fail
This is because we want the ability to retry completely failed
payments.

Upcoming commits will remove these payments on timeout to prevent
DoS issues

Also test that this removal allows retrying single-path payments
2021-09-29 20:25:42 -04:00
Valentine Wallace
8db9c50b8b
Add method to retry payments 2021-09-29 20:25:39 -04:00
Matt Corallo
730d5639a4
Merge pull request #1080 from valentinewallace/2021-09-dup-chan-outpoint
Fix fuzzer-found panic from duplicate channel outpoint
2021-09-30 00:01:35 +00:00