Commit Graph

186 Commits

Author SHA1 Message Date
b300da8446 routing: assume TLV payloads everywhere
This commit removes another check for TLV payload support of the
destination node. We assume TLV payloads as the default everywhere else,
so we just remove two checks that were previously forgotten.
2024-06-26 14:28:51 -07:00
99b3c57b7f routing: assume TLV onion during route construction 2024-06-24 10:01:23 -07:00
738253f5e1 routing: assume TLV onion during path finding 2024-06-24 10:01:21 -07:00
0bae781785 routing: add inbound fee support to pathfinding
Add sender-side support for inbound fees in pathfinding
and route building.
2024-03-31 18:12:28 +02:00
e0a080454a routing: track unifiedPolicyEdge
Preparation so that we can have the inbound fee available
in addition to the outgoing policy.
2024-03-31 18:12:28 +02:00
4732c09a26 multi: Fix final hop payload size for AMP payments. 2024-02-03 12:16:06 +00:00
ff30ff40bf multi: Fix final hop payload size for blinded rt.
The final hop size is calculated differently therefore we extract
the logic in its own function and also account for the case where
the final hop might be a blinded hop.
2024-02-03 12:11:01 +00:00
c1b91fff14 multi: use new AdditionalEdge interface.
In the previous commit the AdditionalEdge interface was introduced
with both of its implementations `BlindedEdge` and `PrivateEdge`.
In both cases where we append a route either by a blinded route
section or private route hints we now use these new types. In
addition the `PayloadSizeFunc` type is introduced in the
`unifiedEdge` struct. This is necessary to have the payload size
function at hand when searching for a route hence not overshooting
the max sphinx package size of 1300 bytes.
2024-02-03 12:10:46 +00:00
1aa1e18b9f routing: add log message. 2024-01-08 16:47:48 +01:00
84cdcd6847 multi: move DB schemas to channeldb/models
This commit moves the ChannelEdgePolicy, ChannelEdgeInfo,
ChanelAuthProof and CachedEdgePolicy structs to the `channeldb/models`
package.
2023-11-08 14:50:35 +02:00
0e179fae1e routing: remove 0-value warning log in pathfinding
Blinded routes can now have "hints" that have zero value edges, so we
remove this log to avoid spamming logs.
2023-10-06 16:38:33 -07:00
014683ee66 routing: include route blinding fields in blinded portion of path
This commit updates route construction to backfill the fields
required for payment to blinded paths and set amount to forward
and expiry fields to zero for intermediate hops (as is instructed
in the route blinding specification).

We could attempt to do this in the first pass, but that loop
relies on fields like amount to forward and expiry to calculate
each hop backwards, so we keep it simple (stupid) and post
processes the blinded portion, since it's computationally cheap
and more readable.
2023-10-06 16:38:33 -07:00
78d9996620 trivial: Fix spelling errors
- Fixes some spelling in code comments and a couple of function names
2023-09-21 22:35:33 -04:00
7df1482cfc routing: add capacity to special edges
Having a capacity available is important for liquidity estimation.

* We add a dummy capacity to hop hints. Hop hints specify neither the
  capacity nor a maxHTLC size, which is why we assume the channel to
  have a high capacity relative to the amount we send.

* We add a capacity to local edges. These channels should always have a
  capacity associated with them, even in the neutrino case (a fallback
  to maxHTLC is not necessary). This is just for completeness, as the
  probability calculation for local channels is done separately.
2023-03-23 11:12:10 +01:00
26d1f427df routing: trace capacity in probability log 2023-02-24 15:28:55 +01:00
58d5131e31 lnd+routerrpc: configure server with new estimator
We add new lnd.conf configuration options for both probability
estimators. Note that this is a breaking change for the existing apriori
parameters.
2023-02-14 13:34:25 +01:00
66ffc64776 router: return probability from findPath
The returned probability can then be used in QueryRoutes to not having
to reconstruct the probability.
2022-12-12 13:22:29 +01:00
516e3a8cca routing: use capacity in pathfinding
Extends the pathfinder with a capacity argument for later usage.

In tests, the inserted testCapacity has no effect, but will be used
later to estimate reduced probabilities from it.
2022-12-12 13:22:28 +01:00
76e711ead0 routing: refactor unified policies to edges
This commit refactors the semantics of unified policies to unified
edges. The main changes are the following renamings:

* unifiedPolicies -> nodeEdgeUnifier
* unifiedPolicy -> edgeUnifier
* unifiedPolicyEdge -> unifiedEdge

Comments and shortened variable names are changed to reflect the new
semantics.
2022-12-12 13:22:26 +01:00
7d29ab905c routing: return *unifiedPolicyEdge in getPolicy
We encapsulate the capacity inside a unifiedPolicyEdge for later usage.
The meaning of "policy" has changed now, which will be refactored in the
next commmit.
2022-12-12 13:19:29 +01:00
befa1b7cf0 routing: Fix possible infinite loop on first hop misleading hint
Add ignore condition to additional edges that connect to self. These
edges are already known and avoiding these hints protect the payment
from malformed channel ids which could lead to infinite loop.

Fixes lightningnetwork#6169.

Co-authored-by: lsunsi <lsunsi@pm.me>
2022-11-11 04:23:55 -03:00
9195f29e61 routing+channeldb: send payment metadata from invoice 2022-04-13 22:55:40 +02:00
ba5abdc090 routing: add time_pref parameter to queryroutes and sendpayment 2022-04-13 20:26:46 +02:00
269a8e74d3 routing: refactor reliability penalty calculation
Base the calculation on the actual float64 overflow point rather than an
indirect limit on probability.

This is a preparation for an infinite attempt cost.
2022-04-13 20:26:08 +02:00
990dda4b18 multi: thread bandwidth check amount down to MayAddOutgoingHtlc
Pass htlc amount down to the channel so that we don't need to rely
on minHtlc (and pad it when the channel sets a 0 min htlc). Update
test to just check some sane values since we're no longer relying
on minHtlc amount at all.
2021-10-19 09:50:51 +02:00
45de686d35 multi: move bandwidth hints behind interface 2021-10-19 09:50:49 +02:00
1d1c42f9ba multi: use minimal policy in cache 2021-09-29 17:00:04 +02:00
369c09be61 channeldb+routing: add in-memory graph
Adds an in-memory channel graph cache for faster pathfinding.

Original PoC by: Joost Jager
Co-Authored by: Oliver Gugger
2021-09-29 17:00:04 +02:00
41ae3530a3 routing/payment_lifecycle: use ShardTracker to track shards
We'll let the payment's lifecycle register each shard it's sending with
the ShardTracker, canceling failed shards. This will be the foundation
for correct AMP derivation for each shard we'll send.
2021-04-27 09:43:40 +02:00
37aa49c7aa routing: fix pathfind edge features being nil 2021-04-13 15:53:18 +08:00
bbfeeec8b1 routing: add proportional attempt cost 2020-09-08 15:47:08 +02:00
17a6175e8b routing+routerrpc: rename PaymentAttemptPenalty to AttemptCost
Make field names consistent with the command line flag.
2020-09-08 14:07:56 +02:00
3ef68baf4a routing: don't treat bad features as an unexpected error
Previous behavior led to the payment loop being abandoned immediately,
resulting in a payment stuck in state in_flight.
2020-05-27 12:15:53 +02:00
c33d94ff27 routing+routerrpc: add multiple outgoing channel restriction 2020-05-12 07:17:24 +02:00
7fc1938f10 routing: payment splitting pre-check
This commit reverts cb4cd49dc8 to bring
back the insufficient local balance failure.

Distinguishing betweeen this failure and a regular "no route" failure
prevents meaningless htlcs from being sent out.
2020-04-18 08:30:26 +02:00
46f5fc7400 routing: distinguish between receiver amount and total amount in newRoute 2020-04-09 08:20:47 +02:00
47f9c1c3fd routing: use routingGraph interface in payment session
Preparation for more test coverage of payment session.

The function findPath now has the call signature of the former
findPathInternal function.
2020-04-09 08:20:37 +02:00
cb4cd49dc8 routing: map insufficient local bandwidth error to no path
With mpp it isn't possible anymore for findPath to determine that there
isn't enough local bandwidth. The full payment amount isn't known at
that point.

In a follow-up, this payment outcome can be reintroduced on a higher
level (payment lifecycle).
2020-04-09 08:20:35 +02:00
5e72a4b77c routing: exit on unexpected RequestRoute error
We whitelist a set of "expected" errors that can be returned from
RequestRoute, by converting them into a new type noRouteError. For any
other error returned by RequestRoute, we'll now exit immediately.
2020-04-02 19:31:24 +02:00
2d07756263 routing: log amount for probability 2020-03-24 19:02:38 +01:00
5ff017664c fix typo 2020-02-27 15:22:00 +02:00
06bdeb56e2 routing: add graph interface 2020-02-11 13:35:38 +01:00
a8ed1b342a routing: remove pathfinding db tx
Pathfinding is never used with an externally supplied bbolt transaction.
2020-02-10 19:55:40 +01:00
c7a241fc59 routing/pathfind: ignore unknown required features
This commit brings us inline with recent modifications to the spec, that
say we shouldn't pay nodes whose feature vectors signal unknown required
features, and also that we shouldn't route through nodes signaling
unknown required features.

Currently we assert that invoices don't have such features during
decoding, but now that users can specify feature vectors via the rpc
interface, it makes sense to perform this check deeper in call stack.
This will also allow us to remove the check from decoding entirely,
making decodepayreq more useful for debugging.
2020-01-08 12:25:00 -08:00
c84e57a522 routing: remove unnecessary newline 2019-12-20 11:00:07 +01:00
b760b25229 routing: limit routing info size during pathfinding
Also the max hop count check can be removed, because the real bound is
the payload size. By moving the check inside the search loop, we now
also backtrack when we hit the limit.
2019-12-20 11:00:05 +01:00
72a6383975 routing: use absolute final expiry in pathfinding 2019-12-20 11:00:00 +01:00
e546a2c42b routing: more efficient feature validation
Also prepares for payload size tracking during pathfinding
2019-12-20 10:17:03 +01:00
95ddab57fa channeldb: add tx argument for FetchLightningNode
To allow execution within an existing tx.
2019-12-20 10:17:01 +01:00
37d9ee302c channeldb: take serialized key to fetch lightning node
This prevents inefficient key conversions in a follow up commit that
change the inner pathfinding loop.
2019-12-19 12:44:00 +01:00