Commit graph

3896 commits

Author SHA1 Message Date
valentinewallace
e45db2bf6c
Merge pull request #1691 from TheBlueMatt/2022-08-dust-retry
Correct payment resolution after on chain failure of dust HTLCs
2022-09-06 20:02:50 -04:00
Matt Corallo
a795e45b42 Correct payment resolution after on chain failure of dust HTLCs
Previously, we wouldn't mark a dust HTLC as permanently resolved if
the commitment transaction went on chain. This resulted in us
always considering the HTLC as pending on restart, when we load the
pending payments set from the monitors.

Fixes #1653.
2022-09-06 20:23:18 +00:00
valentinewallace
8c6cb9953a
Merge pull request #1657 from TheBlueMatt/2022-08-async-man-update
Add a background processor which is async
2022-09-06 16:06:06 -04:00
Matt Corallo
ee2f1a929e
Merge pull request #1695 from TheBlueMatt/2022-08-log-chan_update
Ensure we log private channel_updates at a non-GOSSIP log level
2022-09-06 19:15:05 +00:00
Matt Corallo
602cf5c12b Ensure we log private channel_updates at a non-GOSSIP log level
If we receive a channel_update for one of our private channels, we
will not log the message at the usual TRACE log level as the
message falls into the gossip range. However, for our own channels
they aren't *just* gossip, as we store that info and it changes
how we generate invoices. Thus, we add a log in `ChannelManager`
here at the DEBUG log level.
2022-09-06 17:49:40 +00:00
Matt Corallo
2a5bac22bf Add a background processing function that is async.
Adds a method which operates like BackgroundProcessor::start but
instead of functioning by spawning a background thread it is async.
2022-09-06 17:42:24 +00:00
Matt Corallo
c6890cfc33 Add a Future which can receive manager persistence events
This allows users who don't wish to block a full thread to receive
persistence events.

The `Future` added here is really just a trivial list of callbacks,
but from that we can build a (somewhat ineffecient)
std::future::Future implementation and can (at least once a mapping
for Box<dyn Trait> is added) include the future in no-std bindings
as well.

Fixes #1595
2022-09-06 17:42:21 +00:00
Matt Corallo
2035cebe8a Remove internal references to persistence in waker.rs 2022-09-06 16:22:58 +00:00
Matt Corallo
f99301dd8a
Merge pull request #1692 from TheBlueMatt/2022-08-time-goes-backwards
Handle monotonic clock going backwards during runtime
2022-09-03 16:15:33 +00:00
Matt Corallo
fc7b14b184
Merge pull request #1650 from valentinewallace/2022-08-take-onionmsgs-public 2022-09-02 22:20:32 +00:00
Matt Corallo
82474d3564 Handle monotonic clock going backwards during runtime
We've had some users complain that `duration_since` is panic'ing
for them. This is possible if the machine being run on is buggy and
the "monotonic clock" goes backwards, which sadly some ancient
systems can do.

Rust addressed this issue in 1.60 by forcing
`Instant::duration_since` to not panic if the machine is buggy
(and time goes backwards), but for users on older rust versions we
do the same by hand here.
2022-09-02 21:57:32 +00:00
Matt Corallo
c8ae6c1923 Move open_zero_conf_channel utility to common test utils 2022-09-02 21:29:32 +00:00
Valentine Wallace
a8ea0bde59
Limit OnionMessenger outbound buffer size
Drop OMs if they push us over the max OnionMessenger outbound buffer size
2022-09-02 16:35:35 -04:00
Valentine Wallace
04f4673428
Don't construct OnionMessage while holding peer lock 2022-09-02 16:27:38 -04:00
Valentine Wallace
b9b02b48fb
Refuse to send and forward OMs to disconnected peers
We also refuse to connect to peers that don't advertise onion message
forwarding support.
2022-09-02 16:27:30 -04:00
Valentine Wallace
0b1f476b83
Expose onion message module as public
And fix warnings
2022-09-02 16:25:32 -04:00
Jeffrey Czyz
00f08c910f
Merge pull request #1643 from jurvis/jurvis/2022-07-inflights-htlcs-across-payments
Track in-flight HTLCs across payments when routing
2022-09-01 15:01:30 -05:00
jurvis
80daf942b2
Make payment tests more realistic
Made sure that every hop has a unique receipient. When we simulate
calling `channel_penalty_msat` in `TestRouter`’s find route, use
actual previous node ids instead of just using the payer’s.
2022-08-31 18:50:03 -07:00
jurvis
c70bd1fd55
Keep track of inflight HTLCs across payments
Added two methods, `process_path_inflight_htlcs` and
`remove_path_inflight_htlcs`, that updates that `payment_cache` map with
path information that may have failed, succeeded, or have been given up
on.

Introduced `AccountForInflightHtlcs`, which will wrap our user-provided
scorer. We move the `S:Score` type parameterization from the `Router` to
`find_route`, so we can use our newly introduced
`AccountForInflightHtlcs`.

`AccountForInflightHtlcs` keeps track of a map of inflight HTLCs by
their short channel id, direction, and give us the value that is being
used up.

This map will in turn be populated prior to calling `find_route`, where
we’ll use `create_inflight_map`, to generate a current map of all
inflight HTLCs based on what was stored in `payment_cache`.
2022-08-31 18:50:02 -07:00
Matt Corallo
0624cf9e47
Merge pull request #1687 from TheBlueMatt/2022-08-fuzz-msrv
Drop honggfuzz `arbitrary` dependency to meet MSRV
2022-08-30 17:12:47 +00:00
Matt Corallo
7223f70616 Drop honggfuzz arbitrary dependency to meet MSRV 2022-08-30 15:15:00 +00:00
jurvis
706b638196
Change payment_cache to accept PaymentInfo
Introduces a new `PaymentInfo` struct that contains both the previous
`attempts` count that was tracked as well as the paths that are also
currently inflight.
2022-08-29 22:51:43 -07:00
Jeffrey Czyz
99123cd91a
Merge pull request #1604 from valentinewallace/2022-07-OMs-followup
Onion messages: add some initial rate limiting
2022-08-29 12:17:36 -05:00
Valentine Wallace
f4834def9d
Implement buffering onion messages for peers.
In this commit, we check if a peer's outbound buffer has room for onion
messages, and if so pulls them from an implementer of a new trait,
OnionMessageProvider.

Makes sure channel messages are prioritized over OMs, and OMs are prioritized
over gossip.

The onion_message module remains private until further rate limiting is added.
2022-08-26 19:03:07 -04:00
Valentine Wallace
b28783a0b5
Implement OnionMessageProvider for OnionMessenger 2022-08-26 19:03:05 -04:00
Valentine Wallace
544f72b37c
PeerManager: bump the read pause limit
...to make sure we can still get channel messages out after enqueuing some big gossip messages.
2022-08-26 19:03:05 -04:00
Valentine Wallace
4adff1039f
Add boilerplate for sending and receiving onion messages in PeerManager
Adds the boilerplate needed for PeerManager and OnionMessenger to work
together, with some corresponding docs and misc updates mostly due to the
PeerManager public API changing.
2022-08-26 19:02:59 -04:00
Matt Corallo
2358b0b05f
Merge pull request #1683 from valentinewallace/2022-08-multiqueue-peerman 2022-08-25 21:30:15 +00:00
Matt Corallo
fa62b00f14
Merge pull request #1673 from TheBlueMatt/2022-08-may-learn-preimage-balance
Expose a `Balance` for inbound HTLCs even without a preimage
2022-08-25 20:26:30 +00:00
Valentine Wallace
47e818f198
Separate gossip broadcasts into their own queue in PeerManager
This allows us to better prioritize channel messages over gossip broadcasts and
lays groundwork for rate limiting onion messages more simply, since they won't
be competing with gossip broadcasts for space in the main message queue.
2022-08-25 14:57:43 -04:00
Valentine Wallace
ab149dc9d5
PeerMan: rename drop_gossip util to be more accurate
It's more accurate to name it as dropping gossip broadcasts, as it won't drop
all gossip.
2022-08-25 14:57:43 -04:00
Valentine Wallace
1de698fdd9
PeerMan: fix bug in drop_gossip util
Fixes a flipped bool that was introduced in
4a1ee5f9a9
2022-08-25 14:56:50 -04:00
Matt Corallo
39cede60d0 Rename MaybeClaimableHTLCAwaitingTimeout for consistency
As we now have a MaybePreimageClaimableHTLC, its more consistent
to rename `MaybeClaimableHTLCAwaitingTimeout` to
`MaybeTimeoutClaimableHTLC`.
2022-08-25 18:51:42 +00:00
Matt Corallo
4c9231371b Expose a Balance for inbound HTLCs even without a preimage
If we don't currently have the preimage for an inbound HTLC, that
does not guarantee we can never claim it, but instead only that we
cannot claim it unless we receive the preimage from the channel we
forwarded the channel out on.

Thus, we cannot consider a channel to have no claimable balances if
the only remaining output on the commitment ransaction is an
inbound HTLC for which we do not have the preimage, as we may be
able to claim it in the future.

This commit addresses this issue by adding a new `Balance` variant
- `MaybePreimageClaimableHTLCAwaitingTimeout`, which is generated
until the HTLC output is spent.

Fixes #1620
2022-08-25 18:51:42 +00:00
Matt Corallo
414d8e1c4a
Merge pull request #1682 from tnull/2022-08-export-all-log-levels 2022-08-24 18:41:46 +00:00
Jeffrey Czyz
f2ece975d3
Merge pull request #1652 from valentinewallace/2022-08-reply-paths
Onion messages: support reply paths
2022-08-24 09:55:20 -05:00
Elias Rohrer
c7c88a6572 Export and document all log macros.
Previously, only `log_error` and `log_trace` macros have been exported.
This change exports the macros of all log levels, which enables them to
be used downstream.
2022-08-24 13:59:58 +02:00
Valentine Wallace
950b7d777a
Support sending and receiving reply paths 2022-08-23 20:37:26 -04:00
Valentine Wallace
351349c845
Fix bug in onion message payload decode
Previously, we were decoding payload lengths as a VarInt. Per the spec, this is
wrong -- it should be decoded as a BigSize.  This bug also exists in our
payment payload decoding, to be fixed separately.

Upcoming reply path tests caught this bug because we hadn't encoded a payload
greater than 253 before, so we hadn't hit the problem that VarInts are encoded
as little-endian whereas BigSizes are encoded as big-endian.
2022-08-23 20:33:58 -04:00
Valentine Wallace
dceca5b590
OM functional tests: update util to take nodes by reference
And fix one test to be uniform with the others
2022-08-23 20:33:58 -04:00
Arik
17ae116be0
Merge pull request #1679 from TheBlueMatt/2022-08-no-double-access
Avoid querying the chain for outputs for channels we already have
2022-08-23 13:11:36 -07:00
Matt Corallo
5847abd92d Avoid querying the chain for outputs for channels we already have
If we receive a ChannelAnnouncement message but we already have the
channel, there's no reason to do a chain lookup. Instead of
immediately calling the user-provided `chain::Access` when handling
a ChannelAnnouncement, we first check if we have the corresponding
channel in the graph.

Note that if we do have the corresponding channel but it was not
previously checked against the blockchain, we should still check
with the `chain::Access` and update if necessary.
2022-08-23 17:46:12 +00:00
Jeffrey Czyz
187d18a714
Merge pull request #1681 from dunxen/2022-08-githubactionsfix
Workaround GH Actions issue for 1.45
2022-08-23 09:22:48 -05:00
Duncan Dean
88e562053a
Workaround GH Actions issue for 1.45 2022-08-23 10:54:43 +02:00
Matt Corallo
ea5b62fff6
Merge pull request #1677 from ok300/ok300-patch-1
Bump bitcoin_hashes to v0.11
2022-08-19 22:18:59 +00:00
Matt Corallo
19536c6433
Merge pull request #1676 from arik-so/2022-08-gossip-error-message-fix
Fix script order in gossip key mismatch error.
2022-08-19 19:03:08 +00:00
Matt Corallo
49a0233634
Merge pull request #1575 from NicolaLS/hash-invoice 2022-08-19 17:45:11 +00:00
Arik Sosman
f53492eff2
Fix script order in gossip key mismatch error. 2022-08-19 10:07:55 -07:00
NicolaLS
e263d904a1 derive Hash for Invoice 2022-08-19 16:40:54 +02:00
ok300
1cc2bc5145
Bump bitcoin_hashes to v0.11 2022-08-19 16:40:19 +02:00