Skip to content

block-sync: poll: make best known chain tip optional #807

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

Conversation

valentinewallace
Copy link
Contributor

For clients who are bootstrapping and have no best known tip. Unless I'm missing something here.

@TheBlueMatt
Copy link
Collaborator

Hmm, how are you trying to use Poll, specifically? The synchronize_listeners method in block-sync/init takes a BlockSource instead, which doesn't require a previous tip.

@valentinewallace
Copy link
Contributor Author

valentinewallace commented Feb 26, 2021

Hmm, how are you trying to use Poll, specifically? The synchronize_listeners method in block-sync/init takes a BlockSource instead, which doesn't require a previous tip.

SpvClient::new requires a chain tip. And if we're starting a fresh node and had no reason to call synchronize_listeners, then we don't have one afaict.

@codecov
Copy link

codecov bot commented Feb 26, 2021

Codecov Report

Merging #807 (a1b3de1) into main (e77b160) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #807      +/-   ##
==========================================
+ Coverage   91.00%   91.05%   +0.04%     
==========================================
  Files          48       48              
  Lines       25480    25492      +12     
==========================================
+ Hits        23188    23211      +23     
+ Misses       2292     2281      -11     
Impacted Files Coverage Δ
lightning-block-sync/src/lib.rs 95.37% <100.00%> (ø)
lightning-block-sync/src/poll.rs 92.55% <100.00%> (+0.50%) ⬆️
lightning/src/ln/functional_tests.rs 97.13% <0.00%> (+0.18%) ⬆️

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 e77b160...a1b3de1. Read the comment docs.

@TheBlueMatt
Copy link
Collaborator

And if we're starting a fresh node and had no reason to call synchronize_listeners

Ah, good point. I wonder if we're better off just passing a None in to SpvClient instead, indicating a fresh node. What do you think @jkczyz ?

@TheBlueMatt TheBlueMatt added this to the 0.0.13 milestone Feb 26, 2021
@jkczyz
Copy link
Contributor

jkczyz commented Feb 26, 2021

And if we're starting a fresh node and had no reason to call synchronize_listeners

Ah, good point. I wonder if we're better off just passing a None in to SpvClient instead, indicating a fresh node. What do you think @jkczyz ?

How about another utility in init that given a Network returns a ValidatedBlockHeader of the genesis block?

@TheBlueMatt
Copy link
Collaborator

How about another utility in init that given a Network returns a ValidatedBlockHeader of the genesis block?

That would end up downloading the full chain, no? Ideally we'd just start from the current tip because we don't care about any of the historical data.

@jkczyz
Copy link
Contributor

jkczyz commented Feb 26, 2021

That would end up downloading the full chain, no? Ideally we'd just start from the current tip because we don't care about any of the historical data.

True. Giving None to SpvClient would be preferable then I suppose.

@TheBlueMatt
Copy link
Collaborator

We could also do a util function in init that returns the current best block as a ValidatedBlockHeader, which would maybe be more explicit in the sense that you have to call something that has the word "fresh_node" in it or so.

@jkczyz
Copy link
Contributor

jkczyz commented Feb 28, 2021

We could also do a util function in init that returns the current best block as a ValidatedBlockHeader, which would maybe be more explicit in the sense that you have to call something that has the word "fresh_node" in it or so.

Hmm... ok had some time to think about this. Doesn't calling synchronize_listeners without any listeners already do what we want?

We could make a utility that does this though technically it would ignore the Network parameter. Alternatively, we could refactor the first four lines of synchronize_listeners into a separate pub function -- essentially what you suggested -- and use it in synchronize_listeners. Maybe call it validate_best_block_header given calling it fresh_node wouldn't be applicable in this context.

@TheBlueMatt
Copy link
Collaborator

Either sounds good to me, seems like it would have a similar public API.

@jkczyz
Copy link
Contributor

jkczyz commented Mar 2, 2021

Superseded by #818.

@jkczyz jkczyz closed this Mar 2, 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.

3 participants