Open renepickhardt opened 8 months ago
I find this feature separation API very interesting.
I think we need to make a distinction between the property of the channel (eg. base_fee
, delay
), the quantities that are targeted for optimization (eg. fee, success probability), and the cost function for each of the targeted quantities (eg. uncertainty cost, the fee itself is a cost function for the fee). Which one would you call feature?
I recall that -log
of the success probability was a good choice for a cost function because it allowed to write the total cost as a sum of over the arcs in the route; this is just a reminder that the target quantity and the cost function are not always the same.
Generally in
renepay
one needs to define a linear unit_cost. This can consist of one or several features (which in the best case are also already linear unit_costs). (Theunit_costs
can be seen as slopes.)The documentation and API of the code suggest that currently there are
2
features inrenepay
:s64 pcost = linear_network->arc_prob_cost[arc.idx]
)fcost = linear_network->arc_fee_cost[arc.idx]
)The naming was taken from the following function where the two features are being combined with some parameter
MU
https://github.com/ElementsProject/lightning/blob/02ca226f88bf91c1fc3f654d8faa5aa178f75b96/plugins/renepay/mcf.c#L532While the linearized uncertainty_unit_cost seems to be computed as one would expect (neglecting the open issue of the uncertainty cost often being rounded down to 0 during integer casting) it turns out that the fee cost is computed rather strangely:
https://github.com/ElementsProject/lightning/blob/02ca226f88bf91c1fc3f654d8faa5aa178f75b96/plugins/renepay/flow.c#L866
We see the
fee_unit_cost
consists of theppm
(orfee_rate
) and some penalty for thebase fee
(while I am not sure if this is the best way to approximate channels withbase fee
I certainly think one can do it this way). However the third term in the sum is related to theCLTV
of the involved channels:delay*delay_feefactor
.It is my understanding that historically there was the
delay
coded into the cost function (weights) of dijkstra as people thought they would rather prefer to send funds across channels with a tiny higher fee but lower total CLTV so that in case of onchain failures the funds would not be locked too long. While that kind of reasoning makes some sense to me I believe nowadays with all those pinning attacks circling around the trend is to prefer channels with a higher CLTV deltas? in that case the feature should actually change to somthing like1/dalay
ormax_delay - delay
to achieve one's goals. In any case it may also indicate that adding the delay into the cost function is not the best idea?in any case the code discusses at length in comments how to price uncertainty in sats but here the cost for the CLTV just drops. Also it leas to a final
unit_cost
(or slope) of the linear cost function:Despite
combine_cost_function
suggesting we have only 2 features we do infact have 4 features (three of which are already combined into thefcost
):pfee
(corresponding to theppm
of a channel)bfee
(corresponding to thebase_fee
of a channel)delay
(corresponding to thecltv_delta
of a channel)pcost
(corresponding to the uncertainty cost of thearc
)Problems / Question
The four identified features are combined with some linear combination and weights. Some of the weights are learnt while plugin execution, some others are given to the user as command line parameters. the weight
mu
is even multiplied with the other weights making the entire feature engineering process a bit strange and probably yield unpredictable results.Proposal / Solution
arc
.mu
) or over the lifespan of the lightning node from statistics or could be passed by users (for example to overwrite what the node thinks is best). In this way future features like latency of a channel could be easily added.Removing cltv as a feature
I would argue that
cltv
should not be part of the cost function in payment planning as it produces behavior that seems hard to predict / understand. If thecltv
is important I suggest to set an acceptable cltv range and skip all channels ingossmap
that do not satisfy the acceptablecltv
ranges while feeding thelinear_network
andresidual_network
data structures.