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: blob sidecar validation to ensure KZG commitment count matches #14752

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

crStiv
Copy link

@crStiv crStiv commented Dec 26, 2024

What type of PR is this?

Bug fix

What does this PR do? Why is it needed?

This PR adds validation to ensure that the number of available blob sidecars matches the number of KZG commitments in the block before responding to BlobSidecarsByRange requests. This prevents Prysm nodes from serving an incorrect number of blob sidecars that don't match the block's KZG commitment count.

The changes include:

  • Added validation in streamBlobBatch to count available sidecars
  • Compare count against number of KZG commitments in block
  • Return error if mismatch is detected
  • Added test case to verify the validation behavior

This fix ensures compliance with the P2P specification rule that states: "Clients MUST include all blob sidecars of each block from which they include blob sidecars."

Which issues(s) does this PR fix?

Fixes #14674

Other notes for review

The implementation adds minimal overhead as it only performs counting operations on existing data structures. The error handling follows existing patterns in the codebase.

Acknowledgements

  • I have read CONTRIBUTING.md.
  • I have made an appropriate entry to CHANGELOG.md.
  • I have added a description to this PR with sufficient context for reviewers to understand this PR.

@crStiv crStiv requested a review from a team as a code owner December 26, 2024 13:45
@CLAassistant
Copy link

CLAassistant commented Dec 26, 2024

CLA assistant check
All committers have signed the CLA.

}

// Check if we have all required blob sidecars
if kzgCommitments > 0 && availableSidecars < kzgCommitments {
Copy link
Member

Choose a reason for hiding this comment

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

does it make sense to check availableSidecars != kzgCommitments instead

Copy link
Author

@crStiv crStiv Jan 6, 2025

Choose a reason for hiding this comment

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

does it make sense to check availableSidecars != kzgCommitments instead

Hey Terence, you're absolutely right, therefore I made an update @terencechain

@prestonvanloon
Copy link
Member

This PR fails to build. Please fix

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.

Validate blob sidecar by range response
4 participants