-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix(sync): return control from HeaderStage
back to pipeline
#609
Conversation
I think we can make this more efficient by only streaming |
thanks for the PR @TechieBoy! unfortunately, we cannot download headers onwards, because of long-range attack (refer to the headers section of the book for more details). it's better to trust the CL and walk the canonical chain from the tip to prevent peers from advertising bad blocks to us. we are planning to add some onward logic for chains that don't have EL/CL separation and possibly for pre-merge headers |
Codecov Report
@@ Coverage Diff @@
## main #609 +/- ##
==========================================
+ Coverage 72.22% 72.32% +0.09%
==========================================
Files 255 255
Lines 25783 25792 +9
==========================================
+ Hits 18623 18654 +31
+ Misses 7160 7138 -22
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Makes sense, but we do want to write the headers to db from head onwards, correct? Otherwise the reth/crates/stages/src/stages/headers.rs Lines 98 to 102 in 92f4bb5
Or should it write to db from tip downwards? |
Since we are not appending anymore, it shouldn't matter really.
that's the desired behavior. otherwise we wouldn't know the local "head" |
26b2d68
to
76bb72c
Compare
76bb72c
to
1c602d3
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, great job!
HeaderStage
back to pipeline
👍🏻 Thanks for being so patient and helpful and answering all my questions! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good from me - pending @onbjerg approval
current_progress = current_progress.max(write_progress); | ||
// The downloader returns the headers in descending order starting from the tip | ||
// down to the local head (latest block in db) | ||
let downloaded_headers: Result<Vec<SealedHeader>, DownloadError> = self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Bjerg Ptal - looks good from my side
@@ -166,6 +169,19 @@ impl<D: HeaderDownloader, C: Consensus, H: HeadersClient, S: StatusUpdater> | |||
Ok(()) | |||
} | |||
|
|||
async fn is_stage_done<DB: Database>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@onbjerg PTAL
lgtm, merging |
We only write commit_threshold blocks after fetching them with the downloader.
Closes #607