Skip to content

[#2189] Score Fee Params as a passed in parameter #2237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 11, 2023

Conversation

henghonglee
Copy link
Contributor

@henghonglee henghonglee commented Apr 26, 2023

[#2189] Score Fee Params as a passed in parameter

Description:
Aims to fix https://github.com/lightningdevkit/rust-lightning/issues/2189

1. Introduce ScoreParams to Score Trait, allowing channel penalty calculations to have custom parameters
2. Split up ProbablisticScoreParamters into FeeParameters and DecayParameters
3. Couple tightly decay_params but decouple fee params so that modifying and customizing fee parameters can be more flexible.
4. Propagate changes to affect get_route and find_route in the router
5. Fix tests, put placeholder values on the various test scorers

@henghonglee henghonglee changed the title Issue 2189: Changes to score params https://github.com/lightningdevkit/rust-lightning/issues/2189 Issue 2189: Changes to score params Apr 27, 2023
@henghonglee henghonglee changed the title https://github.com/lightningdevkit/rust-lightning/issues/2189 Issue 2189: Changes to score params [Issue 2189] Changes to score params Apr 27, 2023
@henghonglee henghonglee force-pushed the issue-2189-score-params branch from 9ec4e0f to d3273d3 Compare April 27, 2023 07:34
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!

@henghonglee henghonglee force-pushed the issue-2189-score-params branch 9 times, most recently from 65a65ea to b00c185 Compare April 28, 2023 21:21
@TheBlueMatt
Copy link
Collaborator

Needs rebase, though it looks like you just have some commits that made their way upstream on this branch?

@henghonglee henghonglee force-pushed the issue-2189-score-params branch 2 times, most recently from 7605325 to 25924b3 Compare May 3, 2023 15:21
Copy link
Contributor Author

@henghonglee henghonglee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @TheBlueMatt, Ive tried to list down the issues im facing here. tried a few different variations of this solution but ive rolled back to this one since its the simplest and imo closest to what i want to achieve

@henghonglee henghonglee force-pushed the issue-2189-score-params branch 3 times, most recently from db1db6e to 9362cbd Compare May 3, 2023 16:03
Copy link
Contributor Author

@henghonglee henghonglee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheBlueMatt could you also take a quick look at the other comments that i made? in router.rs

@henghonglee henghonglee force-pushed the issue-2189-score-params branch 3 times, most recently from 530cb5d to 422d73d Compare May 5, 2023 01:15
Copy link
Contributor Author

@henghonglee henghonglee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @TheBlueMatt, it's finally ready for review :)

@henghonglee henghonglee force-pushed the issue-2189-score-params branch from 422d73d to 1c8c153 Compare May 5, 2023 01:23
@henghonglee henghonglee requested a review from TheBlueMatt May 5, 2023 01:23
@henghonglee henghonglee marked this pull request as ready for review May 5, 2023 04:15
@henghonglee henghonglee changed the title [Issue 2189] Changes to score params [Issue 2189] Score Fee Params as a passed in parameter May 5, 2023
@henghonglee henghonglee force-pushed the issue-2189-score-params branch 2 times, most recently from c3e3764 to 490f401 Compare May 9, 2023 00:53
@TheBlueMatt
Copy link
Collaborator

TheBlueMatt commented May 9, 2023

You can tell github thinks your line is too long because it cut off the last word and replace it with ... :). I think its cutoff is around 75, but I'm not 100% sure. 70 is always safe. It was 70.

@henghonglee henghonglee force-pushed the issue-2189-score-params branch 3 times, most recently from 6d882ab to 567a225 Compare May 9, 2023 04:50
@arik-so arik-so self-requested a review May 9, 2023 16:51
pub manual_node_penalties: HashMap<NodeId, u64>,


/// This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think writing out htlc_maximum_msat ≥ 0.5 * channel_capacity might make this a bit easier to read

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just moved this. but happy to make this change if thats necessary

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do it in a separate commit to preserve the move-only-ness, but nothing wrong with cleaning things up when they're getting touched anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure i can tease that out it into a seperate commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 525 to 526
/// these decay parameters affect the score of the channel penalty but are usually not changed on a per-route
/// penalty cost call.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: These
Also, "per-route" could probably go on the next line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay will do

@henghonglee henghonglee force-pushed the issue-2189-score-params branch from 567a225 to d1e9af7 Compare May 9, 2023 23:34
@henghonglee henghonglee requested a review from arik-so May 9, 2023 23:35
@henghonglee henghonglee force-pushed the issue-2189-score-params branch 5 times, most recently from 8aacbe7 to a2d0363 Compare May 10, 2023 05:11
@TheBlueMatt
Copy link
Collaborator

Its not critical, but if you do have to push again for some reason, your commit message still has lines (in the body, post-title) that are longer than 70 chars long. This LGTM, however, I'll let @arik-so take another look.

@henghonglee henghonglee force-pushed the issue-2189-score-params branch 3 times, most recently from 04dc495 to 0614a6a Compare May 10, 2023 18:21
@henghonglee
Copy link
Contributor Author

@arik-so

@arik-so
Copy link
Contributor

arik-so commented May 10, 2023

Looks good, but there are failing tests, so I imagine you're probably gonna need to push again.

This PR aims to create a "stateless" scorer. Instead of passing
in fee params at construction-time, we want to parametrize the
scorer with an associated "parameter" type, which is then
passed to the router function itself, and allows passing
different parameters per route-finding call.
@henghonglee henghonglee force-pushed the issue-2189-score-params branch from 0614a6a to ecd7992 Compare May 10, 2023 19:53
@henghonglee henghonglee force-pushed the issue-2189-score-params branch from ecd7992 to 86af670 Compare May 10, 2023 22:32
@henghonglee
Copy link
Contributor Author

@arik-so checks seems to be passing now

Copy link
Contributor

@arik-so arik-so left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!


#[cfg(test)]
impl ProbabilisticScoringDecayParameters {
fn zero_penalty() -> Self {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, we don't really need a duplicate of default that does the same thing :)

@TheBlueMatt TheBlueMatt merged commit e61b128 into lightningdevkit:main May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants