1
0
Commit Graph

107 Commits

Author SHA1 Message Date
bitromortac
4ee5fa75f6 lnrouter+lnworker: rename my_channels 2021-07-29 16:26:23 +02:00
bitromortac
e6ccbcf7b7 lnrouter: fix self-payments 2021-07-28 08:12:44 +02:00
SomberNight
7ee4a2e299 follow-up prev 2021-06-10 18:52:12 +02:00
bitromortac
2749ea4d49 lnrouter: add inflight htlcs to liquidity hints 2021-05-11 09:17:11 +02:00
bitromortac
5e03d751eb lnrouter: add hint timestamp 2021-04-09 11:11:22 +02:00
bitromortac
bc20f57a78 lnrouter: remove blacklist boolean 2021-04-09 11:11:21 +02:00
bitromortac
2a45fdf09b lnrouter: penalty code simplification
Co-authored-by: ghost43 <somber.night@protonmail.com>
2021-04-06 20:13:42 +02:00
bitromortac
4df67a4f78 lnrouter+lnworker: use liquidity hints
Adds liquidity hints for the sending capabilities of routing channels in the
graph. The channel blacklist is incorporated into liquidity hints.
Liquidity hints are updated when a payment fails with a temporary
channel failure or when it succeeds. Liquidity hints are used to give a
penalty in the _edge_cost heuristics used by the pathfinding algorithm.
The base penalty in (_edge_cost) is removed because it is now part of the
liquidity penalty. We don't return early from get_distances, as we want
to explore all channels.
2021-04-06 20:13:42 +02:00
SomberNight
95b7c976e0 lnrouter.get_distances: fix exception due to rare race
if the graph is being updated while the pathfinding is running,
channel_info might be None here
2021-03-03 14:10:57 +01:00
SomberNight
750d8cfab5 lnworker: run create_route_for_payment end-to-end, incl private edges
We pass the private edges to lnrouter, and let it find routes end-to-end.
Previously the edge_cost heuristics didn't apply to the private edges
and we were just randomly picking one of the route hints and use that.
So e.g. cheaper private edges were not preferred, but they are now.

PathEdge now stores both start_node and end_node; not just end_node.
2021-03-02 18:00:31 +01:00
SomberNight
ab9bf07a79 (trivial) lnrouter: fix type of TrampolineEdge.short_channel_id
also, use keyword arguments inside attr.ib() as PyCharm was complaining
2021-02-24 16:46:59 +01:00
SomberNight
4aab843f17 lnutil.LnFeatures: impl and use "supports" method for feature-bit-tests
Note that for a required feature, BOLT-09 allows setting either:
- only the REQ bit
- both the REQ bit and the OPT bit

Hence, when checking if a feature is supported by e.g. an invoice, both
bits should be checked.

Note that in lnpeer.py, in self.features specifically, REQ implies OPT,
as it is set by ln_compare_features.
2021-02-22 19:53:01 +01:00
ThomasV
ded449233e Trampoline routing.
- trampoline is enabled by default in config, to prevent download of `gossip_db`.
   (if disabled, `gossip_db` will be downloaded, regardless of the existence of channels)
 - if trampoline is enabled:
    - the wallet can only open channels with trampoline nodes
    - already-existing channels with non-trampoline nodes are frozen for sending.
 - there are two types of trampoline payments: legacy and end-to-end (e2e).
 - we decide to perform legacy or e2e based on the invoice:
    - we use trampoline_routing_opt in features to detect Eclair and Phoenix invoices
    - we use trampoline_routing_hints to detect Electrum invoices
 - when trying a legacy payment, we add a second trampoline to the path to preserve privacy.
   (we fall back to a single trampoline if the payment fails for all trampolines)
 - the trampoline list is hardcoded, it will remain so until `trampoline_routing_opt` feature flag is in INIT.
 - there are currently only two nodes in the hardcoded list, it would be nice to have more.
 - similar to Phoenix, we find the fee/cltv by trial-and-error.
    - if there is a second trampoline in the path, we use the same fee for both.
    - the final spec should add fee info in error messages, so we will be able to fine-tune fees
2021-02-17 17:28:13 +01:00
ThomasV
ad91257729 pass blacklist to lnrouter.find_route, so that lnrouter is stateless (see #6778) 2021-01-11 15:19:50 +01:00
ThomasV
d5c360a958 simplify lnrouter API 2021-01-11 12:49:35 +01:00
SomberNight
01fe443928 lnrouter: nicer repr for PathEdge and RouteEdge 2020-11-24 23:44:09 +01:00
ThomasV
526c75ad53 lnrouter: blacklist channels for a limited time (see #6124) 2020-05-10 12:37:27 +02:00
SomberNight
7153e753d1 lnworker._pay: allow specifying path as argument
not exposed to CLI/etc yet but will be used in tests soon
2020-05-06 11:06:40 +02:00
SomberNight
63b18dc30f lnrouter: add PathEdge/LNPaymentPath for (node_id, scid) 2020-05-06 11:06:37 +02:00
ThomasV
1a4d33086b refactoring: remove inspect_edge 2020-04-20 11:48:38 +02:00
ThomasV
ec5330fc21 separate method that runs Dijkstra and return distances 2020-04-20 11:47:29 +02:00
SomberNight
30bf32b34b use option varonion: actually use TLV payloads, and signal support 2020-04-01 21:47:42 +02:00
SomberNight
90f3b667aa small clean-up re max CLTV delta for LN 2020-03-30 02:46:14 +02:00
SomberNight
3ed6afce64 lnchannel: implement freezing channels (for receiving)
A bit weird, I know... :)
It allows for rebalancing our own channels! :P
2020-03-26 09:05:15 +01:00
ThomasV
df15042cee Quantitative easing of lightning fees 2020-03-16 14:47:40 +01:00
ThomasV
b6cb983733 lnworker.pay: run path finding in sep. thread (don't block evt loop) 2020-03-10 17:56:11 +01:00
SomberNight
c95c0dcb80 lnrouter: add comments about path-finding blocking the asyncio loop 2020-03-09 20:39:13 +01:00
SomberNight
cdb72509a7 lnrouter: change edge cost estimate (distance metric)
Old estimate was heavily biased towards simply minimising CLTV sum.
(fees had a too low weight; typically they were ~noise)
Now also take payment_amount into account.
2020-03-03 02:12:42 +01:00
SomberNight
c81335fb44 lnrouter: simplify max fee sanity checks 2020-03-02 19:55:11 +01:00
SomberNight
46d8080c76 ln gossip: don't put own channels into db; always pass them to fn calls
Previously we would put fake chan announcement and fake outgoing chan upd
for own channels into db (to make path finding work). See Peer.add_own_channel().
Now, instead of above, we pass a "my_channels" param to the relevant ChannelDB methods.
2020-02-17 20:38:41 +01:00
SomberNight
b99add59c3 lnworker: introduce PaymentAttemptLog NamedTuple 2019-12-10 03:17:57 +01:00
SomberNight
d4da4aa56c lnrouter: fix off-by-one in NUM_MAX_EDGES_IN_PAYMENT_PATH 2019-09-06 18:36:21 +02:00
SomberNight
509df9ddaf create class for ShortChannelID and use it 2019-09-06 18:09:05 +02:00
ThomasV
246cda2928 fix Flake8 tests 2019-08-20 09:03:12 +02:00
SomberNight
beeb81e179 lnpeer: use correct failure codes in _maybe_forward_htlc 2019-08-20 09:03:12 +02:00
SomberNight
d955285808 lnrouter/channeldb: small import clean-up 2019-08-20 09:03:12 +02:00
ThomasV
e43a3bc63a follow-up prev commit: pass is_mine to _edge_cost 2019-08-20 09:03:12 +02:00
ThomasV
b55f9e9e6a Do not route through channels for which we did not receive
both updates, because this often means one of the nodes is
offline.
2019-08-20 09:03:12 +02:00
ThomasV
f2d58d0e3f optimize channel_db:
- use python objects mirrored by sql database
 - write sql to file asynchronously
 - the sql decorator is awaited in sweepstore, not in channel_db
2019-08-20 09:03:12 +02:00
ThomasV
180f6d34be separate channel_db module 2019-08-20 09:03:12 +02:00
ThomasV
115113f492 remove expensive sql request, python set comparison is faster 2019-08-20 09:03:12 +02:00
SomberNight
9a0ba7fa79 ChannelDB: trivial bugfix for get_channels_for_node 2019-08-20 09:03:11 +02:00
SomberNight
62f58c18fe ChannelDB.on_node_announcement: some speed-up
(e.g. for 100 node anns, was ~5 seconds, now 0.7 sec; so still slow)
2019-08-20 09:03:11 +02:00
SomberNight
cffb89002c fix ChannelDB.compare_channels: was raising "too many SQL variables"
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) too many SQL variables
2019-08-20 09:03:11 +02:00
ThomasV
0acd0c23d3 fix: key must be unique (sql) 2019-08-20 09:03:11 +02:00
ThomasV
eb4e6bb0de improve filter_channel_updates
blacklist channels that do not really get updated
2019-08-20 09:03:11 +02:00
ThomasV
b055eeace2 prune channels older than two weeks from database 2019-08-20 09:03:11 +02:00
ThomasV
522ce5bb9f verify channel updates in peer's TaskGroup 2019-08-20 09:03:11 +02:00
ThomasV
308dc6aa6b use a single queue for gossip messages, so that they are processed in the correct order 2019-08-20 09:03:11 +02:00
ThomasV
e68f318b12 verify node and channel announcements before entering sql lock 2019-08-20 09:03:11 +02:00