Skip to content

Conversation

joostjager
Copy link
Contributor

@joostjager joostjager commented Jan 29, 2025

Fixes #313

Depends on lightningdevkit/rust-lightning#3562

Export functionality in #458

@joostjager joostjager changed the title Import scores Periodical external score merge Jan 30, 2025
@joostjager joostjager force-pushed the import-scores branch 2 times, most recently from e0b7070 to 58acc12 Compare January 30, 2025 13:31
@joostjager joostjager force-pushed the import-scores branch 3 times, most recently from 5858404 to fdf2b5d Compare January 30, 2025 14:04
@joostjager joostjager marked this pull request as ready for review January 31, 2025 08:53
@tnull tnull added this to the 0.6 milestone Jan 31, 2025
Copy link
Collaborator

@tnull tnull left a comment

Choose a reason for hiding this comment

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

Thanks! Did a first pass, already looks pretty good!

@joostjager joostjager force-pushed the import-scores branch 2 times, most recently from 5a42ff9 to 0cf5774 Compare February 1, 2025 17:04
@joostjager joostjager force-pushed the import-scores branch 3 times, most recently from 619c9c9 to 6ded8af Compare February 3, 2025 10:01
@joostjager joostjager force-pushed the import-scores branch 5 times, most recently from 7bf68af to 14167eb Compare February 4, 2025 12:33
@joostjager joostjager requested a review from tnull February 4, 2025 14:43
@joostjager joostjager changed the title Periodical external score merge Periodical external pathfinding scores merge Feb 5, 2025
async fn sync_external_scores(
logger: &Logger, scorer: &Mutex<CombinedScorer<Arc<Graph>, Arc<Logger>>>,
node_metrics: &RwLock<NodeMetrics>, kv_store: Arc<DynStore>, url: &String,
) -> () {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this return a Result?

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 don't think so - this function cannot fail?

src/scoring.rs Outdated
match body {
Err(e) => {
log_error!(logger, "Failed to read external scores update: {}", e);
return;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's avoid these explicit returns if possible.

Copy link
Contributor Author

@joostjager joostjager Feb 7, 2025

Choose a reason for hiding this comment

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

Indeed, not necessary. I wanted to exit the parent function with these returns, but just letting it run would have the same result.

In this current revision I now have a few real ones, after unwrapping the matches a bit.

@joostjager
Copy link
Contributor Author

Comments addressed. Now need to decide in lightningdevkit/rust-lightning#3562 how to read the combined scorer from disk (with local and merged data), and apply that in this PR.

@joostjager joostjager requested a review from tnull February 11, 2025 07:42
@tnull tnull modified the milestones: 0.6, 0.7 Jun 9, 2025
) -> () {
let response = tokio::time::timeout(
Duration::from_secs(EXTERNAL_PATHFINDING_SCORES_SYNC_TIMEOUT_SECS),
reqwest::get(url),
Copy link
Contributor

Choose a reason for hiding this comment

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

should create a reqwest client instead of doing reqwest::get, otherwise it needs to redo TLS and everything each time

Copy link
Collaborator

Choose a reason for hiding this comment

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

should create a reqwest client instead of doing reqwest::get, otherwise it needs to redo TLS and everything each time

Right, but establishing a new connection once an hour is reasonable? And probably preferable compared to keep a connection open if we only use it once an hour?

Copy link
Contributor

Choose a reason for hiding this comment

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

ah yeah true

@joostjager
Copy link
Contributor Author

This has been parked, but I suppose with the new develop branch we can merge this after a rebase.

@tnull
Copy link
Collaborator

tnull commented Sep 10, 2025

This has been parked, but I suppose with the new develop branch we can merge this after a rebase.

Yes, please rebase!

@tnull
Copy link
Collaborator

tnull commented Oct 7, 2025

Gentle ping @joostjager

Save external pathfinding scores in a cache so that they will be
available immediately after a node restart. Otherwise there might be a
time window where new scores need to be downloaded still and the node
operates on local data only.
@joostjager
Copy link
Contributor Author

Rebased

Copy link
Collaborator

@tnull tnull left a comment

Choose a reason for hiding this comment

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

Two minor comments, otherwise should look good.

@tnull
Copy link
Collaborator

tnull commented Oct 17, 2025

@joostjager Feel free to squash the fixup. More detailed/verbose commit messages would also be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Allow to download and import a scorer from a binary file

3 participants