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

fix: add missing single block body download validation #3563

Merged
merged 1 commit into from
Jul 3, 2023

Conversation

mattsse
Copy link
Collaborator

@mattsse mattsse commented Jul 3, 2023

we didn't properly validate that the body response actually belongs to the header.

this adds missing checks to validate payload

@mattsse mattsse requested a review from gakonst as a code owner July 3, 2023 17:16
@mattsse mattsse added C-bug An unexpected or incorrect behavior A-consensus Related to the consensus engine labels Jul 3, 2023
@mattsse mattsse requested a review from Rjected July 3, 2023 17:17
@codecov
Copy link

codecov bot commented Jul 3, 2023

Codecov Report

Merging #3563 (a92c409) into main (8025b05) will decrease coverage by 0.05%.
The diff coverage is 54.28%.

Impacted file tree graph

Impacted Files Coverage Δ
crates/interfaces/src/p2p/full_block.rs 66.33% <52.23%> (-8.13%) ⬇️
crates/primitives/src/peer.rs 85.71% <100.00%> (+13.71%) ⬆️

... and 9 files with indirect coverage changes

Flag Coverage Δ
integration-tests 16.20% <0.00%> (-0.02%) ⬇️
unit-tests 63.90% <54.28%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
reth binary 23.01% <ø> (ø)
blockchain tree 81.25% <ø> (ø)
pipeline 86.98% <ø> (ø)
storage (db) 73.48% <ø> (ø)
trie 95.64% <ø> (ø)
txpool 49.46% <ø> (-0.63%) ⬇️
networking 77.86% <ø> (-0.03%) ⬇️
rpc 57.98% <ø> (-0.01%) ⬇️
consensus 62.58% <ø> (ø)
revm 34.95% <ø> (ø)
payload builder 6.83% <ø> (ø)
primitives 88.28% <54.28%> (-0.20%) ⬇️

Comment on lines +246 to +249
fn ensure_valid_body_response(
header: &SealedHeader,
block: &BlockBody,
) -> Result<(), ConsensusError> {
Copy link
Member

Choose a reason for hiding this comment

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

we already have validate_block_standalone fn

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this requires chain spec, which we don't have here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

could integrate this in a followup but requires a few changes

Copy link
Member

@rkrasiuk rkrasiuk left a comment

Choose a reason for hiding this comment

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

approving with the assumption that ensure_valid_body_response will be dedupped. it is important to do any validation w/ the chain spec

Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

LGTM

@mattsse mattsse added this pull request to the merge queue Jul 3, 2023
Merged via the queue into main with commit 64554dd Jul 3, 2023
@mattsse mattsse deleted the matt/fix-add-block-body-validation branch July 3, 2023 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-consensus Related to the consensus engine C-bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants