Commit graph

6380 commits

Author SHA1 Message Date
Matt Corallo
6ae051694d Make CandidateRouteHop method docs somewhat more descriptive 2023-12-08 20:45:06 +00:00
Matt Corallo
e9bad1b95c Fix indentation in router.rs broken in a1d15ac192 2023-12-08 20:45:06 +00:00
Matt Corallo
cc4bc1df5a Rename CandidateRouteHop::FirstHop::node_id and make it a ref
Rather than calling `CandidateRouteHop::FirstHop::node_id` just
`node_id`, we should call it `payer_node_id` to provide more
context.

We also take this opportunity to make it a reference, avoiding
bloating `CandidateRouteHop`.
2023-12-08 20:45:06 +00:00
Matt Corallo
57857fd520 #[inline] CandidateRouteHop accessors
These are used in the performance-critical routing and scoring
operations, which may happen outside of our crate. Thus, we really
need to allow downstream crates to inline these accessors into
their code, which we do here.
2023-12-08 20:45:06 +00:00
Matt Corallo
fc44e84ca8 Fix new unused warnings in scoring.rs 2023-12-08 20:45:06 +00:00
Matt Corallo
99e4a1fbb6 Privatise CandidateRouteHop::short_channel_id as its a footgun
Short channel "ID"s are not globally unique when they come from a
BOLT 11 route hint or a first hop (which can be an outbound SCID
alias). In those cases, its rather confusing that we have a
`short_channel_id` method which mixes them all together, and even
more confusing that we have a `CandidateHopId` which is not, in
fact returning a unique identifier.

In our routing logic this is mostly fine - the cost of a collision
isn't super high and we should still do just fine finding a route,
however the same can't be true for downstream users, as they may or
may not rely on the apparent guarantees.

Thus, here, we privatise the SCID and id accessors.
2023-12-08 20:45:06 +00:00
Matt Corallo
2caccc5cd6 Fix and re-enable the remembers_historical_failures test
f0ecc3ec73 introduced a regression in
the `remembers_historical_failures` test, and disabled it by simply
removing the `#[test]` annotation. This fixes the test and marks it
as a test again.
2023-12-08 20:45:06 +00:00
Matt Corallo
98ed285b9c Rename DirectedChannelInfo::outbound to from_node_one
...to give a bit more readability on accessing sites.
2023-12-08 20:45:06 +00:00
Matt Corallo
9973331d8e Rewrite docs in CandidateRouteHop to be somewhat more descriptive 2023-12-08 20:45:06 +00:00
Matt Corallo
becdf6fb27
Merge pull request #2551 from jbesraa/expose-CandidateRouteHop-to-channel_penalty_msat
Add CandidateRouteHop to channel_penalty_msat inputs
2023-12-06 01:20:27 +00:00
Matt Corallo
78e88e94a0
Merge pull request #2735 from valentinewallace/2023-11-skimmed-fee-ser
Fix skimmed fee serialization in `Channel`
2023-12-05 23:46:47 +00:00
Matt Corallo
9942994012
Merge pull request #2773 from johncantrell97/apeermanager-lbs
simplify GossipVerifier types using APeerManager
2023-12-05 22:13:50 +00:00
John Cantrell
67659677d4 simplify GossipVerifier types using APeerManager 2023-12-05 16:01:29 -05:00
jbesraa
cbde4a756e
Remove node_id from PathBuildingHop
We remove `node_id` from `PathBuildingHop`
  as we can rely `CandidateRouteHop::target`
  instead.
2023-12-05 21:07:49 +02:00
jbesraa
f0ecc3ec73
Use CandidateRouteHop as input for channel_penalty_msat
We remove `source`, `target` and `scid` from
  `channel_penalty_msat` inputs to consume them from
  `candidate` of type `CandidateRouteHop`
2023-12-05 21:07:48 +02:00
jbesraa
04e93fc887
Change CandidateRouteHop functions visbility
Change `short_channel_id`, `cltv_expiry_delta`
  `fees` and `htlc_minimum_msat` under `CandidateRouteHop` visibility
  to public and add documentation.
2023-12-05 21:07:47 +02:00
jbesraa
a1d15ac192
Add source and target fn's to CandidateRouteHop
We add `CandidateRouteHop::source` and
    `CandidateRouteHop::source` functions to point
    to current and next hops in route respectively.
    As we have now `source` and `target`
    available in `CandidateRouteHop` we also
    remove `CandidateRouteHop::id` inputs
    so now they are consumed from `self.target`
    and `self.source` functions.
    In the `add_entry` macro we also remove `source`
    and `target` arguments in favor of `candidate`
    of type `CandidateRouteHop` that holds the
    needed info.
2023-12-05 21:07:46 +02:00
jbesraa
366d688087
Add source and target to DirectedChannelInfo
`DirectedChannelInfo::source` return the `node_id`
  of the forwarding hop.
  `DirectedChannelInfo::target` return the `node_id`
  of the destination hop.
2023-12-05 21:07:45 +02:00
jbesraa
ec95e589ba
Add outbound flag to DirectedChannelInfo
If `outband` flag is set to true then `ChannelInfo::node_one`
  is forwarding a payment to target `ChannelInfo::node_two`.
  If `outband` flag is set to false then `ChannelInfo::node_two`
  is forwarding a payment to target `ChannelInfo::node_one`.
2023-12-05 21:07:44 +02:00
valentinewallace
37150b4d69
Merge pull request #2764 from TheBlueMatt/2023-11-chacha-cleanup
Trivial ChaCha cleanups
2023-12-05 12:00:40 -05:00
Matt Corallo
242e6aedb2
Merge pull request #2642 from Sharmalm/2346
logging every sent receive onion message
2023-12-05 00:10:01 +00:00
Valentine Wallace
633be238fd
Fix skimmed fee ser in Channel
Previously, if some holding cell HTLCs have skimmed fees present and some
don't, we would fail to deserialize a Channel. See added test coverage.
2023-12-04 16:41:37 -05:00
Wilmer Paulino
12c2086d58
Merge pull request #2753 from TheBlueMatt/2023-11-inbound-preimages
Provide inbound HTLC preimages to the `EcdsaChannelSigner`
2023-12-04 13:15:10 -08:00
Wilmer Paulino
7f96446294
Merge pull request #2771 from tnull/2023-12-log-details-for-ignored-first-hop
Log additional details when ignoring first hops
2023-12-04 11:38:21 -08:00
Matt Corallo
262072d816 Provide inbound HTLC preimages to the EcdsaChannelSigner
The VLS signer has a desire to see preimages for resolved forwarded
HTLCs when they are first claimed by us, even if that claim was for
the inbound edge (where claiming strictly increases our balance).

Luckily, providing that information is rather trivial, which we do
here.

Fixes #2356
2023-12-04 19:36:49 +00:00
Wilmer Paulino
4d66cce487
Merge pull request #2769 from TheBlueMatt/2023-12-2314-cleanups-3
Post-#2314 Cleanups #3
2023-12-04 10:09:52 -08:00
Elias Rohrer
52ecce9e28
Log additional details when ignoring first hops
Users are often confused when we fail to find a route due to some
requirements on the first hop are not being met. While we now take note
and log such candidates, we still previously required users to check
additional details to figure out why exactly the router refused to route
over a particular first hop.

Here, we add additional TRACE logging, in particular for
`ChannelDetails::next_outbound_htlc_limit_msat` and
`ChannelDetails::next_outbound_htlc_minimum_msat` when they are
relevant.
2023-12-04 19:07:54 +01:00
Matt Corallo
1eddd1ef8f
Merge pull request #2768 from benthecarman/preimage-helper
Add helper function for getting preimage from PaymentPurpose
2023-12-04 17:10:33 +00:00
Elias Rohrer
ac06a6a2f6
Merge pull request #2766 from TheBlueMatt/2023-12-2314-cleanups-2
Marginally optimize test logging
2023-12-04 12:15:56 +01:00
Matt Corallo
cf0539eba4 Doc that Record::node_id may be missing even with channel_id
There are various place where we log something related to a channel
but fail to fill in the channel's counterparty information. This is
somewhat surprising, given channel counterparty information is
always known, but simply is sometimes not readily accessible to LDK
when a log is printed.
2023-12-03 19:42:21 +00:00
Matt Corallo
2be5e370e3 Set log metadata in a few additional locations in channelmanager 2023-12-03 19:42:21 +00:00
Matt Corallo
b0606a1193 Log next-hop metadata when forwarding or failing to forward HTLC 2023-12-03 19:42:21 +00:00
Matt Corallo
2fc79cbfd3 Include next-hop counterparty node id in log metadata when sending 2023-12-03 19:42:21 +00:00
Matt Corallo
0ce0d48319 Add missing counterparty node id metadata to logs in HTLC decoding 2023-12-03 19:42:21 +00:00
benthecarman
00f578adee
Add helper function for getting preimage from PaymentPurpose 2023-12-03 12:42:17 -06:00
Matt Corallo
f57295f9d9 Include counterparty node id and channel id in shutdown log
This avoids an important shutdown log being about a channel but not
having the channel metadata.
2023-12-02 20:03:19 +00:00
Matt Corallo
ec1a66e4cd Add missing unwrap in reload_tests.rs 2023-12-02 19:19:07 +00:00
Matt Corallo
dfb02f1878 Marginally optimize test logging
973636bd2a introduced a new `HashMap`
in the `TestLogger` but then did lookups by iterating the entire
map. This fixes that, and also takes this opportunity to stop
allocating new `String`s for the module to store each log entry in
the `TestLogger`
2023-12-02 19:19:07 +00:00
henghonglee
ff5e5221d2 logging every sent and receive onion message
Logs every sent + receive for P2P messages
solves #2346
2023-12-03 00:24:14 +05:30
Matt Corallo
6b43153861
Merge pull request #2314 from henghonglee/issue-2292
Add peer_id and channel_id explicitly to log records
2023-12-02 17:43:32 +00:00
Jeffrey Czyz
e21a500668
Refactor ChainMonitor::update_channel error case
Move the handling of ChannelMonitorUpdateStatus::UnrecoverableError to
the point of error to avoid needing an unwrap later when re-wrapping the
logger.
2023-12-01 11:54:00 -06:00
Jeffrey Czyz
e6d8f350fc
Remove unused handle_error macro rule 2023-12-01 11:54:00 -06:00
henghonglee
df3ab2ee27
Use wrapper to add context to logging
Using a decorator pattern, add peer_id and channel_id to Record
stored on Logger.
2023-12-01 11:53:55 -06:00
henghonglee
a727ccab94
Add WithChannelMonitor 2023-12-01 11:50:34 -06:00
henghonglee
aa502fe948
Add WithChannelContext 2023-12-01 11:30:19 -06:00
henghonglee
fa7f2f4986
Add WithChannelDetails 2023-12-01 11:30:19 -06:00
henghonglee
973636bd2a
Add WithContext and Tests 2023-12-01 11:30:19 -06:00
Jeffrey Czyz
a42aeb5667
Add semantics to logger::Records
Include optional peer and channel ids to logger::Record. This will be
used by wrappers around Logger in order to provide more context (e.g.,
the peer that sent a message, the channel an operation is pertaining to,
etc.). Implementations of Logger can include this as metadata to aid in
searching logs.
2023-12-01 11:30:19 -06:00
henghonglee
0cba31fd38
Pass Record by value to Logger
Instead of passing a reference to a Record, pass the Logger an owned
Record so that it can be decorated with semantic context.
2023-12-01 11:30:19 -06:00
valentinewallace
74bc9e2b4a
Merge pull request #2540 from valentinewallace/2023-08-blinded-errors
Route blinding: support forwarding as the intro node
2023-11-30 23:29:10 -05:00