Skip to content

Commit

Permalink
fix: length check (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0aa0 authored Feb 15, 2024
1 parent 0d04b3d commit 3340da9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions contracts/src/core/EigenDAServiceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ contract EigenDAServiceManager is EigenDAServiceManagerStorage, ServiceManagerBa
"EigenDAServiceManager.confirmBatch: specified referenceBlockNumber is too far in past"
);

//make sure that the quorumNumbers and quorumThresholdPercentages are of the same length
require(
batchHeader.quorumNumbers.length == batchHeader.quorumThresholdPercentages.length,
"EigenDAServiceManager.confirmBatch: quorumNumbers and quorumThresholdPercentages must be of the same length"
);

// calculate reducedBatchHeaderHash which nodes signed
bytes32 reducedBatchHeaderHash = batchHeader.hashBatchHeaderToReducedBatchHeader();

Expand Down
11 changes: 11 additions & 0 deletions contracts/test/unit/EigenDAServiceManagerUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,18 @@ contract EigenDAServiceManagerUnit is BLSMockAVSDeployer {
assertEq(eigenDAServiceManager.batchId(), batchIdToConfirm + 1);
}

function testConfirmBatch_Revert_LengthMismatch(uint256 pseudoRandomNumber) public {
(IEigenDAServiceManager.BatchHeader memory batchHeader, BLSSignatureChecker.NonSignerStakesAndSignature memory nonSignerStakesAndSignature)
= _getHeaderandNonSigners(0, pseudoRandomNumber, 100);
batchHeader.quorumThresholdPercentages = new bytes(0);

cheats.expectRevert(bytes("EigenDAServiceManager.confirmBatch: quorumNumbers and quorumThresholdPercentages must be of the same length"));
cheats.prank(confirmer, confirmer);
eigenDAServiceManager.confirmBatch(
batchHeader,
nonSignerStakesAndSignature
);
}

function _getHeaderandNonSigners(uint256 _nonSigners, uint256 _pseudoRandomNumber, uint8 _threshold) internal returns (IEigenDAServiceManager.BatchHeader memory, BLSSignatureChecker.NonSignerStakesAndSignature memory) {
// register a bunch of operators
Expand Down

0 comments on commit 3340da9

Please sign in to comment.