You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we require a "stateless" scorer, one which returns an absolute score with no context besides the channel and liquidity. This is somewhat annoying, though, for folks who want to have different scorers at different times - they'll have to create two separate scorers and pass them in. You can see this in the API for ProbabilisticScorer, which requires you pass the params at construction-time. Instead, we should parametrize the scorer with an associated "parameter" type, which is then passed to the router function itself, and allows passing a different, eg, ProbabilisticScorerParams per route-finding call.
Should be pretty straightforward to do - just add a assicated type to the Score trait, then add that as an argument to the score-fetching method and make it an argument to the get_/find_ route function.
Hi @TheBlueMatt, I did some reading of the code and have some questions about this task.
From how I understand the scorer system, for each time a get_route / find_route is called, you need to use a scorer. a scorer is currently a single-use object that holds a bunch of states.
The various implementations of Score are these single-use objects that encode the "what" (what the parameters are) and also the "how" (how the scoring is calculated)
These include: FixedPenaltyScorer ProbabilisticScorer ScorerAccountingForInFlightHtlcs BadChannelScorer BadNodeScorer
it seems that find_route requires one of these scorers and is a central public function that does everything to find a single route from a payer to a payee.
IMHO, I think these scorer constructs do a nice job of abstracting the logic and accompanying state required for that logic. passing in the scorerParams in get_route seem to be very specific for only the ProbabilisticScorer flow and creates a leaky abstraction
maybe I did not understand "somewhat annoying, though.. different scorers at different times" right in the original text, did you mean to score each channel differently in a single get_route fn call? I can see that it might be very tricky to compose different scorers for a single get_route.
Maybe the complexity also lies in the multi-path payments and how each found route affects the next and requires a different scorer?
Could you further elaborate on where the annoyances lie in trying to achieve get_route/find_route with multiple scorers? is it memory related? speed/performance related? or mainly in the ergonomics of the implementations?
IMHO, I think these scorer constructs do a nice job of abstracting the logic and accompanying state required for that logic. passing in the scorerParams in get_route seem to be very specific for only the ProbabilisticScorer flow and creates a leaky abstraction
The scorers you listed above are largely test-only. In reality, ~everyone uses the ProbabilisticScorer (or the ScorerAccountingForInFlightHtlcs, which actually wraps the probabilistic one, in practice), and if we were to add some completely different scorer it would also likely have some parameters to tune with.
While you're right that its a lot of extra generics to expose the scoring parameters all the way out through the router, its quite useful in practice - scoring parameters aren't static, some payments may want to prefer to pay less in fees, and others may prefer a higher success probability. Moreso, if we've retried a payment a few times we may even want to prefer a higher success probability for certain retries later on! The current API doesn't allow this, as the parameters are "baked into" the scorer, and you'd have to have a separate scorer for different parameters.
did you mean something like this? hopefully I'm not missing anything obvious here
Hi, @TheBlueMatt
I do have an unfinished draft that I would like to have you take a look at. It seems I would be making a large number of changes so I just wanted to make sure (once again) that I'm still on the right track with regard to the task so that i can continue making all the necessary changes
Activity
henghonglee commentedon Apr 17, 2023
Hi @TheBlueMatt i'd like to give this one a try
henghonglee commentedon Apr 17, 2023
Hi @TheBlueMatt, I did some reading of the code and have some questions about this task.
From how I understand the scorer system, for each time a get_route / find_route is called, you need to use a scorer. a scorer is currently a single-use object that holds a bunch of states.
The various implementations of
Scoreare these single-use objects that encode the "what" (what the parameters are) and also the "how" (how the scoring is calculated)These include:
FixedPenaltyScorerProbabilisticScorerScorerAccountingForInFlightHtlcsBadChannelScorerBadNodeScorerit seems that
find_routerequires one of these scorers and is a central public function that does everything to find a single route from a payer to a payee.IMHO, I think these scorer constructs do a nice job of abstracting the logic and accompanying state required for that logic. passing in the scorerParams in get_route seem to be very specific for only the
ProbabilisticScorerflow and creates a leaky abstractionmaybe I did not understand "somewhat annoying, though.. different scorers at different times" right in the original text, did you mean to score each channel differently in a single
get_routefn call? I can see that it might be very tricky to compose different scorers for a single get_route.Maybe the complexity also lies in the multi-path payments and how each found route affects the next and requires a different scorer?
Could you further elaborate on where the annoyances lie in trying to achieve get_route/find_route with multiple scorers? is it memory related? speed/performance related? or mainly in the ergonomics of the implementations?
henghonglee commentedon Apr 19, 2023
@TheBlueMatt
did you mean something like this? hopefully I'm not missing anything obvious here
TheBlueMatt commentedon Apr 19, 2023
The scorers you listed above are largely test-only. In reality, ~everyone uses the
ProbabilisticScorer(or theScorerAccountingForInFlightHtlcs, which actually wraps the probabilistic one, in practice), and if we were to add some completely different scorer it would also likely have some parameters to tune with.While you're right that its a lot of extra generics to expose the scoring parameters all the way out through the router, its quite useful in practice - scoring parameters aren't static, some payments may want to prefer to pay less in fees, and others may prefer a higher success probability. Moreso, if we've retried a payment a few times we may even want to prefer a higher success probability for certain retries later on! The current API doesn't allow this, as the parameters are "baked into" the scorer, and you'd have to have a separate scorer for different parameters.
Yep, exactly like that!
henghonglee commentedon Apr 26, 2023
Hi, @TheBlueMatt
I do have an unfinished draft that I would like to have you take a look at. It seems I would be making a large number of changes so I just wanted to make sure (once again) that I'm still on the right track with regard to the task so that i can continue making all the necessary changes
Created a draft PR here https://github.com/lightningdevkit/rust-lightning/pull/2237/files.
henghonglee commentedon May 5, 2023
Ready for review :)
[lightningdevkit#2189] Score Fee Params as a passed in parameter
[lightningdevkit#2189] Score Fee Params as a passed in parameter
[lightningdevkit#2189] Score Fee Params as a passed in parameter
[lightningdevkit#2189] Score Fee Params as a passed in parameter
[lightningdevkit#2189] Score Fee Params as a passed in parameter
[lightningdevkit#2189] Score Fee Params as a passed in parameter
[lightningdevkit#2189] Score Fee Params as a passed in parameter
[lightningdevkit#2189] Score Fee Params as a passed in parameter
[lightningdevkit#2189] Score Fee Params as a passed in parameter
[lightningdevkit#2189] Score Fee Params as a passed in parameter
[lightningdevkit#2189] Score Fee Params as a passed in parameter
[lightningdevkit#2189] Score Fee Params as a passed in parameter
[lightningdevkit#2189] Score Fee Params as a passed in parameter
Merge pull request #2237 from henghonglee/issue-2189-score-params
wpaulino commentedon Aug 15, 2023
Done in #2237