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

Creation of blob sidecars (with inclusion proof) when publishing #7721

Merged
merged 15 commits into from
Nov 20, 2023

Conversation

StefanBratanov
Copy link
Contributor

@StefanBratanov StefanBratanov commented Nov 16, 2023

PR Description

  • Add computeBlobSidecar in MiscHelpersDeneb
  • Create a new sidecar selector in BlockOperationSelectorFactory
  • Create createBlobSidecars method in BlockFactory and use it in AbstractBlockPublisher

Fixed Issue(s)

helps with block publishing flow for #7654

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.

@StefanBratanov StefanBratanov marked this pull request as draft November 16, 2023 15:43
Comment on lines 63 to +64
return operationSelector
.createBlobSidecarsSelector()
.createBlobSidecarsSelectorOld()

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
BlockOperationSelectorFactory.createBlobSidecarsSelectorOld
should be avoided because it has been deprecated.
Comment on lines 87 to +88
return operationSelector
.createBlobSidecarsSelector()
.createBlobSidecarsSelectorOld()

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
BlockOperationSelectorFactory.createBlobSidecarsSelectorOld
should be avoided because it has been deprecated.
.isEqualTo(blobsBundle.getCommitments().get(0));
assertThat(blobSidecar.getKZGProof()).isEqualTo(blobsBundle.getProofs().get(0));
});
safeJoin(factory.createBlobSidecarsSelectorOld().apply(block));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note test

Invoking
BlockOperationSelectorFactory.createBlobSidecarsSelectorOld
should be avoided because it has been deprecated.
@StefanBratanov StefanBratanov marked this pull request as ready for review November 17, 2023 11:51
@@ -1181,6 +1207,49 @@ public BeaconBlockBody randomBlindedBeaconBlockBody() {
return randomBlindedBeaconBlockBody(randomUInt64());
}

public BeaconBlockBody randomBlindedBeaconBlockBodyWithCommitments(
final UInt64 slot, final SszList<SszKZGCommitment> commitments) {
BeaconBlockBodySchema<?> schema =
Copy link
Contributor

Choose a reason for hiding this comment

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

final

})
.join();
}

public BeaconBlockBody randomBlindedBeaconBlockBody(UInt64 slotNum) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We could call yours from this one with randomBlobKzgCommitments() at commitments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is for pre-Deneb spec that would fail since there would be no BlobKzgCommitmentsSchema

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, got it. Ok

@@ -1410,8 +1484,7 @@ public BeaconBlockBody randomBeaconBlockBodyWithCommitments(final int count) {
.syncAggregate(randomSyncAggregateIfRequiredBySchema(schema))
.executionPayload(SafeFuture.completedFuture(randomExecutionPayload()))
.blsToExecutionChanges(randomSignedBlsToExecutionChangesList())
.blobKzgCommitments(
SafeFuture.completedFuture(randomBlobKzgCommitments(count))))
.blobKzgCommitments(SafeFuture.completedFuture(commitments)))
.join();
}

Copy link
Contributor

Choose a reason for hiding this comment

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

you could use #randomBeaconBlockBodyWithCommitments( final SszList<SszKZGCommitment> commitments) in randomFullBeaconBlockBody()

Copy link
Contributor

Choose a reason for hiding this comment

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

So this suggestion will fail preDeneb too. Ok

final SignedBeaconBlock signedBeaconBlock,
final UInt64 index,
final Blob blob,
final SszKZGCommitment commitment,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like this interface a bit, because we already have commitment in block and passed index, so passing commitment separately is redundant and could cause error, maybe omit this field?

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 like that idea. Makes things cleaner.


final BlockAndBlobs blockAndBlobs = assertBlobSidecarsCreated(false, spec);

final List<BlobSidecar> blobSidecars = blockAndBlobs.blobSidecars();
Copy link
Contributor

Choose a reason for hiding this comment

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

could you please add assert not empty here, I'm a bit paranoid

Copy link
Contributor Author

@StefanBratanov StefanBratanov Nov 18, 2023

Choose a reason for hiding this comment

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

These assertions are done in the assertBlobSidecarsCreated method following the pattern from other unit tests in this class.


final BlockAndBlobs blockAndBlobs = assertBlobSidecarsCreated(true, spec);

final List<BlobSidecar> blobSidecars = blockAndBlobs.blobSidecars();
Copy link
Contributor

Choose a reason for hiding this comment

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

and here please (check non empty)

@StefanBratanov
Copy link
Contributor Author

Thanks for feedback @zilm13 Added required changes, so you can have another look when you can.

Copy link
Contributor

@zilm13 zilm13 left a comment

Choose a reason for hiding this comment

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

Looks great, good refactor of computeKzgCommitmentInclusionProof
Just some final nits
Also #7721 (comment) is still actual

@StefanBratanov
Copy link
Contributor Author

StefanBratanov commented Nov 20, 2023

Looks great, good refactor of computeKzgCommitmentInclusionProof Just some final nits Also #7721 (comment) is still actual

Thanks. I renamed the method to createBlockAndBlobSidecars in 6a7f1b0 to be more correct. Does it make sense?

@zilm13
Copy link
Contributor

zilm13 commented Nov 20, 2023

@StefanBratanov yeah, looks good

@StefanBratanov StefanBratanov merged commit f3300d8 into Consensys:master Nov 20, 2023
15 checks passed
@StefanBratanov StefanBratanov deleted the creation_blob_sidecars branch November 20, 2023 11:28
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.

2 participants