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

PeerDAS: Add KZG verification when sampling #14187

Merged
merged 7 commits into from
Jul 9, 2024

Conversation

nalepae
Copy link
Contributor

@nalepae nalepae commented Jul 4, 2024

Please read commit by commit.

Before this PR, VerifyKZGInclusionProofColumn and VerifyDataColumnSidecarKZGProofs were not evaluated when receiving columns from a peer during sampling.

Previously, only the root and the column index were evaluated. This allowed a peer to submit a fabricated column with a correct root and index, which posed a security risk.

Now, VerifyKZGInclusionProofColumn and VerifyDataColumnSidecarKZGProofs are evaluated for every sampled column, and the corresponding columns are rejected if these evaluations fail.

@nalepae nalepae added the peerDAS label Jul 4, 2024
if !verified {
return pubsub.ValidationReject, errors.New("failed to verify kzg proof of column")
}

// ?????
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nisdas to what specification rule this portion of code does correspond?

Copy link
Member

Choose a reason for hiding this comment

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

We are just retrieving the state here, it doesnt correspond to any specification rule directly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I was more talking about the following block:

	if err := coreBlocks.VerifyBlockHeaderSignatureUsingCurrentFork(parentState, ds.SignedBlockHeader); err != nil {
		return pubsub.ValidationReject, err
	}

Copy link
Member

Choose a reason for hiding this comment

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

[REJECT] The proposer signature of sidecar.signed_block_header, is valid with respect to the block_header.proposer_index pubkey.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 6431659

@nalepae nalepae force-pushed the peerdas-check-kzg-sampling branch 2 times, most recently from 875ac52 to 3a36a70 Compare July 4, 2024 22:32
@nalepae nalepae force-pushed the peerdas-check-kzg-sampling branch from 3a36a70 to 330a87e Compare July 8, 2024 07:36
@nalepae nalepae marked this pull request as ready for review July 8, 2024 07:50
@nalepae nalepae requested a review from a team as a code owner July 8, 2024 07:50
@nalepae nalepae requested review from prestonvanloon, terencechain and nisdas and removed request for a team July 8, 2024 07:50
@nalepae nalepae added the Ready For Review A pull request ready for code review label Jul 8, 2024
if !verified {
return pubsub.ValidationReject, errors.New("failed to verify kzg proof of column")
}

// ?????
Copy link
Member

Choose a reason for hiding this comment

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

We are just retrieving the state here, it doesnt correspond to any specification rule directly

if err != nil {
return pubsub.ValidationIgnore, err
// Add specific debug log.
if logrus.GetLevel() >= logrus.DebugLevel {
Copy link
Member

Choose a reason for hiding this comment

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

I dont think there is any reason to gate it this way as a time calculation is very cheap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in b4ad914.

@nalepae nalepae merged commit 60652c4 into peerDAS Jul 9, 2024
15 of 16 checks passed
@nalepae nalepae deleted the peerdas-check-kzg-sampling branch July 9, 2024 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
peerDAS Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants