-
Notifications
You must be signed in to change notification settings - Fork 191
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
verifyBlobs util #862
verifyBlobs util #862
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,84 @@ library EigenDARollupUtils { | |
); | ||
} | ||
|
||
/** | ||
* @notice Verifies the inclusion of a blob within a batch confirmed in `eigenDAServiceManager` and its trust assumptions | ||
* @param blobHeaders the headers of the blobs containing relevant attributes of the blobs | ||
* @param eigenDAServiceManager the contract in which the batch was confirmed | ||
* @param blobVerificationProofs the relevant data needed to prove inclusion of the blobs and that the trust assumptions were as expected | ||
*/ | ||
function verifyBlobs( | ||
IEigenDAServiceManager.BlobHeader[] calldata blobHeaders, | ||
IEigenDAServiceManager eigenDAServiceManager, | ||
BlobVerificationProof[] calldata blobVerificationProofs | ||
) external view { | ||
require(blobHeaders.length == blobVerificationProofs.length, "EigenDARollupUtils.verifyBlobs: blobHeaders and blobVerificationProofs must have the same length"); | ||
|
||
bytes memory quorumAdversaryThresholdPercentages = eigenDAServiceManager.quorumAdversaryThresholdPercentages(); | ||
uint256 quorumNumbersRequiredBitmap = BitmapUtils.orderedBytesArrayToBitmap(eigenDAServiceManager.quorumNumbersRequired()); | ||
|
||
for (uint i = 0; i < blobHeaders.length; i++) { | ||
require( | ||
EigenDAHasher.hashBatchMetadata(blobVerificationProofs[i].batchMetadata) | ||
== eigenDAServiceManager.batchIdToBatchMetadataHash(blobVerificationProofs[i].batchId), | ||
"EigenDARollupUtils.verifyBlob: batchMetadata does not match stored metadata" | ||
); | ||
|
||
require( | ||
Merkle.verifyInclusionKeccak( | ||
blobVerificationProofs[i].inclusionProof, | ||
blobVerificationProofs[i].batchMetadata.batchHeader.blobHeadersRoot, | ||
keccak256(abi.encodePacked(EigenDAHasher.hashBlobHeader(blobHeaders[i]))), | ||
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. double hash? |
||
blobVerificationProofs[i].blobIndex | ||
), | ||
"EigenDARollupUtils.verifyBlob: inclusion proof is invalid" | ||
); | ||
|
||
// bitmap of quorum numbers in all quorumBlobParams | ||
uint256 confirmedQuorumsBitmap; | ||
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. we don't return this? 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. if not, why not just point to the indices in quorumBlobParams to verify? |
||
|
||
// require that the security param in each blob is met | ||
for (uint j = 0; j < blobHeaders[i].quorumBlobParams.length; j++) { | ||
// make sure that the quorumIndex matches the given quorumNumber | ||
require(uint8(blobVerificationProofs[i].batchMetadata.batchHeader.quorumNumbers[uint8(blobVerificationProofs[i].quorumIndices[i])]) == blobHeaders[i].quorumBlobParams[i].quorumNumber, | ||
"EigenDARollupUtils.verifyBlob: quorumNumber does not match" | ||
); | ||
|
||
// make sure that the adversaryThresholdPercentage is less than the given confirmationThresholdPercentage | ||
require(blobHeaders[i].quorumBlobParams[i].adversaryThresholdPercentage | ||
< blobHeaders[i].quorumBlobParams[i].confirmationThresholdPercentage, | ||
"EigenDARollupUtils.verifyBlob: adversaryThresholdPercentage is not valid" | ||
); | ||
|
||
// make sure that the adversaryThresholdPercentage is at least the given quorumAdversaryThresholdPercentage | ||
uint8 _adversaryThresholdPercentage = uint8(quorumAdversaryThresholdPercentages[blobHeaders[i].quorumBlobParams[j].quorumNumber]); | ||
if(_adversaryThresholdPercentage > 0){ | ||
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. do we need this check? |
||
require(blobHeaders[i].quorumBlobParams[j].adversaryThresholdPercentage >= _adversaryThresholdPercentage, | ||
"EigenDARollupUtils.verifyBlob: adversaryThresholdPercentage is not met" | ||
); | ||
} | ||
|
||
// make sure that the stake signed for is greater than the given confirmationThresholdPercentage | ||
require(uint8(blobVerificationProofs[i].batchMetadata.batchHeader.signedStakeForQuorums[uint8(blobVerificationProofs[i].quorumIndices[j])]) | ||
>= blobHeaders[i].quorumBlobParams[j].confirmationThresholdPercentage, | ||
"EigenDARollupUtils.verifyBlob: confirmationThresholdPercentage is not met" | ||
); | ||
|
||
// mark confirmed quorum in the bitmap | ||
confirmedQuorumsBitmap = BitmapUtils.setBit(confirmedQuorumsBitmap, blobHeaders[i].quorumBlobParams[j].quorumNumber); | ||
} | ||
|
||
// check that required quorums are a subset of the confirmed quorums | ||
require( | ||
BitmapUtils.isSubsetOf( | ||
quorumNumbersRequiredBitmap, | ||
confirmedQuorumsBitmap | ||
), | ||
"EigenDARollupUtils.verifyBlob: required quorums are not a subset of the confirmed quorums" | ||
); | ||
} | ||
} | ||
|
||
/** | ||
* @notice gets the adversary threshold percentage for a given quorum | ||
* @param eigenDAServiceManager the contract in which the batch was confirmed | ||
|
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.
make this the first param imo