Skip to content

Commit

Permalink
Merge branch 'multiquorums' of https://github.com/Layr-Labs/eigenlaye…
Browse files Browse the repository at this point in the history
…r-contracts into multiquorums
  • Loading branch information
0x0aa0 committed Oct 12, 2023
2 parents e114d65 + dc3e081 commit 26ace0f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/contracts/middleware/BLSRegistryCoordinatorWithIndices.sol
Original file line number Diff line number Diff line change
Expand Up @@ -465,26 +465,34 @@ contract BLSRegistryCoordinatorWithIndices is EIP712, Initializable, IBLSRegistr
// register the operator with the IndexRegistry
uint32[] memory numOperatorsPerQuorum = indexRegistry.registerOperator(operatorId, quorumNumbers);

uint256 quorumBitmapHistoryLength = _operatorIdToQuorumBitmapHistory[operatorId].length;
if(quorumBitmapHistoryLength != 0) {
// set the toBlockNumber of the previous quorum bitmap update
_operatorIdToQuorumBitmapHistory[operatorId][quorumBitmapHistoryLength - 1].nextUpdateBlockNumber = uint32(block.number);
}

// set the operatorId to quorum bitmap history
_operatorIdToQuorumBitmapHistory[operatorId].push(QuorumBitmapUpdate({
updateBlockNumber: uint32(block.number),
nextUpdateBlockNumber: 0,
quorumBitmap: uint192(quorumBitmap)
}));

// set the operator struct
_operators[operator] = Operator({
operatorId: operatorId,
status: OperatorStatus.REGISTERED
});
// if the operator is not already registered, then they are registering for the first time
if (_operators[operator].status != OperatorStatus.REGISTERED) {
_operators[operator] = Operator({
operatorId: operatorId,
status: OperatorStatus.REGISTERED
});

emit OperatorRegistered(operator, operatorId);
}

_afterRegisterOperator(operator, quorumNumbers);

// record a stake update not bonding the operator at all (unbonded at 0), because they haven't served anything yet
// serviceManager.recordFirstStakeUpdate(operator, 0);

emit OperatorRegistered(operator, operatorId);

emit OperatorSocketUpdate(operatorId, socket);

return numOperatorsPerQuorum;
Expand Down
8 changes: 8 additions & 0 deletions src/test/unit/BLSRegistryCoordinatorWithIndicesUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,14 @@ contract BLSRegistryCoordinatorWithIndicesUnit is MockAVSDeployer {
})))
);
assertEq(registryCoordinator.getCurrentQuorumBitmapByOperatorId(defaultOperatorId), quorumBitmap);
assertEq(
keccak256(abi.encode(registryCoordinator.getQuorumBitmapUpdateByOperatorIdByIndex(defaultOperatorId, 0))),
keccak256(abi.encode(IRegistryCoordinator.QuorumBitmapUpdate({
quorumBitmap: uint192(BitmapUtils.orderedBytesArrayToBitmap(quorumNumbers)),
updateBlockNumber: uint32(registrationBlockNumber),
nextUpdateBlockNumber: uint32(nextRegistrationBlockNumber)
})))
);
assertEq(
keccak256(abi.encode(registryCoordinator.getQuorumBitmapUpdateByOperatorIdByIndex(defaultOperatorId, 1))),
keccak256(abi.encode(IRegistryCoordinator.QuorumBitmapUpdate({
Expand Down

0 comments on commit 26ace0f

Please sign in to comment.