-
Notifications
You must be signed in to change notification settings - Fork 825
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
feat: run StaticFileProvider::check_consistency
on start up
#8143
base: main
Are you sure you want to change the base?
Conversation
loop { | ||
if let Some(indices) = provider.block_body_indices(last_block)? { | ||
if indices.last_tx_num() <= highest_tx { | ||
break | ||
} | ||
} | ||
if last_block == 0 { | ||
break | ||
} | ||
last_block -= 1; | ||
|
||
highest_block = Some(last_block); | ||
update_unwind_target(highest_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.
can we move this to static file manager, so that we can re-use it in stages as well?
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 made a first pass, want to also look at unwrap_or_default()
usage
let static_file_entry = static_file_entry.unwrap_or_default(); | ||
let highest_static_block = highest_static_block.unwrap_or_default(); |
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.
is it correct that if we don't even have a genesis block in the segment, we unwrap these to 0
?
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.
a few nits
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.
looks like most of the changes concern the Providerfactory::new call
this no longer requires a result
reth/crates/storage/provider/src/providers/database/mod.rs
Lines 53 to 57 in 76156e2
pub fn new( | |
db: DB, | |
chain_spec: Arc<ChainSpec>, | |
static_file_provider: StaticFileProvider, | |
) -> ProviderResult<ProviderFactory<DB>> { |
yes, because of the stacked PR: #8405 |
The bulk of changes are regarding
ProviderFactory
initialization, but the real change is introducing a function to check the overall consistency between static files and database:reth/crates/storage/provider/src/providers/static_file/manager.rs
Lines 512 to 516 in 14e2dbc
For each segment the following invariants are checked:
reth/crates/storage/provider/src/providers/static_file/manager.rs
Lines 611 to 621 in 14e2dbc
These will be called on starting up the node, before any data is queried from storage. If it fails any check it will try to self-heal, and if not possible, return a
PipelineTarget::Unwind(N)
that will be straight away handled by a standalone unwind-only pipeline.The tests live in
crates/stages/mod.rs
because there are other necessary test functions there and can not be imported into providers crate. Follow-up will refactor the test-utils in stages crate and move them to providers crate.Pending live testing - but open to review