Skip to content
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: validate headers loaded from file on reth import #14050

Merged
merged 1 commit into from
Jan 28, 2025

Conversation

joshieDo
Copy link
Collaborator

@joshieDo joshieDo commented Jan 28, 2025

We were trusting that all headers coming from rlp were valid, but that might not be the case (eg. hive negative tests)

Should solve a bunch of tests on hive eest
#14009

edit: it does solve a bunch of eest tests (consume/rlp)

@joshieDo joshieDo added C-enhancement New feature or request A-cli Related to the reth CLI labels Jan 28, 2025
@joshieDo joshieDo force-pushed the joshie/import-validation branch 2 times, most recently from 2fb92ca to f187331 Compare January 28, 2025 19:39
@joshieDo joshieDo requested a review from fgimenez as a code owner January 28, 2025 19:39
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

smol, nit
this solution seems fine, although the fileclient type and chunk reading is a bit weird and ideally we have a different stream type for this, but we could scope separately

crates/consensus/consensus/src/noop.rs Outdated Show resolved Hide resolved
crates/consensus/consensus/src/noop.rs Outdated Show resolved Hide resolved
@@ -668,7 +717,7 @@ mod tests {
let mut local_header = headers.first().unwrap().clone();

// test
while let Some(client) = reader.next_chunk::<FileClient>().await.unwrap() {
while let Some(client) = reader.next_chunk::<Block>(NoopConsensus::arc()).await.unwrap() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this loops a bit odd, why do we need to provide this per chunk?

Copy link
Collaborator Author

@joshieDo joshieDo Jan 28, 2025

Choose a reason for hiding this comment

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

although not ideal, each chunk is like 1GB worth of blocks that we read from disk, so it should be kinda fine

Comment on lines +94 to +95
while let Some(file_client) =
reader.next_chunk::<BlockTy<N>>(consensus.clone(), Some(sealed_header)).await?
Copy link
Collaborator

Choose a reason for hiding this comment

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

this works, but I wonder if a nicer solution to this would be a custom stream type and not require the consensus per next_chunk call.

but this entire type is weird so seems fine

Copy link
Collaborator Author

@joshieDo joshieDo Jan 28, 2025

Choose a reason for hiding this comment

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

agree, would rather we track this separately tbh, just want it to work for now for hive tests

@joshieDo joshieDo force-pushed the joshie/import-validation branch 2 times, most recently from 3b2de27 to af41aba Compare January 28, 2025 19:49
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm

will scope some improvements to this separately

@joshieDo joshieDo force-pushed the joshie/import-validation branch from af41aba to ad0a920 Compare January 28, 2025 19:52
@joshieDo joshieDo force-pushed the joshie/import-validation branch from ad0a920 to b2fdec7 Compare January 28, 2025 19:53
@joshieDo joshieDo enabled auto-merge January 28, 2025 19:59
@joshieDo joshieDo added this pull request to the merge queue Jan 28, 2025
Merged via the queue into main with commit 7db8e42 Jan 28, 2025
44 checks passed
@joshieDo joshieDo deleted the joshie/import-validation branch January 28, 2025 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Related to the reth CLI C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants