Skip to content
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

Include source and destination nodes in routing::Score #1133

Merged
merged 2 commits into from Oct 19, 2021

Conversation

jkczyz
Copy link
Contributor

@jkczyz jkczyz commented Oct 18, 2021

Expand routing::Score::channel_penalty_msat to include the source and target node ids of the channel. This allows scorers to avoid certain nodes altogether if desired.

In order to make the scoring tests easier to read, only check the
relevant RouteHop fields. The remaining fields are tested elsewhere.
Expand the test to show the path used without scoring.
@codecov
Copy link

codecov bot commented Oct 19, 2021

Codecov Report

Merging #1133 (a950b8f) into main (001bc71) will increase coverage by 0.00%.
The diff coverage is 96.61%.

❗ Current head a950b8f differs from pull request most recent head 54f490c. Consider uploading reports for the commit 54f490c to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1133   +/-   ##
=======================================
  Coverage   90.56%   90.56%           
=======================================
  Files          67       67           
  Lines       34567    34597   +30     
=======================================
+ Hits        31305    31334   +29     
- Misses       3262     3263    +1     
Impacted Files Coverage Δ
lightning/src/routing/router.rs 95.71% <96.42%> (+<0.01%) ⬆️
lightning/src/routing/scorer.rs 66.66% <100.00%> (+9.52%) ⬆️
lightning-invoice/src/de.rs 80.73% <0.00%> (-0.21%) ⬇️
lightning/src/ln/functional_tests.rs 97.33% <0.00%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 001bc71...54f490c. Read the comment docs.

/// An interface used to score payment channels for path finding.
///
/// Scoring is in terms of fees willing to be paid in order to avoid routing through a channel.
pub trait Score {
/// Returns the fee in msats willing to be paid to avoid routing through the given channel.
fn channel_penalty_msat(&self, short_channel_id: u64) -> u64;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit +"in the given direction" on the docs.

@@ -19,7 +19,8 @@ use routing::network_graph::NodeId;
///
/// Scoring is in terms of fees willing to be paid in order to avoid routing through a channel.
pub trait Score {
/// Returns the fee in msats willing to be paid to avoid routing through the given channel.
/// Returns the fee in msats willing to be paid to avoid routing through the given channel from
/// `source` to `destination`.
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't the source and dest of the payment itself, right? Just the forwarder/forwardee of the given short_channel_id? Those names are a bit overloaded for me lol

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. I could use the more general term target instead of destination and reword the docs a bit.

Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

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

Thanks, that makes it clearer for me

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.

Can you squash.

Expand routing::Score::channel_penalty_msat to include the source and
target node ids of the channel. This allows scorers to avoid certain
nodes altogether if desired.
@TheBlueMatt
Copy link
Collaborator

Squashed without changed:

$ git diff-tree -U1 e3a1b8acd 54f490c8c
$

@TheBlueMatt TheBlueMatt merged commit 083828a into lightningdevkit:main Oct 19, 2021
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.

None yet

3 participants