-
Notifications
You must be signed in to change notification settings - Fork 304
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
Improve isDataAvailable
checks
#7575
Merged
tbenr
merged 14 commits into
Consensys:master
from
tbenr:improve-isDataAvailable-checks
Oct 17, 2023
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9de14bc
improve-isDataAvailable-checks
tbenr e516cea
change isDataAvailable signature
tbenr c326d5e
Merge branch 'master' into improve-isDataAvailable-checks
tbenr 7b454d0
update a comment
tbenr e884f3e
Merge remote-tracking branch 'origin/improve-isDataAvailable-checks' …
tbenr 21e46b3
simplified solution
tbenr bedcf74
comment and CodeQL
tbenr 9bae8a2
Merge branch 'master' into improve-isDataAvailable-checks
tbenr a1a15cb
tmp
tbenr a1086d2
update verifyBlobSidecarCompleteness
tbenr bb5abbe
add tests, fuzzers, and finals
tbenr 194f481
Merge branch 'master' into improve-isDataAvailable-checks
tbenr e9c8edb
apply improvements
tbenr 2084294
Merge branch 'master' into improve-isDataAvailable-checks
tbenr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
change isDataAvailable signature
move all blobSidecar-block sanity checks in the availability checker. Fun with tests
- Loading branch information
commit e516cea719f190159733935dca4e52effde2c9af
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.Random; | ||
import java.util.function.BiFunction; | ||
import java.util.function.Consumer; | ||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
|
@@ -2123,24 +2124,37 @@ public Bytes randomBlobBytes() { | |
} | ||
|
||
public List<BlobSidecar> randomBlobSidecarsForBlock(final SignedBeaconBlock block) { | ||
return randomSignedBlobSidecarsForBlock(block).stream() | ||
return randomBlobSidecarsForBlock(block, (__, builder) -> builder); | ||
} | ||
|
||
public List<BlobSidecar> randomBlobSidecarsForBlock( | ||
final SignedBeaconBlock block, | ||
BiFunction<Integer, RandomBlobSidecarBuilder, RandomBlobSidecarBuilder> modifier) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. boring final |
||
return randomSignedBlobSidecarsForBlock(block, modifier).stream() | ||
.map(SignedBlobSidecar::getBlobSidecar) | ||
.collect(toList()); | ||
} | ||
|
||
public List<SignedBlobSidecar> randomSignedBlobSidecarsForBlock(final SignedBeaconBlock block) { | ||
final int numberOfKzgCommitments = | ||
public List<SignedBlobSidecar> randomSignedBlobSidecarsForBlock( | ||
final SignedBeaconBlock block, | ||
BiFunction<Integer, RandomBlobSidecarBuilder, RandomBlobSidecarBuilder> modifier) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. another one |
||
final SszList<SszKZGCommitment> blobKzgCommitments = | ||
BeaconBlockBodyDeneb.required(block.getBeaconBlock().orElseThrow().getBody()) | ||
.getBlobKzgCommitments() | ||
.size(); | ||
return IntStream.range(0, numberOfKzgCommitments) | ||
.getBlobKzgCommitments(); | ||
|
||
return IntStream.range(0, blobKzgCommitments.size()) | ||
.mapToObj( | ||
index -> | ||
createRandomBlobSidecarBuilder() | ||
.slot(block.getSlot()) | ||
.blockRoot(block.getRoot()) | ||
.index(UInt64.valueOf(index)) | ||
.buildSigned()) | ||
index -> { | ||
final RandomBlobSidecarBuilder builder = | ||
createRandomBlobSidecarBuilder() | ||
.slot(block.getSlot()) | ||
.blockRoot(block.getRoot()) | ||
.blockParentRoot(block.getParentRoot()) | ||
.kzgCommitment(blobKzgCommitments.get(index).getBytes()) | ||
.index(UInt64.valueOf(index)); | ||
|
||
return modifier.apply(index, builder).buildSigned(); | ||
}) | ||
.collect(toList()); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I don't like here, both methods, this and
validateBlobSidecarsAgainstBlock
could be called now with part of blobs, which is not clear. Next,isDataAvailable
is a spec thing, so I expect it will verify it completely. Plus the last piece of puzzle, that we call this method with blobSidecars with indexes matching all indexes ofkzgCommitments
from block is somewhere else in the 3rd place.I'm not sure what's the best solution to make this better. My suggestion (not the best one, need to think more on this) is:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or better isDataAvailable(block, verifiedBlobIdentifiers)
return IntRange.of(0, block.getKzgCommitments.size()).map(index -> verifiedBlobIdentifiers.contains(new BlobIdentifier(block.getRoot, index))).filter(false).findFirst().isEmpty()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it isn't clear that those methods can be called with partial blobs. I'm thinking if it is better to go back to single method.
Consider that
ForkChoiceBlobSidecarsAvailabilityChecker::computeFinalValidationResult
is the method performing the checks on the final set.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, yeah, I understand it's happened there but we'd better have it here it and by my understanding it should be called
isDataAvailable
(for block, all data)