2023-12-06 21:14:05 +01:00
|
|
|
#ifndef LIGHTNING_COMMON_GOSSMODS_LISTPEERCHANNELS_H
|
|
|
|
#define LIGHTNING_COMMON_GOSSMODS_LISTPEERCHANNELS_H
|
|
|
|
#include "config.h"
|
|
|
|
#include <bitcoin/short_channel_id.h>
|
|
|
|
#include <ccan/typesafe_cb/typesafe_cb.h>
|
|
|
|
#include <common/amount.h>
|
|
|
|
#include <common/json_parse_simple.h>
|
|
|
|
|
|
|
|
struct node_id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gossmods_from_listpeerchannels: create gossmap_localmods from `listpeerchannels`
|
|
|
|
* @ctx: context to allocate return from
|
|
|
|
* @buf: the JSON buffer from listpeerchannels
|
|
|
|
* @toks: the JSON tokens
|
pay: ignore fees on our own channels when determining routing.
I noticed that run-route-infloop chose some worse-looking paths after
routing was fixed, eg the second node:
Before:
Destination node, success, probability, hops, fees, cltv, scid...
02b3aa1e4ed31be83cca4bd367b2c01e39502cb25e282a9b4520ad376a1ba0a01a,1,0.991856,2,1004,40,2572260x39x0/1,2131897x45x0/0
After:
Destination node, success, probability, hops, fees, cltv, scid...
02b3aa1e4ed31be83cca4bd367b2c01e39502cb25e282a9b4520ad376a1ba0a01a,1,0.954540,3,1046,46,2570715x21x0/1,2346882x26x14/1,2131897x45x0/0
This is because although the final costs don't reflect it, routing was taking
into account local channels, and 2572260x39x0/1 has a base fee of 2970.
There's an easy fix: when we the pay plugin creates localmods for our
gossip graph, add all local channels with delay and fees equal to 0.
We do the same thing in our unit test. This improves things across
the board:
Linear success probability (when found): min-max(mean +/- stddev)
Before: 0.487040-0.999543(0.952548+/-0.075)
After: 0.486985-0.999750(0.975978+/-0.053)
Hops:
Before: 1-5(2.98374+/-0.77)
After: 1-5(2.09593+/-0.63)
Fees:
Before: 0-50848(922.457+/-2.7e+03)
After: 0-50041(861.621+/-2.7e+03)
Delay (blocks):
Before: 0-196(65.8081+/-60)
After: 0-190(60.3285+/-60)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Plugins: `pay` route algorithm doesn't bias against our own "expensive" channels any more.
2024-03-07 03:56:58 +01:00
|
|
|
* @zero_rates: set fees and cltv delay for these channels to 0 (better for routing)
|
2023-12-06 21:14:05 +01:00
|
|
|
* @cb: optional per-channel callback.
|
|
|
|
* @cbarg: arg for @cb.
|
|
|
|
*
|
|
|
|
* This constructs a set of modifications you can apply to your gossmap to include
|
|
|
|
* local (esp. private) channels. You can also have an optional per-channel callback
|
|
|
|
* for special effects.
|
|
|
|
*/
|
|
|
|
struct gossmap_localmods *gossmods_from_listpeerchannels_(const tal_t *ctx,
|
|
|
|
const struct node_id *self,
|
|
|
|
const char *buf,
|
|
|
|
const jsmntok_t *toks,
|
pay: ignore fees on our own channels when determining routing.
I noticed that run-route-infloop chose some worse-looking paths after
routing was fixed, eg the second node:
Before:
Destination node, success, probability, hops, fees, cltv, scid...
02b3aa1e4ed31be83cca4bd367b2c01e39502cb25e282a9b4520ad376a1ba0a01a,1,0.991856,2,1004,40,2572260x39x0/1,2131897x45x0/0
After:
Destination node, success, probability, hops, fees, cltv, scid...
02b3aa1e4ed31be83cca4bd367b2c01e39502cb25e282a9b4520ad376a1ba0a01a,1,0.954540,3,1046,46,2570715x21x0/1,2346882x26x14/1,2131897x45x0/0
This is because although the final costs don't reflect it, routing was taking
into account local channels, and 2572260x39x0/1 has a base fee of 2970.
There's an easy fix: when we the pay plugin creates localmods for our
gossip graph, add all local channels with delay and fees equal to 0.
We do the same thing in our unit test. This improves things across
the board:
Linear success probability (when found): min-max(mean +/- stddev)
Before: 0.487040-0.999543(0.952548+/-0.075)
After: 0.486985-0.999750(0.975978+/-0.053)
Hops:
Before: 1-5(2.98374+/-0.77)
After: 1-5(2.09593+/-0.63)
Fees:
Before: 0-50848(922.457+/-2.7e+03)
After: 0-50041(861.621+/-2.7e+03)
Delay (blocks):
Before: 0-196(65.8081+/-60)
After: 0-190(60.3285+/-60)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Plugins: `pay` route algorithm doesn't bias against our own "expensive" channels any more.
2024-03-07 03:56:58 +01:00
|
|
|
bool zero_rates,
|
2023-12-06 21:14:05 +01:00
|
|
|
void (*cb)(struct gossmap_localmods *mods,
|
|
|
|
const struct node_id *self_,
|
|
|
|
const struct node_id *peer,
|
|
|
|
const struct short_channel_id_dir *scidd,
|
2024-10-04 01:35:53 +02:00
|
|
|
struct amount_msat capacity_msat,
|
2024-03-18 08:31:42 +01:00
|
|
|
struct amount_msat htlcmin,
|
|
|
|
struct amount_msat htlcmax,
|
|
|
|
struct amount_msat spendable,
|
2023-12-06 21:14:05 +01:00
|
|
|
struct amount_msat fee_base,
|
|
|
|
u32 fee_proportional,
|
2024-10-04 01:31:53 +02:00
|
|
|
u16 cltv_delta,
|
2023-12-06 21:14:05 +01:00
|
|
|
bool enabled,
|
|
|
|
const char *buf_,
|
|
|
|
const jsmntok_t *chantok,
|
|
|
|
void *cbarg_),
|
|
|
|
void *cbarg);
|
|
|
|
|
pay: ignore fees on our own channels when determining routing.
I noticed that run-route-infloop chose some worse-looking paths after
routing was fixed, eg the second node:
Before:
Destination node, success, probability, hops, fees, cltv, scid...
02b3aa1e4ed31be83cca4bd367b2c01e39502cb25e282a9b4520ad376a1ba0a01a,1,0.991856,2,1004,40,2572260x39x0/1,2131897x45x0/0
After:
Destination node, success, probability, hops, fees, cltv, scid...
02b3aa1e4ed31be83cca4bd367b2c01e39502cb25e282a9b4520ad376a1ba0a01a,1,0.954540,3,1046,46,2570715x21x0/1,2346882x26x14/1,2131897x45x0/0
This is because although the final costs don't reflect it, routing was taking
into account local channels, and 2572260x39x0/1 has a base fee of 2970.
There's an easy fix: when we the pay plugin creates localmods for our
gossip graph, add all local channels with delay and fees equal to 0.
We do the same thing in our unit test. This improves things across
the board:
Linear success probability (when found): min-max(mean +/- stddev)
Before: 0.487040-0.999543(0.952548+/-0.075)
After: 0.486985-0.999750(0.975978+/-0.053)
Hops:
Before: 1-5(2.98374+/-0.77)
After: 1-5(2.09593+/-0.63)
Fees:
Before: 0-50848(922.457+/-2.7e+03)
After: 0-50041(861.621+/-2.7e+03)
Delay (blocks):
Before: 0-196(65.8081+/-60)
After: 0-190(60.3285+/-60)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Plugins: `pay` route algorithm doesn't bias against our own "expensive" channels any more.
2024-03-07 03:56:58 +01:00
|
|
|
#define gossmods_from_listpeerchannels(ctx, self, buf, toks, zero_rates, cb, cbarg) \
|
|
|
|
gossmods_from_listpeerchannels_((ctx), (self), (buf), (toks), (zero_rates), \
|
2023-12-06 21:14:05 +01:00
|
|
|
typesafe_cb_preargs(void, void *, (cb), (cbarg), \
|
|
|
|
struct gossmap_localmods *, \
|
|
|
|
const struct node_id *, \
|
|
|
|
const struct node_id *, \
|
|
|
|
const struct short_channel_id_dir *, \
|
|
|
|
struct amount_msat, \
|
|
|
|
struct amount_msat, \
|
|
|
|
struct amount_msat, \
|
2024-03-18 08:31:42 +01:00
|
|
|
struct amount_msat, \
|
2024-10-04 01:35:53 +02:00
|
|
|
struct amount_msat, \
|
2023-12-06 21:14:05 +01:00
|
|
|
u32, \
|
2024-10-04 01:31:53 +02:00
|
|
|
u16, \
|
2023-12-06 21:14:05 +01:00
|
|
|
bool, \
|
|
|
|
const char *, \
|
|
|
|
const jsmntok_t *), \
|
|
|
|
(cbarg))
|
|
|
|
|
|
|
|
/* Callback which simply adds to gossmap. */
|
|
|
|
void gossmod_add_localchan(struct gossmap_localmods *mods,
|
|
|
|
const struct node_id *self,
|
|
|
|
const struct node_id *peer,
|
|
|
|
const struct short_channel_id_dir *scidd,
|
2024-10-04 01:35:53 +02:00
|
|
|
struct amount_msat capacity_msat,
|
2024-03-18 08:31:42 +01:00
|
|
|
struct amount_msat htlcmin,
|
|
|
|
struct amount_msat htlcmax,
|
|
|
|
struct amount_msat spendable,
|
2023-12-06 21:14:05 +01:00
|
|
|
struct amount_msat fee_base,
|
|
|
|
u32 fee_proportional,
|
2024-10-04 01:31:53 +02:00
|
|
|
u16 cltv_delta,
|
2023-12-06 21:14:05 +01:00
|
|
|
bool enabled,
|
|
|
|
const char *buf UNUSED,
|
|
|
|
const jsmntok_t *chantok UNUSED,
|
|
|
|
void *cbarg UNUSED);
|
|
|
|
|
|
|
|
#endif /* LIGHTNING_COMMON_GOSSMODS_LISTPEERCHANNELS_H */
|