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

Add BlobSidecarGossipValidator for new BlobSidecar with merkle proof validation #7687

Merged
merged 10 commits into from
Nov 13, 2023

Conversation

zilm13
Copy link
Contributor

@zilm13 zilm13 commented Nov 9, 2023

PR Description

  1. Some old BlobSidecars things renamed to Old and/or marked with Deprecated
  2. MerkleUtil.getPathToNode is rewritten. Old was buggy. testPathNotFound test is not relevant, removed, because we have negative check in the beginning (and test for it), so was passed because of bug. (Correct me if I'm wrong)
  3. We don't need to care about overriding logic of MiscHelpersDeneb.blobKzgCommitmentsGeneralizedIndex() in future fork MiscHelpers, because MAX_BLOB_COMMITMENTS_PER_BLOCK was set to some big value to guarantee that it will not be changed if we change max blobs (Correct me if I'm wrong)

Part of #7654

Fixed Issue(s)

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.

Changelog

  • I thought about adding a changelog entry, and added one if I deemed necessary.

new ArrayList<>(Collections.singleton(GIndexUtil.SELF_G_INDEX))));
int depth = 0;
final List<Long> path = new ArrayList<>();
final int depth = Long.SIZE - Long.numberOfLeadingZeros(nodeIndex);
Copy link
Contributor

Choose a reason for hiding this comment

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

Great code reduction 👍
I'd suggest using GIndexUtil.gIdxGetDepth() here

Copy link
Contributor Author

@zilm13 zilm13 Nov 9, 2023

Choose a reason for hiding this comment

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

Thank you. Done

Copy link
Contributor

@tbenr tbenr left a comment

Choose a reason for hiding this comment

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

LGTM. Just some nits.
I'd like to get an approval from @Nashatyrev too wrt merkle proof part

}

public String toLogString() {
return LogFormatter.formatBlobSidecar(
getSlot(),
getBlockRoot(),
getBlockBodyRoot(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems odd to print the block body root instead of block root here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch, which puts a focus on another issue: we cannot save it to DB since this change unless we get a block with corresponding body_root.
I have added both body_root and state_root to log string, since on most explorers we don't have body_root, but we may still want to see it to identify corresponding block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm stupid, we could do block root from block header. All fixed

public SafeFuture<InternalValidationResult> validate(
final SignedBlobSidecarOld signedBlobSidecar) {
final BlobSidecarOld blobSidecar = signedBlobSidecar.getBlobSidecar();
public SafeFuture<InternalValidationResult> validate(final BlobSidecar blobSidecar) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to unify the validation of the block's field with the BlockGossipValidator. But let's do that on a separate PR (I might pick that up if I get the rid of my current task)

Copy link
Contributor Author

@zilm13 zilm13 Nov 12, 2023

Choose a reason for hiding this comment

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

I've modified previous flow to follow the spec in the order and steps (when it's possible). Also I've added to our plan a task to optimize this (to the bottom)

Copy link
Contributor

@Nashatyrev Nashatyrev left a comment

Choose a reason for hiding this comment

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

LGTM

depth++;
for (int i = 0; i <= depth; ++i) {
path.add(currentIndex);
currentIndex = currentIndex >> 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd use gIdxGetParent here for better clarity

Copy link
Contributor

@tbenr tbenr left a comment

Choose a reason for hiding this comment

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

LGTM

@zilm13 zilm13 merged commit 291d10f into Consensys:master Nov 13, 2023
3 checks passed
@zilm13 zilm13 deleted the blobsidecar-validator branch November 13, 2023 09:59
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.

3 participants