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

Check block requests response in higher level code instead #1238

Merged
merged 2 commits into from
Oct 23, 2023

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented Oct 23, 2023

Right now, the SyncService::blocks_query function downloads the block from a peer then verifies whether the body matches the header.

This has two issues:

  • In order for this to work, one need to also download the header, which is often necessary. There are several TODOs in the code where we download the header when unnecessary.
  • Inconsistency. None of the other networking requests have this verification. Block requests are the only requests that have this, because it's actually possible to perform some verification, whereas for other requests it's not.

In #1200 I'm planning to remove this check.
This PR is a preliminary change to make the high-level code verify the block headers and bodies, instead of the low-level code.

Note that the syncing code already verifies whether headers in responses match the expected hash. As for bodies, I've added a TODO in the optimistic syncing. Since this doesn't concern the light client it isn't critical.

A side change is that I realize that chain_getBlock directly returns the justifications downloaded from the network without verifying them. I've removed this and mentioned it in the CHANGELOG.

@tomaka tomaka added this pull request to the merge queue Oct 23, 2023
Merged via the queue into smol-dot:main with commit 4bc665f Oct 23, 2023
21 checks passed
@tomaka tomaka deleted the check-sync-response branch October 23, 2023 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant