-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(sync): total difficulty stage #665
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
/// NOTE: This stage commits the header changes to the database (everything except the changes to | ||
/// [`HeaderTD`][reth_interfaces::db::tables::HeaderTD] table). The stage does not return the | ||
/// control flow to the pipeline in order to preserve the context of the chain tip. |
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.
this comment has been obsolete after #609
Codecov Report
@@ Coverage Diff @@
## main #665 +/- ##
==========================================
+ Coverage 71.99% 73.15% +1.15%
==========================================
Files 260 261 +1
Lines 26264 26760 +496
==========================================
+ Hits 18909 19575 +666
+ Misses 7355 7185 -170
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. |
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.
ACK from me.
Before, we would only write total difficulty after headers stage is done inside the is_stage_done
function. That works, but it's cleaner to move it to a separate stage, especially given that headers operate in reverse.
cc @onbjerg
let stage_progress = input.stage_progress.unwrap_or_default(); | ||
let previous_stage_progress = input.previous_stage_progress(); | ||
|
||
let start_block = stage_progress + 1; | ||
let end_block = previous_stage_progress.min(start_block + self.commit_threshold); | ||
|
||
if start_block > end_block { | ||
info!(target: "sync::stages::total_difficulty", stage_progress, "Target block already reached"); | ||
return Ok(ExecOutput { stage_progress, done: true }) | ||
} |
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.
I'd like to make this an associated function on the Stage
trait, we do this on every stage and should be something the developer of a stage doesn't need to think about.
let done = end_block >= previous_stage_progress; | ||
info!(target: "sync::stages::total_difficulty", stage_progress = end_block, done, "Sync iteration finished"); | ||
Ok(ExecOutput { done, stage_progress: end_block }) |
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.
same as above for the start/end stuff.
Addresses first part of #607 (comment)
Writing total difficulty into the database is now extracted into a separate stage. Previously, it was done as a one-off write upon
Headers
stage completion.Open to discussing whether this stage should be before or after
Bodies
.