Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
- rename quorumIndices
- more descriptive NATSPEC
  • Loading branch information
0x0aa0 committed Mar 7, 2024
1 parent a45d573 commit 425ecee
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
10 changes: 8 additions & 2 deletions contracts/src/core/EigenDAServiceManagerStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ abstract contract EigenDAServiceManagerStorage is IEigenDAServiceManager {
*/
uint32 public constant BLOCK_STALE_MEASURE = 150;

/// @notice The quorum adversary threshold percentages
/**
* @notice The quorum adversary threshold percentages stored as an ordered bytes array
* this is the percentage of the total stake that must be adversarial to consider a blob invalid
*/
bytes public constant quorumAdversaryThresholdPercentages = hex"2121";

/// @notice The quorum confirmation threshold percentages
/**
* @notice The quorum confirmation threshold percentages stored as an ordered bytes array
* this is the percentage of the total stake needed to confirm a blob
*/
bytes public constant quorumConfirmationThresholdPercentages = hex"4242";

/// @notice The current batchId
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/libraries/EigenDARollupUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ library EigenDARollupUtils {
uint8 blobIndex;
IEigenDAServiceManager.BatchMetadata batchMetadata;
bytes inclusionProof;
bytes quorumThresholdIndexes;
bytes quorumIndices;
}

/**
Expand Down Expand Up @@ -53,7 +53,7 @@ library EigenDARollupUtils {
// require that the security param in each blob is met
for (uint i = 0; i < blobHeader.quorumBlobParams.length; i++) {
// make sure that the quorumIndex matches the given quorumNumber
require(uint8(blobVerificationProof.batchMetadata.batchHeader.quorumNumbers[uint8(blobVerificationProof.quorumThresholdIndexes[i])]) == blobHeader.quorumBlobParams[i].quorumNumber,
require(uint8(blobVerificationProof.batchMetadata.batchHeader.quorumNumbers[uint8(blobVerificationProof.quorumIndices[i])]) == blobHeader.quorumBlobParams[i].quorumNumber,
"EigenDARollupUtils.verifyBlob: quorumNumber does not match"
);

Expand All @@ -72,7 +72,7 @@ library EigenDARollupUtils {
}

// make sure that the stake signed for is greater than the given confirmationThresholdPercentage
require(uint8(blobVerificationProof.batchMetadata.batchHeader.signedStakeForQuorums[uint8(blobVerificationProof.quorumThresholdIndexes[i])])
require(uint8(blobVerificationProof.batchMetadata.batchHeader.signedStakeForQuorums[uint8(blobVerificationProof.quorumIndices[i])])
>= blobHeader.quorumBlobParams[i].confirmationThresholdPercentage,
"EigenDARollupUtils.verifyBlob: confirmationThresholdPercentage is not met"
);
Expand Down
16 changes: 8 additions & 8 deletions contracts/test/unit/EigenDABlobUtils.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ contract EigenDABlobUtilsUnit is BLSMockAVSDeployer {
blobVerificationProof.batchMetadata = batchMetadata;
blobVerificationProof.inclusionProof = abi.encodePacked(keccak256(firstBlobHash));
blobVerificationProof.blobIndex = 1;
blobVerificationProof.quorumThresholdIndexes = new bytes(batchHeader.quorumNumbers.length);
blobVerificationProof.quorumIndices = new bytes(batchHeader.quorumNumbers.length);
for (uint i = 0; i < batchHeader.quorumNumbers.length; i++) {
blobVerificationProof.quorumThresholdIndexes[i] = bytes1(uint8(i));
blobVerificationProof.quorumIndices[i] = bytes1(uint8(i));
}

uint256 gasBefore = gasleft();
Expand Down Expand Up @@ -189,9 +189,9 @@ contract EigenDABlobUtilsUnit is BLSMockAVSDeployer {
blobVerificationProof.batchMetadata = batchMetadata;
blobVerificationProof.inclusionProof = abi.encodePacked(keccak256(firstBlobHash));
blobVerificationProof.blobIndex = 1;
blobVerificationProof.quorumThresholdIndexes = new bytes(batchHeader.quorumNumbers.length);
blobVerificationProof.quorumIndices = new bytes(batchHeader.quorumNumbers.length);
for (uint i = 0; i < batchHeader.quorumNumbers.length; i++) {
blobVerificationProof.quorumThresholdIndexes[i] = bytes1(uint8(i));
blobVerificationProof.quorumIndices[i] = bytes1(uint8(i));
}

uint256 gasBefore = gasleft();
Expand Down Expand Up @@ -235,10 +235,10 @@ contract EigenDABlobUtilsUnit is BLSMockAVSDeployer {
blobVerificationProof.batchMetadata = batchMetadata;
blobVerificationProof.inclusionProof = abi.encodePacked(keccak256(firstBlobHash));
blobVerificationProof.blobIndex = 1;
blobVerificationProof.quorumThresholdIndexes = new bytes(batchHeader.quorumNumbers.length);
blobVerificationProof.quorumIndices = new bytes(batchHeader.quorumNumbers.length);
for (uint i = 0; i < batchHeader.quorumNumbers.length; i++) {
// implant the incorrect quorumNumbers here
blobVerificationProof.quorumThresholdIndexes[i] = bytes1(uint8(batchHeader.quorumNumbers.length - 1 - i));
blobVerificationProof.quorumIndices[i] = bytes1(uint8(batchHeader.quorumNumbers.length - 1 - i));
}

cheats.expectRevert("EigenDARollupUtils.verifyBlob: quorumNumber does not match");
Expand Down Expand Up @@ -280,10 +280,10 @@ contract EigenDABlobUtilsUnit is BLSMockAVSDeployer {
blobVerificationProof.batchMetadata = batchMetadata;
blobVerificationProof.inclusionProof = abi.encodePacked(keccak256(firstBlobHash));
blobVerificationProof.blobIndex = 1;
blobVerificationProof.quorumThresholdIndexes = new bytes(batchHeader.quorumNumbers.length);
blobVerificationProof.quorumIndices = new bytes(batchHeader.quorumNumbers.length);
for (uint i = 0; i < batchHeader.quorumNumbers.length; i++) {
// implant the incorrect quorumNumbers here
blobVerificationProof.quorumThresholdIndexes[i] = bytes1(uint8(i));
blobVerificationProof.quorumIndices[i] = bytes1(uint8(i));
}

cheats.expectRevert("EigenDARollupUtils.verifyBlob: confirmationThresholdPercentage is not met");
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/unit/MockRollup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ contract MockRollupTest is BLSMockAVSDeployer {
blobVerificationProof.batchMetadata = batchMetadata;
blobVerificationProof.inclusionProof = abi.encodePacked(keccak256(firstBlobHash));
blobVerificationProof.blobIndex = 1;
blobVerificationProof.quorumThresholdIndexes = new bytes(batchHeader.quorumNumbers.length);
blobVerificationProof.quorumIndices = new bytes(batchHeader.quorumNumbers.length);
for (uint i = 0; i < batchHeader.quorumNumbers.length; i++) {
blobVerificationProof.quorumThresholdIndexes[i] = bytes1(uint8(i));
blobVerificationProof.quorumIndices[i] = bytes1(uint8(i));
}

return (blobHeader[1], blobVerificationProof);
Expand Down

0 comments on commit 425ecee

Please sign in to comment.