From cfdd7aa87a2c94674ffb91df982d8eaf5cbd0df1 Mon Sep 17 00:00:00 2001 From: Yash Patil <40046473+ypatil12@users.noreply.github.com> Date: Mon, 1 Dec 2025 15:57:29 -0500 Subject: [PATCH] chore: update formatting --- .github/workflows/forge-test-intense.yml | 2 +- .github/workflows/foundry.yml | 4 +- script/utils/OperatorSetUpgradeLib.sol | 16 +- src/BLSSignatureChecker.sol | 20 +- src/EjectionManager.sol | 10 +- src/IndexRegistry.sol | 10 +- src/OperatorStateRetriever.sol | 36 +- src/RegistryCoordinator.sol | 3 +- src/RegistryCoordinatorStorage.sol | 1 - src/ServiceManagerBase.sol | 63 +- src/ServiceManagerBaseStorage.sol | 20 +- src/SlashingRegistryCoordinator.sol | 51 +- src/SlashingRegistryCoordinatorStorage.sol | 6 +- src/SocketRegistryStorage.sol | 1 - src/StakeRegistry.sol | 76 +- src/StakeRegistryStorage.sol | 10 +- src/avs/task/TaskAVSRegistrarBase.sol | 10 +- src/interfaces/IAllowlist.sol | 5 +- src/interfaces/IBLSApkRegistry.sol | 10 +- src/interfaces/IBN254TableCalculator.sol | 5 +- src/interfaces/IECDSAStakeRegistry.sol | 15 +- src/interfaces/IEjectionManager.sol | 5 +- src/interfaces/IIndexRegistry.sol | 5 +- src/interfaces/IInstantSlasher.sol | 5 +- src/interfaces/IKeyRegistrar.sol | 5 +- src/interfaces/IRegistryCoordinator.sol | 10 +- src/interfaces/IServiceManager.sol | 17 +- src/interfaces/IServiceManagerUI.sol | 5 +- src/interfaces/ISlasher.sol | 5 +- .../ISlashingRegistryCoordinator.sol | 11 +- src/interfaces/ISocketRegistry.sol | 5 +- src/interfaces/ISocketRegistryV2.sol | 5 +- src/interfaces/IStakeRegistry.sol | 31 +- src/interfaces/IVetoableSlasher.sol | 5 +- src/libraries/BN254.sol | 10 +- src/libraries/BitmapUtils.sol | 43 +- src/middlewareV2/registrar/AVSRegistrar.sol | 5 +- .../registrar/AVSRegistrarStorage.sol | 11 +- .../registrar/modules/Allowlist.sol | 10 +- .../registrar/modules/AllowlistStorage.sol | 5 +- .../registrar/modules/SocketRegistry.sol | 20 +- .../modules/SocketRegistryStorage.sol | 6 +- .../presets/AVSRegistrarAsIdentifier.sol | 15 +- .../presets/AVSRegistrarWithAllowlist.sol | 10 +- .../presets/AVSRegistrarWithSocket.sol | 10 +- .../tableCalculator/BN254TableCalculator.sol | 5 +- .../BN254TableCalculatorBase.sol | 41 +- .../tableCalculator/ECDSATableCalculator.sol | 5 +- .../ECDSATableCalculatorBase.sol | 5 +- .../BN254TableCalculatorWithCaps.sol | 15 +- .../BN254WeightedTableCalculator.sol | 15 +- src/slashers/InstantSlasher.sol | 5 +- src/slashers/base/SlasherBase.sol | 8 +- src/slashers/base/SlasherStorage.sol | 6 +- .../BLSSigCheckOperatorStateRetriever.sol | 14 +- src/unaudited/BLSSigCheckUtils.sol | 85 +- src/unaudited/BN256G2.sol | 26 +- src/unaudited/ECDSAServiceManagerBase.sol | 59 +- src/unaudited/ECDSAStakeRegistry.sol | 46 +- src/unaudited/ECDSAStakeRegistryStorage.sol | 12 +- .../ECDSAStakeRegistryEqualWeight.sol | 10 +- .../ECDSAStakeRegistryPermissioned.sol | 10 +- test/events/IServiceManagerBaseEvents.sol | 1 - test/ffi/BLSSignatureCheckerFFI.t.sol | 17 +- test/fork/EigenDA.t.sol | 96 +- test/fork/End2End.t.sol | 115 +-- test/harnesses/AVSDirectoryHarness.sol | 5 +- test/harnesses/BLSApkRegistryHarness.sol | 5 +- test/harnesses/BLSSigCheckUtilsHarness.sol | 50 +- test/harnesses/BitmapUtilsWrapper.sol | 30 +- .../RegistryCoordinatorHarness.t.sol | 26 +- test/harnesses/StakeRegistryHarness.sol | 15 +- test/integration/CoreRegistration.t.sol | 27 +- test/integration/IntegrationBase.t.sol | 116 ++- test/integration/IntegrationChecks.t.sol | 30 +- test/integration/IntegrationConfig.t.sol | 43 +- test/integration/IntegrationDeployer.t.sol | 11 +- test/integration/OperatorSetUser.t.sol | 32 +- test/integration/User.t.sol | 36 +- .../mocks/BeaconChainOracleMock.t.sol | 5 +- .../tests/Full_Register_Deregister.t.sol | 21 +- test/mocks/AVSDirectoryMock.sol | 15 +- test/mocks/AllocationManagerMock.sol | 34 +- test/mocks/DelegationManagerHarness.sol | 21 +- test/mocks/DelegationMock.sol | 5 +- test/mocks/ECDSAServiceManagerMock.sol | 17 +- test/mocks/ECDSAStakeRegistryMock.sol | 15 +- test/mocks/ERC20Mock.sol | 5 +- test/mocks/EigenPodManagerMock.sol | 10 +- test/mocks/KeyRegistrarMock.sol | 10 +- test/mocks/MockTaskAVSRegistrar.sol | 10 +- test/mocks/PermissionControllerMock.sol | 25 +- test/mocks/RegistryCoordinatorMock.sol | 5 +- test/mocks/RewardsCoordinatorMock.sol | 36 +- test/mocks/StakeRegistryMock.sol | 25 +- test/unit/AVSRegistrar.t.sol | 11 +- test/unit/BLSApkRegistryUnit.t.sol | 23 +- .../BLSSigCheckOperatorStateRetriever.t.sol | 82 +- test/unit/BLSSigCheckUtilsUnit.t.sol | 14 +- test/unit/BLSSignatureCheckerUnit.t.sol | 42 +- test/unit/BitmapUtils.t.sol | 36 +- test/unit/ECDSAServiceManager.t.sol | 26 +- .../ECDSAStakeRegistryEqualWeightUnit.t.sol | 10 +- .../ECDSAStakeRegistryPermissionedUnit.t.sol | 10 +- test/unit/ECDSAStakeRegistryUnit.t.sol | 25 +- test/unit/EjectionManagerUnit.t.sol | 18 +- test/unit/IndexRegistryUnit.t.sol | 79 +- test/unit/InstantSlasher.t.sol | 250 +++-- test/unit/OperatorStateRetrieverUnit.t.sol | 98 +- test/unit/RegistryCoordinatorUnit.t.sol | 240 ++--- test/unit/ServiceManagerBase.t.sol | 82 +- .../SlashingRegistryCoordinatorUnit.t.sol | 959 +++++++++--------- test/unit/StakeRegistryUnit.t.sol | 90 +- test/unit/TaskAVSRegistrarBaseUnit.t.sol | 35 +- test/unit/UpgradeableProxyLib.sol | 11 +- test/unit/VetoableSlasher.t.sol | 240 ++--- .../AVSRegistrarAllowlistUnit.t.sol | 18 +- .../AVSRegistrarAsIdentifierUnit.t.sol | 29 +- test/unit/middlewareV2/AVSRegistrarBase.t.sol | 15 +- .../middlewareV2/AVSRegistrarSocketUnit.t.sol | 9 +- test/unit/middlewareV2/AllowlistUnit.t.sol | 10 +- .../BN254TableCalculatorBaseUnit.t.sol | 24 +- .../BN254TableCalculatorUnit.t.sol | 20 +- .../BN254TableCalculatorWithCapsUnit.t.sol | 25 +- .../BN254WeightedTableCalculatorUnit.t.sol | 30 +- .../ECDSATableCalculatorBaseUnit.t.sol | 24 +- .../ECDSATableCalculatorUnit.t.sol | 20 +- test/unit/middlewareV2/MockDeployer.sol | 10 +- test/utils/BLSMockAVSDeployer.sol | 33 +- test/utils/BN256G2.sol | 26 +- test/utils/CoreDeployLib.sol | 48 +- test/utils/MiddlewareDeployLib.sol | 54 +- test/utils/MockAVSDeployer.sol | 41 +- test/utils/OperatorLib.sol | 70 +- test/utils/OperatorWalletLib.sol | 5 +- test/utils/Random.sol | 49 +- test/utils/SignatureCompaction.sol | 11 +- 137 files changed, 2801 insertions(+), 2065 deletions(-) diff --git a/.github/workflows/forge-test-intense.yml b/.github/workflows/forge-test-intense.yml index 1091e5be8..08b3c40f7 100644 --- a/.github/workflows/forge-test-intense.yml +++ b/.github/workflows/forge-test-intense.yml @@ -29,7 +29,7 @@ jobs: - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 with: - version: v1.3.5 + version: v1.5.0 # Build the project and display contract sizes. - name: Forge Build diff --git a/.github/workflows/foundry.yml b/.github/workflows/foundry.yml index a82ffd35b..eb54a2ac1 100644 --- a/.github/workflows/foundry.yml +++ b/.github/workflows/foundry.yml @@ -33,7 +33,7 @@ jobs: - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 with: - version: v1.3.5 + version: v1.5.0 # Run Forge's formatting checker to ensure consistent code style. - name: Forge Fmt @@ -73,7 +73,7 @@ jobs: - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 with: - version: v1.3.5 + version: v1.5.0 # Install LCOV for coverage report generation. - name: Install LCOV diff --git a/script/utils/OperatorSetUpgradeLib.sol b/script/utils/OperatorSetUpgradeLib.sol index adaf8a23c..79ff19516 100644 --- a/script/utils/OperatorSetUpgradeLib.sol +++ b/script/utils/OperatorSetUpgradeLib.sol @@ -2,8 +2,9 @@ pragma solidity ^0.8.0; // Deploy L2AVS proxy -import {ITransparentUpgradeableProxy} from - "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { + ITransparentUpgradeableProxy +} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; import {Vm} from "forge-std/Vm.sol"; @@ -30,12 +31,19 @@ library OperatorSetUpgradeLib { bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; - function upgrade(address proxy, address implementation, bytes memory data) internal { + function upgrade( + address proxy, + address implementation, + bytes memory data + ) internal { ProxyAdmin admin = ProxyAdmin(getAdmin(proxy)); admin.upgradeAndCall(ITransparentUpgradeableProxy(payable(proxy)), implementation, data); } - function upgrade(address proxy, address implementation) internal { + function upgrade( + address proxy, + address implementation + ) internal { ProxyAdmin admin = ProxyAdmin(getAdmin(proxy)); admin.upgrade(ITransparentUpgradeableProxy(payable(proxy)), implementation); } diff --git a/src/BLSSignatureChecker.sol b/src/BLSSignatureChecker.sol index 407dea867..ec5593f11 100644 --- a/src/BLSSignatureChecker.sol +++ b/src/BLSSignatureChecker.sol @@ -99,8 +99,7 @@ contract BLSSignatureChecker is BLSSignatureCheckerStorage { } // Get the quorums the nonsigner was registered for at referenceBlockNumber - nonSigners.quorumBitmaps[j] = registryCoordinator - .getQuorumBitmapAtBlockNumberByIndex({ + nonSigners.quorumBitmaps[j] = registryCoordinator.getQuorumBitmapAtBlockNumberByIndex({ operatorId: nonSigners.pubkeyHashes[j], blockNumber: referenceBlockNumber, index: params.nonSignerQuorumBitmapIndices[j] @@ -144,12 +143,12 @@ contract BLSSignatureChecker is BLSSignatureCheckerStorage { apk = apk.plus(params.quorumApks[i]); // Get the total and starting signed stake for the quorum at referenceBlockNumber - stakeTotals.totalStakeForQuorum[i] = stakeRegistry - .getTotalStakeAtBlockNumberFromIndex({ - quorumNumber: uint8(quorumNumbers[i]), - blockNumber: referenceBlockNumber, - index: params.totalStakeIndices[i] - }); + stakeTotals.totalStakeForQuorum[i] = + stakeRegistry.getTotalStakeAtBlockNumberFromIndex({ + quorumNumber: uint8(quorumNumbers[i]), + blockNumber: referenceBlockNumber, + index: params.totalStakeIndices[i] + }); stakeTotals.signedStakeForQuorum[i] = stakeTotals.totalStakeForQuorum[i]; // Keep track of the nonSigners index in the quorum @@ -160,8 +159,9 @@ contract BLSSignatureChecker is BLSSignatureCheckerStorage { for (uint256 j = 0; j < params.nonSignerPubkeys.length; j++) { // if the nonSigner is a part of the quorum, subtract their stake from the running total if (BitmapUtils.isSet(nonSigners.quorumBitmaps[j], uint8(quorumNumbers[i]))) { - stakeTotals.signedStakeForQuorum[i] -= stakeRegistry - .getStakeAtBlockNumberAndIndex({ + stakeTotals.signedStakeForQuorum[ + i + ] -= stakeRegistry.getStakeAtBlockNumberAndIndex({ quorumNumber: uint8(quorumNumbers[i]), blockNumber: referenceBlockNumber, operatorId: nonSigners.pubkeyHashes[j], diff --git a/src/EjectionManager.sol b/src/EjectionManager.sol index 369827b63..96f84f3fa 100644 --- a/src/EjectionManager.sol +++ b/src/EjectionManager.sol @@ -97,7 +97,10 @@ contract EjectionManager is OwnableUpgradeable, EjectionManagerStorage { } /// @inheritdoc IEjectionManager - function setEjector(address ejector, bool status) external onlyOwner { + function setEjector( + address ejector, + bool status + ) external onlyOwner { _setEjector(ejector, status); } @@ -116,7 +119,10 @@ contract EjectionManager is OwnableUpgradeable, EjectionManagerStorage { } ///@dev internal function to set the ejector - function _setEjector(address ejector, bool status) internal { + function _setEjector( + address ejector, + bool status + ) internal { isEjector[ejector] = status; emit EjectorUpdated(ejector, status); } diff --git a/src/IndexRegistry.sol b/src/IndexRegistry.sol index 26dc8bbf4..29fd72c01 100644 --- a/src/IndexRegistry.sol +++ b/src/IndexRegistry.sol @@ -114,10 +114,10 @@ contract IndexRegistry is IndexRegistryStorage { // If this is the first time we're using this operatorIndex, push its first update // This maintains an invariant: existing indices have nonzero history if (_operatorIndexHistory[quorumNumber][newOperatorCount - 1].length == 0) { - _operatorIndexHistory[quorumNumber][newOperatorCount - 1].push( + _operatorIndexHistory[quorumNumber][newOperatorCount + - 1].push( OperatorUpdate({ - operatorId: OPERATOR_DOES_NOT_EXIST_ID, - fromBlockNumber: uint32(block.number) + operatorId: OPERATOR_DOES_NOT_EXIST_ID, fromBlockNumber: uint32(block.number) }) ); } @@ -149,7 +149,9 @@ contract IndexRegistry is IndexRegistryStorage { lastUpdate.numOperators = newOperatorCount; } else { _operatorCountHistory[quorumNumber].push( - QuorumUpdate({numOperators: newOperatorCount, fromBlockNumber: uint32(block.number)}) + QuorumUpdate({ + numOperators: newOperatorCount, fromBlockNumber: uint32(block.number) + }) ); } } diff --git a/src/OperatorStateRetriever.sol b/src/OperatorStateRetriever.sol index 4e4a342d4..82ccaa1a4 100644 --- a/src/OperatorStateRetriever.sol +++ b/src/OperatorStateRetriever.sol @@ -118,8 +118,10 @@ contract OperatorStateRetriever { CheckSignaturesIndices memory checkSignaturesIndices; // get the indices of the quorumBitmap updates for each of the operators in the nonSignerOperatorIds array - checkSignaturesIndices.nonSignerQuorumBitmapIndices = registryCoordinator - .getQuorumBitmapIndicesAtBlockNumber(referenceBlockNumber, nonSignerOperatorIds); + checkSignaturesIndices.nonSignerQuorumBitmapIndices = + registryCoordinator.getQuorumBitmapIndicesAtBlockNumber( + referenceBlockNumber, nonSignerOperatorIds + ); // get the indices of the totalStake updates for each of the quorums in the quorumNumbers array checkSignaturesIndices.totalStakeIndices = @@ -138,24 +140,28 @@ contract OperatorStateRetriever { for (uint256 i = 0; i < nonSignerOperatorIds.length; i++) { // get the quorumBitmap for the operator at the given blocknumber and index - uint192 nonSignerQuorumBitmap = registryCoordinator - .getQuorumBitmapAtBlockNumberByIndex( - nonSignerOperatorIds[i], - referenceBlockNumber, - checkSignaturesIndices.nonSignerQuorumBitmapIndices[i] - ); + uint192 nonSignerQuorumBitmap = + registryCoordinator.getQuorumBitmapAtBlockNumberByIndex( + nonSignerOperatorIds[i], + referenceBlockNumber, + checkSignaturesIndices.nonSignerQuorumBitmapIndices[i] + ); require(nonSignerQuorumBitmap != 0, OperatorNotRegistered()); // if the operator was a part of the quorum and the quorum is a part of the provided quorumNumbers if ((nonSignerQuorumBitmap >> uint8(quorumNumbers[quorumNumberIndex])) & 1 == 1) { // get the index of the stake update for the operator at the given blocknumber and quorum number - checkSignaturesIndices.nonSignerStakeIndices[quorumNumberIndex][numNonSignersForQuorum] - = stakeRegistry.getStakeUpdateIndexAtBlockNumber( - nonSignerOperatorIds[i], - uint8(quorumNumbers[quorumNumberIndex]), - referenceBlockNumber - ); + checkSignaturesIndices.nonSignerStakeIndices[ + quorumNumberIndex + ][ + numNonSignersForQuorum + ] = + stakeRegistry.getStakeUpdateIndexAtBlockNumber( + nonSignerOperatorIds[i], + uint8(quorumNumbers[quorumNumberIndex]), + referenceBlockNumber + ); numNonSignersForQuorum++; } } @@ -167,7 +173,7 @@ contract OperatorStateRetriever { checkSignaturesIndices.nonSignerStakeIndices[quorumNumberIndex][i]; } checkSignaturesIndices.nonSignerStakeIndices[quorumNumberIndex] = - nonSignerStakeIndicesForQuorum; + nonSignerStakeIndicesForQuorum; } IBLSApkRegistry blsApkRegistry = registryCoordinator.blsApkRegistry(); diff --git a/src/RegistryCoordinator.sol b/src/RegistryCoordinator.sol index bc8033364..d0844b531 100644 --- a/src/RegistryCoordinator.sol +++ b/src/RegistryCoordinator.sol @@ -5,7 +5,8 @@ import {ISemVerMixin} from "eigenlayer-contracts/src/contracts/interfaces/ISemVe import {SemVerMixin} from "eigenlayer-contracts/src/contracts/mixins/SemVerMixin.sol"; import {IBLSApkRegistryTypes} from "./interfaces/IBLSApkRegistry.sol"; import { - IRegistryCoordinator, IRegistryCoordinatorTypes + IRegistryCoordinator, + IRegistryCoordinatorTypes } from "./interfaces/IRegistryCoordinator.sol"; import {BitmapUtils} from "./libraries/BitmapUtils.sol"; diff --git a/src/RegistryCoordinatorStorage.sol b/src/RegistryCoordinatorStorage.sol index 8b1a55c70..204bd0a75 100644 --- a/src/RegistryCoordinatorStorage.sol +++ b/src/RegistryCoordinatorStorage.sol @@ -10,7 +10,6 @@ abstract contract RegistryCoordinatorStorage is IRegistryCoordinator { * CONSTANTS AND IMMUTABLES * */ - /// @notice the ServiceManager for this AVS, which forwards calls onto EigenLayer's core contracts IServiceManager public immutable serviceManager; diff --git a/src/ServiceManagerBase.sol b/src/ServiceManagerBase.sol index 086fa14cc..a24839337 100644 --- a/src/ServiceManagerBase.sol +++ b/src/ServiceManagerBase.sol @@ -3,17 +3,20 @@ pragma solidity ^0.8.27; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; -import {ISignatureUtilsMixinTypes} from - "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; +import { + ISignatureUtilsMixinTypes +} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; -import {IRewardsCoordinator} from - "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; +import { + IRewardsCoordinator +} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; import { IAllocationManager, IAllocationManagerTypes } from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; import {ServiceManagerBaseStorage} from "./ServiceManagerBaseStorage.sol"; import {IServiceManager} from "./interfaces/IServiceManager.sol"; @@ -94,12 +97,13 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage { } /// @inheritdoc IServiceManager - function setAppointee(address appointee, address target, bytes4 selector) external onlyOwner { + function setAppointee( + address appointee, + address target, + bytes4 selector + ) external onlyOwner { _permissionController.setAppointee({ - account: address(this), - appointee: appointee, - target: target, - selector: selector + account: address(this), appointee: appointee, target: target, selector: selector }); } @@ -110,10 +114,7 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage { bytes4 selector ) external onlyOwner { _permissionController.removeAppointee({ - account: address(this), - appointee: appointee, - target: target, - selector: selector + account: address(this), appointee: appointee, target: target, selector: selector }); } @@ -147,12 +148,10 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage { for (uint256 i = 0; i < rewardsSubmissions.length; ++i) { // transfer token to ServiceManager and approve RewardsCoordinator to transfer again // in createAVSRewardsSubmission() call - rewardsSubmissions[i].token.safeTransferFrom( - msg.sender, address(this), rewardsSubmissions[i].amount - ); - rewardsSubmissions[i].token.safeIncreaseAllowance( - address(_rewardsCoordinator), rewardsSubmissions[i].amount - ); + rewardsSubmissions[i].token + .safeTransferFrom(msg.sender, address(this), rewardsSubmissions[i].amount); + rewardsSubmissions[i].token + .safeIncreaseAllowance(address(_rewardsCoordinator), rewardsSubmissions[i].amount); } _rewardsCoordinator.createAVSRewardsSubmission(rewardsSubmissions); @@ -173,26 +172,26 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage { * smaller array of submissions if necessary. */ function createOperatorDirectedAVSRewardsSubmission( - IRewardsCoordinator.OperatorDirectedRewardsSubmission[] calldata - operatorDirectedRewardsSubmissions + IRewardsCoordinator + .OperatorDirectedRewardsSubmission[] calldata operatorDirectedRewardsSubmissions ) public virtual onlyRewardsInitiator { for (uint256 i = 0; i < operatorDirectedRewardsSubmissions.length; ++i) { // Calculate total amount of token to transfer uint256 totalAmount = 0; for ( - uint256 j = 0; j < operatorDirectedRewardsSubmissions[i].operatorRewards.length; ++j + uint256 j = 0; + j < operatorDirectedRewardsSubmissions[i].operatorRewards.length; + ++j ) { totalAmount += operatorDirectedRewardsSubmissions[i].operatorRewards[j].amount; } // Transfer token to ServiceManager and approve RewardsCoordinator to transfer again // in createOperatorDirectedAVSRewardsSubmission() call - operatorDirectedRewardsSubmissions[i].token.safeTransferFrom( - msg.sender, address(this), totalAmount - ); - operatorDirectedRewardsSubmissions[i].token.safeIncreaseAllowance( - address(_rewardsCoordinator), totalAmount - ); + operatorDirectedRewardsSubmissions[i].token + .safeTransferFrom(msg.sender, address(this), totalAmount); + operatorDirectedRewardsSubmissions[i].token + .safeIncreaseAllowance(address(_rewardsCoordinator), totalAmount); } _rewardsCoordinator.createOperatorDirectedAVSRewardsSubmission( @@ -238,9 +237,7 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage { uint32[] memory operatorSetIds ) public virtual onlyRegistryCoordinator { IAllocationManager.DeregisterParams memory params = IAllocationManagerTypes.DeregisterParams({ - operator: operator, - avs: address(this), - operatorSetIds: operatorSetIds + operator: operator, avs: address(this), operatorSetIds: operatorSetIds }); _allocationManager.deregisterFromOperatorSets(params); } diff --git a/src/ServiceManagerBaseStorage.sol b/src/ServiceManagerBaseStorage.sol index 4fdd0039b..3778bdaab 100644 --- a/src/ServiceManagerBaseStorage.sol +++ b/src/ServiceManagerBaseStorage.sol @@ -8,14 +8,18 @@ import {ISlashingRegistryCoordinator} from "./interfaces/ISlashingRegistryCoordi import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol"; import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; -import {IRewardsCoordinator} from - "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IRewardsCoordinator +} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; /** * @title Storage variables for the `ServiceManagerBase` contract. diff --git a/src/SlashingRegistryCoordinator.sol b/src/SlashingRegistryCoordinator.sol index 01c334abb..31d9296c5 100644 --- a/src/SlashingRegistryCoordinator.sol +++ b/src/SlashingRegistryCoordinator.sol @@ -2,8 +2,9 @@ pragma solidity ^0.8.27; import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol"; -import {ISignatureUtilsMixin} from - "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; +import { + ISignatureUtilsMixin +} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; import { @@ -26,8 +27,9 @@ import {QuorumBitmapHistoryLib} from "./libraries/QuorumBitmapHistoryLib.sol"; import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol"; import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol"; -import {EIP712Upgradeable} from - "@openzeppelin-upgrades/contracts/utils/cryptography/EIP712Upgradeable.sol"; +import { + EIP712Upgradeable +} from "@openzeppelin-upgrades/contracts/utils/cryptography/EIP712Upgradeable.sol"; import {Pausable} from "eigenlayer-contracts/src/contracts/permissions/Pausable.sol"; import {SlashingRegistryCoordinatorStorage} from "./SlashingRegistryCoordinatorStorage.sol"; @@ -82,11 +84,7 @@ contract SlashingRegistryCoordinator is string memory _version ) SlashingRegistryCoordinatorStorage( - _stakeRegistry, - _blsApkRegistry, - _indexRegistry, - _socketRegistry, - _allocationManager + _stakeRegistry, _blsApkRegistry, _indexRegistry, _socketRegistry, _allocationManager ) SemVerMixin(_version) Pausable(_pauserRegistry) @@ -182,13 +180,12 @@ contract SlashingRegistryCoordinator is quorumNumbers: quorumNumbers, socket: socket, checkMaxOperatorCount: true - }).numOperatorsPerQuorum; + }) + .numOperatorsPerQuorum; } else if (registrationType == RegistrationType.CHURN) { // Decode registration data from bytes ( - , - , - , + ,,, OperatorKickParam[] memory operatorKickParams, SignatureWithSaltAndExpiry memory churnApproverSignature ) = abi.decode( @@ -382,7 +379,10 @@ contract SlashingRegistryCoordinator is * @param operator The operator to force deregister from the avs * @param quorumNumbers The quorum numbers to eject the operator from */ - function _kickOperator(address operator, bytes memory quorumNumbers) internal virtual { + function _kickOperator( + address operator, + bytes memory quorumNumbers + ) internal virtual { OperatorInfo storage operatorInfo = _operatorInfo[operator]; // Only proceed if operator is currently registered require(operatorInfo.status == OperatorStatus.REGISTERED, OperatorNotRegistered()); @@ -532,7 +532,10 @@ contract SlashingRegistryCoordinator is * @param quorumNumbers the quorum numbers to deregister from * the core EigenLayer contract AllocationManager */ - function _deregisterOperator(address operator, bytes memory quorumNumbers) internal virtual { + function _deregisterOperator( + address operator, + bytes memory quorumNumbers + ) internal virtual { // Fetch the operator's info and ensure they are registered OperatorInfo storage operatorInfo = _operatorInfo[operator]; bytes32 operatorId = operatorInfo.operatorId; @@ -590,9 +593,7 @@ contract SlashingRegistryCoordinator is ) internal virtual { allocationManager.deregisterFromOperatorSets( IAllocationManagerTypes.DeregisterParams({ - operator: operator, - avs: avs, - operatorSetIds: _getOperatorSetIds(quorumNumbers) + operator: operator, avs: avs, operatorSetIds: _getOperatorSetIds(quorumNumbers) }) ); } @@ -743,7 +744,10 @@ contract SlashingRegistryCoordinator is * @param socket The new socket address to set for the operator * @dev Emits an OperatorSocketUpdate event after updating */ - function _setOperatorSocket(bytes32 operatorId, string memory socket) internal { + function _setOperatorSocket( + bytes32 operatorId, + string memory socket + ) internal { socketRegistry.setOperatorSocket(operatorId, socket); emit OperatorSocketUpdate(operatorId, socket); } @@ -819,9 +823,7 @@ contract SlashingRegistryCoordinator is // Initialize CreateSetParams with quorumNumber as operatorSetId createSetParams[0] = IAllocationManagerTypes.CreateSetParamsV2({ - operatorSetId: quorumNumber, - strategies: strategies, - slasher: slasher + operatorSetId: quorumNumber, strategies: strategies, slasher: slasher }); allocationManager.createOperatorSets({avs: avs, params: createSetParams}); @@ -860,7 +862,10 @@ contract SlashingRegistryCoordinator is * @notice Record an update to an operator's quorum bitmap. * @param newBitmap is the most up-to-date set of bitmaps the operator is registered for */ - function _updateOperatorBitmap(bytes32 operatorId, uint192 newBitmap) internal { + function _updateOperatorBitmap( + bytes32 operatorId, + uint192 newBitmap + ) internal { QuorumBitmapHistoryLib.updateOperatorBitmap(_operatorBitmapHistory, operatorId, newBitmap); } diff --git a/src/SlashingRegistryCoordinatorStorage.sol b/src/SlashingRegistryCoordinatorStorage.sol index 6a9042afd..909e7c865 100644 --- a/src/SlashingRegistryCoordinatorStorage.sol +++ b/src/SlashingRegistryCoordinatorStorage.sol @@ -4,8 +4,9 @@ pragma solidity ^0.8.27; import {IBLSApkRegistry} from "./interfaces/IBLSApkRegistry.sol"; import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol"; import {IIndexRegistry} from "./interfaces/IIndexRegistry.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {ISlashingRegistryCoordinator} from "./interfaces/ISlashingRegistryCoordinator.sol"; import {ISocketRegistry} from "./interfaces/ISocketRegistry.sol"; @@ -15,7 +16,6 @@ abstract contract SlashingRegistryCoordinatorStorage is ISlashingRegistryCoordin * CONSTANTS AND IMMUTABLES * */ - /// @notice The EIP-712 typehash for the `DelegationApproval` struct used by the contract bytes32 public constant OPERATOR_CHURN_APPROVAL_TYPEHASH = keccak256( "OperatorChurnApproval(address registeringOperator,bytes32 registeringOperatorId,OperatorKickParam[] operatorKickParams,bytes32 salt,uint256 expiry)OperatorKickParam(uint8 quorumNumber,address operator)" diff --git a/src/SocketRegistryStorage.sol b/src/SocketRegistryStorage.sol index 41d7d3b33..2f9e8d4bb 100644 --- a/src/SocketRegistryStorage.sol +++ b/src/SocketRegistryStorage.sol @@ -13,7 +13,6 @@ abstract contract SocketRegistryStorage is ISocketRegistry { * CONSTANTS AND IMMUTABLES * */ - /// @notice The address of the SlashingRegistryCoordinator address public immutable slashingRegistryCoordinator; diff --git a/src/StakeRegistry.sol b/src/StakeRegistry.sol index 401086f0b..60afeb5a5 100644 --- a/src/StakeRegistry.sol +++ b/src/StakeRegistry.sol @@ -3,12 +3,14 @@ pragma solidity ^0.8.27; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; import {OperatorSet} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {AllocationManager} from "eigenlayer-contracts/src/contracts/core/AllocationManager.sol"; import {StakeRegistryStorage, IStrategy} from "./StakeRegistryStorage.sol"; @@ -54,10 +56,7 @@ contract StakeRegistry is StakeRegistryStorage { IAllocationManager _allocationManager ) StakeRegistryStorage( - _slashingRegistryCoordinator, - _delegationManager, - _avsDirectory, - _allocationManager + _slashingRegistryCoordinator, _delegationManager, _avsDirectory, _allocationManager ) {} @@ -87,9 +86,7 @@ contract StakeRegistry is StakeRegistryStorage { // Update the operator's stake int256 stakeDelta = _recordOperatorStakeUpdate({ - operatorId: operatorId, - quorumNumber: quorumNumber, - newStake: currentStake + operatorId: operatorId, quorumNumber: quorumNumber, newStake: currentStake }); // Update this quorum's total stake by applying the operator's delta @@ -115,9 +112,7 @@ contract StakeRegistry is StakeRegistryStorage { // Update the operator's stake for the quorum and retrieve the shares removed int256 stakeDelta = _recordOperatorStakeUpdate({ - operatorId: operatorId, - quorumNumber: quorumNumber, - newStake: 0 + operatorId: operatorId, quorumNumber: quorumNumber, newStake: 0 }); // Apply the operator's stake delta to the total stake for this quorum @@ -159,9 +154,7 @@ contract StakeRegistry is StakeRegistryStorage { // Update the operator's stake and retrieve the delta // If we're deregistering them, their weight is set to 0 int256 stakeDelta = _recordOperatorStakeUpdate({ - operatorId: operatorIds[i], - quorumNumber: quorumNumber, - newStake: stakeWeights[i] + operatorId: operatorIds[i], quorumNumber: quorumNumber, newStake: stakeWeights[i] }); totalStakeDelta += stakeDelta; @@ -186,9 +179,7 @@ contract StakeRegistry is StakeRegistryStorage { _totalStakeHistory[quorumNumber].push( StakeUpdate({ - updateBlockNumber: uint32(block.number), - nextUpdateBlockNumber: 0, - stake: 0 + updateBlockNumber: uint32(block.number), nextUpdateBlockNumber: 0, stake: 0 }) ); } @@ -208,9 +199,7 @@ contract StakeRegistry is StakeRegistryStorage { _totalStakeHistory[quorumNumber].push( StakeUpdate({ - updateBlockNumber: uint32(block.number), - nextUpdateBlockNumber: 0, - stake: 0 + updateBlockNumber: uint32(block.number), nextUpdateBlockNumber: 0, stake: 0 }) ); } @@ -247,9 +236,7 @@ contract StakeRegistry is StakeRegistryStorage { strategiesToAdd[i] = _strategyParams[i].strategy; } allocationManager.addStrategiesToOperatorSet({ - avs: avs, - operatorSetId: quorumNumber, - strategies: strategiesToAdd + avs: avs, operatorSetId: quorumNumber, strategies: strategiesToAdd }); } } @@ -286,9 +273,7 @@ contract StakeRegistry is StakeRegistryStorage { address avs = registryCoordinator.avs(); if (allocationManager.isOperatorSet(OperatorSet(avs, quorumNumber))) { allocationManager.removeStrategiesFromOperatorSet({ - avs: avs, - operatorSetId: quorumNumber, - strategies: _strategiesToRemove + avs: avs, operatorSetId: quorumNumber, strategies: _strategiesToRemove }); } } @@ -342,7 +327,10 @@ contract StakeRegistry is StakeRegistryStorage { ); } - function _setMinimumStakeForQuorum(uint8 quorumNumber, uint96 minimumStake) internal { + function _setMinimumStakeForQuorum( + uint8 quorumNumber, + uint96 minimumStake + ) internal { minimumStakeForQuorum[quorumNumber] = minimumStake; emit MinimumStakeForQuorumUpdated(quorumNumber, minimumStake); } @@ -476,12 +464,18 @@ contract StakeRegistry is StakeRegistryStorage { } /// @notice Returns the change between a previous and current value as a signed int - function _calculateDelta(uint96 prev, uint96 cur) internal pure returns (int256) { + function _calculateDelta( + uint96 prev, + uint96 cur + ) internal pure returns (int256) { return int256(uint256(cur)) - int256(uint256(prev)); } /// @notice Adds or subtracts delta from value, according to its sign - function _applyDelta(uint96 value, int256 delta) internal pure returns (uint96) { + function _applyDelta( + uint96 value, + int256 delta + ) internal pure returns (uint96) { if (delta < 0) { return value - uint96(uint256(-delta)); } else { @@ -560,7 +554,9 @@ contract StakeRegistry is StakeRegistryStorage { // calculate added weight for strategy and multiplier if (strategyShares[opIndex][stratIndex] > 0) { - weights[opIndex] += uint96( + weights[ + opIndex + ] += uint96( strategyShares[opIndex][stratIndex] * strategyAndMultiplier.multiplier / WEIGHTING_DIVISOR ); @@ -684,8 +680,8 @@ contract StakeRegistry is StakeRegistryStorage { uint32 blockNumber ) external view returns (uint96) { return operatorStakeHistory[operatorId][quorumNumber][_getStakeUpdateIndexForOperatorAtBlockNumber( - operatorId, quorumNumber, blockNumber - )].stake; + operatorId, quorumNumber, blockNumber + )].stake; } /// @inheritdoc IStakeRegistry @@ -781,7 +777,10 @@ contract StakeRegistry is StakeRegistryStorage { * @param quorumNumber The quorum number to set the stake type for * @param _stakeType The type of stake to track (TOTAL_DELEGATED, TOTAL_SLASHABLE, or BOTH) */ - function _setStakeType(uint8 quorumNumber, IStakeRegistryTypes.StakeType _stakeType) internal { + function _setStakeType( + uint8 quorumNumber, + IStakeRegistryTypes.StakeType _stakeType + ) internal { stakeTypePerQuorum[quorumNumber] = _stakeType; emit StakeTypeSet(_stakeType); } @@ -791,7 +790,10 @@ contract StakeRegistry is StakeRegistryStorage { * @param quorumNumber The quorum number to set the look ahead period for * @param _lookAheadBlocks The number of blocks to look ahead when checking shares */ - function _setLookAheadPeriod(uint8 quorumNumber, uint32 _lookAheadBlocks) internal { + function _setLookAheadPeriod( + uint8 quorumNumber, + uint32 _lookAheadBlocks + ) internal { require( stakeTypePerQuorum[quorumNumber] == IStakeRegistryTypes.StakeType.TOTAL_SLASHABLE, QuorumNotSlashable() diff --git a/src/StakeRegistryStorage.sol b/src/StakeRegistryStorage.sol index db9bfba34..76d0f5bbc 100644 --- a/src/StakeRegistryStorage.sol +++ b/src/StakeRegistryStorage.sol @@ -1,11 +1,13 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol"; import {ISlashingRegistryCoordinator} from "./interfaces/ISlashingRegistryCoordinator.sol"; diff --git a/src/avs/task/TaskAVSRegistrarBase.sol b/src/avs/task/TaskAVSRegistrarBase.sol index 60c7b7f09..185c3bde3 100644 --- a/src/avs/task/TaskAVSRegistrarBase.sol +++ b/src/avs/task/TaskAVSRegistrarBase.sol @@ -1,10 +1,12 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; import {OperatorSet} from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; diff --git a/src/interfaces/IAllowlist.sol b/src/interfaces/IAllowlist.sol index 558c47344..4b266be42 100644 --- a/src/interfaces/IAllowlist.sol +++ b/src/interfaces/IAllowlist.sol @@ -24,7 +24,10 @@ interface IAllowlist is IAllowlistErrors, IAllowlistEvents { * @param operator The operator to add to the allowlist * @dev Only callable by the owner */ - function addOperatorToAllowlist(OperatorSet memory operatorSet, address operator) external; + function addOperatorToAllowlist( + OperatorSet memory operatorSet, + address operator + ) external; /** * @notice Removes an operator from the allowlist diff --git a/src/interfaces/IBLSApkRegistry.sol b/src/interfaces/IBLSApkRegistry.sol index 2fd3b68ec..2e5c991b5 100644 --- a/src/interfaces/IBLSApkRegistry.sol +++ b/src/interfaces/IBLSApkRegistry.sol @@ -170,7 +170,10 @@ interface IBLSApkRegistry is IBLSApkRegistryErrors, IBLSApkRegistryEvents { * 3. `quorumNumbers` is ordered ascending * 4. The operator is not already registered */ - function registerOperator(address operator, bytes calldata quorumNumbers) external; + function registerOperator( + address operator, + bytes calldata quorumNumbers + ) external; /* * @notice Deregisters `operator`'s pubkey from `quorumNumbers`. @@ -184,7 +187,10 @@ interface IBLSApkRegistry is IBLSApkRegistryErrors, IBLSApkRegistryEvents { * 4. The operator is not already deregistered * 5. `quorumNumbers` is a subset of the operator's registered quorums */ - function deregisterOperator(address operator, bytes calldata quorumNumbers) external; + function deregisterOperator( + address operator, + bytes calldata quorumNumbers + ) external; /* * @notice Initializes `quorumNumber` by pushing its first APK update. diff --git a/src/interfaces/IBN254TableCalculator.sol b/src/interfaces/IBN254TableCalculator.sol index 52a7fcdf7..bbbb763aa 100644 --- a/src/interfaces/IBN254TableCalculator.sol +++ b/src/interfaces/IBN254TableCalculator.sol @@ -7,8 +7,9 @@ import { IOperatorTableCalculator, IOperatorTableCalculatorTypes } from "eigenlayer-contracts/src/contracts/interfaces/IOperatorTableCalculator.sol"; -import {IBN254CertificateVerifierTypes} from - "eigenlayer-contracts/src/contracts/interfaces/IBN254CertificateVerifier.sol"; +import { + IBN254CertificateVerifierTypes +} from "eigenlayer-contracts/src/contracts/interfaces/IBN254CertificateVerifier.sol"; interface IBN254TableCalculator is IOperatorTableCalculator, IOperatorTableCalculatorTypes { /** diff --git a/src/interfaces/IECDSAStakeRegistry.sol b/src/interfaces/IECDSAStakeRegistry.sol index bcf49e78d..4bc88ecf3 100644 --- a/src/interfaces/IECDSAStakeRegistry.sol +++ b/src/interfaces/IECDSAStakeRegistry.sol @@ -1,11 +1,13 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; -import {IERC1271Upgradeable} from - "@openzeppelin-upgrades/contracts/interfaces/IERC1271Upgradeable.sol"; +import { + IERC1271Upgradeable +} from "@openzeppelin-upgrades/contracts/interfaces/IERC1271Upgradeable.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; -import {ISignatureUtilsMixinTypes} from - "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; +import { + ISignatureUtilsMixinTypes +} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; // TODO: many of these errors do not have test coverage. @@ -180,7 +182,10 @@ interface IECDSAStakeRegistry is * @param newMinimumWeight The new weight an operator must have to join the operator set. * @param operators The list of operators to update after changing the minimum weight. */ - function updateMinimumWeight(uint256 newMinimumWeight, address[] memory operators) external; + function updateMinimumWeight( + uint256 newMinimumWeight, + address[] memory operators + ) external; /* * @notice Sets a new cumulative threshold weight for message validation. diff --git a/src/interfaces/IEjectionManager.sol b/src/interfaces/IEjectionManager.sol index 56db0dd1e..d6ffb46c3 100644 --- a/src/interfaces/IEjectionManager.sol +++ b/src/interfaces/IEjectionManager.sol @@ -137,7 +137,10 @@ interface IEjectionManager is IEjectionManagerErrors, IEjectionManagerEvents { * @param ejector The address to permission. * @param status The status to set for the given address. */ - function setEjector(address ejector, bool status) external; + function setEjector( + address ejector, + bool status + ) external; /* VIEW */ diff --git a/src/interfaces/IIndexRegistry.sol b/src/interfaces/IIndexRegistry.sol index c4d5d9975..cb78a6e6d 100644 --- a/src/interfaces/IIndexRegistry.sol +++ b/src/interfaces/IIndexRegistry.sol @@ -100,7 +100,10 @@ interface IIndexRegistry is IIndexRegistryErrors, IIndexRegistryEvents { * 4) the operator is not already deregistered * 5) `quorumNumbers` is a subset of the quorumNumbers that the operator is registered for */ - function deregisterOperator(bytes32 operatorId, bytes calldata quorumNumbers) external; + function deregisterOperator( + bytes32 operatorId, + bytes calldata quorumNumbers + ) external; /* * @notice Initializes a new quorum `quorumNumber`. diff --git a/src/interfaces/IInstantSlasher.sol b/src/interfaces/IInstantSlasher.sol index d6d4d048d..bb53b1398 100644 --- a/src/interfaces/IInstantSlasher.sol +++ b/src/interfaces/IInstantSlasher.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {ISlasher} from "./ISlasher.sol"; /// @title IInstantSlasher diff --git a/src/interfaces/IKeyRegistrar.sol b/src/interfaces/IKeyRegistrar.sol index cb496e678..786028736 100644 --- a/src/interfaces/IKeyRegistrar.sol +++ b/src/interfaces/IKeyRegistrar.sol @@ -15,7 +15,10 @@ interface IKeyRegistrar { address operator ) external returns (bool); - function removeKey(OperatorSet calldata operatorSet, address operator) external; + function removeKey( + OperatorSet calldata operatorSet, + address operator + ) external; function isRegistered( OperatorSet calldata operatorSet, diff --git a/src/interfaces/IRegistryCoordinator.sol b/src/interfaces/IRegistryCoordinator.sol index 88cb29f92..3dea958a3 100644 --- a/src/interfaces/IRegistryCoordinator.sol +++ b/src/interfaces/IRegistryCoordinator.sol @@ -7,16 +7,18 @@ import { ISlashingRegistryCoordinatorEvents, ISlashingRegistryCoordinatorTypes } from "./ISlashingRegistryCoordinator.sol"; -import {ISignatureUtilsMixinTypes} from - "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; +import { + ISignatureUtilsMixinTypes +} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; import {IBLSApkRegistry, IBLSApkRegistryTypes} from "./IBLSApkRegistry.sol"; import {IServiceManager} from "./IServiceManager.sol"; import {IStakeRegistry} from "./IStakeRegistry.sol"; import {IIndexRegistry} from "./IIndexRegistry.sol"; import {ISocketRegistry} from "./ISocketRegistry.sol"; import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; interface IRegistryCoordinatorErrors is ISlashingRegistryCoordinatorErrors { /// @notice Thrown when operator sets mode is already enabled. diff --git a/src/interfaces/IServiceManager.sol b/src/interfaces/IServiceManager.sol index d123dcee6..86abddde6 100644 --- a/src/interfaces/IServiceManager.sol +++ b/src/interfaces/IServiceManager.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; -import {IRewardsCoordinator} from - "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; +import { + IRewardsCoordinator +} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; import {IServiceManagerUI} from "./IServiceManagerUI.sol"; interface IServiceManagerErrors { @@ -79,7 +80,11 @@ interface IServiceManager is IServiceManagerUI, IServiceManagerErrors, IServiceM * @param target The address of the target to set the appointee for. * @param selector The function selector to set the appointee for. */ - function setAppointee(address appointee, address target, bytes4 selector) external; + function setAppointee( + address appointee, + address target, + bytes4 selector + ) external; /** * @notice Calls `removeAppointee` on the `PermissionController` contract. @@ -88,7 +93,11 @@ interface IServiceManager is IServiceManagerUI, IServiceManagerErrors, IServiceM * @param target The address of the target to remove the appointee for. * @param selector The function selector to remove the appointee for. */ - function removeAppointee(address appointee, address target, bytes4 selector) external; + function removeAppointee( + address appointee, + address target, + bytes4 selector + ) external; /** * @notice Deregisters an operator from specified operator sets diff --git a/src/interfaces/IServiceManagerUI.sol b/src/interfaces/IServiceManagerUI.sol index a0d937787..c0c922722 100644 --- a/src/interfaces/IServiceManagerUI.sol +++ b/src/interfaces/IServiceManagerUI.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; -import {ISignatureUtilsMixinTypes} from - "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; +import { + ISignatureUtilsMixinTypes +} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; /** * @title Minimal interface for a ServiceManager-type contract that AVS ServiceManager contracts must implement diff --git a/src/interfaces/ISlasher.sol b/src/interfaces/ISlasher.sol index ab9620a96..6731f12f9 100644 --- a/src/interfaces/ISlasher.sol +++ b/src/interfaces/ISlasher.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; interface ISlasherErrors { /// @notice Thrown when a caller without slasher privileges attempts a restricted operation diff --git a/src/interfaces/ISlashingRegistryCoordinator.sol b/src/interfaces/ISlashingRegistryCoordinator.sol index 08e90a608..05c563fe3 100644 --- a/src/interfaces/ISlashingRegistryCoordinator.sol +++ b/src/interfaces/ISlashingRegistryCoordinator.sol @@ -5,8 +5,9 @@ import {IBLSApkRegistry} from "./IBLSApkRegistry.sol"; import {IStakeRegistry} from "./IStakeRegistry.sol"; import {IIndexRegistry} from "./IIndexRegistry.sol"; import {BN254} from "../libraries/BN254.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IBLSApkRegistry} from "./IBLSApkRegistry.sol"; import {IStakeRegistry, IStakeRegistryTypes} from "./IStakeRegistry.sol"; import {IIndexRegistry} from "./IIndexRegistry.sol"; @@ -238,7 +239,6 @@ interface ISlashingRegistryCoordinator is ISlashingRegistryCoordinatorEvents { /// IMMUTABLES & CONSTANTS - /** * @notice EIP-712 typehash for operator churn approval signatures. * @return The typehash constant. @@ -383,7 +383,10 @@ interface ISlashingRegistryCoordinator is * @dev Can only be called by the ejector address. * @dev The operator cannot re-register until ejectionCooldown period has passed. */ - function ejectOperator(address operator, bytes memory quorumNumbers) external; + function ejectOperator( + address operator, + bytes memory quorumNumbers + ) external; /** * @notice Creates a new quorum that tracks total delegated stake for operators. diff --git a/src/interfaces/ISocketRegistry.sol b/src/interfaces/ISocketRegistry.sol index d94b1dba3..41a57f530 100644 --- a/src/interfaces/ISocketRegistry.sol +++ b/src/interfaces/ISocketRegistry.sol @@ -13,7 +13,10 @@ interface ISocketRegistry is ISocketRegistryErrors { * @param _socket The socket (any arbitrary string as deemed useful by an AVS) to set. * @dev Only callable by the SlashingRegistryCoordinator. */ - function setOperatorSocket(bytes32 _operatorId, string memory _socket) external; + function setOperatorSocket( + bytes32 _operatorId, + string memory _socket + ) external; /** * @notice Gets the stored socket for an operator. diff --git a/src/interfaces/ISocketRegistryV2.sol b/src/interfaces/ISocketRegistryV2.sol index 4070ba69b..5787f67a9 100644 --- a/src/interfaces/ISocketRegistryV2.sol +++ b/src/interfaces/ISocketRegistryV2.sol @@ -24,5 +24,8 @@ interface ISocketRegistryV2 is ISocketRegistryEvents { * @dev Reverts for: * - InvalidPermissions: The caller does not have permission to call this function (via core `PermissionController`) */ - function updateSocket(address operator, string memory socket) external; + function updateSocket( + address operator, + string memory socket + ) external; } diff --git a/src/interfaces/IStakeRegistry.sol b/src/interfaces/IStakeRegistry.sol index aa0cc750b..533e571b6 100644 --- a/src/interfaces/IStakeRegistry.sol +++ b/src/interfaces/IStakeRegistry.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; /// @notice Interface containing all error definitions for the StakeRegistry contract. @@ -125,7 +126,6 @@ interface IStakeRegistryEvents is IStakeRegistryTypes { interface IStakeRegistry is IStakeRegistryErrors, IStakeRegistryEvents { /// STATE - /** * @notice Returns the EigenLayer delegation manager contract. */ @@ -165,7 +165,10 @@ interface IStakeRegistry is IStakeRegistryErrors, IStakeRegistryEvents { * 4) The operator is not already deregistered. * 5) `quorumNumbers` is a subset of the quorumNumbers that the operator is registered for. */ - function deregisterOperator(bytes32 operatorId, bytes memory quorumNumbers) external; + function deregisterOperator( + bytes32 operatorId, + bytes memory quorumNumbers + ) external; /** * @notice Called by the registry coordinator to update the stake of a list of operators for a specific quorum. @@ -211,14 +214,20 @@ interface IStakeRegistry is IStakeRegistryErrors, IStakeRegistryEvents { * @param quorumNumber The quorum number to set the minimum stake for. * @param minimumStake The new minimum stake requirement. */ - function setMinimumStakeForQuorum(uint8 quorumNumber, uint96 minimumStake) external; + function setMinimumStakeForQuorum( + uint8 quorumNumber, + uint96 minimumStake + ) external; /** * @notice Sets the look ahead time to `lookAheadBlocks` for checking operator shares for a specific quorum. * @param quorumNumber The quorum number to set the look ahead period for. * @param lookAheadBlocks The number of blocks to look ahead when checking shares. */ - function setSlashableStakeLookahead(uint8 quorumNumber, uint32 lookAheadBlocks) external; + function setSlashableStakeLookahead( + uint8 quorumNumber, + uint32 lookAheadBlocks + ) external; /** * @notice Adds new strategies and their associated multipliers to the specified quorum. @@ -228,7 +237,10 @@ interface IStakeRegistry is IStakeRegistryErrors, IStakeRegistryEvents { * @param quorumNumber The quorum number to add strategies to. * @param strategyParams The strategy parameters to add. */ - function addStrategies(uint8 quorumNumber, StrategyParams[] memory strategyParams) external; + function addStrategies( + uint8 quorumNumber, + StrategyParams[] memory strategyParams + ) external; /** * @notice Removes strategies and their associated weights from the specified quorum. @@ -237,7 +249,10 @@ interface IStakeRegistry is IStakeRegistryErrors, IStakeRegistryEvents { * @dev Higher indices should be *first* in the list of `indicesToRemove`, since otherwise * the removal of lower index entries will cause a shift in the indices of the other strategiesToRemove. */ - function removeStrategies(uint8 quorumNumber, uint256[] calldata indicesToRemove) external; + function removeStrategies( + uint8 quorumNumber, + uint256[] calldata indicesToRemove + ) external; /** * @notice Modifies the weights of strategies that are already in the mapping strategyParams. diff --git a/src/interfaces/IVetoableSlasher.sol b/src/interfaces/IVetoableSlasher.sol index 0f2f8ab2e..caf62e6d2 100644 --- a/src/interfaces/IVetoableSlasher.sol +++ b/src/interfaces/IVetoableSlasher.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {ISlasher} from "./ISlasher.sol"; interface IVetoableSlasherErrors { diff --git a/src/libraries/BN254.sol b/src/libraries/BN254.sol index df4b8248c..8bc903197 100644 --- a/src/libraries/BN254.sol +++ b/src/libraries/BN254.sol @@ -117,7 +117,10 @@ library BN254 { /** * @return r the sum of two points of G1 */ - function plus(G1Point memory p1, G1Point memory p2) internal view returns (G1Point memory r) { + function plus( + G1Point memory p1, + G1Point memory p2 + ) internal view returns (G1Point memory r) { uint256[4] memory input; input[0] = p1.X; input[1] = p1.Y; @@ -187,7 +190,10 @@ library BN254 { * p == p.scalar_mul(1) and p.plus(p) == p.scalar_mul(2) for all * points p. */ - function scalar_mul(G1Point memory p, uint256 s) internal view returns (G1Point memory r) { + function scalar_mul( + G1Point memory p, + uint256 s + ) internal view returns (G1Point memory r) { uint256[3] memory input; input[0] = p.X; input[1] = p.Y; diff --git a/src/libraries/BitmapUtils.sol b/src/libraries/BitmapUtils.sol index cbe670a3c..cd35760d4 100644 --- a/src/libraries/BitmapUtils.sol +++ b/src/libraries/BitmapUtils.sol @@ -122,7 +122,13 @@ library BitmapUtils { */ function bitmapToBytesArray( uint256 bitmap - ) internal pure returns (bytes memory /*bytesArray*/ ) { + ) + internal + pure + returns ( + bytes memory /*bytesArray*/ + ) + { // initialize an empty uint256 to be used as a bitmask inside the loop uint256 bitMask; // allocate only the needed amount of memory @@ -163,7 +169,10 @@ library BitmapUtils { } /// @notice Returns `true` if `bit` is in `bitmap`. Returns `false` otherwise. - function isSet(uint256 bitmap, uint8 bit) internal pure returns (bool) { + function isSet( + uint256 bitmap, + uint8 bit + ) internal pure returns (bool) { return 1 == ((bitmap >> bit) & 1); } @@ -173,7 +182,10 @@ library BitmapUtils { * the original bitmap. Using this correctly requires an assignment statement: * `bitmap = bitmap.setBit(bit);` */ - function setBit(uint256 bitmap, uint8 bit) internal pure returns (uint256) { + function setBit( + uint256 bitmap, + uint8 bit + ) internal pure returns (uint256) { return bitmap | (1 << bit); } @@ -189,14 +201,20 @@ library BitmapUtils { /** * @notice Returns true if `a` and `b` have no common set bits */ - function noBitsInCommon(uint256 a, uint256 b) internal pure returns (bool) { + function noBitsInCommon( + uint256 a, + uint256 b + ) internal pure returns (bool) { return a & b == 0; } /** * @notice Returns true if `a` is a subset of `b`: ALL of the bits in `a` are also in `b` */ - function isSubsetOf(uint256 a, uint256 b) internal pure returns (bool) { + function isSubsetOf( + uint256 a, + uint256 b + ) internal pure returns (bool) { return a & b == a; } @@ -204,7 +222,10 @@ library BitmapUtils { * @notice Returns a new bitmap that contains all bits set in either `a` or `b` * @dev Result is the union of `a` and `b` */ - function plus(uint256 a, uint256 b) internal pure returns (uint256) { + function plus( + uint256 a, + uint256 b + ) internal pure returns (uint256) { return a | b; } @@ -212,7 +233,10 @@ library BitmapUtils { * @notice Returns a new bitmap that clears all set bits of `b` from `a` * @dev Negates `b` and returns the intersection of the result with `a` */ - function minus(uint256 a, uint256 b) internal pure returns (uint256) { + function minus( + uint256 a, + uint256 b + ) internal pure returns (uint256) { return a & ~b; } @@ -220,7 +244,10 @@ library BitmapUtils { * @notice Returns a new bitmap that contains only bits set in both `a` and `b` * @dev Result is the intersection of `a` and `b` */ - function and(uint256 a, uint256 b) internal pure returns (uint256) { + function and( + uint256 a, + uint256 b + ) internal pure returns (uint256) { return a & b; } } diff --git a/src/middlewareV2/registrar/AVSRegistrar.sol b/src/middlewareV2/registrar/AVSRegistrar.sol index def58b14e..45145df1c 100644 --- a/src/middlewareV2/registrar/AVSRegistrar.sol +++ b/src/middlewareV2/registrar/AVSRegistrar.sol @@ -3,8 +3,9 @@ pragma solidity ^0.8.27; import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; import {IAVSRegistrarInternal} from "../../interfaces/IAVSRegistrarInternal.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import { OperatorSetLib, OperatorSet diff --git a/src/middlewareV2/registrar/AVSRegistrarStorage.sol b/src/middlewareV2/registrar/AVSRegistrarStorage.sol index f893d1fe9..2805846f2 100644 --- a/src/middlewareV2/registrar/AVSRegistrarStorage.sol +++ b/src/middlewareV2/registrar/AVSRegistrarStorage.sol @@ -4,8 +4,9 @@ pragma solidity ^0.8.27; import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; import {IAVSRegistrarInternal} from "../../interfaces/IAVSRegistrarInternal.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; /// @notice A minimal storage contract for the AVSRegistrar abstract contract AVSRegistrarStorage is IAVSRegistrar, IAVSRegistrarInternal { @@ -14,7 +15,6 @@ abstract contract AVSRegistrarStorage is IAVSRegistrar, IAVSRegistrarInternal { * CONSTANTS AND IMMUTABLES * */ - /// @notice The allocation manager in EigenLayer core IAllocationManager public immutable allocationManager; @@ -25,7 +25,10 @@ abstract contract AVSRegistrarStorage is IAVSRegistrar, IAVSRegistrarInternal { /// @dev In practice, the AVS address in EigenLayer core is address that initialized the Metadata URI. address public avs; - constructor(IAllocationManager _allocationManager, IKeyRegistrar _keyRegistrar) { + constructor( + IAllocationManager _allocationManager, + IKeyRegistrar _keyRegistrar + ) { allocationManager = _allocationManager; keyRegistrar = _keyRegistrar; } diff --git a/src/middlewareV2/registrar/modules/Allowlist.sol b/src/middlewareV2/registrar/modules/Allowlist.sol index 7d44df7f4..7c6cf6ddc 100644 --- a/src/middlewareV2/registrar/modules/Allowlist.sol +++ b/src/middlewareV2/registrar/modules/Allowlist.sol @@ -4,10 +4,12 @@ pragma solidity ^0.8.27; import {IAllowlist} from "../../../interfaces/IAllowlist.sol"; import {AllowlistStorage} from "./AllowlistStorage.sol"; -import {OwnableUpgradeable} from - "openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol"; -import {EnumerableSetUpgradeable} from - "openzeppelin-contracts-upgradeable/contracts/utils/structs/EnumerableSetUpgradeable.sol"; +import { + OwnableUpgradeable +} from "openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol"; +import { + EnumerableSetUpgradeable +} from "openzeppelin-contracts-upgradeable/contracts/utils/structs/EnumerableSetUpgradeable.sol"; import { OperatorSet, diff --git a/src/middlewareV2/registrar/modules/AllowlistStorage.sol b/src/middlewareV2/registrar/modules/AllowlistStorage.sol index 3c419f8c8..cf053a2cc 100644 --- a/src/middlewareV2/registrar/modules/AllowlistStorage.sol +++ b/src/middlewareV2/registrar/modules/AllowlistStorage.sol @@ -3,8 +3,9 @@ pragma solidity ^0.8.27; import {IAllowlist} from "../../../interfaces/IAllowlist.sol"; -import {EnumerableSetUpgradeable} from - "openzeppelin-contracts-upgradeable/contracts/utils/structs/EnumerableSetUpgradeable.sol"; +import { + EnumerableSetUpgradeable +} from "openzeppelin-contracts-upgradeable/contracts/utils/structs/EnumerableSetUpgradeable.sol"; abstract contract AllowlistStorage is IAllowlist { using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; diff --git a/src/middlewareV2/registrar/modules/SocketRegistry.sol b/src/middlewareV2/registrar/modules/SocketRegistry.sol index 4f1b0fde6..90560c7cf 100644 --- a/src/middlewareV2/registrar/modules/SocketRegistry.sol +++ b/src/middlewareV2/registrar/modules/SocketRegistry.sol @@ -7,10 +7,12 @@ import { OperatorSetLib, OperatorSet } from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; -import {PermissionControllerMixin} from - "eigenlayer-contracts/src/contracts/mixins/PermissionControllerMixin.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + PermissionControllerMixin +} from "eigenlayer-contracts/src/contracts/mixins/PermissionControllerMixin.sol"; /// @notice A module that allows for the setting and removal of operator sockets /// @dev This contract assumes a single socket per operator @@ -29,7 +31,10 @@ abstract contract SocketRegistry is SocketRegistryStorage, PermissionControllerM } /// @inheritdoc ISocketRegistryV2 - function updateSocket(address operator, string memory socket) external checkCanCall(operator) { + function updateSocket( + address operator, + string memory socket + ) external checkCanCall(operator) { _setOperatorSocket(operator, socket); } @@ -39,7 +44,10 @@ abstract contract SocketRegistry is SocketRegistryStorage, PermissionControllerM * @param socket The socket (any arbitrary string as deemed useful by an AVS) to set. * @dev This function sets a single socket per operator, regardless of operatorSet. */ - function _setOperatorSocket(address operator, string memory socket) internal { + function _setOperatorSocket( + address operator, + string memory socket + ) internal { _operatorToSocket[operator] = socket; emit OperatorSocketSet(operator, socket); } diff --git a/src/middlewareV2/registrar/modules/SocketRegistryStorage.sol b/src/middlewareV2/registrar/modules/SocketRegistryStorage.sol index 703f1d60d..dad064f35 100644 --- a/src/middlewareV2/registrar/modules/SocketRegistryStorage.sol +++ b/src/middlewareV2/registrar/modules/SocketRegistryStorage.sol @@ -2,8 +2,9 @@ pragma solidity ^0.8.12; import {ISocketRegistryV2} from "../../../interfaces/ISocketRegistryV2.sol"; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; /** * @title Storage variables for the `SocketRegistry` contract. @@ -15,7 +16,6 @@ abstract contract SocketRegistryStorage is ISocketRegistryV2 { * STATE * */ - /// @notice A mapping from operator address to socket mapping(address operator => string operatorSocket) internal _operatorToSocket; diff --git a/src/middlewareV2/registrar/presets/AVSRegistrarAsIdentifier.sol b/src/middlewareV2/registrar/presets/AVSRegistrarAsIdentifier.sol index cc926b4b5..b0974d845 100644 --- a/src/middlewareV2/registrar/presets/AVSRegistrarAsIdentifier.sol +++ b/src/middlewareV2/registrar/presets/AVSRegistrarAsIdentifier.sol @@ -4,10 +4,12 @@ pragma solidity ^0.8.27; import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol"; import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; import {IAVSRegistrarInternal} from "../../../interfaces/IAVSRegistrarInternal.sol"; @@ -34,7 +36,10 @@ contract AVSRegistrarAsIdentifier is AVSRegistrar { * @param metadataURI The metadataURI for the AVS * @dev This function enables the address of the AVS in the core protocol to be the proxy AVSRegistrarAsIdentifier contract */ - function initialize(address admin, string memory metadataURI) public initializer { + function initialize( + address admin, + string memory metadataURI + ) public initializer { __AVSRegistrar_init(address(this)); // Set the metadataURI and the registrar for the AVS to this registrar contract diff --git a/src/middlewareV2/registrar/presets/AVSRegistrarWithAllowlist.sol b/src/middlewareV2/registrar/presets/AVSRegistrarWithAllowlist.sol index 9ecc56de8..ac8f9d90c 100644 --- a/src/middlewareV2/registrar/presets/AVSRegistrarWithAllowlist.sol +++ b/src/middlewareV2/registrar/presets/AVSRegistrarWithAllowlist.sol @@ -2,8 +2,9 @@ pragma solidity ^0.8.27; import {IAVSRegistrarWithAllowlist} from "../../../interfaces/IAVSRegistrarWithAllowlist.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; import {AVSRegistrar} from "../AVSRegistrar.sol"; @@ -16,7 +17,10 @@ contract AVSRegistrarWithAllowlist is AVSRegistrar, Allowlist, IAVSRegistrarWith IKeyRegistrar _keyRegistrar ) AVSRegistrar(_allocationManager, _keyRegistrar) {} - function initialize(address avs, address admin) external initializer { + function initialize( + address avs, + address admin + ) external initializer { // Initialize the AVSRegistrar __AVSRegistrar_init(avs); diff --git a/src/middlewareV2/registrar/presets/AVSRegistrarWithSocket.sol b/src/middlewareV2/registrar/presets/AVSRegistrarWithSocket.sol index c1ec51ed5..e640bb69f 100644 --- a/src/middlewareV2/registrar/presets/AVSRegistrarWithSocket.sol +++ b/src/middlewareV2/registrar/presets/AVSRegistrarWithSocket.sol @@ -1,10 +1,12 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; import {IAVSRegistrarWithSocket} from "../../../interfaces/IAVSRegistrarWithSocket.sol"; diff --git a/src/middlewareV2/tableCalculator/BN254TableCalculator.sol b/src/middlewareV2/tableCalculator/BN254TableCalculator.sol index 98f70cfa1..ce11c2baa 100644 --- a/src/middlewareV2/tableCalculator/BN254TableCalculator.sol +++ b/src/middlewareV2/tableCalculator/BN254TableCalculator.sol @@ -2,8 +2,9 @@ pragma solidity ^0.8.27; import {OperatorSet} from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; diff --git a/src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol b/src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol index 2b6a3f72f..8501a4ca2 100644 --- a/src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol +++ b/src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol @@ -2,15 +2,18 @@ pragma solidity ^0.8.27; import {OperatorSet} from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; -import {IOperatorTableCalculator} from - "eigenlayer-contracts/src/contracts/interfaces/IOperatorTableCalculator.sol"; +import { + IOperatorTableCalculator +} from "eigenlayer-contracts/src/contracts/interfaces/IOperatorTableCalculator.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; import {Merkle} from "eigenlayer-contracts/src/contracts/libraries/Merkle.sol"; import {BN254} from "eigenlayer-contracts/src/contracts/libraries/BN254.sol"; -import {IBN254CertificateVerifierTypes} from - "eigenlayer-contracts/src/contracts/interfaces/IBN254CertificateVerifier.sol"; -import {LeafCalculatorMixin} from - "eigenlayer-contracts/src/contracts/mixins/LeafCalculatorMixin.sol"; +import { + IBN254CertificateVerifierTypes +} from "eigenlayer-contracts/src/contracts/interfaces/IBN254CertificateVerifier.sol"; +import { + LeafCalculatorMixin +} from "eigenlayer-contracts/src/contracts/mixins/LeafCalculatorMixin.sol"; import {IBN254TableCalculator} from "../../interfaces/IBN254TableCalculator.sol"; /** @@ -138,16 +141,16 @@ abstract contract BN254TableCalculatorBase is IBN254TableCalculator, LeafCalcula ) = _buildRegisteredOperatorData(operatorSet); if (registeredOperatorInfos.length == 0) { - return ( - new IBN254CertificateVerifierTypes.BN254OperatorInfoWitness[](0), - BN254.G1Point(0, 0) - ); + return + ( + new IBN254CertificateVerifierTypes.BN254OperatorInfoWitness[](0), + BN254.G1Point(0, 0) + ); } // Prepare outputs with max length then resize - nonSignerWitnesses = new IBN254CertificateVerifierTypes.BN254OperatorInfoWitness[]( - registeredOperators.length - ); + nonSignerWitnesses = new IBN254CertificateVerifierTypes + .BN254OperatorInfoWitness[](registeredOperators.length); nonSignerApk = BN254.G1Point(0, 0); uint256 nonSignerCount = 0; @@ -164,12 +167,12 @@ abstract contract BN254TableCalculatorBase is IBN254TableCalculator, LeafCalcula BN254OperatorInfo memory opInfo = registeredOperatorInfos[idx]; nonSignerApk = nonSignerApk.plus(opInfo.pubkey); - nonSignerWitnesses[nonSignerCount] = IBN254CertificateVerifierTypes - .BN254OperatorInfoWitness({ - operatorIndex: uint32(idx), - operatorInfoProof: Merkle.getProofKeccak(operatorInfoLeaves, idx), - operatorInfo: opInfo - }); + nonSignerWitnesses[nonSignerCount] = + IBN254CertificateVerifierTypes.BN254OperatorInfoWitness({ + operatorIndex: uint32(idx), + operatorInfoProof: Merkle.getProofKeccak(operatorInfoLeaves, idx), + operatorInfo: opInfo + }); nonSignerCount++; } diff --git a/src/middlewareV2/tableCalculator/ECDSATableCalculator.sol b/src/middlewareV2/tableCalculator/ECDSATableCalculator.sol index e7e658ce8..064a67c57 100644 --- a/src/middlewareV2/tableCalculator/ECDSATableCalculator.sol +++ b/src/middlewareV2/tableCalculator/ECDSATableCalculator.sol @@ -2,8 +2,9 @@ pragma solidity ^0.8.27; import {OperatorSet} from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; diff --git a/src/middlewareV2/tableCalculator/ECDSATableCalculatorBase.sol b/src/middlewareV2/tableCalculator/ECDSATableCalculatorBase.sol index a6dcf9c2e..f58d8a71e 100644 --- a/src/middlewareV2/tableCalculator/ECDSATableCalculatorBase.sol +++ b/src/middlewareV2/tableCalculator/ECDSATableCalculatorBase.sol @@ -2,8 +2,9 @@ pragma solidity ^0.8.27; import {OperatorSet} from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; -import {IOperatorTableCalculator} from - "eigenlayer-contracts/src/contracts/interfaces/IOperatorTableCalculator.sol"; +import { + IOperatorTableCalculator +} from "eigenlayer-contracts/src/contracts/interfaces/IOperatorTableCalculator.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; import {IECDSATableCalculator} from "../../interfaces/IECDSATableCalculator.sol"; diff --git a/src/middlewareV2/tableCalculator/unaudited/BN254TableCalculatorWithCaps.sol b/src/middlewareV2/tableCalculator/unaudited/BN254TableCalculatorWithCaps.sol index 77054e885..89f066168 100644 --- a/src/middlewareV2/tableCalculator/unaudited/BN254TableCalculatorWithCaps.sol +++ b/src/middlewareV2/tableCalculator/unaudited/BN254TableCalculatorWithCaps.sol @@ -2,14 +2,17 @@ pragma solidity ^0.8.27; import {OperatorSet} from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; -import {PermissionControllerMixin} from - "eigenlayer-contracts/src/contracts/mixins/PermissionControllerMixin.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + PermissionControllerMixin +} from "eigenlayer-contracts/src/contracts/mixins/PermissionControllerMixin.sol"; import "../BN254TableCalculatorBase.sol"; import {WeightCapUtils} from "../../../unaudited/libraries/WeightCapUtils.sol"; diff --git a/src/middlewareV2/tableCalculator/unaudited/BN254WeightedTableCalculator.sol b/src/middlewareV2/tableCalculator/unaudited/BN254WeightedTableCalculator.sol index d40f32a43..f321ac612 100644 --- a/src/middlewareV2/tableCalculator/unaudited/BN254WeightedTableCalculator.sol +++ b/src/middlewareV2/tableCalculator/unaudited/BN254WeightedTableCalculator.sol @@ -2,14 +2,17 @@ pragma solidity ^0.8.27; import {OperatorSet} from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; -import {PermissionControllerMixin} from - "eigenlayer-contracts/src/contracts/mixins/PermissionControllerMixin.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + PermissionControllerMixin +} from "eigenlayer-contracts/src/contracts/mixins/PermissionControllerMixin.sol"; import "../BN254TableCalculatorBase.sol"; diff --git a/src/slashers/InstantSlasher.sol b/src/slashers/InstantSlasher.sol index c575e3606..a7e19ec25 100644 --- a/src/slashers/InstantSlasher.sol +++ b/src/slashers/InstantSlasher.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol"; import {SlasherBase} from "./base/SlasherBase.sol"; import {ISlashingRegistryCoordinator} from "../interfaces/ISlashingRegistryCoordinator.sol"; diff --git a/src/slashers/base/SlasherBase.sol b/src/slashers/base/SlasherBase.sol index a9cac33d7..59a5e9d92 100644 --- a/src/slashers/base/SlasherBase.sol +++ b/src/slashers/base/SlasherBase.sol @@ -36,8 +36,7 @@ abstract contract SlasherBase is SlasherStorage { IAllocationManager.SlashingParams memory params ) internal virtual returns (uint256 slashId) { (slashId,) = allocationManager.slashOperator({ - avs: slashingRegistryCoordinator.avs(), - params: params + avs: slashingRegistryCoordinator.avs(), params: params }); emit OperatorSlashed( slashId, params.operator, params.operatorSetId, params.wadsToSlash, params.description @@ -50,7 +49,10 @@ abstract contract SlasherBase is SlasherStorage { } /// @notice Internal function to optionally fulfill burn or redistribution instead of waiting for cron job - function _fulfillBurnOrRedistribution(uint32 operatorSetId, uint256 slashId) internal virtual { + function _fulfillBurnOrRedistribution( + uint32 operatorSetId, + uint256 slashId + ) internal virtual { strategyManager.clearBurnOrRedistributableShares({ operatorSet: OperatorSet({avs: slashingRegistryCoordinator.avs(), id: operatorSetId}), slashId: slashId diff --git a/src/slashers/base/SlasherStorage.sol b/src/slashers/base/SlasherStorage.sol index afdf1dbfc..3e02f1649 100644 --- a/src/slashers/base/SlasherStorage.sol +++ b/src/slashers/base/SlasherStorage.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol"; import {ISlashingRegistryCoordinator} from "../../interfaces/ISlashingRegistryCoordinator.sol"; import {ISlasher} from "../../interfaces/ISlasher.sol"; @@ -16,7 +17,6 @@ abstract contract SlasherStorage is ISlasher { * CONSTANTS AND IMMUTABLES * */ - /// @notice The `AllocationManager` tracks operator sets, operator set allocations, and slashing in EigenLayer. IAllocationManager public immutable allocationManager; /// @notice The `StrategyManager` handles strategy inflows/outflows. diff --git a/src/unaudited/BLSSigCheckOperatorStateRetriever.sol b/src/unaudited/BLSSigCheckOperatorStateRetriever.sol index 118030f71..3573ffb25 100644 --- a/src/unaudited/BLSSigCheckOperatorStateRetriever.sol +++ b/src/unaudited/BLSSigCheckOperatorStateRetriever.sol @@ -87,15 +87,17 @@ contract BLSSigCheckOperatorStateRetriever is OperatorStateRetriever { // Extra scope for stack limit { - uint32[] memory signingOperatorQuorumBitmapIndices = registryCoordinator - .getQuorumBitmapIndicesAtBlockNumber(blockNumber, m.signingOperatorIds); + uint32[] memory signingOperatorQuorumBitmapIndices = + registryCoordinator.getQuorumBitmapIndicesAtBlockNumber( + blockNumber, m.signingOperatorIds + ); uint256 bitmap = BitmapUtils.orderedBytesArrayToBitmap(quorumNumbers); // Check that all operators are registered (this is like the check in getCheckSignaturesIndices, but we check against _signing_ operators) for (uint256 i = 0; i < operators.length; i++) { - uint192 signingOperatorQuorumBitmap = registryCoordinator - .getQuorumBitmapAtBlockNumberByIndex( - m.signingOperatorIds[i], blockNumber, signingOperatorQuorumBitmapIndices[i] - ); + uint192 signingOperatorQuorumBitmap = + registryCoordinator.getQuorumBitmapAtBlockNumberByIndex( + m.signingOperatorIds[i], blockNumber, signingOperatorQuorumBitmapIndices[i] + ); require( !uint256(signingOperatorQuorumBitmap).noBitsInCommon(bitmap), OperatorNotRegistered() diff --git a/src/unaudited/BLSSigCheckUtils.sol b/src/unaudited/BLSSigCheckUtils.sol index d2abaa77d..19baf8f2e 100644 --- a/src/unaudited/BLSSigCheckUtils.sol +++ b/src/unaudited/BLSSigCheckUtils.sol @@ -15,11 +15,17 @@ import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; * _Available since v5.1._ */ library Comparators { - function lt(uint256 a, uint256 b) internal pure returns (bool) { + function lt( + uint256 a, + uint256 b + ) internal pure returns (bool) { return a < b; } - function gt(uint256 a, uint256 b) internal pure returns (bool) { + function gt( + uint256 a, + uint256 b + ) internal pure returns (bool) { return a > b; } } @@ -74,7 +80,10 @@ library SlotDerivation { /** * @dev Add an offset to a slot to get the n-th element of a structure or an array. */ - function offset(bytes32 slot, uint256 pos) internal pure returns (bytes32 result) { + function offset( + bytes32 slot, + uint256 pos + ) internal pure returns (bytes32 result) { unchecked { return bytes32(uint256(slot) + pos); } @@ -95,7 +104,10 @@ library SlotDerivation { /** * @dev Derive the location of a mapping element from the key. */ - function deriveMapping(bytes32 slot, address key) internal pure returns (bytes32 result) { + function deriveMapping( + bytes32 slot, + address key + ) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, and(key, shr(96, not(0)))) mstore(0x20, slot) @@ -106,7 +118,10 @@ library SlotDerivation { /** * @dev Derive the location of a mapping element from the key. */ - function deriveMapping(bytes32 slot, bool key) internal pure returns (bytes32 result) { + function deriveMapping( + bytes32 slot, + bool key + ) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, iszero(iszero(key))) mstore(0x20, slot) @@ -117,7 +132,10 @@ library SlotDerivation { /** * @dev Derive the location of a mapping element from the key. */ - function deriveMapping(bytes32 slot, bytes32 key) internal pure returns (bytes32 result) { + function deriveMapping( + bytes32 slot, + bytes32 key + ) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, key) mstore(0x20, slot) @@ -128,7 +146,10 @@ library SlotDerivation { /** * @dev Derive the location of a mapping element from the key. */ - function deriveMapping(bytes32 slot, uint256 key) internal pure returns (bytes32 result) { + function deriveMapping( + bytes32 slot, + uint256 key + ) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, key) mstore(0x20, slot) @@ -139,7 +160,10 @@ library SlotDerivation { /** * @dev Derive the location of a mapping element from the key. */ - function deriveMapping(bytes32 slot, int256 key) internal pure returns (bytes32 result) { + function deriveMapping( + bytes32 slot, + int256 key + ) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, key) mstore(0x20, slot) @@ -168,7 +192,10 @@ library SlotDerivation { /** * @dev Derive the location of a mapping element from the key. */ - function deriveMapping(bytes32 slot, bytes memory key) internal pure returns (bytes32 result) { + function deriveMapping( + bytes32 slot, + bytes memory key + ) internal pure returns (bytes32 result) { assembly ("memory-safe") { let length := mload(key) let begin := add(key, 0x20) @@ -355,7 +382,10 @@ library Arrays { /** * @dev Swaps the elements memory location `ptr1` and `ptr2`. */ - function _swap(uint256 ptr1, uint256 ptr2) private pure { + function _swap( + uint256 ptr1, + uint256 ptr2 + ) private pure { assembly { let value1 := mload(ptr1) let value2 := mload(ptr2) @@ -452,7 +482,10 @@ library Arrays { * * See C++'s https://en.cppreference.com/w/cpp/algorithm/lower_bound[lower_bound]. */ - function lowerBound(uint256[] storage array, uint256 element) internal view returns (uint256) { + function lowerBound( + uint256[] storage array, + uint256 element + ) internal view returns (uint256) { uint256 low = 0; uint256 high = array.length; @@ -486,7 +519,10 @@ library Arrays { * * See C++'s https://en.cppreference.com/w/cpp/algorithm/upper_bound[upper_bound]. */ - function upperBound(uint256[] storage array, uint256 element) internal view returns (uint256) { + function upperBound( + uint256[] storage array, + uint256 element + ) internal view returns (uint256) { uint256 low = 0; uint256 high = array.length; @@ -731,7 +767,10 @@ library Arrays { * * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased. */ - function unsafeSetLength(address[] storage array, uint256 len) internal { + function unsafeSetLength( + address[] storage array, + uint256 len + ) internal { assembly ("memory-safe") { sstore(array.slot, len) } @@ -742,7 +781,10 @@ library Arrays { * * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased. */ - function unsafeSetLength(bytes32[] storage array, uint256 len) internal { + function unsafeSetLength( + bytes32[] storage array, + uint256 len + ) internal { assembly ("memory-safe") { sstore(array.slot, len) } @@ -753,7 +795,10 @@ library Arrays { * * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased. */ - function unsafeSetLength(uint256[] storage array, uint256 len) internal { + function unsafeSetLength( + uint256[] storage array, + uint256 len + ) internal { assembly ("memory-safe") { sstore(array.slot, len) } @@ -764,7 +809,10 @@ library Arrays { * * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased. */ - function unsafeSetLength(bytes[] storage array, uint256 len) internal { + function unsafeSetLength( + bytes[] storage array, + uint256 len + ) internal { assembly ("memory-safe") { sstore(array.slot, len) } @@ -775,7 +823,10 @@ library Arrays { * * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased. */ - function unsafeSetLength(string[] storage array, uint256 len) internal { + function unsafeSetLength( + string[] storage array, + uint256 len + ) internal { assembly ("memory-safe") { sstore(array.slot, len) } diff --git a/src/unaudited/BN256G2.sol b/src/unaudited/BN256G2.sol index a1721df38..02f366c6e 100644 --- a/src/unaudited/BN256G2.sol +++ b/src/unaudited/BN256G2.sol @@ -100,7 +100,11 @@ library BN256G2 { return FIELD_MODULUS; } - function submod(uint256 a, uint256 b, uint256 n) internal pure returns (uint256) { + function submod( + uint256 a, + uint256 b, + uint256 n + ) internal pure returns (uint256) { return addmod(a, n - b, n); } @@ -116,7 +120,11 @@ library BN256G2 { ); } - function _FQ2Muc(uint256 xx, uint256 xy, uint256 c) internal pure returns (uint256, uint256) { + function _FQ2Muc( + uint256 xx, + uint256 xy, + uint256 c + ) internal pure returns (uint256, uint256) { return (mulmod(xx, c, FIELD_MODULUS), mulmod(xy, c, FIELD_MODULUS)); } @@ -148,7 +156,10 @@ library BN256G2 { return _FQ2Mul(xx, xy, yx, yy); } - function _FQ2Inv(uint256 x, uint256 y) internal view returns (uint256, uint256) { + function _FQ2Inv( + uint256 x, + uint256 y + ) internal view returns (uint256, uint256) { uint256 inv = _modInv( addmod(mulmod(y, y, FIELD_MODULUS), mulmod(x, x, FIELD_MODULUS), FIELD_MODULUS), FIELD_MODULUS @@ -174,7 +185,10 @@ library BN256G2 { return yyx == 0 && yyy == 0; } - function _modInv(uint256 a, uint256 n) internal view returns (uint256 result) { + function _modInv( + uint256 a, + uint256 n + ) internal view returns (uint256 result) { bool success; assembly { let freemem := mload(0x40) @@ -221,11 +235,11 @@ library BN256G2 { ) internal pure returns (uint256[6] memory pt3) { if (pt1zx == 0 && pt1zy == 0) { (pt3[PTXX], pt3[PTXY], pt3[PTYX], pt3[PTYY], pt3[PTZX], pt3[PTZY]) = - (pt2xx, pt2xy, pt2yx, pt2yy, pt2zx, pt2zy); + (pt2xx, pt2xy, pt2yx, pt2yy, pt2zx, pt2zy); return pt3; } else if (pt2zx == 0 && pt2zy == 0) { (pt3[PTXX], pt3[PTXY], pt3[PTYX], pt3[PTYY], pt3[PTZX], pt3[PTZY]) = - (pt1xx, pt1xy, pt1yx, pt1yy, pt1zx, pt1zy); + (pt1xx, pt1xy, pt1yx, pt1yy, pt1zx, pt1zy); return pt3; } diff --git a/src/unaudited/ECDSAServiceManagerBase.sol b/src/unaudited/ECDSAServiceManagerBase.sol index 191ca49a4..5d3efcc31 100644 --- a/src/unaudited/ECDSAServiceManagerBase.sol +++ b/src/unaudited/ECDSAServiceManagerBase.sol @@ -4,21 +4,25 @@ pragma solidity ^0.8.27; import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; -import {ISignatureUtilsMixinTypes} from - "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; +import { + ISignatureUtilsMixinTypes +} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; import {IServiceManager} from "../interfaces/IServiceManager.sol"; import {IServiceManagerUI} from "../interfaces/IServiceManagerUI.sol"; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; -import {IRewardsCoordinator} from - "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; +import { + IRewardsCoordinator +} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; import {IECDSAStakeRegistryTypes} from "../interfaces/IECDSAStakeRegistry.sol"; import {ECDSAStakeRegistry} from "../unaudited/ECDSAStakeRegistry.sol"; import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; abstract contract ECDSAServiceManagerBase is IServiceManager, OwnableUpgradeable { using SafeERC20 for IERC20; @@ -112,8 +116,8 @@ abstract contract ECDSAServiceManagerBase is IServiceManager, OwnableUpgradeable } function createOperatorDirectedAVSRewardsSubmission( - IRewardsCoordinator.OperatorDirectedRewardsSubmission[] calldata - operatorDirectedRewardsSubmissions + IRewardsCoordinator + .OperatorDirectedRewardsSubmission[] calldata operatorDirectedRewardsSubmissions ) external virtual onlyRewardsInitiator { _createOperatorDirectedAVSRewardsSubmission(operatorDirectedRewardsSubmissions); } @@ -195,12 +199,10 @@ abstract contract ECDSAServiceManagerBase is IServiceManager, OwnableUpgradeable IRewardsCoordinator.RewardsSubmission[] calldata rewardsSubmissions ) internal virtual { for (uint256 i = 0; i < rewardsSubmissions.length; ++i) { - rewardsSubmissions[i].token.safeTransferFrom( - msg.sender, address(this), rewardsSubmissions[i].amount - ); - rewardsSubmissions[i].token.safeIncreaseAllowance( - rewardsCoordinator, rewardsSubmissions[i].amount - ); + rewardsSubmissions[i].token + .safeTransferFrom(msg.sender, address(this), rewardsSubmissions[i].amount); + rewardsSubmissions[i].token + .safeIncreaseAllowance(rewardsCoordinator, rewardsSubmissions[i].amount); } IRewardsCoordinator(rewardsCoordinator).createAVSRewardsSubmission(rewardsSubmissions); @@ -212,31 +214,32 @@ abstract contract ECDSAServiceManagerBase is IServiceManager, OwnableUpgradeable * @param operatorDirectedRewardsSubmissions The operator-directed rewards submissions being created. */ function _createOperatorDirectedAVSRewardsSubmission( - IRewardsCoordinator.OperatorDirectedRewardsSubmission[] calldata - operatorDirectedRewardsSubmissions + IRewardsCoordinator + .OperatorDirectedRewardsSubmission[] calldata operatorDirectedRewardsSubmissions ) internal virtual { for (uint256 i = 0; i < operatorDirectedRewardsSubmissions.length; ++i) { // Calculate total amount of token to transfer uint256 totalAmount = 0; for ( - uint256 j = 0; j < operatorDirectedRewardsSubmissions[i].operatorRewards.length; ++j + uint256 j = 0; + j < operatorDirectedRewardsSubmissions[i].operatorRewards.length; + ++j ) { totalAmount += operatorDirectedRewardsSubmissions[i].operatorRewards[j].amount; } // Transfer token to ServiceManager and approve RewardsCoordinator to transfer again // in createOperatorDirectedAVSRewardsSubmission() call - operatorDirectedRewardsSubmissions[i].token.safeTransferFrom( - msg.sender, address(this), totalAmount - ); - operatorDirectedRewardsSubmissions[i].token.safeIncreaseAllowance( - rewardsCoordinator, totalAmount - ); + operatorDirectedRewardsSubmissions[i].token + .safeTransferFrom(msg.sender, address(this), totalAmount); + operatorDirectedRewardsSubmissions[i].token + .safeIncreaseAllowance(rewardsCoordinator, totalAmount); } - IRewardsCoordinator(rewardsCoordinator).createOperatorDirectedAVSRewardsSubmission( - address(this), operatorDirectedRewardsSubmissions - ); + IRewardsCoordinator(rewardsCoordinator) + .createOperatorDirectedAVSRewardsSubmission( + address(this), operatorDirectedRewardsSubmissions + ); } /** diff --git a/src/unaudited/ECDSAStakeRegistry.sol b/src/unaudited/ECDSAStakeRegistry.sol index 884d7586a..a98168d60 100644 --- a/src/unaudited/ECDSAStakeRegistry.sol +++ b/src/unaudited/ECDSAStakeRegistry.sol @@ -7,28 +7,29 @@ import { IECDSAStakeRegistryTypes } from "./ECDSAStakeRegistryStorage.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; -import {ISignatureUtilsMixinTypes} from - "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + ISignatureUtilsMixinTypes +} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; import {IServiceManager} from "../interfaces/IServiceManager.sol"; import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol"; -import {CheckpointsUpgradeable} from - "@openzeppelin-upgrades/contracts/utils/CheckpointsUpgradeable.sol"; -import {SignatureCheckerUpgradeable} from - "@openzeppelin-upgrades/contracts/utils/cryptography/SignatureCheckerUpgradeable.sol"; -import {IERC1271Upgradeable} from - "@openzeppelin-upgrades/contracts/interfaces/IERC1271Upgradeable.sol"; +import { + CheckpointsUpgradeable +} from "@openzeppelin-upgrades/contracts/utils/CheckpointsUpgradeable.sol"; +import { + SignatureCheckerUpgradeable +} from "@openzeppelin-upgrades/contracts/utils/cryptography/SignatureCheckerUpgradeable.sol"; +import { + IERC1271Upgradeable +} from "@openzeppelin-upgrades/contracts/interfaces/IERC1271Upgradeable.sol"; /// @title ECDSA Stake Registry /// @dev THIS CONTRACT IS NOT AUDITED /// @notice Manages operator registration and quorum updates for an AVS using ECDSA signatures. -contract ECDSAStakeRegistry is - IERC1271Upgradeable, - OwnableUpgradeable, - ECDSAStakeRegistryStorage -{ +contract ECDSAStakeRegistry is IERC1271Upgradeable, OwnableUpgradeable, ECDSAStakeRegistryStorage { using SignatureCheckerUpgradeable for address; using CheckpointsUpgradeable for CheckpointsUpgradeable.History; @@ -334,7 +335,10 @@ contract ECDSAStakeRegistry is /// @dev Internal function to update an operator's signing key /// @param operator The address of the operator to update the signing key for /// @param newSigningKey The new signing key to set for the operator - function _updateOperatorSigningKey(address operator, address newSigningKey) internal { + function _updateOperatorSigningKey( + address operator, + address newSigningKey + ) internal { address oldSigningKey = address(uint160(_operatorSigningKeyHistory[operator].latest())); if (newSigningKey == oldSigningKey) { return; @@ -463,7 +467,10 @@ contract ECDSAStakeRegistry is /// @notice Ensures that signers are sorted in ascending order by address. /// @param lastSigner The address of the last signer. /// @param currentSigner The address of the current signer. - function _validateSortedSigners(address lastSigner, address currentSigner) internal pure { + function _validateSortedSigners( + address lastSigner, + address currentSigner + ) internal pure { if (lastSigner >= currentSigner) { revert NotSorted(); } @@ -540,7 +547,10 @@ contract ECDSAStakeRegistry is /// @notice Validates that the cumulative stake of signed messages meets or exceeds the required threshold. /// @param signedWeight The cumulative weight of the signers that have signed the message. /// @param referenceBlock The block number to verify the stake threshold for - function _validateThresholdStake(uint256 signedWeight, uint32 referenceBlock) internal view { + function _validateThresholdStake( + uint256 signedWeight, + uint32 referenceBlock + ) internal view { uint256 totalWeight = _getTotalWeight(referenceBlock); if (signedWeight > totalWeight) { revert InvalidSignedWeight(); diff --git a/src/unaudited/ECDSAStakeRegistryStorage.sol b/src/unaudited/ECDSAStakeRegistryStorage.sol index 8d9d69d80..757093cb9 100644 --- a/src/unaudited/ECDSAStakeRegistryStorage.sol +++ b/src/unaudited/ECDSAStakeRegistryStorage.sol @@ -1,13 +1,13 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; -import {CheckpointsUpgradeable} from - "@openzeppelin-upgrades/contracts/utils/CheckpointsUpgradeable.sol"; import { - IECDSAStakeRegistry, IECDSAStakeRegistryTypes -} from "../interfaces/IECDSAStakeRegistry.sol"; + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + CheckpointsUpgradeable +} from "@openzeppelin-upgrades/contracts/utils/CheckpointsUpgradeable.sol"; +import {IECDSAStakeRegistry, IECDSAStakeRegistryTypes} from "../interfaces/IECDSAStakeRegistry.sol"; abstract contract ECDSAStakeRegistryStorage is IECDSAStakeRegistry { /// @notice Manages staking delegations through the DelegationManager interface diff --git a/src/unaudited/examples/ECDSAStakeRegistryEqualWeight.sol b/src/unaudited/examples/ECDSAStakeRegistryEqualWeight.sol index eafb32258..83a5fc9e2 100644 --- a/src/unaudited/examples/ECDSAStakeRegistryEqualWeight.sol +++ b/src/unaudited/examples/ECDSAStakeRegistryEqualWeight.sol @@ -2,10 +2,12 @@ pragma solidity ^0.8.27; import {ECDSAStakeRegistryPermissioned} from "./ECDSAStakeRegistryPermissioned.sol"; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; -import {CheckpointsUpgradeable} from - "@openzeppelin-upgrades/contracts/utils/CheckpointsUpgradeable.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + CheckpointsUpgradeable +} from "@openzeppelin-upgrades/contracts/utils/CheckpointsUpgradeable.sol"; /// @title ECDSA Stake Registry with Equal Weight /// @dev THIS CONTRACT IS NOT AUDITED diff --git a/src/unaudited/examples/ECDSAStakeRegistryPermissioned.sol b/src/unaudited/examples/ECDSAStakeRegistryPermissioned.sol index 219786ad9..c70df13e3 100644 --- a/src/unaudited/examples/ECDSAStakeRegistryPermissioned.sol +++ b/src/unaudited/examples/ECDSAStakeRegistryPermissioned.sol @@ -1,11 +1,13 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; -import {ISignatureUtilsMixinTypes} from - "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; +import { + ISignatureUtilsMixinTypes +} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; import {ECDSAStakeRegistry} from "../ECDSAStakeRegistry.sol"; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; /// @title ECDSA Stake Registry with an Operator Allowlist /// @dev THIS CONTRACT IS NOT AUDITED diff --git a/test/events/IServiceManagerBaseEvents.sol b/test/events/IServiceManagerBaseEvents.sol index 45b12cf52..9e919cd82 100644 --- a/test/events/IServiceManagerBaseEvents.sol +++ b/test/events/IServiceManagerBaseEvents.sol @@ -8,7 +8,6 @@ import { interface IServiceManagerBaseEvents { /// RewardsCoordinator EVENTS /// - /// @notice emitted when an AVS creates a valid RewardsSubmission event AVSRewardsSubmissionCreated( address indexed avs, diff --git a/test/ffi/BLSSignatureCheckerFFI.t.sol b/test/ffi/BLSSignatureCheckerFFI.t.sol index 55e6c0c4c..f65b1fa7c 100644 --- a/test/ffi/BLSSignatureCheckerFFI.t.sol +++ b/test/ffi/BLSSignatureCheckerFFI.t.sol @@ -136,8 +136,7 @@ contract BLSSignatureCheckerFFITests is MockAVSDeployer, G2Operations { uint256 numNonSigners, uint256 quorumBitmap ) internal returns (uint32, BLSSignatureChecker.NonSignerStakesAndSignature memory) { - (uint256[] memory signerPrivateKeys, uint256[] memory nonSignerPrivateKeys) = - _generateSignerAndNonSignerPrivateKeys( + (uint256[] memory signerPrivateKeys, uint256[] memory nonSignerPrivateKeys) = _generateSignerAndNonSignerPrivateKeys( pseudoRandomNumber, maxOperatorsToRegister - numNonSigners, numNonSigners ); bytes memory quorumNumbers = BitmapUtils.bitmapToBytesArray(quorumBitmap); @@ -188,23 +187,23 @@ contract BLSSignatureCheckerFFITests is MockAVSDeployer, G2Operations { _registerOperatorWithCoordinator(operators[i], quorumBitmap, pubkeys[i], defaultStake); } - uint32 referenceBlockNumber = registrationBlockNumber - + blocksBetweenRegistrations * uint32(maxOperatorsToRegister) + 1; + uint32 referenceBlockNumber = registrationBlockNumber + blocksBetweenRegistrations + * uint32(maxOperatorsToRegister) + 1; cheats.roll(referenceBlockNumber + 100); OperatorStateRetriever.CheckSignaturesIndices memory checkSignaturesIndices = - operatorStateRetriever.getCheckSignaturesIndices( - registryCoordinator, referenceBlockNumber, quorumNumbers, nonSignerOperatorIds - ); + operatorStateRetriever.getCheckSignaturesIndices( + registryCoordinator, referenceBlockNumber, quorumNumbers, nonSignerOperatorIds + ); nonSignerStakesAndSignature.nonSignerQuorumBitmapIndices = - checkSignaturesIndices.nonSignerQuorumBitmapIndices; + checkSignaturesIndices.nonSignerQuorumBitmapIndices; nonSignerStakesAndSignature.apkG2 = aggSignerApkG2; nonSignerStakesAndSignature.sigma = sigma; nonSignerStakesAndSignature.quorumApkIndices = checkSignaturesIndices.quorumApkIndices; nonSignerStakesAndSignature.totalStakeIndices = checkSignaturesIndices.totalStakeIndices; nonSignerStakesAndSignature.nonSignerStakeIndices = - checkSignaturesIndices.nonSignerStakeIndices; + checkSignaturesIndices.nonSignerStakeIndices; return (referenceBlockNumber, nonSignerStakesAndSignature); } diff --git a/test/fork/EigenDA.t.sol b/test/fork/EigenDA.t.sol index 9ccbabadf..cb323020f 100644 --- a/test/fork/EigenDA.t.sol +++ b/test/fork/EigenDA.t.sol @@ -19,15 +19,18 @@ import {IIndexRegistry} from "../../src/interfaces/IIndexRegistry.sol"; import {ISlashingRegistryCoordinator} from "../../src/interfaces/ISlashingRegistryCoordinator.sol"; import {ISocketRegistry} from "../../src/interfaces/ISocketRegistry.sol"; import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol"; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; -import {IRewardsCoordinator} from - "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + IRewardsCoordinator +} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; import { IAllocationManager, OperatorSet, @@ -42,8 +45,9 @@ import { // Import concrete implementation for deployment import {RegistryCoordinator, IRegistryCoordinatorTypes} from "../../src/RegistryCoordinator.sol"; -import {ISlashingRegistryCoordinatorTypes} from - "../../src/interfaces/ISlashingRegistryCoordinator.sol"; +import { + ISlashingRegistryCoordinatorTypes +} from "../../src/interfaces/ISlashingRegistryCoordinator.sol"; import {ServiceManagerBase} from "../../src/ServiceManagerBase.sol"; import {BLSApkRegistry} from "../../src/BLSApkRegistry.sol"; import {IndexRegistry} from "../../src/IndexRegistry.sol"; @@ -508,10 +512,10 @@ contract EigenDATest is Test { bytes32 salt = keccak256(abi.encodePacked(block.timestamp, operators[0].key.addr)); uint256 expiry = block.timestamp + 1 hours; - bytes32 operatorRegistrationDigestHash = avsDirectory - .calculateOperatorAVSRegistrationDigestHash( - operators[0].key.addr, address(serviceManager), salt, expiry - ); + bytes32 operatorRegistrationDigestHash = + avsDirectory.calculateOperatorAVSRegistrationDigestHash( + operators[0].key.addr, address(serviceManager), salt, expiry + ); bytes memory signature = OperatorLib.signWithOperatorKey(operators[0], operatorRegistrationDigestHash); @@ -522,19 +526,17 @@ contract EigenDATest is Test { BN254.G1Point memory blsSig = OperatorLib.signMessage(operators[0].signingKey, pubkeyRegistrationMessageHash); - IBLSApkRegistryTypes.PubkeyRegistrationParams memory params = IBLSApkRegistryTypes - .PubkeyRegistrationParams({ - pubkeyG1: operators[0].signingKey.publicKeyG1, - pubkeyG2: operators[0].signingKey.publicKeyG2, - pubkeyRegistrationSignature: blsSig - }); + IBLSApkRegistryTypes.PubkeyRegistrationParams memory params = + IBLSApkRegistryTypes.PubkeyRegistrationParams({ + pubkeyG1: operators[0].signingKey.publicKeyG1, + pubkeyG2: operators[0].signingKey.publicKeyG2, + pubkeyRegistrationSignature: blsSig + }); ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory operatorSignature = - ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry({ - signature: signature, - salt: salt, - expiry: expiry - }); + ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry({ + signature: signature, salt: salt, expiry: expiry + }); uint256 quorumBitmap = 0; for (uint256 i = 0; i < quorumsToRegister.length; i++) { @@ -543,9 +545,8 @@ contract EigenDATest is Test { bytes memory quorumNumbersBytes = BitmapUtils.bitmapToBytesArray(quorumBitmap); vm.expectRevert(bytes4(keccak256("M2QuorumRegistrationIsDisabled()"))); - IRegistryCoordinator(address(registryCoordinator)).registerOperator( - quorumNumbersBytes, "socket", params, operatorSignature - ); + IRegistryCoordinator(address(registryCoordinator)) + .registerOperator(quorumNumbersBytes, "socket", params, operatorSignature); vm.stopPrank(); console.log("Successfully verified M2 registration is disabled"); @@ -646,11 +647,11 @@ contract EigenDATest is Test { console.log("Creating a new slashable stake quorum (quorum 1)..."); ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParam = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 100, - kickBIPsOfOperatorStake: 10500, // 105% - kickBIPsOfTotalStake: 100 // 1% - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 100, + kickBIPsOfOperatorStake: 10500, // 105% + kickBIPsOfTotalStake: 100 // 1% + }); IStakeRegistryTypes.StrategyParams[] memory strategyParams = new IStakeRegistryTypes.StrategyParams[](1); @@ -673,11 +674,11 @@ contract EigenDATest is Test { // Define parameters for the new quorum ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParam = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 100, - kickBIPsOfOperatorStake: 10500, // 105% - kickBIPsOfTotalStake: 100 // 1% - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 100, + kickBIPsOfOperatorStake: 10500, // 105% + kickBIPsOfTotalStake: 100 // 1% + }); IStakeRegistryTypes.StrategyParams[] memory strategyParams = new IStakeRegistryTypes.StrategyParams[](1); @@ -821,20 +822,19 @@ contract EigenDATest is Test { ); IRegistryCoordinatorTypes.SlashingRegistryParams memory slashingParams = - IRegistryCoordinatorTypes.SlashingRegistryParams({ - stakeRegistry: stakeRegistry, - blsApkRegistry: apkRegistry, - indexRegistry: indexRegistry, - socketRegistry: ISocketRegistry(socketRegistry), - allocationManager: allocationManager, - pauserRegistry: IPauserRegistry(eigenDAData.permissions.pauserRegistry) - }); + IRegistryCoordinatorTypes.SlashingRegistryParams({ + stakeRegistry: stakeRegistry, + blsApkRegistry: apkRegistry, + indexRegistry: indexRegistry, + socketRegistry: ISocketRegistry(socketRegistry), + allocationManager: allocationManager, + pauserRegistry: IPauserRegistry(eigenDAData.permissions.pauserRegistry) + }); IRegistryCoordinatorTypes.RegistryCoordinatorParams memory params = - IRegistryCoordinatorTypes.RegistryCoordinatorParams({ - serviceManager: serviceManager, - slashingParams: slashingParams - }); + IRegistryCoordinatorTypes.RegistryCoordinatorParams({ + serviceManager: serviceManager, slashingParams: slashingParams + }); newRegistryCoordinatorImpl = address(new RegistryCoordinator(params)); diff --git a/test/fork/End2End.t.sol b/test/fork/End2End.t.sol index 5624eb3ef..d9a432ed1 100644 --- a/test/fork/End2End.t.sol +++ b/test/fork/End2End.t.sol @@ -8,10 +8,12 @@ import {OperatorLib} from "../utils/OperatorLib.sol"; import {UpgradeableProxyLib} from "../unit/UpgradeableProxyLib.sol"; import {MiddlewareDeployLib} from "../utils/MiddlewareDeployLib.sol"; import {BN254} from "../../src/libraries/BN254.sol"; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; -import {IAllocationManagerTypes} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IAllocationManagerTypes +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import {IServiceManager} from "../../src/interfaces/IServiceManager.sol"; import {IStakeRegistry, IStakeRegistryTypes} from "../../src/interfaces/IStakeRegistry.sol"; @@ -20,8 +22,9 @@ import {RegistryCoordinator} from "../../src/RegistryCoordinator.sol"; import {IRegistryCoordinator} from "../../src/interfaces/IRegistryCoordinator.sol"; import {OperatorSet} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {AllocationManager} from "eigenlayer-contracts/src/contracts/core/AllocationManager.sol"; -import {PermissionController} from - "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; +import { + PermissionController +} from "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; import {ServiceManagerMock} from "../mocks/ServiceManagerMock.sol"; import { ISlashingRegistryCoordinator, @@ -195,19 +198,20 @@ contract End2EndForkTest is Test { // Set the metadata URI, AVS Registrar and UAM apointee for operator set creation vm.startPrank(middlewareDeployment.serviceManager); - AllocationManager(coreDeployment.allocationManager).updateAVSMetadataURI( - middlewareDeployment.serviceManager, "metadata" - ); - AllocationManager(coreDeployment.allocationManager).setAVSRegistrar( - middlewareDeployment.serviceManager, - IAVSRegistrar(middlewareDeployment.registryCoordinator) - ); - PermissionController(coreDeployment.permissionController).setAppointee( - address(middlewareDeployment.serviceManager), - address(middlewareDeployment.registryCoordinator), - coreDeployment.allocationManager, - bytes4(keccak256("createOperatorSets(address,(uint32,address[],address)[])")) - ); + AllocationManager(coreDeployment.allocationManager) + .updateAVSMetadataURI(middlewareDeployment.serviceManager, "metadata"); + AllocationManager(coreDeployment.allocationManager) + .setAVSRegistrar( + middlewareDeployment.serviceManager, + IAVSRegistrar(middlewareDeployment.registryCoordinator) + ); + PermissionController(coreDeployment.permissionController) + .setAppointee( + address(middlewareDeployment.serviceManager), + address(middlewareDeployment.registryCoordinator), + coreDeployment.allocationManager, + bytes4(keccak256("createOperatorSets(address,(uint32,address[],address)[])")) + ); vm.stopPrank(); } @@ -249,18 +253,16 @@ contract End2EndForkTest is Test { ) internal { // Verify and register operators for (uint256 i = 0; i < 5; i++) { - bool isRegistered = IDelegationManager(coreDeployment.delegationManager).isOperator( - operators[i].key.addr - ); + bool isRegistered = IDelegationManager(coreDeployment.delegationManager) + .isOperator(operators[i].key.addr); assertFalse(isRegistered, "Operator should not be registered"); } _registerOperatorsAsEigenLayerOperators(operators, coreDeployment.delegationManager); for (uint256 i = 0; i < 5; i++) { - bool isRegistered = IDelegationManager(coreDeployment.delegationManager).isOperator( - operators[i].key.addr - ); + bool isRegistered = IDelegationManager(coreDeployment.delegationManager) + .isOperator(operators[i].key.addr); assertTrue(isRegistered, "Operator should be registered"); } @@ -300,17 +302,14 @@ contract End2EndForkTest is Test { // Create first quorum ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 10, - kickBIPsOfOperatorStake: 100, - kickBIPsOfTotalStake: 100 - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 10, kickBIPsOfOperatorStake: 100, kickBIPsOfTotalStake: 100 + }); IStakeRegistry.StrategyParams[] memory strategyParams = new IStakeRegistry.StrategyParams[](1); strategyParams[0] = IStakeRegistryTypes.StrategyParams({ - strategy: IStrategy(middlewareConfig.strategy), - multiplier: 1 ether + strategy: IStrategy(middlewareConfig.strategy), multiplier: 1 ether }); RegistryCoordinator(middlewareDeployment.registryCoordinator) @@ -339,9 +338,8 @@ contract End2EndForkTest is Test { bytes memory quorumNumbers = new bytes(1); quorumNumbers[0] = bytes1(uint8(0)); vm.prank(middlewareConfig.admin); - RegistryCoordinator(middlewareDeployment.registryCoordinator).updateOperatorsForQuorum( - middlewareConfig.operators, quorumNumbers - ); + RegistryCoordinator(middlewareDeployment.registryCoordinator) + .updateOperatorsForQuorum(middlewareConfig.operators, quorumNumbers); } function _setupSecondQuorumAndOperatorSet( @@ -355,20 +353,22 @@ contract End2EndForkTest is Test { IStakeRegistry.StrategyParams[] memory strategyParams = new IStakeRegistry.StrategyParams[](1); strategyParams[0] = IStakeRegistryTypes.StrategyParams({ - strategy: IStrategy(middlewareConfig.strategy), - multiplier: 1 ether + strategy: IStrategy(middlewareConfig.strategy), multiplier: 1 ether }); ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 10, - kickBIPsOfOperatorStake: 0, - kickBIPsOfTotalStake: 0 - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 10, kickBIPsOfOperatorStake: 0, kickBIPsOfTotalStake: 0 + }); - RegistryCoordinator(middlewareDeployment.registryCoordinator).createSlashableStakeQuorum( - operatorSetParams, 100, strategyParams, 10, address(middlewareDeployment.serviceManager) - ); + RegistryCoordinator(middlewareDeployment.registryCoordinator) + .createSlashableStakeQuorum( + operatorSetParams, + 100, + strategyParams, + 10, + address(middlewareDeployment.serviceManager) + ); vm.stopPrank(); _setupOperatorAllocations( @@ -397,9 +397,8 @@ contract End2EndForkTest is Test { quorumNumbers[0] = bytes1(uint8(1)); vm.prank(middlewareConfig.admin); - RegistryCoordinator(middlewareDeployment.registryCoordinator).updateOperatorsForQuorum( - middlewareConfig.operators, quorumNumbers - ); + RegistryCoordinator(middlewareDeployment.registryCoordinator) + .updateOperatorsForQuorum(middlewareConfig.operators, quorumNumbers); } function _setupOperatorAllocations( @@ -431,9 +430,7 @@ contract End2EndForkTest is Test { IAllocationManagerTypes.AllocateParams[] memory allocParams = new IAllocationManagerTypes.AllocateParams[](1); allocParams[0] = IAllocationManagerTypes.AllocateParams({ - operatorSet: operatorSet, - strategies: allocStrategies, - newMagnitudes: magnitudes + operatorSet: operatorSet, strategies: allocStrategies, newMagnitudes: magnitudes }); for (uint256 i = 0; i < 5; i++) { @@ -452,14 +449,14 @@ contract End2EndForkTest is Test { ConfigData memory middlewareConfig, MiddlewareDeployLib.MiddlewareDeployData memory middlewareDeployment ) internal { - IAllocationManagerTypes.SlashingParams memory slashingParams = IAllocationManagerTypes - .SlashingParams({ - operator: operators[0].key.addr, - operatorSetId: 1, - strategies: new IStrategy[](1), - wadsToSlash: new uint256[](1), - description: "Test slashing" - }); + IAllocationManagerTypes.SlashingParams memory slashingParams = + IAllocationManagerTypes.SlashingParams({ + operator: operators[0].key.addr, + operatorSetId: 1, + strategies: new IStrategy[](1), + wadsToSlash: new uint256[](1), + description: "Test slashing" + }); slashingParams.strategies[0] = IStrategy(middlewareConfig.strategy); slashingParams.wadsToSlash[0] = 0.5e18; diff --git a/test/harnesses/AVSDirectoryHarness.sol b/test/harnesses/AVSDirectoryHarness.sol index 6124ce0c3..f0f0fe2d7 100644 --- a/test/harnesses/AVSDirectoryHarness.sol +++ b/test/harnesses/AVSDirectoryHarness.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; import {AVSDirectory} from "eigenlayer-contracts/src/contracts/core/AVSDirectory.sol"; import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol"; diff --git a/test/harnesses/BLSApkRegistryHarness.sol b/test/harnesses/BLSApkRegistryHarness.sol index b97ba9555..d6285bbcd 100644 --- a/test/harnesses/BLSApkRegistryHarness.sol +++ b/test/harnesses/BLSApkRegistryHarness.sol @@ -9,7 +9,10 @@ contract BLSApkRegistryHarness is BLSApkRegistry { ISlashingRegistryCoordinator _slashingRegistryCoordinator ) BLSApkRegistry(_slashingRegistryCoordinator) {} - function setBLSPublicKey(address account, BN254.G1Point memory pk) external { + function setBLSPublicKey( + address account, + BN254.G1Point memory pk + ) external { bytes32 pubkeyHash = BN254.hashG1Point(pk); // store updates operatorToPubkeyHash[account] = pubkeyHash; diff --git a/test/harnesses/BLSSigCheckUtilsHarness.sol b/test/harnesses/BLSSigCheckUtilsHarness.sol index a7d4decc7..de5240b90 100644 --- a/test/harnesses/BLSSigCheckUtilsHarness.sol +++ b/test/harnesses/BLSSigCheckUtilsHarness.sol @@ -48,11 +48,17 @@ contract BLSSigCheckUtilsHarness { * Comparators library functions * */ - function lt(uint256 a, uint256 b) public pure returns (bool) { + function lt( + uint256 a, + uint256 b + ) public pure returns (bool) { return Comparators.lt(a, b); } - function gt(uint256 a, uint256 b) public pure returns (bool) { + function gt( + uint256 a, + uint256 b + ) public pure returns (bool) { return Comparators.gt(a, b); } @@ -67,7 +73,10 @@ contract BLSSigCheckUtilsHarness { return namespace.erc7201Slot(); } - function offset(bytes32 slot, uint256 pos) public pure returns (bytes32) { + function offset( + bytes32 slot, + uint256 pos + ) public pure returns (bytes32) { return slot.offset(pos); } @@ -77,31 +86,52 @@ contract BLSSigCheckUtilsHarness { return slot.deriveArray(); } - function deriveMappingAddress(bytes32 slot, address key) public pure returns (bytes32) { + function deriveMappingAddress( + bytes32 slot, + address key + ) public pure returns (bytes32) { return slot.deriveMapping(key); } - function deriveMappingBool(bytes32 slot, bool key) public pure returns (bytes32) { + function deriveMappingBool( + bytes32 slot, + bool key + ) public pure returns (bytes32) { return slot.deriveMapping(key); } - function deriveMappingBytes32(bytes32 slot, bytes32 key) public pure returns (bytes32) { + function deriveMappingBytes32( + bytes32 slot, + bytes32 key + ) public pure returns (bytes32) { return slot.deriveMapping(key); } - function deriveMappingUint256(bytes32 slot, uint256 key) public pure returns (bytes32) { + function deriveMappingUint256( + bytes32 slot, + uint256 key + ) public pure returns (bytes32) { return slot.deriveMapping(key); } - function deriveMappingInt256(bytes32 slot, int256 key) public pure returns (bytes32) { + function deriveMappingInt256( + bytes32 slot, + int256 key + ) public pure returns (bytes32) { return slot.deriveMapping(key); } - function deriveMappingString(bytes32 slot, string memory key) public pure returns (bytes32) { + function deriveMappingString( + bytes32 slot, + string memory key + ) public pure returns (bytes32) { return slot.deriveMapping(key); } - function deriveMappingBytes(bytes32 slot, bytes memory key) public pure returns (bytes32) { + function deriveMappingBytes( + bytes32 slot, + bytes memory key + ) public pure returns (bytes32) { return slot.deriveMapping(key); } diff --git a/test/harnesses/BitmapUtilsWrapper.sol b/test/harnesses/BitmapUtilsWrapper.sol index 982d2e1a7..8ce5b5d2f 100644 --- a/test/harnesses/BitmapUtilsWrapper.sol +++ b/test/harnesses/BitmapUtilsWrapper.sol @@ -29,11 +29,17 @@ contract BitmapUtilsWrapper { return BitmapUtils.countNumOnes(n); } - function isSet(uint256 bitmap, uint8 numberToCheckForInclusion) external pure returns (bool) { + function isSet( + uint256 bitmap, + uint8 numberToCheckForInclusion + ) external pure returns (bool) { return BitmapUtils.isSet(bitmap, numberToCheckForInclusion); } - function setBit(uint256 bitmap, uint8 bit) external pure returns (uint256) { + function setBit( + uint256 bitmap, + uint8 bit + ) external pure returns (uint256) { return BitmapUtils.setBit(bitmap, bit); } @@ -43,19 +49,31 @@ contract BitmapUtilsWrapper { return BitmapUtils.isEmpty(bitmap); } - function noBitsInCommon(uint256 a, uint256 b) external pure returns (bool) { + function noBitsInCommon( + uint256 a, + uint256 b + ) external pure returns (bool) { return BitmapUtils.noBitsInCommon(a, b); } - function isSubsetOf(uint256 a, uint256 b) external pure returns (bool) { + function isSubsetOf( + uint256 a, + uint256 b + ) external pure returns (bool) { return BitmapUtils.isSubsetOf(a, b); } - function plus(uint256 a, uint256 b) external pure returns (uint256) { + function plus( + uint256 a, + uint256 b + ) external pure returns (uint256) { return BitmapUtils.plus(a, b); } - function minus(uint256 a, uint256 b) external pure returns (uint256) { + function minus( + uint256 a, + uint256 b + ) external pure returns (uint256) { return BitmapUtils.minus(a, b); } } diff --git a/test/harnesses/RegistryCoordinatorHarness.t.sol b/test/harnesses/RegistryCoordinatorHarness.t.sol index f580f0430..dc0272084 100644 --- a/test/harnesses/RegistryCoordinatorHarness.t.sol +++ b/test/harnesses/RegistryCoordinatorHarness.t.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol"; @@ -28,8 +29,7 @@ contract RegistryCoordinatorHarness is RegistryCoordinator, Test { IPauserRegistry _pauserRegistry, string memory _version ) - RegistryCoordinator( - IRegistryCoordinatorTypes.RegistryCoordinatorParams( + RegistryCoordinator(IRegistryCoordinatorTypes.RegistryCoordinatorParams( _serviceManager, IRegistryCoordinatorTypes.SlashingRegistryParams( _stakeRegistry, @@ -39,8 +39,7 @@ contract RegistryCoordinatorHarness is RegistryCoordinator, Test { _allocationManager, _pauserRegistry ) - ) - ) + )) { _transferOwnership(msg.sender); } @@ -51,7 +50,10 @@ contract RegistryCoordinatorHarness is RegistryCoordinator, Test { quorumCount = count; } - function setOperatorId(address operator, bytes32 operatorId) external { + function setOperatorId( + address operator, + bytes32 operatorId + ) external { _operatorInfo[operator].operatorId = operatorId; } @@ -73,12 +75,18 @@ contract RegistryCoordinatorHarness is RegistryCoordinator, Test { } // @notice exposes the internal `_deregisterOperator` function, overriding all access controls - function _deregisterOperatorExternal(address operator, bytes calldata quorumNumbers) external { + function _deregisterOperatorExternal( + address operator, + bytes calldata quorumNumbers + ) external { _deregisterOperator(operator, quorumNumbers); } // @notice exposes the internal `_updateOperatorBitmap` function, overriding all access controls - function _updateOperatorBitmapExternal(bytes32 operatorId, uint192 quorumBitmap) external { + function _updateOperatorBitmapExternal( + bytes32 operatorId, + uint192 quorumBitmap + ) external { _updateOperatorBitmap(operatorId, quorumBitmap); } diff --git a/test/harnesses/StakeRegistryHarness.sol b/test/harnesses/StakeRegistryHarness.sol index 2a2055411..970816ae2 100644 --- a/test/harnesses/StakeRegistryHarness.sol +++ b/test/harnesses/StakeRegistryHarness.sol @@ -20,15 +20,24 @@ contract StakeRegistryHarness is StakeRegistry { return _recordOperatorStakeUpdate(operatorId, quorumNumber, newStake); } - function recordTotalStakeUpdate(uint8 quorumNumber, int256 stakeDelta) external { + function recordTotalStakeUpdate( + uint8 quorumNumber, + int256 stakeDelta + ) external { _recordTotalStakeUpdate(quorumNumber, stakeDelta); } - function calculateDelta(uint96 prev, uint96 cur) external pure returns (int256) { + function calculateDelta( + uint96 prev, + uint96 cur + ) external pure returns (int256) { return _calculateDelta(prev, cur); } - function applyDelta(uint96 value, int256 delta) external pure returns (uint96) { + function applyDelta( + uint96 value, + int256 delta + ) external pure returns (uint96) { return _applyDelta(value, delta); } } diff --git a/test/integration/CoreRegistration.t.sol b/test/integration/CoreRegistration.t.sol index ec5590516..c2ac89df9 100644 --- a/test/integration/CoreRegistration.t.sol +++ b/test/integration/CoreRegistration.t.sol @@ -14,12 +14,15 @@ import { IDelegationManagerTypes } from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; import {RewardsCoordinator} from "eigenlayer-contracts/src/contracts/core/RewardsCoordinator.sol"; -import {IRewardsCoordinator} from - "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; -import {PermissionController} from - "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; -import {ITransparentUpgradeableProxy} from - "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { + IRewardsCoordinator +} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; +import { + PermissionController +} from "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; +import { + ITransparentUpgradeableProxy +} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import { ISignatureUtilsMixin, ISignatureUtilsMixinTypes @@ -151,9 +154,9 @@ contract Test_CoreRegistration is MockAVSDeployer { // Get operator signature ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory operatorSignature = - _getOperatorSignature( - operatorPrivateKey, operator, address(serviceManager), emptySalt, maxExpiry - ); + _getOperatorSignature( + operatorPrivateKey, operator, address(serviceManager), emptySalt, maxExpiry + ); // set operator as registered in Eigenlayer delegationMock.setIsOperator(operator, true); @@ -240,9 +243,9 @@ contract Test_CoreRegistration is MockAVSDeployer { ) internal { // Get operator signature ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory operatorSignature = - _getOperatorSignature( - operatorPrivateKey, operator, address(serviceManager), emptySalt, maxExpiry - ); + _getOperatorSignature( + operatorPrivateKey, operator, address(serviceManager), emptySalt, maxExpiry + ); // set operator as registered in Eigenlayer delegationMock.setIsOperator(operator, true); diff --git a/test/integration/IntegrationBase.t.sol b/test/integration/IntegrationBase.t.sol index 0122ca956..9e273cffc 100644 --- a/test/integration/IntegrationBase.t.sol +++ b/test/integration/IntegrationBase.t.sol @@ -20,7 +20,10 @@ abstract contract IntegrationBase is IntegrationConfig { /// RegistryCoordinator: - function assert_HasOperatorInfoWithId(User user, string memory err) internal { + function assert_HasOperatorInfoWithId( + User user, + string memory err + ) internal { bytes32 expectedId = user.operatorId(); bytes32 actualId = slashingRegistryCoordinator.getOperatorId(address(user)); @@ -28,7 +31,10 @@ abstract contract IntegrationBase is IntegrationConfig { } /// @dev Also checks that the user has NEVER_REGISTERED status - function assert_HasNoOperatorInfo(User user, string memory err) internal { + function assert_HasNoOperatorInfo( + User user, + string memory err + ) internal { ISlashingRegistryCoordinatorTypes.OperatorInfo memory info = _getOperatorInfo(user); assertEq(info.operatorId, bytes32(0), err); @@ -37,21 +43,30 @@ abstract contract IntegrationBase is IntegrationConfig { ); } - function assert_HasRegisteredStatus(User user, string memory err) internal { + function assert_HasRegisteredStatus( + User user, + string memory err + ) internal { ISlashingRegistryCoordinatorTypes.OperatorStatus status = slashingRegistryCoordinator.getOperatorStatus(address(user)); assertTrue(status == ISlashingRegistryCoordinatorTypes.OperatorStatus.REGISTERED, err); } - function assert_HasDeregisteredStatus(User user, string memory err) internal { + function assert_HasDeregisteredStatus( + User user, + string memory err + ) internal { ISlashingRegistryCoordinatorTypes.OperatorStatus status = slashingRegistryCoordinator.getOperatorStatus(address(user)); assertTrue(status == ISlashingRegistryCoordinatorTypes.OperatorStatus.DEREGISTERED, err); } - function assert_EmptyQuorumBitmap(User user, string memory err) internal { + function assert_EmptyQuorumBitmap( + User user, + string memory err + ) internal { uint192 bitmap = slashingRegistryCoordinator.getCurrentQuorumBitmap(user.operatorId()); assertTrue(bitmap == 0, err); @@ -99,7 +114,10 @@ abstract contract IntegrationBase is IntegrationConfig { } /// @dev Checks whether each of the quorums has been initialized in the RegistryCoordinator - function assert_QuorumsExist(bytes memory quorums, string memory err) internal { + function assert_QuorumsExist( + bytes memory quorums, + string memory err + ) internal { uint8 count = slashingRegistryCoordinator.quorumCount(); for (uint256 i = 0; i < quorums.length; i++) { uint8 quorum = uint8(quorums[i]); @@ -110,7 +128,10 @@ abstract contract IntegrationBase is IntegrationConfig { /// BLSApkRegistry: - function assert_NoRegisteredPubkey(User user, string memory err) internal { + function assert_NoRegisteredPubkey( + User user, + string memory err + ) internal { (uint256 pubkeyX, uint256 pubkeyY) = blsApkRegistry.operatorToPubkey(address(user)); bytes32 pubkeyHash = blsApkRegistry.operatorToPubkeyHash(address(user)); @@ -119,7 +140,10 @@ abstract contract IntegrationBase is IntegrationConfig { assertEq(pubkeyHash, 0, err); } - function assert_HasRegisteredPubkey(User user, string memory err) internal { + function assert_HasRegisteredPubkey( + User user, + string memory err + ) internal { BN254.G1Point memory expectedPubkey = user.pubkeyG1(); (uint256 actualPkX, uint256 actualPkY) = blsApkRegistry.operatorToPubkey(address(user)); @@ -136,7 +160,11 @@ abstract contract IntegrationBase is IntegrationConfig { /// StakeRegistry: - function assert_NoExistingStake(User user, bytes memory quorums, string memory err) internal { + function assert_NoExistingStake( + User user, + bytes memory quorums, + string memory err + ) internal { bytes32 operatorId = user.operatorId(); for (uint256 i = 0; i < quorums.length; i++) { @@ -186,7 +214,10 @@ abstract contract IntegrationBase is IntegrationConfig { /// @dev Checks that we're specifically UNDER the max operator count, i.e. we are allowing /// at least one more operator to register - function assert_BelowMaxOperators(bytes memory quorums, string memory err) internal { + function assert_BelowMaxOperators( + bytes memory quorums, + string memory err + ) internal { for (uint256 i = 0; i < quorums.length; i++) { uint8 quorum = uint8(quorums[i]); @@ -200,14 +231,20 @@ abstract contract IntegrationBase is IntegrationConfig { /// AVSDirectory: - function assert_NotRegisteredToAVS(User operator, string memory err) internal { + function assert_NotRegisteredToAVS( + User operator, + string memory err + ) internal { IAVSDirectoryTypes.OperatorAVSRegistrationStatus status = avsDirectory.avsOperatorStatus(address(serviceManager), address(operator)); assertTrue(status == IAVSDirectoryTypes.OperatorAVSRegistrationStatus.UNREGISTERED, err); } - function assert_IsRegisteredToAVS(User operator, string memory err) internal { + function assert_IsRegisteredToAVS( + User operator, + string memory err + ) internal { IAVSDirectory.OperatorAVSRegistrationStatus status = avsDirectory.avsOperatorStatus(address(serviceManager), address(operator)); @@ -273,7 +310,10 @@ abstract contract IntegrationBase is IntegrationConfig { } } - function assert_Snap_Unchanged_OperatorInfo(User user, string memory err) internal { + function assert_Snap_Unchanged_OperatorInfo( + User user, + string memory err + ) internal { ISlashingRegistryCoordinatorTypes.OperatorInfo memory curInfo = _getOperatorInfo(user); ISlashingRegistryCoordinatorTypes.OperatorInfo memory prevInfo = _getPrevOperatorInfo(user); @@ -281,7 +321,10 @@ abstract contract IntegrationBase is IntegrationConfig { assertTrue(prevInfo.status == curInfo.status, err); } - function assert_Snap_Unchanged_QuorumBitmap(User user, string memory err) internal { + function assert_Snap_Unchanged_QuorumBitmap( + User user, + string memory err + ) internal { bytes32 operatorId = user.operatorId(); uint192 curBitmap = _getQuorumBitmap(operatorId); @@ -325,7 +368,10 @@ abstract contract IntegrationBase is IntegrationConfig { } } - function assert_Snap_Unchanged_QuorumApk(bytes memory quorums, string memory err) internal { + function assert_Snap_Unchanged_QuorumApk( + bytes memory quorums, + string memory err + ) internal { BN254.G1Point[] memory curApks = _getQuorumApks(quorums); BN254.G1Point[] memory prevApks = _getPrevQuorumApks(quorums); @@ -523,7 +569,10 @@ abstract contract IntegrationBase is IntegrationConfig { } } - function assert_Snap_Unchanged_TotalStake(bytes memory quorums, string memory err) internal { + function assert_Snap_Unchanged_TotalStake( + bytes memory quorums, + string memory err + ) internal { uint96[] memory curTotalStakes = _getTotalStakes(quorums); uint96[] memory prevTotalStakes = _getPrevTotalStakes(quorums); @@ -533,7 +582,10 @@ abstract contract IntegrationBase is IntegrationConfig { } /// @dev After registering for quorums, checks that the totalOperatorsForQuorum increased by 1 - function assert_Snap_Added_OperatorCount(bytes memory quorums, string memory err) internal { + function assert_Snap_Added_OperatorCount( + bytes memory quorums, + string memory err + ) internal { uint32[] memory curOperatorCounts = _getOperatorCounts(quorums); uint32[] memory prevOperatorCounts = _getPrevOperatorCounts(quorums); @@ -542,7 +594,10 @@ abstract contract IntegrationBase is IntegrationConfig { } } - function assert_Snap_Reduced_OperatorCount(bytes memory quorums, string memory err) internal { + function assert_Snap_Reduced_OperatorCount( + bytes memory quorums, + string memory err + ) internal { uint32[] memory curOperatorCounts = _getOperatorCounts(quorums); uint32[] memory prevOperatorCounts = _getPrevOperatorCounts(quorums); @@ -738,7 +793,10 @@ abstract contract IntegrationBase is IntegrationConfig { assertEq(prevQueuedWithdrawals + withdrawals.length, curQueuedWithdrawals, err); } - function assert_Snap_Added_QueuedWithdrawal(User staker, string memory err) internal { + function assert_Snap_Added_QueuedWithdrawal( + User staker, + string memory err + ) internal { uint256 curQueuedWithdrawal = _getCumulativeWithdrawals(staker); // Use timewarp to get previous cumulative withdrawals uint256 prevQueuedWithdrawal = _getPrevCumulativeWithdrawals(staker); @@ -810,7 +868,10 @@ abstract contract IntegrationBase is IntegrationConfig { return tokens; } - function _contains(bytes32[] memory operatorIds, User operator) internal view returns (bool) { + function _contains( + bytes32[] memory operatorIds, + User operator + ) internal view returns (bool) { bytes32 checkId = operator.operatorId(); for (uint256 i = 0; i < operatorIds.length; i++) { @@ -941,7 +1002,10 @@ abstract contract IntegrationBase is IntegrationConfig { /// StakeRegistry: - function _getStakes(User user, bytes memory quorums) internal view returns (uint96[] memory) { + function _getStakes( + User user, + bytes memory quorums + ) internal view returns (uint96[] memory) { bytes32 operatorId = user.operatorId(); uint96[] memory stakes = new uint96[](quorums.length); @@ -959,7 +1023,10 @@ abstract contract IntegrationBase is IntegrationConfig { return _getStakes(user, quorums); } - function _getWeights(User user, bytes memory quorums) internal view returns (uint96[] memory) { + function _getWeights( + User user, + bytes memory quorums + ) internal view returns (uint96[] memory) { uint96[] memory weights = new uint96[](quorums.length); for (uint256 i = 0; i < quorums.length; i++) { @@ -978,7 +1045,10 @@ abstract contract IntegrationBase is IntegrationConfig { /// @dev Calculates the amount added to the user's stake weight for each quorum since the last snapshot /// NOTE: Fails if the user's stake weight was reduced - function _getAddedWeight(User user, bytes memory quorums) internal returns (uint96[] memory) { + function _getAddedWeight( + User user, + bytes memory quorums + ) internal returns (uint96[] memory) { uint96[] memory curWeights = _getWeights(user, quorums); uint96[] memory prevWeights = _getPrevWeights(user, quorums); diff --git a/test/integration/IntegrationChecks.t.sol b/test/integration/IntegrationChecks.t.sol index 6792cf5b8..1b425d1cf 100644 --- a/test/integration/IntegrationChecks.t.sol +++ b/test/integration/IntegrationChecks.t.sol @@ -36,7 +36,10 @@ contract IntegrationChecks is IntegrationBase { * POST-REGISTER CHECKS * */ - function check_Register_State(User operator, bytes memory quorums) internal { + function check_Register_State( + User operator, + bytes memory quorums + ) internal { _log("check_Register_State", operator); // AllocationManager @@ -92,9 +95,8 @@ contract IntegrationChecks is IntegrationBase { ) internal { _log("check_Churned_State", incomingOperator); - bytes memory combinedQuorums = churnedQuorums.orderedBytesArrayToBitmap().plus( - standardQuorums.orderedBytesArrayToBitmap() - ).bitmapToBytesArray(); + bytes memory combinedQuorums = churnedQuorums.orderedBytesArrayToBitmap() + .plus(standardQuorums.orderedBytesArrayToBitmap()).bitmapToBytesArray(); // RegistryCoordinator assert_HasOperatorInfoWithId(incomingOperator, "operatorInfo should have operatorId"); @@ -329,7 +331,10 @@ contract IntegrationChecks is IntegrationBase { /// @dev Validate state when, after exiting from the core contracts, updateOperators is called /// We expect that the operator is completely deregistered. /// NOTE: This is a combination of check_Deregister_State and check_CompleteDeregister_State - function check_WithdrawUpdate_State(User operator, bytes memory quorums) internal { + function check_WithdrawUpdate_State( + User operator, + bytes memory quorums + ) internal { _log("check_WithdrawUpdate_State", operator); // AllocationManager @@ -372,7 +377,10 @@ contract IntegrationChecks is IntegrationBase { } /// @dev Used to validate a stake update after NO core balance changes occured - function check_NoUpdate_State(User operator, bytes memory quorums) internal { + function check_NoUpdate_State( + User operator, + bytes memory quorums + ) internal { _log("check_NoChangeUpdate_State", operator); // RegistryCoordinator @@ -407,7 +415,10 @@ contract IntegrationChecks is IntegrationBase { */ /// @dev Check that the operator correctly deregistered from some quorums - function check_Deregister_State(User operator, bytes memory quorums) internal { + function check_Deregister_State( + User operator, + bytes memory quorums + ) internal { _log("check_Deregister_State", operator); // AllocationManager @@ -470,7 +481,10 @@ contract IntegrationChecks is IntegrationBase { /// example output: /// - check_Register_State(Operator0) - function _log(string memory s, User user) internal { + function _log( + string memory s, + User user + ) internal { emit log(string.concat("- ", s, "(", user.NAME(), ")")); } } diff --git a/test/integration/IntegrationConfig.t.sol b/test/integration/IntegrationConfig.t.sol index b0a9376ed..95b1ab1a6 100644 --- a/test/integration/IntegrationConfig.t.sol +++ b/test/integration/IntegrationConfig.t.sol @@ -6,12 +6,12 @@ import "forge-std/Test.sol"; import "./IntegrationDeployer.t.sol"; import "../ffi/util/G2Operations.sol"; import "./utils/BitmapStrings.t.sol"; -import {ISlashingRegistryCoordinatorTypes} from - "../../src/interfaces/ISlashingRegistryCoordinator.sol"; +import { + ISlashingRegistryCoordinatorTypes +} from "../../src/interfaces/ISlashingRegistryCoordinator.sol"; contract Constants { /// IECDSAStakeRegistryTypes.Quorum Config: - /// @dev Default OperatorSetParam values used to initialize quorums /// NOTE: This means each quorum has an operator limit of MAX_OPERATOR_COUNT by default /// This is a low number because each operator receives its own BLS keypair, which @@ -172,11 +172,11 @@ contract IntegrationConfig is IntegrationDeployer, G2Operations, Constants { // Default OperatorSetParams for all quorums ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSet = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: MAX_OPERATOR_COUNT, - kickBIPsOfOperatorStake: KICK_BIPS_OPERATOR_STAKE, - kickBIPsOfTotalStake: KICK_BIPS_TOTAL_STAKE - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: MAX_OPERATOR_COUNT, + kickBIPsOfOperatorStake: KICK_BIPS_OPERATOR_STAKE, + kickBIPsOfTotalStake: KICK_BIPS_TOTAL_STAKE + }); // Initialize each quorum for (uint256 i = 0; i < quorumCount; i++) { @@ -249,11 +249,9 @@ contract IntegrationConfig is IntegrationDeployer, G2Operations, Constants { // Decide how many operators to register for each quorum initially uint256 initialOperators = _randInitialOperators(operatorSet); - emit log( - string.concat( + emit log(string.concat( "Registering ", initialOperators.toString(), " initial operators in each quorum" - ) - ); + )); // For each initial operator, register for all quorums for (uint256 j = 0; j < initialOperators; j++) { @@ -411,7 +409,7 @@ contract IntegrationConfig is IntegrationDeployer, G2Operations, Constants { // more stake than the outgoing operator by kickBIPsOfOperatorStake while ( _getWeight(quorum, incomingOperator) - <= _individualKickThreshold(operatorToChurnStake, params) + <= _individualKickThreshold(operatorToChurnStake, params) || operatorToChurnStake >= _totalKickThreshold( currentTotalStake + _getWeight(quorum, incomingOperator), params @@ -443,7 +441,10 @@ contract IntegrationConfig is IntegrationDeployer, G2Operations, Constants { return totalStake * setParams.kickBIPsOfTotalStake / BIPS_DENOMINATOR; } - function _getWeight(uint8 quorum, User operator) internal view returns (uint96) { + function _getWeight( + uint8 quorum, + User operator + ) internal view returns (uint96) { return stakeRegistry.weightOfOperatorForQuorum(quorum, address(operator)); } @@ -477,10 +478,12 @@ contract IntegrationConfig is IntegrationDeployer, G2Operations, Constants { ) internal returns (User) { uint32 curNumOperators = indexRegistry.totalOperatorsForQuorum(quorum); - bytes32 randId = indexRegistry.getLatestOperatorUpdate({ + bytes32 randId = + indexRegistry.getLatestOperatorUpdate({ quorumNumber: quorum, operatorIndex: uint32(_randUint({min: 0, max: curNumOperators - 1})) - }).operatorId; + }) + .operatorId; return User(blsApkRegistry.getOperatorFromPubkeyHash(randId)); } @@ -505,7 +508,10 @@ contract IntegrationConfig is IntegrationDeployer, G2Operations, Constants { /// @dev Uses `random` to return a random uint, with a range given by `min` and `max` (inclusive) /// @return `min` <= result <= `max` - function _randUint(uint256 min, uint256 max) internal returns (uint256) { + function _randUint( + uint256 min, + uint256 max + ) internal returns (uint256) { uint256 range = max - min + 1; // calculate the number of bits needed for the range @@ -618,8 +624,7 @@ contract IntegrationConfig is IntegrationDeployer, G2Operations, Constants { for (uint256 i = 0; i < params.length; i++) { params[i] = IStakeRegistryTypes.StrategyParams({ - strategy: allStrats[i], - multiplier: DEFAULT_STRATEGY_MULTIPLIER + strategy: allStrats[i], multiplier: DEFAULT_STRATEGY_MULTIPLIER }); } diff --git a/test/integration/IntegrationDeployer.t.sol b/test/integration/IntegrationDeployer.t.sol index 551440945..b03f3f882 100644 --- a/test/integration/IntegrationDeployer.t.sol +++ b/test/integration/IntegrationDeployer.t.sol @@ -7,8 +7,9 @@ import "forge-std/Test.sol"; import "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetFixedSupply.sol"; import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; -import {ITransparentUpgradeableProxy} from - "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { + ITransparentUpgradeableProxy +} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import "@openzeppelin/contracts/proxy/beacon/IBeacon.sol"; import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; @@ -262,7 +263,8 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { ITransparentUpgradeableProxy(payable(address(delegationManager))), address(delegationImplementation), abi.encodeWithSelector( - DelegationManager.initialize.selector, 0 /* initialPausedStatus */ + DelegationManager.initialize.selector, + 0 /* initialPausedStatus */ ) ); // StrategyManager @@ -427,8 +429,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { ); serviceManager.initialize({ - initialOwner: registryCoordinatorOwner, - rewardsInitiator: address(msg.sender) + initialOwner: registryCoordinatorOwner, rewardsInitiator: address(msg.sender) }); IStakeRegistryTypes.StakeType[] memory quorumStakeTypes = diff --git a/test/integration/OperatorSetUser.t.sol b/test/integration/OperatorSetUser.t.sol index 1adae0c1a..7c6145a6e 100644 --- a/test/integration/OperatorSetUser.t.sol +++ b/test/integration/OperatorSetUser.t.sol @@ -52,8 +52,10 @@ contract OperatorSetUser is User { bytes memory data = abi.encode( ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, NAME, pubkeyParams ); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({avs: avs, operatorSetIds: _getOperatorSetIds(quorums), data: data}); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: avs, operatorSetIds: _getOperatorSetIds(quorums), data: data + }); allocationManager.registerForOperatorSets({operator: address(this), params: registerParams}); @@ -102,8 +104,10 @@ contract OperatorSetUser is User { churnApproverSignature ); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({avs: avs, operatorSetIds: _getOperatorSetIds(allQuorums), data: data}); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: avs, operatorSetIds: _getOperatorSetIds(allQuorums), data: data + }); allocationManager.registerForOperatorSets({operator: address(this), params: registerParams}); } @@ -112,8 +116,10 @@ contract OperatorSetUser is User { ) public virtual override createSnapshot { _log("deregisterOperator", quorums); uint32[] memory operatorSetIds = _getOperatorSetIds(quorums); - IAllocationManagerTypes.DeregisterParams memory deregisterParams = IAllocationManagerTypes - .DeregisterParams({avs: avs, operator: address(this), operatorSetIds: operatorSetIds}); + IAllocationManagerTypes.DeregisterParams memory deregisterParams = + IAllocationManagerTypes.DeregisterParams({ + avs: avs, operator: address(this), operatorSetIds: operatorSetIds + }); allocationManager.deregisterFromOperatorSets({params: deregisterParams}); } @@ -175,8 +181,7 @@ contract OperatorSetUser is User { while (churnIdx + stdIdx < allQuorums.length) { if (churnIdx == churnQuorums.length) { kickParams[churnIdx + stdIdx] = ISlashingRegistryCoordinatorTypes.OperatorKickParam({ - quorumNumber: 0, - operator: address(0) + quorumNumber: 0, operator: address(0) }); stdIdx++; } else if ( @@ -189,8 +194,7 @@ contract OperatorSetUser is User { churnIdx++; } else if (standardQuorums[stdIdx] < churnQuorums[churnIdx]) { kickParams[churnIdx + stdIdx] = ISlashingRegistryCoordinatorTypes.OperatorKickParam({ - quorumNumber: 0, - operator: address(0) + quorumNumber: 0, operator: address(0) }); stdIdx++; } else { @@ -218,11 +222,9 @@ contract OperatorSetUser is User { } signature[signature.length - 1] = bytes1(v); ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory churnApproverSignature = - ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry({ - signature: signature, - salt: _salt, - expiry: expiry - }); + ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry({ + signature: signature, salt: _salt, expiry: expiry + }); return (kickParams, churnApproverSignature); } diff --git a/test/integration/User.t.sol b/test/integration/User.t.sol index b6f31cdc7..f5dfcc245 100644 --- a/test/integration/User.t.sol +++ b/test/integration/User.t.sol @@ -259,9 +259,7 @@ contract User is Test { IDelegationManagerTypes.QueuedWithdrawalParams[] memory params = new IDelegationManager.QueuedWithdrawalParams[](1); params[0] = IDelegationManagerTypes.QueuedWithdrawalParams({ - strategies: strategies, - depositShares: shares, - __deprecated_withdrawer: address(this) + strategies: strategies, depositShares: shares, __deprecated_withdrawer: address(this) }); delegationManager.queueWithdrawals(params); @@ -274,7 +272,10 @@ contract User is Test { */ bytes4 internal constant EIP1271_MAGICVALUE = 0x1626ba7e; - function isValidSignature(bytes32 digestHash, bytes memory) public view returns (bytes4) { + function isValidSignature( + bytes32 digestHash, + bytes memory + ) public view returns (bytes4) { if (digests[digestHash]) { return EIP1271_MAGICVALUE; } @@ -291,11 +292,9 @@ contract User is Test { returns (ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory) { ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory signature = - ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry({ - signature: new bytes(0), - salt: bytes32(salt++), - expiry: type(uint256).max - }); + ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry({ + signature: new bytes(0), salt: bytes32(salt++), expiry: type(uint256).max + }); bytes32 digest = avsDirectory.calculateOperatorAVSRegistrationDigestHash({ operator: address(this), @@ -316,7 +315,10 @@ contract User is Test { } // Operator0.registerOperator: 0x00010203... - function _log(string memory s, bytes calldata quorums) internal virtual { + function _log( + string memory s, + bytes calldata quorums + ) internal virtual { emit log_named_string(string.concat(NAME, ".", s), quorums.toString()); } @@ -371,8 +373,7 @@ contract User is Test { while (churnIdx + stdIdx < allQuorums.length) { if (churnIdx == churnQuorums.length) { kickParams[churnIdx + stdIdx] = ISlashingRegistryCoordinatorTypes.OperatorKickParam({ - quorumNumber: 0, - operator: address(0) + quorumNumber: 0, operator: address(0) }); stdIdx++; } else if ( @@ -385,8 +386,7 @@ contract User is Test { churnIdx++; } else if (standardQuorums[stdIdx] < churnQuorums[churnIdx]) { kickParams[churnIdx + stdIdx] = ISlashingRegistryCoordinatorTypes.OperatorKickParam({ - quorumNumber: 0, - operator: address(0) + quorumNumber: 0, operator: address(0) }); stdIdx++; } else { @@ -414,11 +414,9 @@ contract User is Test { } signature[signature.length - 1] = bytes1(v); ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory churnApproverSignature = - ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry({ - signature: signature, - salt: _salt, - expiry: expiry - }); + ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry({ + signature: signature, salt: _salt, expiry: expiry + }); return (kickParams, churnApproverSignature); } diff --git a/test/integration/mocks/BeaconChainOracleMock.t.sol b/test/integration/mocks/BeaconChainOracleMock.t.sol index 766bb8e79..58ac7655b 100644 --- a/test/integration/mocks/BeaconChainOracleMock.t.sol +++ b/test/integration/mocks/BeaconChainOracleMock.t.sol @@ -17,7 +17,10 @@ contract BeaconChainOracleMock { return blockRoots[uint64(timestamp)]; } - function setBlockRoot(uint64 timestamp, bytes32 blockRoot) public { + function setBlockRoot( + uint64 timestamp, + bytes32 blockRoot + ) public { blockRoots[timestamp] = blockRoot; } } diff --git a/test/integration/tests/Full_Register_Deregister.t.sol b/test/integration/tests/Full_Register_Deregister.t.sol index 47340f8fa..b9c5c1eb5 100644 --- a/test/integration/tests/Full_Register_Deregister.t.sol +++ b/test/integration/tests/Full_Register_Deregister.t.sol @@ -32,9 +32,7 @@ contract Integration_Full_Register_Deregister is IntegrationChecks { // Select churnable operators in each quorum. If needed, deals/deposits assets // for the operator, and fills any non-full quorums User[] memory churnTargets = _getChurnTargets({ - incomingOperator: operator, - churnQuorums: quorums, - standardQuorums: new bytes(0) + incomingOperator: operator, churnQuorums: quorums, standardQuorums: new bytes(0) }); check_Never_Registered(operator); @@ -83,9 +81,7 @@ contract Integration_Full_Register_Deregister is IntegrationChecks { // Select churnable operators in each quorum, dealing additional assets to // the main operator if needed User[] memory churnTargets = _getChurnTargets({ - incomingOperator: operator, - churnQuorums: quorums, - standardQuorums: new bytes(0) + incomingOperator: operator, churnQuorums: quorums, standardQuorums: new bytes(0) }); check_Never_Registered(operator); @@ -148,25 +144,20 @@ contract Integration_Full_Register_Deregister is IntegrationChecks { // Select some quorums to register using churn, and the rest without churn bytes memory churnQuorums = _selectRand(quorums); - bytes memory standardQuorums = quorums.orderedBytesArrayToBitmap().minus( - churnQuorums.orderedBytesArrayToBitmap() - ).bitmapToBytesArray(); + bytes memory standardQuorums = quorums.orderedBytesArrayToBitmap() + .minus(churnQuorums.orderedBytesArrayToBitmap()).bitmapToBytesArray(); // Select churnable operators in each quorum. If needed, deals/deposits assets // for the operator, and deregisters operators from standardQuorums to make room User[] memory churnTargets = _getChurnTargets({ - incomingOperator: operator, - churnQuorums: churnQuorums, - standardQuorums: standardQuorums + incomingOperator: operator, churnQuorums: churnQuorums, standardQuorums: standardQuorums }); check_Never_Registered(operator); // 1. Register for *some* quorums with churn, and the rest without churn operator.registerOperatorWithChurn({ - churnQuorums: churnQuorums, - churnTargets: churnTargets, - standardQuorums: standardQuorums + churnQuorums: churnQuorums, churnTargets: churnTargets, standardQuorums: standardQuorums }); check_Churned_State({ incomingOperator: operator, diff --git a/test/mocks/AVSDirectoryMock.sol b/test/mocks/AVSDirectoryMock.sol index 1f175da4b..bc54a4dfb 100644 --- a/test/mocks/AVSDirectoryMock.sol +++ b/test/mocks/AVSDirectoryMock.sol @@ -12,7 +12,10 @@ import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol"; contract AVSDirectoryMock is IAVSDirectory { - function initialize(address initialOwner, uint256 initialPausedStatus) external {} + function initialize( + address initialOwner, + uint256 initialPausedStatus + ) external {} function createOperatorSets( uint32[] calldata operatorSetIds @@ -70,13 +73,19 @@ contract AVSDirectoryMock is IAVSDirectory { address operator ) external {} - function operatorSaltIsSpent(address operator, bytes32 salt) external view returns (bool) {} + function operatorSaltIsSpent( + address operator, + bytes32 salt + ) external view returns (bool) {} function operatorSetsEnabled( address avs ) external view returns (bool) {} - function isOperatorSet(address avs, uint32 operatorSetId) external view returns (bool) {} + function isOperatorSet( + address avs, + uint32 operatorSetId + ) external view returns (bool) {} function getNumOperatorSetsOfOperator( address operator diff --git a/test/mocks/AllocationManagerMock.sol b/test/mocks/AllocationManagerMock.sol index 51808edc9..6a2633d62 100644 --- a/test/mocks/AllocationManagerMock.sol +++ b/test/mocks/AllocationManagerMock.sol @@ -9,8 +9,9 @@ import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSR import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol"; import {ISemVerMixin} from "eigenlayer-contracts/src/contracts/interfaces/ISemVerMixin.sol"; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; contract AllocationManagerIntermediate is IAllocationManager { mapping(address avs => address avsRegistrar) internal _avsRegistrar; @@ -44,9 +45,15 @@ contract AllocationManagerIntermediate is IAllocationManager { DeregisterParams calldata params ) external virtual {} - function setAllocationDelay(address operator, uint32 delay) external virtual {} + function setAllocationDelay( + address operator, + uint32 delay + ) external virtual {} - function setAVSRegistrar(address avs, IAVSRegistrar avsRegistrar) external { + function setAVSRegistrar( + address avs, + IAVSRegistrar avsRegistrar + ) external { _avsRegistrar[avs] = address(avsRegistrar); } @@ -56,9 +63,15 @@ contract AllocationManagerIntermediate is IAllocationManager { return IAVSRegistrar(_avsRegistrar[avs]); } - function updateAVSMetadataURI(address avs, string calldata metadataURI) external virtual {} + function updateAVSMetadataURI( + address avs, + string calldata metadataURI + ) external virtual {} - function createOperatorSets(address avs, CreateSetParams[] calldata params) external virtual {} + function createOperatorSets( + address avs, + CreateSetParams[] calldata params + ) external virtual {} function createOperatorSets( address avs, @@ -246,7 +259,10 @@ contract AllocationManagerIntermediate is IAllocationManager { OperatorSet[] memory operatorSets ) external virtual {} - function updateSlasher(OperatorSet memory operatorSet, address slasher) external virtual {} + function updateSlasher( + OperatorSet memory operatorSet, + address slasher + ) external virtual {} function getSlasher( OperatorSet memory operatorSet @@ -280,8 +296,8 @@ contract AllocationManagerMock is AllocationManagerIntermediate { mapping( bytes32 operatorSetKey => mapping( - address operator => mapping(IStrategy strategy => uint256 minimumSlashableStake) - ) + address operator => mapping(IStrategy strategy => uint256 minimumSlashableStake) + ) ) internal _minimumSlashableStake; function DEALLOCATION_DELAY() external pure override returns (uint32) { diff --git a/test/mocks/DelegationManagerHarness.sol b/test/mocks/DelegationManagerHarness.sol index f644fee1e..b3ae63b97 100644 --- a/test/mocks/DelegationManagerHarness.sol +++ b/test/mocks/DelegationManagerHarness.sol @@ -7,12 +7,14 @@ import {console2 as console} from "forge-std/Test.sol"; import {DelegationManager} from "eigenlayer-contracts/src/contracts/core/DelegationManager.sol"; import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol"; import {IEigenPodManager} from "eigenlayer-contracts/src/contracts/interfaces/IEigenPodManager.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol"; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; contract DelegationManagerHarness is DelegationManager { constructor( @@ -34,7 +36,10 @@ contract DelegationManagerHarness is DelegationManager { ) {} - function setIsOperator(address operator, bool isOperator) external { + function setIsOperator( + address operator, + bool isOperator + ) external { if (isOperator) { delegatedTo[operator] = operator; } else { @@ -42,7 +47,11 @@ contract DelegationManagerHarness is DelegationManager { } } - function setOperatorShares(address operator, IStrategy strategy, uint256 shares) external { + function setOperatorShares( + address operator, + IStrategy strategy, + uint256 shares + ) external { operatorShares[operator][strategy] = shares; } } diff --git a/test/mocks/DelegationMock.sol b/test/mocks/DelegationMock.sol index 2af2947d0..6cb4eae35 100644 --- a/test/mocks/DelegationMock.sol +++ b/test/mocks/DelegationMock.sol @@ -327,7 +327,10 @@ contract DelegationMock is DelegationIntermediate { _weightOf[operator][strategy] = actualWeight; } - function setIsOperator(address operator, bool isOperator) external { + function setIsOperator( + address operator, + bool isOperator + ) external { _isOperator[operator] = isOperator; } diff --git a/test/mocks/ECDSAServiceManagerMock.sol b/test/mocks/ECDSAServiceManagerMock.sol index 07a263cff..e5d3bdc3c 100644 --- a/test/mocks/ECDSAServiceManagerMock.sol +++ b/test/mocks/ECDSAServiceManagerMock.sol @@ -2,8 +2,9 @@ pragma solidity ^0.8.27; import "../../src/unaudited/ECDSAServiceManagerBase.sol"; -import {IAllocationManagerTypes} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManagerTypes +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; contract ECDSAServiceManagerMock is ECDSAServiceManagerBase { constructor( @@ -46,7 +47,15 @@ contract ECDSAServiceManagerMock is ECDSAServiceManagerBase { address admin ) external {} - function setAppointee(address appointee, address target, bytes4 selector) external {} + function setAppointee( + address appointee, + address target, + bytes4 selector + ) external {} - function removeAppointee(address appointee, address target, bytes4 selector) external {} + function removeAppointee( + address appointee, + address target, + bytes4 selector + ) external {} } diff --git a/test/mocks/ECDSAStakeRegistryMock.sol b/test/mocks/ECDSAStakeRegistryMock.sol index 2ee445a54..d239264ec 100644 --- a/test/mocks/ECDSAStakeRegistryMock.sol +++ b/test/mocks/ECDSAStakeRegistryMock.sol @@ -2,8 +2,9 @@ pragma solidity ^0.8.27; import "../../src/unaudited/ECDSAStakeRegistry.sol"; -import {CheckpointsUpgradeable} from - "@openzeppelin-upgrades/contracts/utils/CheckpointsUpgradeable.sol"; +import { + CheckpointsUpgradeable +} from "@openzeppelin-upgrades/contracts/utils/CheckpointsUpgradeable.sol"; /** * @title Mock for ECDSAStakeRegistry @@ -21,7 +22,10 @@ contract ECDSAStakeRegistryMock is ECDSAStakeRegistry { * @param blockNumber The block number * @param weight The weight to set */ - function setTotalWeightAtBlock(uint32 blockNumber, uint256 weight) external { + function setTotalWeightAtBlock( + uint32 blockNumber, + uint256 weight + ) external { _totalWeightHistory.push(weight); } @@ -30,7 +34,10 @@ contract ECDSAStakeRegistryMock is ECDSAStakeRegistry { * @param blockNumber The block number * @param weight The weight to set */ - function setThresholdWeightAtBlock(uint32 blockNumber, uint256 weight) external { + function setThresholdWeightAtBlock( + uint32 blockNumber, + uint256 weight + ) external { _thresholdWeightHistory.push(weight); } } diff --git a/test/mocks/ERC20Mock.sol b/test/mocks/ERC20Mock.sol index f4c95bcc8..2bbffeb16 100644 --- a/test/mocks/ERC20Mock.sol +++ b/test/mocks/ERC20Mock.sol @@ -7,7 +7,10 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; contract ERC20Mock is ERC20 { constructor() ERC20("", "") {} - function mint(address account, uint256 amount) public { + function mint( + address account, + uint256 amount + ) public { _mint(account, amount); } } diff --git a/test/mocks/EigenPodManagerMock.sol b/test/mocks/EigenPodManagerMock.sol index 2515e6992..85150e417 100644 --- a/test/mocks/EigenPodManagerMock.sol +++ b/test/mocks/EigenPodManagerMock.sol @@ -25,7 +25,10 @@ contract EigenPodManagerMock is Test, Pausable, IEigenPodManager { return podShares[podOwner]; } - function setPodOwnerShares(address podOwner, int256 shares) external { + function setPodOwnerShares( + address podOwner, + int256 shares + ) external { podShares[podOwner] = shares; } @@ -125,7 +128,10 @@ contract EigenPodManagerMock is Test, Pausable, IEigenPodManager { function burnableETHShares() external view returns (uint256) {} - function increaseBurnableShares(IStrategy strategy, uint256 addedSharesToBurn) external {} + function increaseBurnableShares( + IStrategy strategy, + uint256 addedSharesToBurn + ) external {} function increaseBurnOrRedistributableShares( OperatorSet calldata, diff --git a/test/mocks/KeyRegistrarMock.sol b/test/mocks/KeyRegistrarMock.sol index f6d399f97..a0066d7c8 100644 --- a/test/mocks/KeyRegistrarMock.sol +++ b/test/mocks/KeyRegistrarMock.sol @@ -30,7 +30,10 @@ contract KeyRegistrarMock is IKeyRegistrar { address initialOwner ) external {} - function configureOperatorSet(OperatorSet memory operatorSet, CurveType curveType) external {} + function configureOperatorSet( + OperatorSet memory operatorSet, + CurveType curveType + ) external {} function configureOperatorSetWithMinDelay( OperatorSet memory operatorSet, @@ -62,7 +65,10 @@ contract KeyRegistrarMock is IKeyRegistrar { bytes calldata signature ) external {} - function deregisterKey(address operator, OperatorSet memory operatorSet) external {} + function deregisterKey( + address operator, + OperatorSet memory operatorSet + ) external {} function isRegistered( OperatorSet memory operatorSet, diff --git a/test/mocks/MockTaskAVSRegistrar.sol b/test/mocks/MockTaskAVSRegistrar.sol index 8cf2c8434..2a103d7a9 100644 --- a/test/mocks/MockTaskAVSRegistrar.sol +++ b/test/mocks/MockTaskAVSRegistrar.sol @@ -1,11 +1,13 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; import {TaskAVSRegistrarBase} from "../../src/avs/task/TaskAVSRegistrarBase.sol"; contract MockTaskAVSRegistrar is TaskAVSRegistrarBase { diff --git a/test/mocks/PermissionControllerMock.sol b/test/mocks/PermissionControllerMock.sol index d66731844..213ec3783 100644 --- a/test/mocks/PermissionControllerMock.sol +++ b/test/mocks/PermissionControllerMock.sol @@ -1,20 +1,30 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; import {ISemVerMixin} from "eigenlayer-contracts/src/contracts/interfaces/ISemVerMixin.sol"; contract PermissionControllerIntermediate is IPermissionController { - function addPendingAdmin(address account, address admin) external virtual {} + function addPendingAdmin( + address account, + address admin + ) external virtual {} - function removePendingAdmin(address account, address admin) external virtual {} + function removePendingAdmin( + address account, + address admin + ) external virtual {} function acceptAdmin( address account ) external virtual {} - function removeAdmin(address account, address admin) external virtual {} + function removeAdmin( + address account, + address admin + ) external virtual {} function setAppointee( address account, @@ -30,7 +40,10 @@ contract PermissionControllerIntermediate is IPermissionController { bytes4 selector ) external virtual {} - function isAdmin(address account, address caller) external view virtual returns (bool) {} + function isAdmin( + address account, + address caller + ) external view virtual returns (bool) {} function isPendingAdmin( address account, diff --git a/test/mocks/RegistryCoordinatorMock.sol b/test/mocks/RegistryCoordinatorMock.sol index e162355da..5d678ebfc 100644 --- a/test/mocks/RegistryCoordinatorMock.sol +++ b/test/mocks/RegistryCoordinatorMock.sol @@ -102,7 +102,10 @@ abstract contract RegistryCoordinatorMock is IRegistryCoordinator { // Keep existing implementations function blsApkRegistry() external view virtual returns (IBLSApkRegistry) {} - function ejectOperator(address operator, bytes calldata quorumNumbers) external virtual {} + function ejectOperator( + address operator, + bytes calldata quorumNumbers + ) external virtual {} function getOperatorSetParams( uint8 quorumNumber ) external view virtual returns (OperatorSetParam memory) {} diff --git a/test/mocks/RewardsCoordinatorMock.sol b/test/mocks/RewardsCoordinatorMock.sol index 37283ab94..e04c02136 100644 --- a/test/mocks/RewardsCoordinatorMock.sol +++ b/test/mocks/RewardsCoordinatorMock.sol @@ -4,8 +4,9 @@ pragma solidity ^0.8.27; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol"; -import {IRewardsCoordinator} from - "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; +import { + IRewardsCoordinator +} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; import {ISemVerMixin} from "eigenlayer-contracts/src/contracts/interfaces/ISemVerMixin.sol"; import "./AVSDirectoryMock.sol"; @@ -51,14 +52,20 @@ contract RewardsCoordinatorMock is IRewardsCoordinator { OperatorDirectedRewardsSubmission[] calldata operatorDirectedRewardsSubmissions ) external override {} - function processClaim(RewardsMerkleClaim calldata claim, address recipient) external override {} + function processClaim( + RewardsMerkleClaim calldata claim, + address recipient + ) external override {} function processClaims( RewardsMerkleClaim[] calldata claims, address recipient ) external override {} - function submitRoot(bytes32 root, uint32 rewardsCalculationEndTimestamp) external override {} + function submitRoot( + bytes32 root, + uint32 rewardsCalculationEndTimestamp + ) external override {} function disableRoot( uint32 rootIndex @@ -68,7 +75,10 @@ contract RewardsCoordinatorMock is IRewardsCoordinator { address claimer ) external override {} - function setClaimerFor(address earner, address claimer) external override {} + function setClaimerFor( + address earner, + address claimer + ) external override {} function setActivationDelay( uint32 _activationDelay @@ -78,15 +88,25 @@ contract RewardsCoordinatorMock is IRewardsCoordinator { uint16 split ) external override {} - function setOperatorAVSSplit(address operator, address avs, uint16 split) external override {} + function setOperatorAVSSplit( + address operator, + address avs, + uint16 split + ) external override {} - function setOperatorPISplit(address operator, uint16 split) external override {} + function setOperatorPISplit( + address operator, + uint16 split + ) external override {} function setRewardsUpdater( address _rewardsUpdater ) external override {} - function setRewardsForAllSubmitter(address _submitter, bool _newValue) external override {} + function setRewardsForAllSubmitter( + address _submitter, + bool _newValue + ) external override {} function activationDelay() external view override returns (uint32) {} diff --git a/test/mocks/StakeRegistryMock.sol b/test/mocks/StakeRegistryMock.sol index d428a8f75..b02eb962c 100644 --- a/test/mocks/StakeRegistryMock.sol +++ b/test/mocks/StakeRegistryMock.sol @@ -21,9 +21,15 @@ contract StakeRegistryMock is IStakeRegistry { uint8 quorumNumber ) external view returns (uint256) {} - function setMinimumStakeForQuorum(uint8 quorumNumber, uint96 minimumStake) external {} + function setMinimumStakeForQuorum( + uint8 quorumNumber, + uint96 minimumStake + ) external {} - function setSlashableStakeLookahead(uint8 quorumNumber, uint32 lookAheadBlocks) external {} + function setSlashableStakeLookahead( + uint8 quorumNumber, + uint32 lookAheadBlocks + ) external {} function set_updateOperatorStakeReturnBitmap( uint192 newValue @@ -77,7 +83,10 @@ contract StakeRegistryMock is IStakeRegistry { * 4) the operator is not already deregistered * 5) `quorumNumbers` is a subset of the quorumNumbers that the operator is registered for */ - function deregisterOperator(bytes32 operatorId, bytes memory quorumNumbers) external {} + function deregisterOperator( + bytes32 operatorId, + bytes memory quorumNumbers + ) external {} /** * @notice Initialize a new quorum created by the registry coordinator by setting strategies, weights, and minimum stake @@ -89,7 +98,10 @@ contract StakeRegistryMock is IStakeRegistry { ) external {} /// @notice Adds new strategies and the associated multipliers to the @param quorumNumber. - function addStrategies(uint8 quorumNumber, StrategyParams[] memory strategyParams) external {} + function addStrategies( + uint8 quorumNumber, + StrategyParams[] memory strategyParams + ) external {} /** * @notice This function is used for removing strategies and their associated weights from the @@ -97,7 +109,10 @@ contract StakeRegistryMock is IStakeRegistry { * @dev higher indices should be *first* in the list of @param indicesToRemove, since otherwise * the removal of lower index entries will cause a shift in the indices of the other strategiesToRemove */ - function removeStrategies(uint8 quorumNumber, uint256[] calldata indicesToRemove) external {} + function removeStrategies( + uint8 quorumNumber, + uint256[] calldata indicesToRemove + ) external {} /** * @notice This function is used for modifying the weights of strategies that are already in the diff --git a/test/unit/AVSRegistrar.t.sol b/test/unit/AVSRegistrar.t.sol index 936588528..9d8d83fc6 100644 --- a/test/unit/AVSRegistrar.t.sol +++ b/test/unit/AVSRegistrar.t.sol @@ -8,8 +8,9 @@ import {IStakeRegistry} from "../../src/interfaces/IStakeRegistry.sol"; import {BitmapUtils} from "../../src/libraries/BitmapUtils.sol"; import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; -import {IAllocationManagerTypes} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManagerTypes +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {AVSRegistrarMock} from "../mocks/AVSRegistrarMock.sol"; import {console2 as console} from "forge-std/Test.sol"; @@ -49,8 +50,7 @@ contract AVSRegistrarTest is MockAVSDeployer { IAllocationManagerTypes.CreateSetParams[] memory createSetParams = new IAllocationManagerTypes.CreateSetParams[](1); createSetParams[0] = IAllocationManagerTypes.CreateSetParams({ - operatorSetId: operatorSetId, - strategies: new IStrategy[](0) + operatorSetId: operatorSetId, strategies: new IStrategy[](0) }); // Create operator set @@ -85,8 +85,7 @@ contract AVSRegistrarTest is MockAVSDeployer { IAllocationManagerTypes.CreateSetParams[] memory createSetParams = new IAllocationManagerTypes.CreateSetParams[](1); createSetParams[0] = IAllocationManagerTypes.CreateSetParams({ - operatorSetId: operatorSetId, - strategies: new IStrategy[](0) + operatorSetId: operatorSetId, strategies: new IStrategy[](0) }); // Create operator set diff --git a/test/unit/BLSApkRegistryUnit.t.sol b/test/unit/BLSApkRegistryUnit.t.sol index 8ba06d90c..1d828b9b3 100644 --- a/test/unit/BLSApkRegistryUnit.t.sol +++ b/test/unit/BLSApkRegistryUnit.t.sol @@ -66,13 +66,13 @@ contract BLSApkRegistryUnitTests is BLSMockAVSDeployer, IBLSApkRegistryEvents { //privKey*G2 pubkeyRegistrationParams.pubkeyG2.X[1] = - 19101821850089705274637533855249918363070101489527618151493230256975900223847; + 19101821850089705274637533855249918363070101489527618151493230256975900223847; pubkeyRegistrationParams.pubkeyG2.X[0] = - 5334410886741819556325359147377682006012228123419628681352847439302316235957; + 5334410886741819556325359147377682006012228123419628681352847439302316235957; pubkeyRegistrationParams.pubkeyG2.Y[1] = - 354176189041917478648604979334478067325821134838555150300539079146482658331; + 354176189041917478648604979334478067325821134838555150300539079146482658331; pubkeyRegistrationParams.pubkeyG2.Y[0] = - 4185483097059047421902184823581361466320657066600218863748375739772335928910; + 4185483097059047421902184823581361466320657066600218863748375739772335928910; // Initialize 3 quorums _initializeQuorum(); @@ -192,7 +192,10 @@ contract BLSApkRegistryUnitTests is BLSMockAVSDeployer, IBLSApkRegistryEvents { /** * @dev register operator, assumes operator has a registered BLS public key and that quorumNumbers are valid */ - function _registerOperator(address operator, bytes memory quorumNumbers) internal { + function _registerOperator( + address operator, + bytes memory quorumNumbers + ) internal { bytes32 operatorId = blsApkRegistry.getOperatorId(operator); cheats.prank(address(registryCoordinator)); cheats.expectEmit(true, true, true, true, address(blsApkRegistry)); @@ -203,7 +206,10 @@ contract BLSApkRegistryUnitTests is BLSMockAVSDeployer, IBLSApkRegistryEvents { /** * @dev deregister operator, assumes operator has a registered BLS public key and that quorumNumbers are valid */ - function _deregisterOperator(address operator, bytes memory quorumNumbers) internal { + function _deregisterOperator( + address operator, + bytes memory quorumNumbers + ) internal { bytes32 operatorId = blsApkRegistry.getOperatorId(operator); cheats.prank(address(registryCoordinator)); cheats.expectEmit(true, true, true, true, address(blsApkRegistry)); @@ -645,7 +651,10 @@ contract BLSApkRegistryUnitTests_quorumApkUpdates is BLSApkRegistryUnitTests { * @dev register/deregister up to 200 operators and check quorum apk updates * Test uses only the defaultQuorumNumber */ - function testFuzz_quorumApkUpdates(uint256 numOperators, uint256[200] memory randSeed) public { + function testFuzz_quorumApkUpdates( + uint256 numOperators, + uint256[200] memory randSeed + ) public { numOperators = uint256(bound(numOperators, 1, 200)); bytes memory quorumNumbers = new bytes(1); quorumNumbers[0] = bytes1(defaultQuorumNumber); diff --git a/test/unit/BLSSigCheckOperatorStateRetriever.t.sol b/test/unit/BLSSigCheckOperatorStateRetriever.t.sol index b47c052c9..1dcdd0ed9 100644 --- a/test/unit/BLSSigCheckOperatorStateRetriever.t.sol +++ b/test/unit/BLSSigCheckOperatorStateRetriever.t.sol @@ -6,8 +6,9 @@ import {IStakeRegistryErrors} from "../../src/interfaces/IStakeRegistry.sol"; import {ISlashingRegistryCoordinatorTypes} from "../../src/interfaces/IRegistryCoordinator.sol"; import {IBLSSignatureCheckerTypes} from "../../src/interfaces/IBLSSignatureChecker.sol"; import {BN256G2} from "../../src/unaudited/BN256G2.sol"; -import {BLSSigCheckOperatorStateRetriever} from - "../../src/unaudited/BLSSigCheckOperatorStateRetriever.sol"; +import { + BLSSigCheckOperatorStateRetriever +} from "../../src/unaudited/BLSSigCheckOperatorStateRetriever.sol"; import {OperatorStateRetrieverUnitTests} from "./OperatorStateRetrieverUnit.t.sol"; contract BLSSigCheckOperatorStateRetrieverUnitTests is @@ -104,9 +105,13 @@ contract BLSSigCheckOperatorStateRetrieverUnitTests is // Call the function under test IBLSSignatureCheckerTypes.NonSignerStakesAndSignature memory result = - sigCheckOperatorStateRetriever.getNonSignerStakesAndSignature( - registryCoordinator, quorumNumbers, dummySigma, signingOperators, uint32(block.number) - ); + sigCheckOperatorStateRetriever.getNonSignerStakesAndSignature( + registryCoordinator, + quorumNumbers, + dummySigma, + signingOperators, + uint32(block.number) + ); // Non-signers assertEq(result.nonSignerQuorumBitmapIndices.length, 0, "Should have no non-signer"); @@ -194,9 +199,13 @@ contract BLSSigCheckOperatorStateRetrieverUnitTests is // Call under test IBLSSignatureCheckerTypes.NonSignerStakesAndSignature memory result = - sigCheckOperatorStateRetriever.getNonSignerStakesAndSignature( - registryCoordinator, quorumNumbers, dummySigma, signingOperators, uint32(block.number) - ); + sigCheckOperatorStateRetriever.getNonSignerStakesAndSignature( + registryCoordinator, + quorumNumbers, + dummySigma, + signingOperators, + uint32(block.number) + ); // Validate // One non-signer => otherOperator @@ -303,13 +312,13 @@ contract BLSSigCheckOperatorStateRetrieverUnitTests is // Call the function under test IBLSSignatureCheckerTypes.NonSignerStakesAndSignature memory result = - sigCheckOperatorStateRetriever.getNonSignerStakesAndSignature( - registryCoordinator, - quorumNumbers, - dummySigma, - signingOperators, - registrationBlockNumber - ); + sigCheckOperatorStateRetriever.getNonSignerStakesAndSignature( + registryCoordinator, + quorumNumbers, + dummySigma, + signingOperators, + registrationBlockNumber + ); // Non-signers assertEq(result.nonSignerQuorumBitmapIndices.length, 0, "Should have no non-signer"); @@ -559,17 +568,16 @@ contract BLSSigCheckOperatorStateRetrieverUnitTests is cheats.roll(initialBlock + 10); ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: defaultMaxOperatorCount, - kickBIPsOfOperatorStake: defaultKickBIPsOfOperatorStake, - kickBIPsOfTotalStake: defaultKickBIPsOfTotalStake - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: defaultMaxOperatorCount, + kickBIPsOfOperatorStake: defaultKickBIPsOfOperatorStake, + kickBIPsOfTotalStake: defaultKickBIPsOfTotalStake + }); uint96 minimumStake = 1; IStakeRegistryTypes.StrategyParams[] memory strategyParams = new IStakeRegistryTypes.StrategyParams[](1); strategyParams[0] = IStakeRegistryTypes.StrategyParams({ - strategy: IStrategy(address(1000)), - multiplier: 1e16 + strategy: IStrategy(address(1000)), multiplier: 1e16 }); // Create quorum 8 @@ -652,9 +660,13 @@ contract BLSSigCheckOperatorStateRetrieverUnitTests is // Call the function under test vm.expectRevert(OperatorStateRetriever.OperatorNotRegistered.selector); IBLSSignatureCheckerTypes.NonSignerStakesAndSignature memory result = - sigCheckOperatorStateRetriever.getNonSignerStakesAndSignature( - registryCoordinator, quorumNumbers, dummySigma, signingOperators, uint32(block.number) - ); + sigCheckOperatorStateRetriever.getNonSignerStakesAndSignature( + registryCoordinator, + quorumNumbers, + dummySigma, + signingOperators, + uint32(block.number) + ); } function test_getNonSignerStakesAndSignature_nonSignersAreSorted() public { @@ -699,9 +711,13 @@ contract BLSSigCheckOperatorStateRetrieverUnitTests is // Call the function under test IBLSSignatureCheckerTypes.NonSignerStakesAndSignature memory result = - sigCheckOperatorStateRetriever.getNonSignerStakesAndSignature( - registryCoordinator, quorumNumbers, dummySigma, signingOperators, uint32(block.number) - ); + sigCheckOperatorStateRetriever.getNonSignerStakesAndSignature( + registryCoordinator, + quorumNumbers, + dummySigma, + signingOperators, + uint32(block.number) + ); // Verify we have 2 non-signers assertEq(result.nonSignerQuorumBitmapIndices.length, 2, "Should have 2 non-signers"); @@ -775,9 +791,13 @@ contract BLSSigCheckOperatorStateRetrieverUnitTests is // Call the function under test IBLSSignatureCheckerTypes.NonSignerStakesAndSignature memory result = - sigCheckOperatorStateRetriever.getNonSignerStakesAndSignature( - registryCoordinator, quorumNumbers, dummySigma, signingOperators, uint32(block.number) - ); + sigCheckOperatorStateRetriever.getNonSignerStakesAndSignature( + registryCoordinator, + quorumNumbers, + dummySigma, + signingOperators, + uint32(block.number) + ); // Verify we have the correct number of non-signers uint256 expectedNonSigners = numOperators - numSigners; diff --git a/test/unit/BLSSigCheckUtilsUnit.t.sol b/test/unit/BLSSigCheckUtilsUnit.t.sol index 7ed2121a8..2adbf52da 100644 --- a/test/unit/BLSSigCheckUtilsUnit.t.sol +++ b/test/unit/BLSSigCheckUtilsUnit.t.sol @@ -107,7 +107,10 @@ contract BLSSigCheckUtilsUnitTests is Test { /** * @notice Fuzz test with random points */ - function testFuzz_isOnCurve_randomPoints(uint256 x, uint256 y) public pure { + function testFuzz_isOnCurve_randomPoints( + uint256 x, + uint256 y + ) public pure { BN254.G1Point memory point = BN254.G1Point(x, y); // Calculate expected result @@ -262,9 +265,9 @@ contract BLSSigCheckUtilsUnitTests is Test { // Another valid point testPoints[2].x = - 9727523064272218541460723335320998459488975639302513747055235660443850046724; + 9727523064272218541460723335320998459488975639302513747055235660443850046724; testPoints[2].y = - 5031696974169251245229961296941447383441169981934237515842977230762345915487; + 5031696974169251245229961296941447383441169981934237515842977230762345915487; testPoints[2].shouldBeOnCurve = true; // Invalid point @@ -299,7 +302,10 @@ contract BLSSigCheckUtilsUnitTests is Test { assertFalse(harness.gt(1, 1), "1 > 1 should be false"); } - function testFuzz_comparators(uint256 a, uint256 b) public { + function testFuzz_comparators( + uint256 a, + uint256 b + ) public { bool ltResult = harness.lt(a, b); bool gtResult = harness.gt(a, b); diff --git a/test/unit/BLSSignatureCheckerUnit.t.sol b/test/unit/BLSSignatureCheckerUnit.t.sol index c2b30a8bc..1c04d00b4 100644 --- a/test/unit/BLSSignatureCheckerUnit.t.sol +++ b/test/unit/BLSSignatureCheckerUnit.t.sol @@ -183,16 +183,16 @@ contract BLSSignatureCheckerUnitTests is BLSMockAVSDeployer { ); IBLSSignatureCheckerTypes.NonSignerStakesAndSignature memory incorrectLengthInputs = - IBLSSignatureCheckerTypes.NonSignerStakesAndSignature({ - nonSignerQuorumBitmapIndices: nonSignerStakesAndSignature.nonSignerQuorumBitmapIndices, - nonSignerPubkeys: nonSignerStakesAndSignature.nonSignerPubkeys, - quorumApks: nonSignerStakesAndSignature.quorumApks, - apkG2: nonSignerStakesAndSignature.apkG2, - sigma: nonSignerStakesAndSignature.sigma, - quorumApkIndices: nonSignerStakesAndSignature.quorumApkIndices, - totalStakeIndices: nonSignerStakesAndSignature.totalStakeIndices, - nonSignerStakeIndices: nonSignerStakesAndSignature.nonSignerStakeIndices - }); + IBLSSignatureCheckerTypes.NonSignerStakesAndSignature({ + nonSignerQuorumBitmapIndices: nonSignerStakesAndSignature.nonSignerQuorumBitmapIndices, + nonSignerPubkeys: nonSignerStakesAndSignature.nonSignerPubkeys, + quorumApks: nonSignerStakesAndSignature.quorumApks, + apkG2: nonSignerStakesAndSignature.apkG2, + sigma: nonSignerStakesAndSignature.sigma, + quorumApkIndices: nonSignerStakesAndSignature.quorumApkIndices, + totalStakeIndices: nonSignerStakesAndSignature.totalStakeIndices, + nonSignerStakeIndices: nonSignerStakesAndSignature.nonSignerStakeIndices + }); // make one part of the input incorrect length incorrectLengthInputs.quorumApks = new BN254.G1Point[](5); @@ -230,7 +230,7 @@ contract BLSSignatureCheckerUnitTests is BLSMockAVSDeployer { // reset the input to correct values incorrectLengthInputs.nonSignerStakeIndices = - nonSignerStakesAndSignature.nonSignerStakeIndices; + nonSignerStakesAndSignature.nonSignerStakeIndices; // make one part of the input incorrect length incorrectLengthInputs.nonSignerQuorumBitmapIndices = new uint32[](nonSignerStakesAndSignature.nonSignerPubkeys.length + 1); @@ -241,7 +241,7 @@ contract BLSSignatureCheckerUnitTests is BLSMockAVSDeployer { // reset the input to correct values incorrectLengthInputs.nonSignerQuorumBitmapIndices = - nonSignerStakesAndSignature.nonSignerQuorumBitmapIndices; + nonSignerStakesAndSignature.nonSignerQuorumBitmapIndices; // sanity check for call passing with the correct values blsSignatureChecker.checkSignatures( msgHash, quorumNumbers, referenceBlockNumber, incorrectLengthInputs @@ -256,7 +256,8 @@ contract BLSSignatureCheckerUnitTests is BLSMockAVSDeployer { bytes memory quorumNumbers = BitmapUtils.bitmapToBytesArray(quorumBitmap); ( /*uint32 referenceBlockNumber*/ - , BLSSignatureChecker.NonSignerStakesAndSignature memory nonSignerStakesAndSignature + , + BLSSignatureChecker.NonSignerStakesAndSignature memory nonSignerStakesAndSignature ) = _registerSignatoriesAndGetNonSignerStakeAndSignatureRandom( pseudoRandomNumber, numNonSigners, quorumBitmap ); @@ -308,10 +309,11 @@ contract BLSSignatureCheckerUnitTests is BLSMockAVSDeployer { ( nonSignerStakesAndSignature.nonSignerPubkeys[0], nonSignerStakesAndSignature.nonSignerPubkeys[1] - ) = ( - nonSignerStakesAndSignature.nonSignerPubkeys[1], - nonSignerStakesAndSignature.nonSignerPubkeys[0] - ); + ) = + ( + nonSignerStakesAndSignature.nonSignerPubkeys[1], + nonSignerStakesAndSignature.nonSignerPubkeys[0] + ); cheats.expectRevert(IBLSSignatureCheckerErrors.NonSignerPubkeysNotSorted.selector); blsSignatureChecker.checkSignatures( msgHash, quorumNumbers, referenceBlockNumber, nonSignerStakesAndSignature @@ -525,8 +527,7 @@ contract BLSSignatureCheckerUnitTests is BLSMockAVSDeployer { 1, numNonSigners, quorumBitmap ); - (bool pairingSuccessful, bool signatureIsValid) = blsSignatureChecker - .trySignatureAndApkVerification( + (bool pairingSuccessful, bool signatureIsValid) = blsSignatureChecker.trySignatureAndApkVerification( msgHash, nonSignerStakesAndSignature.quorumApks[0], nonSignerStakesAndSignature.apkG2, @@ -574,8 +575,7 @@ contract BLSSignatureCheckerUnitTests is BLSMockAVSDeployer { [type(uint256).max, type(uint256).max], [type(uint256).max, type(uint256).max] ); - (bool pairingSuccessful, bool signatureIsValid) = blsSignatureChecker - .trySignatureAndApkVerification( + (bool pairingSuccessful, bool signatureIsValid) = blsSignatureChecker.trySignatureAndApkVerification( msgHash, nonSignerStakesAndSignature.quorumApks[0], invalidG2Point, diff --git a/test/unit/BitmapUtils.t.sol b/test/unit/BitmapUtils.t.sol index a29f0cc5d..d7481fb87 100644 --- a/test/unit/BitmapUtils.t.sol +++ b/test/unit/BitmapUtils.t.sol @@ -46,7 +46,10 @@ contract BitmapUtilsUnitTests_bitwiseOperations is BitmapUtilsUnitTests { } } - function test_setBit(uint256 bitmap, uint8 bitToSet) public { + function test_setBit( + uint256 bitmap, + uint8 bitToSet + ) public { // Ensure that numberToAdd isn't already in the bitmap cheats.assume(bitmap | (1 << bitToSet) != bitmap); uint256 updatedBitmap = bitmapUtilsWrapper.setBit(bitmap, bitToSet); @@ -64,7 +67,10 @@ contract BitmapUtilsUnitTests_bitwiseOperations is BitmapUtilsUnitTests { } } - function testFuzz_noBitsInCommon(uint256 a, uint256 b) public { + function testFuzz_noBitsInCommon( + uint256 a, + uint256 b + ) public { // 1000 and 0111 have no bits in common assertTrue(bitmapUtilsWrapper.noBitsInCommon(8, 7), "noBitsInCommon function is broken"); // 1101 and 0010 have no bits in common @@ -82,7 +88,10 @@ contract BitmapUtilsUnitTests_bitwiseOperations is BitmapUtilsUnitTests { assertTrue(bitmapUtilsWrapper.noBitsInCommon(a, b), "noBitsInCommon function is broken"); } - function testFuzz_isSubsetOf(uint256 a, uint256 b) public { + function testFuzz_isSubsetOf( + uint256 a, + uint256 b + ) public { // 1000 is a subset of 1000 assertTrue(bitmapUtilsWrapper.isSubsetOf(8, 8), "isSubsetOf function is broken"); // 1000 is a subset of 1001 @@ -98,7 +107,10 @@ contract BitmapUtilsUnitTests_bitwiseOperations is BitmapUtilsUnitTests { } } - function testFuzz_plus(uint256 a, uint256 b) public { + function testFuzz_plus( + uint256 a, + uint256 b + ) public { uint256 bitwisePlus = bitmapUtilsWrapper.plus(a, b); for (uint256 i = 0; i < 256; ++i) { if ((a >> i) & 1 == 1 || (b >> i) & 1 == 1) { @@ -108,7 +120,10 @@ contract BitmapUtilsUnitTests_bitwiseOperations is BitmapUtilsUnitTests { } } - function testFuzz_minus(uint256 a, uint256 b) public { + function testFuzz_minus( + uint256 a, + uint256 b + ) public { uint256 bitwiseMinus = bitmapUtilsWrapper.minus(a, b); for (uint256 i = 0; i < 256; ++i) { if ((a >> i) & 1 == 1 && (b >> i) & 1 == 0) { @@ -148,7 +163,10 @@ contract BitmapUtilsUnitTests_bytesArrayToBitmap is BitmapUtilsUnitTests { } // ensure that the bitmap encoding of a two uint8's (i.e. a two byte array) matches the expected output - function testFuzz_TwoByteEncoding(uint8 firstFuzzedNumber, uint8 secondFuzzedNumber) public { + function testFuzz_TwoByteEncoding( + uint8 firstFuzzedNumber, + uint8 secondFuzzedNumber + ) public { cheats.assume(secondFuzzedNumber > firstFuzzedNumber); bytes1 firstSingleByte = bytes1(firstFuzzedNumber); bytes1 secondSingleByte = bytes1(secondFuzzedNumber); @@ -173,7 +191,11 @@ contract BitmapUtilsUnitTests_bytesArrayToBitmap is BitmapUtilsUnitTests { // ensure that converting bytes array => bitmap => bytes array returns the original bytes array (i.e. is lossless and artifactless) // note that this only works on ordered arrays, because unordered arrays will be returned ordered - function testFuzz_BytesArrayToBitmapToBytesArray(uint8 a, uint8 b, uint8 c) public view { + function testFuzz_BytesArrayToBitmapToBytesArray( + uint8 a, + uint8 b, + uint8 c + ) public view { a = uint8(bound(a, 0, 31)); b = uint8(bound(b, 0, 31)); c = uint8(bound(c, 0, 31)); diff --git a/test/unit/ECDSAServiceManager.t.sol b/test/unit/ECDSAServiceManager.t.sol index 7d86cc0c6..880081869 100644 --- a/test/unit/ECDSAServiceManager.t.sol +++ b/test/unit/ECDSAServiceManager.t.sol @@ -7,10 +7,12 @@ import { ISignatureUtilsMixin, ISignatureUtilsMixinTypes } from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; -import {IRewardsCoordinator} from - "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IRewardsCoordinator +} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; @@ -21,7 +23,10 @@ import {IECDSAStakeRegistryTypes} from "../../src/interfaces/IECDSAStakeRegistry import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; contract MockDelegationManager { - function operatorShares(address, address) external pure returns (uint256) { + function operatorShares( + address, + address + ) external pure returns (uint256) { return 1000; // Return a dummy value for simplicity } @@ -53,7 +58,10 @@ contract MockAVSDirectory { } contract MockAllocationManager { - function setAVSRegistrar(address avs, address registrar) external {} + function setAVSRegistrar( + address avs, + address registrar + ) external {} } contract MockRewardsCoordinator { @@ -110,12 +118,10 @@ contract ECDSAServiceManagerSetup is Test { strategies: new IECDSAStakeRegistryTypes.StrategyParams[](2) }); quorum.strategies[0] = IECDSAStakeRegistryTypes.StrategyParams({ - strategy: IStrategy(address(420)), - multiplier: 5000 + strategy: IStrategy(address(420)), multiplier: 5000 }); quorum.strategies[1] = IECDSAStakeRegistryTypes.StrategyParams({ - strategy: IStrategy(address(421)), - multiplier: 5000 + strategy: IStrategy(address(421)), multiplier: 5000 }); address[] memory operators = new address[](0); diff --git a/test/unit/ECDSAStakeRegistryEqualWeightUnit.t.sol b/test/unit/ECDSAStakeRegistryEqualWeightUnit.t.sol index 60cbd94e4..39f02efc8 100644 --- a/test/unit/ECDSAStakeRegistryEqualWeightUnit.t.sol +++ b/test/unit/ECDSAStakeRegistryEqualWeightUnit.t.sol @@ -5,8 +5,9 @@ import { ISignatureUtilsMixin, ISignatureUtilsMixinTypes } from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import { @@ -14,8 +15,9 @@ import { IECDSAStakeRegistryTypes } from "../../src/interfaces/IECDSAStakeRegistry.sol"; import {ECDSAStakeRegistrySetup} from "./ECDSAStakeRegistryUnit.t.sol"; -import {ECDSAStakeRegistryEqualWeight} from - "../../src/unaudited/examples/ECDSAStakeRegistryEqualWeight.sol"; +import { + ECDSAStakeRegistryEqualWeight +} from "../../src/unaudited/examples/ECDSAStakeRegistryEqualWeight.sol"; contract EqualWeightECDSARegistry is ECDSAStakeRegistrySetup { ECDSAStakeRegistryEqualWeight internal fixedWeightRegistry; diff --git a/test/unit/ECDSAStakeRegistryPermissionedUnit.t.sol b/test/unit/ECDSAStakeRegistryPermissionedUnit.t.sol index 61c355d07..f9c2370ac 100644 --- a/test/unit/ECDSAStakeRegistryPermissionedUnit.t.sol +++ b/test/unit/ECDSAStakeRegistryPermissionedUnit.t.sol @@ -5,8 +5,9 @@ import { ISignatureUtilsMixin, ISignatureUtilsMixinTypes } from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import { @@ -15,8 +16,9 @@ import { IECDSAStakeRegistryErrors } from "../../src/interfaces/IECDSAStakeRegistry.sol"; import {ECDSAStakeRegistrySetup} from "./ECDSAStakeRegistryUnit.t.sol"; -import {ECDSAStakeRegistryPermissioned} from - "../../src/unaudited/examples/ECDSAStakeRegistryPermissioned.sol"; +import { + ECDSAStakeRegistryPermissioned +} from "../../src/unaudited/examples/ECDSAStakeRegistryPermissioned.sol"; contract PermissionedECDSAStakeRegistryTest is ECDSAStakeRegistrySetup { ECDSAStakeRegistryPermissioned internal permissionedRegistry; diff --git a/test/unit/ECDSAStakeRegistryUnit.t.sol b/test/unit/ECDSAStakeRegistryUnit.t.sol index 0d9fbf1c6..bce29a308 100644 --- a/test/unit/ECDSAStakeRegistryUnit.t.sol +++ b/test/unit/ECDSAStakeRegistryUnit.t.sol @@ -7,8 +7,9 @@ import { ISignatureUtilsMixin, ISignatureUtilsMixinTypes } from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import {ECDSAStakeRegistry} from "../../src/unaudited/ECDSAStakeRegistry.sol"; @@ -32,7 +33,10 @@ contract MockServiceManager { } contract MockDelegationManager { - function operatorShares(address, address) external pure returns (uint256) { + function operatorShares( + address, + address + ) external pure returns (uint256) { return 1000; // Return a dummy value for simplicity } @@ -126,8 +130,7 @@ contract ECDSAStakeRegistryTest is ECDSAStakeRegistrySetup { strategies: new IECDSAStakeRegistryTypes.StrategyParams[](1) }); validQuorum.strategies[0] = IECDSAStakeRegistryTypes.StrategyParams({ - strategy: IStrategy(address(420)), - multiplier: 10000 + strategy: IStrategy(address(420)), multiplier: 10000 }); address[] memory operators = new address[](2); @@ -221,9 +224,7 @@ contract ECDSAStakeRegistryTest is ECDSAStakeRegistrySetup { MockServiceManager.registerOperatorToAVS.selector, operator1, ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry({ - signature: signatureData, - salt: bytes32(uint256(0x120)), - expiry: 10 + signature: signatureData, salt: bytes32(uint256(0x120)), expiry: 10 }) ), abi.encode(50) @@ -962,8 +963,7 @@ contract ECDSAStakeRegistryEventsTest is ECDSAStakeRegistrySetup { strategies: new IECDSAStakeRegistryTypes.StrategyParams[](1) }); newQuorum.strategies[0] = IECDSAStakeRegistryTypes.StrategyParams({ - strategy: IStrategy(address(0x1234)), - multiplier: 10000 + strategy: IStrategy(address(0x1234)), multiplier: 10000 }); vm.expectEmit(true, true, true, true); @@ -1377,7 +1377,10 @@ contract ECDSAStakeRegistryFuzzTests is ECDSAStakeRegistrySetup { ); } - function testFuzz_RegisterDeregisterOperator(address operator, uint256 operatorPk) public { + function testFuzz_RegisterDeregisterOperator( + address operator, + uint256 operatorPk + ) public { vm.assume(operator != address(0)); vm.assume(operatorPk != 0); vm.assume(!registry.operatorRegistered(operator)); diff --git a/test/unit/EjectionManagerUnit.t.sol b/test/unit/EjectionManagerUnit.t.sol index 25ef6ee16..181a37520 100644 --- a/test/unit/EjectionManagerUnit.t.sol +++ b/test/unit/EjectionManagerUnit.t.sol @@ -36,8 +36,7 @@ contract EjectionManagerUnitTests is MockAVSDeployer { for (uint8 i = 0; i < numQuorums; i++) { quorumEjectionParams.push( IEjectionManagerTypes.QuorumEjectionParams({ - rateLimitWindow: ratelimitWindow, - ejectableStakePercent: ejectableStakePercent + rateLimitWindow: ratelimitWindow, ejectableStakePercent: ejectableStakePercent }) ); } @@ -522,10 +521,9 @@ contract EjectionManagerUnitTests is MockAVSDeployer { ratelimitWindow = 2 days; ejectableStakePercent = 2000; IEjectionManagerTypes.QuorumEjectionParams memory _quorumEjectionParams = - IEjectionManagerTypes.QuorumEjectionParams({ - rateLimitWindow: ratelimitWindow, - ejectableStakePercent: ejectableStakePercent - }); + IEjectionManagerTypes.QuorumEjectionParams({ + rateLimitWindow: ratelimitWindow, ejectableStakePercent: ejectableStakePercent + }); cheats.expectEmit(true, true, true, true, address(ejectionManager)); emit QuorumEjectionParamsSet(quorumNumber, ratelimitWindow, ejectableStakePercent); @@ -567,8 +565,7 @@ contract EjectionManagerUnitTests is MockAVSDeployer { ejectionManager.setQuorumEjectionParams( 0, IEjectionManagerTypes.QuorumEjectionParams({ - rateLimitWindow: 7 days, - ejectableStakePercent: 9999 + rateLimitWindow: 7 days, ejectableStakePercent: 9999 }) ); @@ -577,7 +574,10 @@ contract EjectionManagerUnitTests is MockAVSDeployer { ejectionManager.amountEjectableForQuorum(1); } - function _registerOperators(uint8 numOperators, uint96 stake) internal { + function _registerOperators( + uint8 numOperators, + uint96 stake + ) internal { for (uint256 i = 0; i < numOperators; i++) { BN254.G1Point memory pubKey = BN254.hashToG1(keccak256(abi.encodePacked(i))); address operator = _incrementAddress(defaultOperator, i); diff --git a/test/unit/IndexRegistryUnit.t.sol b/test/unit/IndexRegistryUnit.t.sol index 8a8e5bc44..3eb11f3b1 100644 --- a/test/unit/IndexRegistryUnit.t.sol +++ b/test/unit/IndexRegistryUnit.t.sol @@ -124,13 +124,19 @@ contract IndexRegistryUnitTests is MockAVSDeployer, IIndexRegistryEvents { } /// @dev deregister an operator for a given set of quorums - function _deregisterOperator(bytes32 operatorId, bytes memory quorumNumbers) internal { + function _deregisterOperator( + bytes32 operatorId, + bytes memory quorumNumbers + ) internal { cheats.prank(address(registryCoordinator)); indexRegistry.deregisterOperator(operatorId, quorumNumbers); } /// @dev deregister an operator for a single quorum - function _deregisterOperatorSingleQuorum(bytes32 operatorId, uint8 quorumNumber) internal { + function _deregisterOperatorSingleQuorum( + bytes32 operatorId, + uint8 quorumNumber + ) internal { bytes memory quorumNumbers = new bytes(1); quorumNumbers[0] = bytes1(quorumNumber); cheats.prank(address(registryCoordinator)); @@ -139,7 +145,11 @@ contract IndexRegistryUnitTests is MockAVSDeployer, IIndexRegistryEvents { /// @dev Uses `rand` to return a random uint, with a range given by `min` and `max` (inclusive) /// @return `min` <= result <= `max` - function _randUint(bytes32 rand, uint256 min, uint256 max) internal pure returns (uint256) { + function _randUint( + bytes32 rand, + uint256 min, + uint256 max + ) internal pure returns (uint256) { // hashing makes for more uniform randomness rand = keccak256(abi.encodePacked(rand)); @@ -259,8 +269,9 @@ contract IndexRegistryUnitTests_configAndGetters is IndexRegistryUnitTests { bytes32[] memory currRegisteredOperatorIds = new bytes32[](numOperators); uint256 currIndex = 0; for (uint256 i = 0; i < numOperators; i++) { - uint256 rand = - _randUint({rand: keccak256(abi.encodePacked(bytes32(i), randSalt)), min: 0, max: 1}); + uint256 rand = _randUint({ + rand: keccak256(abi.encodePacked(bytes32(i), randSalt)), min: 0, max: 1 + }); // Roll block number currBlockNumber += 10; @@ -303,8 +314,9 @@ contract IndexRegistryUnitTests_configAndGetters is IndexRegistryUnitTests { uint256 currIndex = 0; uint32 currBlockNumber = uint32(block.number); for (uint256 i = 0; i < numOperators; i++) { - uint256 rand = - _randUint({rand: keccak256(abi.encodePacked(bytes32(i), randSalt)), min: 0, max: 1}); + uint256 rand = _randUint({ + rand: keccak256(abi.encodePacked(bytes32(i), randSalt)), min: 0, max: 1 + }); // Roll block number currBlockNumber += 10; @@ -344,8 +356,9 @@ contract IndexRegistryUnitTests_configAndGetters is IndexRegistryUnitTests { bytes32[] memory currRegisteredOperatorIds = new bytes32[](numOperators); uint256 currIndex = 0; for (uint256 i = 0; i < numOperators; i++) { - uint256 rand = - _randUint({rand: keccak256(abi.encodePacked(bytes32(i), randSalt)), min: 0, max: 1}); + uint256 rand = _randUint({ + rand: keccak256(abi.encodePacked(bytes32(i), randSalt)), min: 0, max: 1 + }); // deregister operator, must also have at least one registered operator if (rand == 0 && currIndex > 0) { @@ -468,7 +481,10 @@ contract IndexRegistryUnitTests_registerOperator is IndexRegistryUnitTests { * We ensure that none of the invalid quorumNumbers are initialized by masking out the initialized quorums and * expect a revert on registerOperator */ - function testFuzz_Revert_WhenInvalidQuorums(uint192 bitmap, uint192 invalidBitmap) public { + function testFuzz_Revert_WhenInvalidQuorums( + uint192 bitmap, + uint192 invalidBitmap + ) public { cheats.assume(bitmap > initializedQuorumBitmap); cheats.assume(invalidBitmap > initializedQuorumBitmap); // mask out quorums that are already initialized and the quorums that are not going to be registered @@ -752,7 +768,10 @@ contract IndexRegistryUnitTests_deregisterOperator is IndexRegistryUnitTests { * we ensure that none of the invalid quorumNumbers are initialized by masking out the initialized quorums and * expect a revert on deregisterOperator */ - function testFuzz_Revert_WhenInvalidQuorums(uint192 bitmap, uint192 invalidBitmap) public { + function testFuzz_Revert_WhenInvalidQuorums( + uint192 bitmap, + uint192 invalidBitmap + ) public { cheats.assume(bitmap > initializedQuorumBitmap); cheats.assume(invalidBitmap > initializedQuorumBitmap); // mask out quorums that are already initialized and the quorums that are not going to be registered @@ -875,8 +894,8 @@ contract IndexRegistryUnitTests_deregisterOperator is IndexRegistryUnitTests { // get operator index, if operator index is new quorumCount // then other operator indexes are unchanged // otherwise the popped index operatorId will replace the deregistered operator's index - uint32 operatorIndex = - IndexRegistry(address(indexRegistry)).currentOperatorIndex(quorumNumber, operatorId); + uint32 operatorIndex = IndexRegistry(address(indexRegistry)) + .currentOperatorIndex(quorumNumber, operatorId); uint32 quorumCountBefore = indexRegistry.getLatestQuorumUpdate(quorumNumber).numOperators; @@ -884,10 +903,11 @@ contract IndexRegistryUnitTests_deregisterOperator is IndexRegistryUnitTests { operatorIndex <= quorumCountBefore - 1, "operator index should be less than quorumCount" ); - bytes32 operatorIdAtBeforeQuorumCount = indexRegistry.getLatestOperatorUpdate({ - quorumNumber: quorumNumber, - operatorIndex: quorumCountBefore - 1 - }).operatorId; + bytes32 operatorIdAtBeforeQuorumCount = + indexRegistry.getLatestOperatorUpdate({ + quorumNumber: quorumNumber, operatorIndex: quorumCountBefore - 1 + }) + .operatorId; if (operatorIndex != quorumCountBefore - 1) { // expect popped index operator to be reassigned @@ -951,8 +971,8 @@ contract IndexRegistryUnitTests_deregisterOperator is IndexRegistryUnitTests { // get operator index, if operator index is new quorumCount // then other operator indexes are unchanged // otherwise the popped index operatorId will replace the deregistered operator's index - uint32 operatorIndex = - IndexRegistry(address(indexRegistry)).currentOperatorIndex(quorumNumber, operatorId); + uint32 operatorIndex = IndexRegistry(address(indexRegistry)) + .currentOperatorIndex(quorumNumber, operatorId); uint32 quorumCountBefore = indexRegistry.getLatestQuorumUpdate(quorumNumber).numOperators; @@ -960,10 +980,11 @@ contract IndexRegistryUnitTests_deregisterOperator is IndexRegistryUnitTests { operatorIndex <= quorumCountBefore - 1, "operator index should be less than quorumCount" ); - bytes32 operatorIdAtBeforeQuorumCount = indexRegistry.getLatestOperatorUpdate({ - quorumNumber: quorumNumber, - operatorIndex: quorumCountBefore - 1 - }).operatorId; + bytes32 operatorIdAtBeforeQuorumCount = + indexRegistry.getLatestOperatorUpdate({ + quorumNumber: quorumNumber, operatorIndex: quorumCountBefore - 1 + }) + .operatorId; if (operatorIndex != quorumCountBefore - 1) { // expect popped index operator to be reassigned @@ -1047,8 +1068,10 @@ contract IndexRegistryUnitTests_deregisterOperator is IndexRegistryUnitTests { expectedFromBlockNumber: block.number }); - IIndexRegistry.OperatorUpdate memory operatorUpdate = indexRegistry - .getLatestOperatorUpdate({quorumNumber: uint8(quorumsToRemove[i]), operatorIndex: 0}); + IIndexRegistry.OperatorUpdate memory operatorUpdate = + indexRegistry.getLatestOperatorUpdate({ + quorumNumber: uint8(quorumsToRemove[i]), operatorIndex: 0 + }); assertEq( operatorUpdate.fromBlockNumber, block.number, "fromBlockNumber not set correctly" ); @@ -1102,8 +1125,10 @@ contract IndexRegistryUnitTests_deregisterOperator is IndexRegistryUnitTests { }); // Check operator's index for removed quorums - IIndexRegistry.OperatorUpdate memory operatorUpdate = indexRegistry - .getLatestOperatorUpdate({quorumNumber: uint8(quorumsToRemove[i]), operatorIndex: 1}); + IIndexRegistry.OperatorUpdate memory operatorUpdate = + indexRegistry.getLatestOperatorUpdate({ + quorumNumber: uint8(quorumsToRemove[i]), operatorIndex: 1 + }); assertEq( operatorUpdate.fromBlockNumber, block.number, "fromBlockNumber not set correctly" ); diff --git a/test/unit/InstantSlasher.t.sol b/test/unit/InstantSlasher.t.sol index bc2e77147..adea3a51f 100644 --- a/test/unit/InstantSlasher.t.sol +++ b/test/unit/InstantSlasher.t.sol @@ -16,21 +16,25 @@ import {ISlasher, ISlasherTypes, ISlasherErrors} from "../../src/interfaces/ISla import {ISlashingRegistryCoordinator} from "../../src/interfaces/ISlashingRegistryCoordinator.sol"; import {IStakeRegistry, IStakeRegistryTypes} from "../../src/interfaces/IStakeRegistry.sol"; import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; -import {TransparentUpgradeableProxy} from - "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { + TransparentUpgradeableProxy +} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import {EmptyContract} from "eigenlayer-contracts/src/test/mocks/EmptyContract.sol"; import {AllocationManager} from "eigenlayer-contracts/src/contracts/core/AllocationManager.sol"; -import {PermissionController} from - "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; +import { + PermissionController +} from "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; import {PauserRegistry} from "eigenlayer-contracts/src/contracts/permissions/PauserRegistry.sol"; import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol"; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol"; import {DelegationMock} from "../mocks/DelegationMock.sol"; import {SlashingRegistryCoordinator} from "../../src/SlashingRegistryCoordinator.sol"; -import {ISlashingRegistryCoordinatorTypes} from - "../../src/interfaces/ISlashingRegistryCoordinator.sol"; +import { + ISlashingRegistryCoordinatorTypes +} from "../../src/interfaces/ISlashingRegistryCoordinator.sol"; import {IBLSApkRegistry, IBLSApkRegistryTypes} from "../../src/interfaces/IBLSApkRegistry.sol"; import {IIndexRegistry} from "../../src/interfaces/IIndexRegistry.sol"; import {ISocketRegistry} from "../../src/interfaces/ISocketRegistry.sol"; @@ -137,16 +141,14 @@ contract InstantSlasherTest is Test { vm.stopPrank(); vm.startPrank(strategyManagerOwner); - IStrategyManager(coreDeployment.strategyManager).setStrategyWhitelister( - coreDeployment.strategyFactory - ); + IStrategyManager(coreDeployment.strategyManager) + .setStrategyWhitelister(coreDeployment.strategyFactory); vm.stopPrank(); vm.startPrank(proxyAdminOwner); mockStrategy = IStrategy( - StrategyFactory(coreDeployment.strategyFactory).deployNewStrategy( - IERC20(address(mockToken)) - ) + StrategyFactory(coreDeployment.strategyFactory) + .deployNewStrategy(IERC20(address(mockToken))) ); vm.stopPrank(); @@ -178,14 +180,14 @@ contract InstantSlasherTest is Test { middlewareConfig.blsApkRegistry.initialOwner = proxyAdminOwner; vm.startPrank(proxyAdminOwner); - MiddlewareDeployLib.MiddlewareDeployData memory middlewareDeployments = MiddlewareDeployLib - .deployMiddleware( - address(proxyAdmin), - coreDeployment.allocationManager, - coreDeployment.strategyManager, - address(pauserRegistry), - middlewareConfig - ); + MiddlewareDeployLib.MiddlewareDeployData memory middlewareDeployments = + MiddlewareDeployLib.deployMiddleware( + address(proxyAdmin), + coreDeployment.allocationManager, + coreDeployment.strategyManager, + address(pauserRegistry), + middlewareConfig + ); vm.stopPrank(); vm.startPrank(serviceManager); @@ -195,26 +197,29 @@ contract InstantSlasherTest is Test { instantSlasher = InstantSlasher(middlewareDeployments.instantSlasher); stakeRegistry = StakeRegistry(middlewareDeployments.stakeRegistry); - PermissionController(coreDeployment.permissionController).setAppointee( - address(serviceManager), - address(slashingRegistryCoordinator), - coreDeployment.allocationManager, - bytes4(keccak256("createOperatorSets(address,(uint32,address[],address)[])")) - ); - - PermissionController(coreDeployment.permissionController).setAppointee( - address(serviceManager), - address(slashingRegistryCoordinator), - coreDeployment.allocationManager, - AllocationManager.deregisterFromOperatorSets.selector - ); - - PermissionController(coreDeployment.permissionController).setAppointee( - address(serviceManager), - proxyAdminOwner, - coreDeployment.allocationManager, - AllocationManager.updateAVSMetadataURI.selector - ); + PermissionController(coreDeployment.permissionController) + .setAppointee( + address(serviceManager), + address(slashingRegistryCoordinator), + coreDeployment.allocationManager, + bytes4(keccak256("createOperatorSets(address,(uint32,address[],address)[])")) + ); + + PermissionController(coreDeployment.permissionController) + .setAppointee( + address(serviceManager), + address(slashingRegistryCoordinator), + coreDeployment.allocationManager, + AllocationManager.deregisterFromOperatorSets.selector + ); + + PermissionController(coreDeployment.permissionController) + .setAppointee( + address(serviceManager), + proxyAdminOwner, + coreDeployment.allocationManager, + AllocationManager.updateAVSMetadataURI.selector + ); vm.stopPrank(); @@ -231,16 +236,13 @@ contract InstantSlasherTest is Test { IStakeRegistryTypes.StrategyParams({strategy: mockStrategy, multiplier: 1 ether}); ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 10, - kickBIPsOfOperatorStake: 0, - kickBIPsOfTotalStake: 0 - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 10, kickBIPsOfOperatorStake: 0, kickBIPsOfTotalStake: 0 + }); vm.startPrank(proxyAdminOwner); - IAllocationManager(coreDeployment.allocationManager).updateAVSMetadataURI( - serviceManager, "fake-avs-metadata" - ); + IAllocationManager(coreDeployment.allocationManager) + .updateAVSMetadataURI(serviceManager, "fake-avs-metadata"); slashingRegistryCoordinator.createSlashableStakeQuorum( operatorSetParams, 1 ether, strategyParams, 0, address(instantSlasher) ); @@ -266,26 +268,22 @@ contract InstantSlasherTest is Test { // Roll block number so we don't underflow in the DM when calculating `prevQueuedScaledShares` vm.roll(block.number + ALLOCATION_CONFIGURATION_DELAY + 1); vm.startPrank(operatorWallet.key.addr); - IDelegationManager(coreDeployment.delegationManager).registerAsOperator( - address(0), 1, "metadata" - ); + IDelegationManager(coreDeployment.delegationManager) + .registerAsOperator(address(0), 1, "metadata"); uint256 depositAmount = 1 ether; mockToken.mint(operatorWallet.key.addr, depositAmount); mockToken.approve(address(coreDeployment.strategyManager), depositAmount); - IStrategyManager(coreDeployment.strategyManager).depositIntoStrategy( - mockStrategy, mockToken, depositAmount - ); + IStrategyManager(coreDeployment.strategyManager) + .depositIntoStrategy(mockStrategy, mockToken, depositAmount); uint32 minDelay = 1; - IAllocationManager(coreDeployment.allocationManager).setAllocationDelay( - operatorWallet.key.addr, minDelay - ); + IAllocationManager(coreDeployment.allocationManager) + .setAllocationDelay(operatorWallet.key.addr, minDelay); vm.stopPrank(); - (bool isSet,) = IAllocationManager(coreDeployment.allocationManager).getAllocationDelay( - operatorWallet.key.addr - ); + (bool isSet,) = IAllocationManager(coreDeployment.allocationManager) + .getAllocationDelay(operatorWallet.key.addr); assertTrue(isSet, "Operator allocation delay set"); IStrategy[] memory allocStrategies = new IStrategy[](1); @@ -299,11 +297,13 @@ contract InstantSlasherTest is Test { vm.startPrank(serviceManager); IAllocationManagerTypes.CreateSetParams[] memory createParams = new IAllocationManagerTypes.CreateSetParams[](1); - createParams[0] = - IAllocationManagerTypes.CreateSetParams({operatorSetId: 0, strategies: allocStrategies}); - IAllocationManager(coreDeployment.allocationManager).setAVSRegistrar( - address(serviceManager), IAVSRegistrar(address(slashingRegistryCoordinator)) - ); + createParams[0] = IAllocationManagerTypes.CreateSetParams({ + operatorSetId: 0, strategies: allocStrategies + }); + IAllocationManager(coreDeployment.allocationManager) + .setAVSRegistrar( + address(serviceManager), IAVSRegistrar(address(slashingRegistryCoordinator)) + ); vm.stopPrank(); vm.startPrank(operatorWallet.key.addr); @@ -311,14 +311,11 @@ contract InstantSlasherTest is Test { IAllocationManagerTypes.AllocateParams[] memory allocParams = new IAllocationManagerTypes.AllocateParams[](1); allocParams[0] = IAllocationManagerTypes.AllocateParams({ - operatorSet: operatorSet, - strategies: allocStrategies, - newMagnitudes: magnitudes + operatorSet: operatorSet, strategies: allocStrategies, newMagnitudes: magnitudes }); - IAllocationManager(coreDeployment.allocationManager).modifyAllocations( - operatorWallet.key.addr, allocParams - ); + IAllocationManager(coreDeployment.allocationManager) + .modifyAllocations(operatorWallet.key.addr, allocParams); vm.roll(block.number + 100); uint32[] memory operatorSetIds = new uint32[](1); @@ -326,34 +323,30 @@ contract InstantSlasherTest is Test { bytes32 messageHash = slashingRegistryCoordinator.calculatePubkeyRegistrationMessageHash( operatorWallet.key.addr ); - IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = IBLSApkRegistryTypes - .PubkeyRegistrationParams({ - pubkeyRegistrationSignature: SigningKeyOperationsLib.sign( - operatorWallet.signingKey, messageHash - ), - pubkeyG1: operatorWallet.signingKey.publicKeyG1, - pubkeyG2: operatorWallet.signingKey.publicKeyG2 - }); + IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = + IBLSApkRegistryTypes.PubkeyRegistrationParams({ + pubkeyRegistrationSignature: SigningKeyOperationsLib.sign( + operatorWallet.signingKey, messageHash + ), + pubkeyG1: operatorWallet.signingKey.publicKeyG1, + pubkeyG2: operatorWallet.signingKey.publicKeyG2 + }); bytes memory registrationData = abi.encode( ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, "socket", pubkeyParams ); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: operatorSetIds, - data: registrationData - }); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - operatorWallet.key.addr, registerParams - ); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), operatorSetIds: operatorSetIds, data: registrationData + }); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(operatorWallet.key.addr, registerParams); vm.stopPrank(); vm.roll(block.number + 100); - IAllocationManagerTypes.SlashingParams memory params = IAllocationManagerTypes - .SlashingParams({ + IAllocationManagerTypes.SlashingParams memory params = IAllocationManagerTypes.SlashingParams({ operator: operatorWallet.key.addr, operatorSetId: 0, strategies: allocStrategies, @@ -482,8 +475,7 @@ contract InstantSlasherTest is Test { IStrategy[] memory allocStrategies = new IStrategy[](1); allocStrategies[0] = mockStrategy; - IAllocationManagerTypes.SlashingParams memory params = IAllocationManagerTypes - .SlashingParams({ + IAllocationManagerTypes.SlashingParams memory params = IAllocationManagerTypes.SlashingParams({ operator: operatorWallet.key.addr, operatorSetId: 0, strategies: allocStrategies, @@ -506,8 +498,7 @@ contract InstantSlasherTest is Test { IStrategy[] memory allocStrategies = new IStrategy[](1); allocStrategies[0] = mockStrategy; - IAllocationManagerTypes.SlashingParams memory params = IAllocationManagerTypes - .SlashingParams({ + IAllocationManagerTypes.SlashingParams memory params = IAllocationManagerTypes.SlashingParams({ operator: operatorWallet.key.addr, operatorSetId: 0, strategies: allocStrategies, @@ -524,21 +515,18 @@ contract InstantSlasherTest is Test { function _setupOperatorForSlashing() internal returns (bytes32) { vm.startPrank(operatorWallet.key.addr); - IDelegationManager(coreDeployment.delegationManager).registerAsOperator( - address(0), 1, "metadata" - ); + IDelegationManager(coreDeployment.delegationManager) + .registerAsOperator(address(0), 1, "metadata"); uint256 depositAmount = 2 ether; mockToken.mint(operatorWallet.key.addr, depositAmount); mockToken.approve(address(coreDeployment.strategyManager), depositAmount); - IStrategyManager(coreDeployment.strategyManager).depositIntoStrategy( - mockStrategy, mockToken, depositAmount - ); + IStrategyManager(coreDeployment.strategyManager) + .depositIntoStrategy(mockStrategy, mockToken, depositAmount); uint32 minDelay = 1; - IAllocationManager(coreDeployment.allocationManager).setAllocationDelay( - operatorWallet.key.addr, minDelay - ); + IAllocationManager(coreDeployment.allocationManager) + .setAllocationDelay(operatorWallet.key.addr, minDelay); vm.stopPrank(); vm.roll(block.number + ALLOCATION_CONFIGURATION_DELAY + 1); @@ -554,11 +542,13 @@ contract InstantSlasherTest is Test { vm.startPrank(serviceManager); IAllocationManagerTypes.CreateSetParams[] memory createParams = new IAllocationManagerTypes.CreateSetParams[](1); - createParams[0] = - IAllocationManagerTypes.CreateSetParams({operatorSetId: 0, strategies: allocStrategies}); - IAllocationManager(coreDeployment.allocationManager).setAVSRegistrar( - address(serviceManager), IAVSRegistrar(address(slashingRegistryCoordinator)) - ); + createParams[0] = IAllocationManagerTypes.CreateSetParams({ + operatorSetId: 0, strategies: allocStrategies + }); + IAllocationManager(coreDeployment.allocationManager) + .setAVSRegistrar( + address(serviceManager), IAVSRegistrar(address(slashingRegistryCoordinator)) + ); vm.stopPrank(); vm.startPrank(operatorWallet.key.addr); @@ -566,14 +556,11 @@ contract InstantSlasherTest is Test { IAllocationManagerTypes.AllocateParams[] memory allocParams = new IAllocationManagerTypes.AllocateParams[](1); allocParams[0] = IAllocationManagerTypes.AllocateParams({ - operatorSet: operatorSet, - strategies: allocStrategies, - newMagnitudes: magnitudes + operatorSet: operatorSet, strategies: allocStrategies, newMagnitudes: magnitudes }); - IAllocationManager(coreDeployment.allocationManager).modifyAllocations( - operatorWallet.key.addr, allocParams - ); + IAllocationManager(coreDeployment.allocationManager) + .modifyAllocations(operatorWallet.key.addr, allocParams); vm.roll(block.number + 100); uint32[] memory operatorSetIds = new uint32[](1); @@ -581,28 +568,25 @@ contract InstantSlasherTest is Test { bytes32 messageHash = slashingRegistryCoordinator.calculatePubkeyRegistrationMessageHash( operatorWallet.key.addr ); - IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = IBLSApkRegistryTypes - .PubkeyRegistrationParams({ - pubkeyRegistrationSignature: SigningKeyOperationsLib.sign( - operatorWallet.signingKey, messageHash - ), - pubkeyG1: operatorWallet.signingKey.publicKeyG1, - pubkeyG2: operatorWallet.signingKey.publicKeyG2 - }); + IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = + IBLSApkRegistryTypes.PubkeyRegistrationParams({ + pubkeyRegistrationSignature: SigningKeyOperationsLib.sign( + operatorWallet.signingKey, messageHash + ), + pubkeyG1: operatorWallet.signingKey.publicKeyG1, + pubkeyG2: operatorWallet.signingKey.publicKeyG2 + }); bytes memory registrationData = abi.encode( ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, "socket", pubkeyParams ); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: operatorSetIds, - data: registrationData - }); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - operatorWallet.key.addr, registerParams - ); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), operatorSetIds: operatorSetIds, data: registrationData + }); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(operatorWallet.key.addr, registerParams); vm.stopPrank(); vm.roll(block.number + 100); diff --git a/test/unit/OperatorStateRetrieverUnit.t.sol b/test/unit/OperatorStateRetrieverUnit.t.sol index 374180eed..23a8b26af 100644 --- a/test/unit/OperatorStateRetrieverUnit.t.sol +++ b/test/unit/OperatorStateRetrieverUnit.t.sol @@ -51,8 +51,7 @@ contract OperatorStateRetrieverUnitTests is MockAVSDeployer { cheats.prank(defaultOperator); registryCoordinator.deregisterOperator(BitmapUtils.bitmapToBytesArray(quorumBitmap)); - (uint256 fetchedQuorumBitmap, OperatorStateRetriever.Operator[][] memory operators) = - operatorStateRetriever.getOperatorState( + (uint256 fetchedQuorumBitmap, OperatorStateRetriever.Operator[][] memory operators) = operatorStateRetriever.getOperatorState( registryCoordinator, defaultOperatorId, uint32(block.number) ); assertEq(fetchedQuorumBitmap, 0); @@ -64,8 +63,7 @@ contract OperatorStateRetrieverUnitTests is MockAVSDeployer { cheats.roll(registrationBlockNumber); _registerOperatorWithCoordinator(defaultOperator, quorumBitmap, defaultPubKey); - (uint256 fetchedQuorumBitmap, OperatorStateRetriever.Operator[][] memory operators) = - operatorStateRetriever.getOperatorState( + (uint256 fetchedQuorumBitmap, OperatorStateRetriever.Operator[][] memory operators) = operatorStateRetriever.getOperatorState( registryCoordinator, defaultOperatorId, uint32(block.number) ); assertEq(fetchedQuorumBitmap, 1); @@ -90,17 +88,16 @@ contract OperatorStateRetrieverUnitTests is MockAVSDeployer { function test_getOperatorState_revert_quorumNotCreatedAtReferenceBlockNumber() public { cheats.roll(registrationBlockNumber); ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: defaultMaxOperatorCount, - kickBIPsOfOperatorStake: defaultKickBIPsOfOperatorStake, - kickBIPsOfTotalStake: defaultKickBIPsOfTotalStake - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: defaultMaxOperatorCount, + kickBIPsOfOperatorStake: defaultKickBIPsOfOperatorStake, + kickBIPsOfTotalStake: defaultKickBIPsOfTotalStake + }); uint96 minimumStake = 1; IStakeRegistryTypes.StrategyParams[] memory strategyParams = new IStakeRegistryTypes.StrategyParams[](1); strategyParams[0] = IStakeRegistryTypes.StrategyParams({ - strategy: IStrategy(address(1000)), - multiplier: 1e16 + strategy: IStrategy(address(1000)), multiplier: 1e16 }); cheats.prank(registryCoordinator.owner()); @@ -131,12 +128,12 @@ contract OperatorStateRetrieverUnitTests is MockAVSDeployer { otherOperator, quorumBitmapThree, otherPubKey, defaultStake - 1 ); - OperatorStateRetriever.Operator[][] memory operators = operatorStateRetriever - .getOperatorState( - registryCoordinator, - BitmapUtils.bitmapToBytesArray(quorumBitmapThree), - uint32(block.number) - ); + OperatorStateRetriever.Operator[][] memory operators = + operatorStateRetriever.getOperatorState( + registryCoordinator, + BitmapUtils.bitmapToBytesArray(quorumBitmapThree), + uint32(block.number) + ); assertEq(operators.length, 2); assertEq(operators[0].length, 2); assertEq(operators[1].length, 1); @@ -223,9 +220,7 @@ contract OperatorStateRetrieverUnitTests is MockAVSDeployer { ); } - function test_getCheckSignaturesIndices_revert_quorumNotCreatedAtReferenceBlockNumber() - public - { + function test_getCheckSignaturesIndices_revert_quorumNotCreatedAtReferenceBlockNumber() public { cheats.roll(registrationBlockNumber); _registerOperatorWithCoordinator(defaultOperator, 1, defaultPubKey); @@ -234,17 +229,16 @@ contract OperatorStateRetrieverUnitTests is MockAVSDeployer { nonSignerOperatorIds[0] = defaultOperatorId; ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: defaultMaxOperatorCount, - kickBIPsOfOperatorStake: defaultKickBIPsOfOperatorStake, - kickBIPsOfTotalStake: defaultKickBIPsOfTotalStake - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: defaultMaxOperatorCount, + kickBIPsOfOperatorStake: defaultKickBIPsOfOperatorStake, + kickBIPsOfTotalStake: defaultKickBIPsOfTotalStake + }); uint96 minimumStake = 1; IStakeRegistryTypes.StrategyParams[] memory strategyParams = new IStakeRegistryTypes.StrategyParams[](1); strategyParams[0] = IStakeRegistryTypes.StrategyParams({ - strategy: IStrategy(address(1000)), - multiplier: 1e16 + strategy: IStrategy(address(1000)), multiplier: 1e16 }); cheats.prank(registryCoordinator.owner()); @@ -302,12 +296,12 @@ contract OperatorStateRetrieverUnitTests is MockAVSDeployer { nonSignerOperatorIds[1] = otherOperatorId; OperatorStateRetriever.CheckSignaturesIndices memory checkSignaturesIndices = - operatorStateRetriever.getCheckSignaturesIndices( - registryCoordinator, - uint32(block.number), - BitmapUtils.bitmapToBytesArray(quorumBitmapThree), - nonSignerOperatorIds - ); + operatorStateRetriever.getCheckSignaturesIndices( + registryCoordinator, + uint32(block.number), + BitmapUtils.bitmapToBytesArray(quorumBitmapThree), + nonSignerOperatorIds + ); // we're querying for 2 operators, so there should be 2 nonSignerQuorumBitmapIndices assertEq(checkSignaturesIndices.nonSignerQuorumBitmapIndices.length, 2); // the first operator (0) registered for quorum 1, (1) deregistered from quorum 1, and (2) registered for quorum 2 @@ -390,8 +384,7 @@ contract OperatorStateRetrieverUnitTests is MockAVSDeployer { uint256 gasBefore = gasleft(); // retrieve the ordered list of operators for each quorum along with their id and stake - (uint256 quorumBitmap, OperatorStateRetriever.Operator[][] memory operators) = - operatorStateRetriever.getOperatorState( + (uint256 quorumBitmap, OperatorStateRetriever.Operator[][] memory operators) = operatorStateRetriever.getOperatorState( registryCoordinator, operatorMetadatas[i].operatorId, blockNumber ); uint256 gasAfter = gasleft(); @@ -412,8 +405,8 @@ contract OperatorStateRetrieverUnitTests is MockAVSDeployer { operatorMetadatas[operatorIndexToDeregister].quorumBitmap ); - uint32 deregistrationBlockNumber = registrationBlockNumber - + blocksBetweenRegistrations * (uint32(operatorMetadatas.length) + 1); + uint32 deregistrationBlockNumber = registrationBlockNumber + blocksBetweenRegistrations + * (uint32(operatorMetadatas.length) + 1); cheats.roll(deregistrationBlockNumber); cheats.prank(_incrementAddress(defaultOperator, operatorIndexToDeregister)); @@ -424,8 +417,9 @@ contract OperatorStateRetrieverUnitTests is MockAVSDeployer { // loop through indices till we find operatorIndexToDeregister, then move that last operator into that index for (uint256 j = 0; j < expectedOperatorOverallIndices[quorumNumber].length; j++) { if (expectedOperatorOverallIndices[quorumNumber][j] == operatorIndexToDeregister) { - expectedOperatorOverallIndices[quorumNumber][j] = expectedOperatorOverallIndices[quorumNumber][expectedOperatorOverallIndices[quorumNumber] - .length - 1]; + expectedOperatorOverallIndices[quorumNumber][j] = expectedOperatorOverallIndices[ + quorumNumber + ][expectedOperatorOverallIndices[quorumNumber].length - 1]; break; } } @@ -470,12 +464,12 @@ contract OperatorStateRetrieverUnitTests is MockAVSDeployer { bytes32[] memory nonSignerOperatorIds = new bytes32[](0); OperatorStateRetriever.CheckSignaturesIndices memory checkSignaturesIndices = - operatorStateRetriever.getCheckSignaturesIndices( - registryCoordinator, - cumulativeBlockNumber, - allInclusiveQuorumNumbers, - nonSignerOperatorIds - ); + operatorStateRetriever.getCheckSignaturesIndices( + registryCoordinator, + cumulativeBlockNumber, + allInclusiveQuorumNumbers, + nonSignerOperatorIds + ); assertEq( checkSignaturesIndices.nonSignerQuorumBitmapIndices.length, @@ -541,16 +535,16 @@ contract OperatorStateRetrieverUnitTests is MockAVSDeployer { ) % operatorMetadatas.length; for (uint256 i = 0; i < nonSignerOperatorIds.length; i++) { nonSignerOperatorIds[i] = - operatorMetadatas[(randomIndex + i) % operatorMetadatas.length].operatorId; + operatorMetadatas[(randomIndex + i) % operatorMetadatas.length].operatorId; } OperatorStateRetriever.CheckSignaturesIndices memory checkSignaturesIndices = - operatorStateRetriever.getCheckSignaturesIndices( - registryCoordinator, - cumulativeBlockNumber, - allInclusiveQuorumNumbers, - nonSignerOperatorIds - ); + operatorStateRetriever.getCheckSignaturesIndices( + registryCoordinator, + cumulativeBlockNumber, + allInclusiveQuorumNumbers, + nonSignerOperatorIds + ); assertEq( checkSignaturesIndices.nonSignerQuorumBitmapIndices.length, diff --git a/test/unit/RegistryCoordinatorUnit.t.sol b/test/unit/RegistryCoordinatorUnit.t.sol index a911672b5..9be9ee6ff 100644 --- a/test/unit/RegistryCoordinatorUnit.t.sol +++ b/test/unit/RegistryCoordinatorUnit.t.sol @@ -100,8 +100,9 @@ contract RegistryCoordinatorUnitTests is MockAVSDeployer { } operatorToRegister = _incrementAddress(defaultOperator, defaultMaxOperatorCount); - operatorToRegisterPubKey = - BN254.hashToG1(keccak256(abi.encodePacked(pseudoRandomNumber, defaultMaxOperatorCount))); + operatorToRegisterPubKey = BN254.hashToG1( + keccak256(abi.encodePacked(pseudoRandomNumber, defaultMaxOperatorCount)) + ); bytes32 operatorToRegisterId = BN254.hashG1Point(operatorToRegisterPubKey); bytes32 operatorToKickId; address operatorToKick; @@ -125,8 +126,7 @@ contract RegistryCoordinatorUnitTests is MockAVSDeployer { operatorIdsToSwap[0] = operatorToRegisterId; operatorKickParams[0] = ISlashingRegistryCoordinatorTypes.OperatorKickParam({ - quorumNumber: uint8(quorumNumbers[0]), - operator: operatorToKick + quorumNumber: uint8(quorumNumbers[0]), operator: operatorToKick }); } @@ -246,17 +246,16 @@ contract RegistryCoordinatorUnitTests_Initialization_Setters is RegistryCoordina _deployMockEigenLayerAndAVS(0); ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: defaultMaxOperatorCount, - kickBIPsOfOperatorStake: defaultKickBIPsOfOperatorStake, - kickBIPsOfTotalStake: defaultKickBIPsOfTotalStake - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: defaultMaxOperatorCount, + kickBIPsOfOperatorStake: defaultKickBIPsOfOperatorStake, + kickBIPsOfTotalStake: defaultKickBIPsOfTotalStake + }); uint96 minimumStake = 1; IStakeRegistryTypes.StrategyParams[] memory strategyParams = new IStakeRegistryTypes.StrategyParams[](1); strategyParams[0] = IStakeRegistryTypes.StrategyParams({ - strategy: IStrategy(address(1000)), - multiplier: 1e16 + strategy: IStrategy(address(1000)), multiplier: 1e16 }); uint8 quorumCountBefore = registryCoordinator.quorumCount(); @@ -992,8 +991,8 @@ contract RegistryCoordinatorUnitTests_DeregisterOperator_EjectOperator is for (uint256 i = 0; i < numOperators; i++) { // limit to maxQuorumsToRegisterFor quorums via mask so we don't run out of gas, make them all register for quorum 0 as well quorumBitmaps[i] = uint256( - keccak256(abi.encodePacked("quorumBitmap", pseudoRandomNumber, i)) - ) & (1 << maxQuorumsToRegisterFor - 1) | 1; + keccak256(abi.encodePacked("quorumBitmap", pseudoRandomNumber, i)) + ) & (1 << maxQuorumsToRegisterFor - 1) | 1; } cheats.roll(registrationBlockNumber); @@ -1705,8 +1704,7 @@ contract RegistryCoordinatorUnitTests_RegisterOperatorWithChurn is RegistryCoord operatorIdsToSwap[0] = operatorToRegisterId; operatorKickParams[0] = ISlashingRegistryCoordinatorTypes.OperatorKickParam({ - quorumNumber: defaultQuorumNumber, - operator: operatorToKick + quorumNumber: defaultQuorumNumber, operator: operatorToKick }); } @@ -1744,13 +1742,13 @@ contract RegistryCoordinatorUnitTests_RegisterOperatorWithChurn is RegistryCoord { ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory emptyAVSRegSig; ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory signatureWithExpiry = - _signOperatorChurnApproval( - operatorToRegister, - operatorToRegisterId, - operatorKickParams, - defaultSalt, - block.timestamp + 10 - ); + _signOperatorChurnApproval( + operatorToRegister, + operatorToRegisterId, + operatorKickParams, + defaultSalt, + block.timestamp + 10 + ); cheats.prank(operatorToRegister); uint256 gasBefore = gasleft(); registryCoordinator.registerOperatorWithChurn( @@ -1821,13 +1819,13 @@ contract RegistryCoordinatorUnitTests_RegisterOperatorWithChurn is RegistryCoord cheats.roll(registrationBlockNumber); ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory signatureWithExpiry = - _signOperatorChurnApproval( - operatorToRegister, - operatorToRegisterId, - operatorKickParams, - defaultSalt, - block.timestamp + 10 - ); + _signOperatorChurnApproval( + operatorToRegister, + operatorToRegisterId, + operatorKickParams, + defaultSalt, + block.timestamp + 10 + ); cheats.prank(operatorToRegister); cheats.expectRevert(bytes4(keccak256("InsufficientStakeForChurn()"))); registryCoordinator.registerOperatorWithChurn( @@ -1866,13 +1864,13 @@ contract RegistryCoordinatorUnitTests_RegisterOperatorWithChurn is RegistryCoord cheats.roll(registrationBlockNumber); ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory signatureWithExpiry = - _signOperatorChurnApproval( - operatorToRegister, - operatorToRegisterId, - operatorKickParams, - defaultSalt, - block.timestamp + 10 - ); + _signOperatorChurnApproval( + operatorToRegister, + operatorToRegisterId, + operatorKickParams, + defaultSalt, + block.timestamp + 10 + ); cheats.prank(operatorToRegister); cheats.expectRevert(bytes4(keccak256("CannotKickOperatorAboveThreshold()"))); registryCoordinator.registerOperatorWithChurn( @@ -1893,8 +1891,7 @@ contract RegistryCoordinatorUnitTests_RegisterOperatorWithChurn is RegistryCoord ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory emptyAVSRegSig; ( - address operatorToRegister, - , + address operatorToRegister,, ISlashingRegistryCoordinatorTypes.OperatorKickParam[] memory operatorKickParams ) = _test_registerOperatorWithChurn_SetUp(pseudoRandomNumber, quorumNumbers, defaultStake); @@ -1938,13 +1935,13 @@ contract RegistryCoordinatorUnitTests_RegisterOperatorWithChurn is RegistryCoord cheats.roll(registrationBlockNumber); ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory signatureWithSaltAndExpiry = - _signOperatorChurnApproval( - operatorToRegister, - operatorToRegisterId, - operatorKickParams, - defaultSalt, - block.timestamp - 1 - ); + _signOperatorChurnApproval( + operatorToRegister, + operatorToRegisterId, + operatorKickParams, + defaultSalt, + block.timestamp - 1 + ); cheats.prank(operatorToRegister); cheats.expectRevert(bytes4(keccak256("SignatureExpired()"))); registryCoordinator.registerOperatorWithChurn( @@ -2039,9 +2036,8 @@ contract RegistryCoordinatorUnitTests_UpdateOperators is RegistryCoordinatorUnit operatorsToUpdate[0] = defaultOperator; // force a staticcall to the `updateOperators` function -- this should *pass* because the call should be a strict no-op! - (bool success,) = address(registryCoordinator).staticcall( - abi.encodeWithSignature("updateOperators(address[])", operatorsToUpdate) - ); + (bool success,) = address(registryCoordinator) + .staticcall(abi.encodeWithSignature("updateOperators(address[])", operatorsToUpdate)); require(success, "staticcall failed!"); } @@ -2362,17 +2358,14 @@ contract RegistryCoordinatorUnitTests_BeforeMigration is RegistryCoordinatorUnit _deployMockEigenLayerAndAVS(0); // Set up test params ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 10, - kickBIPsOfOperatorStake: 0, - kickBIPsOfTotalStake: 0 - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 10, kickBIPsOfOperatorStake: 0, kickBIPsOfTotalStake: 0 + }); uint96 minimumStake = 100; IStakeRegistryTypes.StrategyParams[] memory strategyParams = new IStakeRegistryTypes.StrategyParams[](1); strategyParams[0] = IStakeRegistryTypes.StrategyParams({ - strategy: IStrategy(address(0x1)), - multiplier: 1000 + strategy: IStrategy(address(0x1)), multiplier: 1000 }); // Get initial quorum count @@ -2398,17 +2391,14 @@ contract RegistryCoordinatorUnitTests_BeforeMigration is RegistryCoordinatorUnit function test_CreateSlashableStakeQuorum_Reverts() public { _deployMockEigenLayerAndAVS(0); ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 10, - kickBIPsOfOperatorStake: 0, - kickBIPsOfTotalStake: 0 - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 10, kickBIPsOfOperatorStake: 0, kickBIPsOfTotalStake: 0 + }); uint96 minimumStake = 100; IStakeRegistryTypes.StrategyParams[] memory strategyParams = new IStakeRegistryTypes.StrategyParams[](1); strategyParams[0] = IStakeRegistryTypes.StrategyParams({ - strategy: IStrategy(address(0x1)), - multiplier: 1000 + strategy: IStrategy(address(0x1)), multiplier: 1000 }); uint32 lookAheadPeriod = 100; @@ -2447,22 +2437,20 @@ contract RegistryCoordinatorUnitTests_AfterMigration is RegistryCoordinatorUnitT ); bytes memory signature = OperatorKeyOperationsLib.sign(operatorToRegister.key, digestHash); ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory operatorSignature = - ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry({ - signature: signature, - salt: salt, - expiry: expiry - }); + ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry({ + signature: signature, salt: salt, expiry: expiry + }); bytes32 messageHash = registryCoordinator.calculatePubkeyRegistrationMessageHash(operatorToRegister.key.addr); IBLSApkRegistryTypes.PubkeyRegistrationParams memory operatorRegisterApkParams = - IBLSApkRegistryTypes.PubkeyRegistrationParams({ - pubkeyRegistrationSignature: SigningKeyOperationsLib.sign( - operatorToRegister.signingKey, messageHash - ), - pubkeyG1: operatorToRegister.signingKey.publicKeyG1, - pubkeyG2: operatorToRegister.signingKey.publicKeyG2 - }); + IBLSApkRegistryTypes.PubkeyRegistrationParams({ + pubkeyRegistrationSignature: SigningKeyOperationsLib.sign( + operatorToRegister.signingKey, messageHash + ), + pubkeyG1: operatorToRegister.signingKey.publicKeyG1, + pubkeyG2: operatorToRegister.signingKey.publicKeyG2 + }); string memory socket = "socket"; @@ -2512,11 +2500,9 @@ contract RegistryCoordinatorUnitTests_AfterMigration is RegistryCoordinatorUnitT // Create quorum params ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 10, - kickBIPsOfOperatorStake: 1000, - kickBIPsOfTotalStake: 100 - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 10, kickBIPsOfOperatorStake: 1000, kickBIPsOfTotalStake: 100 + }); uint96 minimumStake = 100; IStakeRegistryTypes.StrategyParams[] memory strategyParams = new IStakeRegistryTypes.StrategyParams[](1); @@ -2541,16 +2527,15 @@ contract RegistryCoordinatorUnitTests_AfterMigration is RegistryCoordinatorUnitT // Create quorum params ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 10, - kickBIPsOfOperatorStake: 1000, - kickBIPsOfTotalStake: 100 - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 10, kickBIPsOfOperatorStake: 1000, kickBIPsOfTotalStake: 100 + }); uint96 minimumStake = 100; IStakeRegistryTypes.StrategyParams[] memory strategyParams = new IStakeRegistryTypes.StrategyParams[](1); - strategyParams[0] = - IStakeRegistryTypes.StrategyParams({strategy: IStrategy(address(1)), multiplier: 10000}); + strategyParams[0] = IStakeRegistryTypes.StrategyParams({ + strategy: IStrategy(address(1)), multiplier: 10000 + }); // Create total delegated stake quorum cheats.prank(registryCoordinatorOwner); @@ -2566,17 +2551,16 @@ contract RegistryCoordinatorUnitTests_AfterMigration is RegistryCoordinatorUnitT // Create quorum params ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 10, - kickBIPsOfOperatorStake: 1000, - kickBIPsOfTotalStake: 100 - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 10, kickBIPsOfOperatorStake: 1000, kickBIPsOfTotalStake: 100 + }); uint96 minimumStake = 100; IStakeRegistryTypes.StrategyParams[] memory strategyParams = new IStakeRegistryTypes.StrategyParams[](1); - strategyParams[0] = - IStakeRegistryTypes.StrategyParams({strategy: IStrategy(address(1)), multiplier: 10000}); + strategyParams[0] = IStakeRegistryTypes.StrategyParams({ + strategy: IStrategy(address(1)), multiplier: 10000 + }); // Create total delegated stake quorum cheats.prank(registryCoordinatorOwner); @@ -2611,17 +2595,16 @@ contract RegistryCoordinatorUnitTests_AfterMigration is RegistryCoordinatorUnitT // Create quorum params ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 10, - kickBIPsOfOperatorStake: 1000, - kickBIPsOfTotalStake: 100 - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 10, kickBIPsOfOperatorStake: 1000, kickBIPsOfTotalStake: 100 + }); uint96 minimumStake = 100; IStakeRegistryTypes.StrategyParams[] memory strategyParams = new IStakeRegistryTypes.StrategyParams[](1); - strategyParams[0] = - IStakeRegistryTypes.StrategyParams({strategy: IStrategy(address(1)), multiplier: 10000}); + strategyParams[0] = IStakeRegistryTypes.StrategyParams({ + strategy: IStrategy(address(1)), multiplier: 10000 + }); // Create total delegated stake quorum cheats.prank(registryCoordinatorOwner); @@ -2642,8 +2625,7 @@ contract RegistryCoordinatorUnitTests_AfterMigration is RegistryCoordinatorUnitT ISlashingRegistryCoordinatorTypes.OperatorKickParam[] memory operatorKickParams = new ISlashingRegistryCoordinatorTypes.OperatorKickParam[](1); operatorKickParams[0] = ISlashingRegistryCoordinatorTypes.OperatorKickParam({ - operator: address(0x1), - quorumNumber: 0 + operator: address(0x1), quorumNumber: 0 }); ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory churnApproverSignature; @@ -2669,17 +2651,18 @@ contract RegistryCoordinatorUnitTests_AfterMigration is RegistryCoordinatorUnitT _deployMockEigenLayerAndAVS(0); ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: defaultMaxOperatorCount, - kickBIPsOfOperatorStake: defaultKickBIPsOfOperatorStake, - kickBIPsOfTotalStake: defaultKickBIPsOfTotalStake - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: defaultMaxOperatorCount, + kickBIPsOfOperatorStake: defaultKickBIPsOfOperatorStake, + kickBIPsOfTotalStake: defaultKickBIPsOfTotalStake + }); uint96 minimumStake = 100; IStakeRegistryTypes.StrategyParams[] memory strategyParams = new IStakeRegistryTypes.StrategyParams[](1); - strategyParams[0] = - IStakeRegistryTypes.StrategyParams({strategy: IStrategy(address(1)), multiplier: 10000}); + strategyParams[0] = IStakeRegistryTypes.StrategyParams({ + strategy: IStrategy(address(1)), multiplier: 10000 + }); cheats.prank(registryCoordinatorOwner); registryCoordinator.createTotalDelegatedStakeQuorum( @@ -2696,17 +2679,16 @@ contract RegistryCoordinatorUnitTests_AfterMigration is RegistryCoordinatorUnitT // Create quorum params ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 10, - kickBIPsOfOperatorStake: 1000, - kickBIPsOfTotalStake: 100 - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 10, kickBIPsOfOperatorStake: 1000, kickBIPsOfTotalStake: 100 + }); uint96 minimumStake = 100; IStakeRegistryTypes.StrategyParams[] memory strategyParams = new IStakeRegistryTypes.StrategyParams[](1); - strategyParams[0] = - IStakeRegistryTypes.StrategyParams({strategy: IStrategy(address(1)), multiplier: 10000}); + strategyParams[0] = IStakeRegistryTypes.StrategyParams({ + strategy: IStrategy(address(1)), multiplier: 10000 + }); // Create total delegated stake quorum cheats.prank(registryCoordinatorOwner); @@ -2742,17 +2724,16 @@ contract RegistryCoordinatorUnitTests_AfterMigration is RegistryCoordinatorUnitT // Create quorum params ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 10, - kickBIPsOfOperatorStake: 1000, - kickBIPsOfTotalStake: 100 - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 10, kickBIPsOfOperatorStake: 1000, kickBIPsOfTotalStake: 100 + }); uint96 minimumStake = 100; IStakeRegistryTypes.StrategyParams[] memory strategyParams = new IStakeRegistryTypes.StrategyParams[](1); - strategyParams[0] = - IStakeRegistryTypes.StrategyParams({strategy: IStrategy(address(1)), multiplier: 10000}); + strategyParams[0] = IStakeRegistryTypes.StrategyParams({ + strategy: IStrategy(address(1)), multiplier: 10000 + }); // Create total delegated stake quorum cheats.prank(registryCoordinatorOwner); @@ -2785,17 +2766,16 @@ contract RegistryCoordinatorUnitTests_AfterMigration is RegistryCoordinatorUnitT // Create quorum params ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 10, - kickBIPsOfOperatorStake: 1000, - kickBIPsOfTotalStake: 100 - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 10, kickBIPsOfOperatorStake: 1000, kickBIPsOfTotalStake: 100 + }); uint96 minimumStake = 100; IStakeRegistryTypes.StrategyParams[] memory strategyParams = new IStakeRegistryTypes.StrategyParams[](1); - strategyParams[0] = - IStakeRegistryTypes.StrategyParams({strategy: IStrategy(address(1)), multiplier: 10000}); + strategyParams[0] = IStakeRegistryTypes.StrategyParams({ + strategy: IStrategy(address(1)), multiplier: 10000 + }); // Create total delegated stake quorum cheats.prank(registryCoordinatorOwner); diff --git a/test/unit/ServiceManagerBase.t.sol b/test/unit/ServiceManagerBase.t.sol index 492d2e579..51f79e5f3 100644 --- a/test/unit/ServiceManagerBase.t.sol +++ b/test/unit/ServiceManagerBase.t.sol @@ -9,8 +9,9 @@ import { IRewardsCoordinatorTypes, IERC20 } from "eigenlayer-contracts/src/contracts/core/RewardsCoordinator.sol"; -import {PermissionController} from - "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; +import { + PermissionController +} from "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; import {StrategyBase} from "eigenlayer-contracts/src/contracts/strategies/StrategyBase.sol"; import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol"; import {IServiceManagerBaseEvents} from "../events/IServiceManagerBaseEvents.sol"; @@ -69,17 +70,17 @@ contract ServiceManagerBase_UnitTests is MockAVSDeployer, IServiceManagerBaseEve // Deploy rewards coordinator rewardsCoordinatorImplementation = new RewardsCoordinator( IRewardsCoordinatorTypes.RewardsCoordinatorConstructorParams({ - delegationManager: delegationMock, - strategyManager: IStrategyManager(address(strategyManagerMock)), - allocationManager: allocationManagerMock, - pauserRegistry: pauserRegistry, - permissionController: permissionControllerMock, - CALCULATION_INTERVAL_SECONDS: CALCULATION_INTERVAL_SECONDS, - MAX_REWARDS_DURATION: MAX_REWARDS_DURATION, - MAX_RETROACTIVE_LENGTH: MAX_RETROACTIVE_LENGTH, - MAX_FUTURE_LENGTH: MAX_FUTURE_LENGTH, - GENESIS_REWARDS_TIMESTAMP: GENESIS_REWARDS_TIMESTAMP - }) + delegationManager: delegationMock, + strategyManager: IStrategyManager(address(strategyManagerMock)), + allocationManager: allocationManagerMock, + pauserRegistry: pauserRegistry, + permissionController: permissionControllerMock, + CALCULATION_INTERVAL_SECONDS: CALCULATION_INTERVAL_SECONDS, + MAX_REWARDS_DURATION: MAX_REWARDS_DURATION, + MAX_RETROACTIVE_LENGTH: MAX_RETROACTIVE_LENGTH, + MAX_FUTURE_LENGTH: MAX_FUTURE_LENGTH, + GENESIS_REWARDS_TIMESTAMP: GENESIS_REWARDS_TIMESTAMP + }) ); rewardsCoordinator = RewardsCoordinator( @@ -136,7 +137,10 @@ contract ServiceManagerBase_UnitTests is MockAVSDeployer, IServiceManagerBaseEve } /// @notice deploy token to owner and approve ServiceManager. Used for deploying reward tokens - function _deployMockRewardTokens(address owner, uint256 numTokens) internal virtual { + function _deployMockRewardTokens( + address owner, + uint256 numTokens + ) internal virtual { cheats.startPrank(owner); for (uint256 i = 0; i < numTokens; ++i) { IERC20 token = @@ -235,7 +239,10 @@ contract ServiceManagerBase_UnitTests is MockAVSDeployer, IServiceManagerBaseEve return arr; } - function _maxTimestamp(uint32 timestamp1, uint32 timestamp2) internal pure returns (uint32) { + function _maxTimestamp( + uint32 timestamp1, + uint32 timestamp2 + ) internal pure returns (uint32) { return timestamp1 > timestamp2 ? timestamp1 : timestamp2; } @@ -398,13 +405,13 @@ contract ServiceManagerBase_UnitTests is MockAVSDeployer, IServiceManagerBaseEve // 2. Create reward submission input param IRewardsCoordinatorTypes.RewardsSubmission memory rewardsSubmission = - IRewardsCoordinatorTypes.RewardsSubmission({ - strategiesAndMultipliers: defaultStrategyAndMultipliers, - token: rewardTokens[i], - amount: amounts[i], - startTimestamp: uint32(startTimestamp), - duration: uint32(duration) - }); + IRewardsCoordinatorTypes.RewardsSubmission({ + strategiesAndMultipliers: defaultStrategyAndMultipliers, + token: rewardTokens[i], + amount: amounts[i], + startTimestamp: uint32(startTimestamp), + duration: uint32(duration) + }); rewardsSubmissions[i] = rewardsSubmission; // 3. expected event emitted for this rewardsSubmission @@ -501,13 +508,13 @@ contract ServiceManagerBase_UnitTests is MockAVSDeployer, IServiceManagerBaseEve // 2. Create reward submission input param IRewardsCoordinatorTypes.RewardsSubmission memory rewardsSubmission = - IRewardsCoordinatorTypes.RewardsSubmission({ - strategiesAndMultipliers: defaultStrategyAndMultipliers, - token: rewardToken, - amount: amounts[i], - startTimestamp: uint32(startTimestamp), - duration: uint32(duration) - }); + IRewardsCoordinatorTypes.RewardsSubmission({ + strategiesAndMultipliers: defaultStrategyAndMultipliers, + token: rewardToken, + amount: amounts[i], + startTimestamp: uint32(startTimestamp), + duration: uint32(duration) + }); rewardsSubmissions[i] = rewardsSubmission; // 3. expected event emitted for this avs rewards submission @@ -862,8 +869,8 @@ contract ServiceManagerBase_UnitTests is MockAVSDeployer, IServiceManagerBaseEve ) + CALCULATION_INTERVAL_SECONDS - 1, block.timestamp - 1 // Must be in past for operator directed rewards ); - submissionStartTimestamp = - submissionStartTimestamp - (submissionStartTimestamp % CALCULATION_INTERVAL_SECONDS); + submissionStartTimestamp = submissionStartTimestamp + - (submissionStartTimestamp % CALCULATION_INTERVAL_SECONDS); // loop and find the latest startTimestamp and the longest duration, then warp start + duration + 1 if (submissionStartTimestamp > latestStartTimestamp) { @@ -877,8 +884,7 @@ contract ServiceManagerBase_UnitTests is MockAVSDeployer, IServiceManagerBaseEve IRewardsCoordinatorTypes.OperatorReward[] memory operatorRewards = new IRewardsCoordinatorTypes.OperatorReward[](1); operatorRewards[0] = IRewardsCoordinatorTypes.OperatorReward({ - operator: address(0x1), - amount: amounts[i] + operator: address(0x1), amount: amounts[i] }); rewardsSubmissions[i] = IRewardsCoordinatorTypes.OperatorDirectedRewardsSubmission({ @@ -925,12 +931,10 @@ contract ServiceManagerBase_UnitTests is MockAVSDeployer, IServiceManagerBaseEve uint32[] memory operatorSetIds ) public { // Mock the expected call to allocationManager - IAllocationManagerTypes.DeregisterParams memory expectedParams = IAllocationManagerTypes - .DeregisterParams({ - operator: operator, - avs: address(serviceManager), - operatorSetIds: operatorSetIds - }); + IAllocationManagerTypes.DeregisterParams memory expectedParams = + IAllocationManagerTypes.DeregisterParams({ + operator: operator, avs: address(serviceManager), operatorSetIds: operatorSetIds + }); cheats.expectCall( address(allocationManagerMock), diff --git a/test/unit/SlashingRegistryCoordinatorUnit.t.sol b/test/unit/SlashingRegistryCoordinatorUnit.t.sol index 2ef94c835..6d1d3c683 100644 --- a/test/unit/SlashingRegistryCoordinatorUnit.t.sol +++ b/test/unit/SlashingRegistryCoordinatorUnit.t.sol @@ -24,25 +24,30 @@ import {ISlashingRegistryCoordinator} from "../../src/interfaces/ISlashingRegist import {IServiceManager} from "../../src/interfaces/IServiceManager.sol"; import {IStakeRegistry, IStakeRegistryTypes} from "../../src/interfaces/IStakeRegistry.sol"; import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; -import {TransparentUpgradeableProxy} from - "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { + TransparentUpgradeableProxy +} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import {EmptyContract} from "eigenlayer-contracts/src/test/mocks/EmptyContract.sol"; import {AllocationManager} from "eigenlayer-contracts/src/contracts/core/AllocationManager.sol"; -import {PermissionController} from - "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; +import { + PermissionController +} from "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; import {PauserRegistry} from "eigenlayer-contracts/src/contracts/permissions/PauserRegistry.sol"; import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol"; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol"; import {IStrategyFactory} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyFactory.sol"; import {IEigenPodManager} from "eigenlayer-contracts/src/contracts/interfaces/IEigenPodManager.sol"; import {DelegationManagerHarness} from "../mocks/DelegationManagerHarness.sol"; import {SlashingRegistryCoordinator} from "../../src/SlashingRegistryCoordinator.sol"; -import {ISlashingRegistryCoordinatorTypes} from - "../../src/interfaces/ISlashingRegistryCoordinator.sol"; +import { + ISlashingRegistryCoordinatorTypes +} from "../../src/interfaces/ISlashingRegistryCoordinator.sol"; import {IBLSApkRegistry, IBLSApkRegistryTypes} from "../../src/interfaces/IBLSApkRegistry.sol"; import {BitmapUtils} from "../../src/libraries/BitmapUtils.sol"; import {IIndexRegistry} from "../../src/interfaces/IIndexRegistry.sol"; @@ -131,8 +136,8 @@ contract SlashingRegistryCoordinatorUnitTestSetup is view returns (IStakeRegistryTypes.StrategyParams[] memory) { - IStakeRegistryTypes.StrategyParams[] memory strategyParams = - new IStakeRegistryTypes.StrategyParams[](1); + IStakeRegistryTypes.StrategyParams[] memory + strategyParams = new IStakeRegistryTypes.StrategyParams[](1); strategyParams[0] = IStakeRegistryTypes.StrategyParams({strategy: mockStrategy, multiplier: 1 ether}); return strategyParams; @@ -144,9 +149,7 @@ contract SlashingRegistryCoordinatorUnitTestSetup is returns (ISlashingRegistryCoordinatorTypes.OperatorSetParam memory) { return ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 10, - kickBIPsOfOperatorStake: 0, - kickBIPsOfTotalStake: 0 + maxOperatorCount: 10, kickBIPsOfOperatorStake: 0, kickBIPsOfTotalStake: 0 }); } @@ -218,16 +221,14 @@ contract SlashingRegistryCoordinatorUnitTestSetup is vm.stopPrank(); vm.startPrank(strategyManagerOwner); - IStrategyManager(coreDeployment.strategyManager).setStrategyWhitelister( - coreDeployment.strategyFactory - ); + IStrategyManager(coreDeployment.strategyManager) + .setStrategyWhitelister(coreDeployment.strategyFactory); vm.stopPrank(); vm.startPrank(proxyAdminOwner); mockStrategy = IStrategy( - StrategyFactory(coreDeployment.strategyFactory).deployNewStrategy( - IERC20(address(mockToken)) - ) + StrategyFactory(coreDeployment.strategyFactory) + .deployNewStrategy(IERC20(address(mockToken))) ); vm.stopPrank(); @@ -249,23 +250,24 @@ contract SlashingRegistryCoordinatorUnitTestSetup is middlewareConfig.instantSlasher.slasher = slasher; vm.startPrank(proxyAdminOwner); - MiddlewareDeployLib.MiddlewareDeployData memory middlewareDeployments = MiddlewareDeployLib - .deployMiddleware( - address(proxyAdmin), - coreDeployment.allocationManager, - coreDeployment.strategyManager, - address(pauserRegistry), - middlewareConfig - ); + MiddlewareDeployLib.MiddlewareDeployData memory middlewareDeployments = + MiddlewareDeployLib.deployMiddleware( + address(proxyAdmin), + coreDeployment.allocationManager, + coreDeployment.strategyManager, + address(pauserRegistry), + middlewareConfig + ); vm.stopPrank(); vm.startPrank(serviceManager); - PermissionController(coreDeployment.permissionController).setAppointee( - address(serviceManager), - address(instantSlasher), - coreDeployment.allocationManager, - AllocationManager.slashOperator.selector - ); + PermissionController(coreDeployment.permissionController) + .setAppointee( + address(serviceManager), + address(instantSlasher), + coreDeployment.allocationManager, + AllocationManager.slashOperator.selector + ); slashingRegistryCoordinator = SlashingRegistryCoordinator(middlewareDeployments.slashingRegistryCoordinator); @@ -275,26 +277,29 @@ contract SlashingRegistryCoordinatorUnitTestSetup is blsApkRegistry = BLSApkRegistry(middlewareDeployments.blsApkRegistry); indexRegistry = IndexRegistry(middlewareDeployments.indexRegistry); - PermissionController(coreDeployment.permissionController).setAppointee( - address(serviceManager), - address(slashingRegistryCoordinator), - coreDeployment.allocationManager, - bytes4(keccak256("createOperatorSets(address,(uint32,address[],address)[])")) - ); + PermissionController(coreDeployment.permissionController) + .setAppointee( + address(serviceManager), + address(slashingRegistryCoordinator), + coreDeployment.allocationManager, + bytes4(keccak256("createOperatorSets(address,(uint32,address[],address)[])")) + ); - PermissionController(coreDeployment.permissionController).setAppointee( - address(serviceManager), - address(instantSlasher), - coreDeployment.allocationManager, - AllocationManager.slashOperator.selector - ); + PermissionController(coreDeployment.permissionController) + .setAppointee( + address(serviceManager), + address(instantSlasher), + coreDeployment.allocationManager, + AllocationManager.slashOperator.selector + ); - PermissionController(coreDeployment.permissionController).setAppointee( - address(serviceManager), - proxyAdminOwner, - coreDeployment.allocationManager, - AllocationManager.updateAVSMetadataURI.selector - ); + PermissionController(coreDeployment.permissionController) + .setAppointee( + address(serviceManager), + proxyAdminOwner, + coreDeployment.allocationManager, + AllocationManager.updateAVSMetadataURI.selector + ); vm.stopPrank(); @@ -304,16 +309,13 @@ contract SlashingRegistryCoordinatorUnitTestSetup is IStakeRegistryTypes.StrategyParams({strategy: mockStrategy, multiplier: 1 ether}); ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 10, - kickBIPsOfOperatorStake: 0, - kickBIPsOfTotalStake: 0 - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 10, kickBIPsOfOperatorStake: 0, kickBIPsOfTotalStake: 0 + }); vm.startPrank(proxyAdminOwner); - IAllocationManager(coreDeployment.allocationManager).updateAVSMetadataURI( - serviceManager, "fake-avs-metadata" - ); + IAllocationManager(coreDeployment.allocationManager) + .updateAVSMetadataURI(serviceManager, "fake-avs-metadata"); slashingRegistryCoordinator.createTotalDelegatedStakeQuorum( operatorSetParams, 1 ether, strategyParams ); @@ -325,9 +327,10 @@ contract SlashingRegistryCoordinatorUnitTestSetup is vm.label(coreDeployment.allocationManager, "AllocationManager Proxy"); vm.prank(serviceManager); - IAllocationManager(coreDeployment.allocationManager).setAVSRegistrar( - address(serviceManager), IAVSRegistrar(address(slashingRegistryCoordinator)) - ); + IAllocationManager(coreDeployment.allocationManager) + .setAVSRegistrar( + address(serviceManager), IAVSRegistrar(address(slashingRegistryCoordinator)) + ); for (uint256 i = 0; i < operatorIds.length(); i++) { bytes32 operatorId = operatorIds.at(i); @@ -338,15 +341,15 @@ contract SlashingRegistryCoordinatorUnitTestSetup is vm.startPrank(operator.key.addr); mockToken.approve(address(coreDeployment.strategyManager), STAKE_AMOUNT); - IStrategyManager(coreDeployment.strategyManager).depositIntoStrategy( - mockStrategy, mockToken, STAKE_AMOUNT - ); + IStrategyManager(coreDeployment.strategyManager) + .depositIntoStrategy(mockStrategy, mockToken, STAKE_AMOUNT); - IDelegationManager(coreDeployment.delegationManager).registerAsOperator( - address(0), // no delegation approver - 0, // no allocation delay - string.concat("operator-metadata_", vm.toString(i)) - ); + IDelegationManager(coreDeployment.delegationManager) + .registerAsOperator( + address(0), // no delegation approver + 0, // no allocation delay + string.concat("operator-metadata_", vm.toString(i)) + ); vm.stopPrank(); } @@ -360,19 +363,18 @@ contract SlashingRegistryCoordinatorUnitTestSetup is IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = createPubkeyRegistrationParams(operator, operator.key.addr); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: operatorSetIds, - data: abi.encode( - ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, socket, pubkeyParams - ) - }); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), + operatorSetIds: operatorSetIds, + data: abi.encode( + ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, socket, pubkeyParams + ) + }); vm.prank(operator.key.addr); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - operator.key.addr, registerParams - ); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(operator.key.addr, registerParams); } // Helper function to register an operator in the SlashingRegistryCoordinator for a single quorum @@ -387,13 +389,14 @@ contract SlashingRegistryCoordinatorUnitTestSetup is registerOperatorInSlashingRegistryCoordinator(operator, socket, operatorSetIds); } - function _setOperatorWeight(address operator, uint96 weight) internal { - DelegationManagerHarness(address(coreDeployment.delegationManager)).setOperatorShares( - operator, mockStrategy, weight - ); - DelegationManagerHarness(address(coreDeployment.delegationManager)).setIsOperator( - operator, true - ); + function _setOperatorWeight( + address operator, + uint96 weight + ) internal { + DelegationManagerHarness(address(coreDeployment.delegationManager)) + .setOperatorShares(operator, mockStrategy, weight); + DelegationManagerHarness(address(coreDeployment.delegationManager)) + .setIsOperator(operator, true); } function _useDelegationManagerHarness() internal { @@ -447,7 +450,10 @@ contract SlashingRegistryCoordinatorUnitTestSetup is ); } - function _verifyOperatorBitmap(bytes32 operatorId, uint192 expectedBitmap) internal view { + function _verifyOperatorBitmap( + bytes32 operatorId, + uint192 expectedBitmap + ) internal view { uint192 currentBitmap = slashingRegistryCoordinator.getCurrentQuorumBitmap(operatorId); assertEq(currentBitmap, expectedBitmap, "Operator bitmap does not match expected bitmap"); } @@ -470,9 +476,7 @@ contract SlashingRegistryCoordinator_Initialize is SlashingRegistryCoordinatorUn } } -contract SlashingRegistryCoordinator_SetChurnApprover is - SlashingRegistryCoordinatorUnitTestSetup -{ +contract SlashingRegistryCoordinator_SetChurnApprover is SlashingRegistryCoordinatorUnitTestSetup { address newChurnApprover = address(0x123); function test_setChurnApprover() public { @@ -588,12 +592,10 @@ contract SlashingRegistryCoordinator_AVSSupport is SlashingRegistryCoordinatorUn super.setUp(); testOperator = OperatorWalletLib.createOperator("test_operator"); _useDelegationManagerHarness(); - DelegationManagerHarness(address(coreDeployment.delegationManager)).setOperatorShares( - testOperator.key.addr, mockStrategy, STAKE_AMOUNT - ); - DelegationManagerHarness(address(coreDeployment.delegationManager)).setIsOperator( - testOperator.key.addr, true - ); + DelegationManagerHarness(address(coreDeployment.delegationManager)) + .setOperatorShares(testOperator.key.addr, mockStrategy, STAKE_AMOUNT); + DelegationManagerHarness(address(coreDeployment.delegationManager)) + .setIsOperator(testOperator.key.addr, true); // Store the original AVS and set new AVS oldAVS = slashingRegistryCoordinator.avs(); @@ -605,21 +607,22 @@ contract SlashingRegistryCoordinator_AVSSupport is SlashingRegistryCoordinatorUn IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = createPubkeyRegistrationParams(testOperator, testOperator.key.addr); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: oldAVS, // Using old AVS that no longer matches - operatorSetIds: new uint32[](1), - data: abi.encode( - ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, "socket:8545", pubkeyParams - ) - }); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: oldAVS, // Using old AVS that no longer matches + operatorSetIds: new uint32[](1), + data: abi.encode( + ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, + "socket:8545", + pubkeyParams + ) + }); registerParams.operatorSetIds[0] = 0; vm.prank(testOperator.key.addr); vm.expectRevert(bytes4(keccak256("InvalidAVS()"))); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - testOperator.key.addr, registerParams - ); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(testOperator.key.addr, registerParams); } function test_RevertsWhen_DeregisterOldAVS() public { @@ -633,18 +636,17 @@ contract SlashingRegistryCoordinator_AVSSupport is SlashingRegistryCoordinatorUn vm.prank(proxyAdminOwner); slashingRegistryCoordinator.setAVS(address(0x123)); - IAllocationManagerTypes.DeregisterParams memory deregisterParams = IAllocationManagerTypes - .DeregisterParams({ - operator: testOperator.key.addr, - avs: oldAVS, // Using old AVS that no longer matches - operatorSetIds: operatorSetIds - }); + IAllocationManagerTypes.DeregisterParams memory deregisterParams = + IAllocationManagerTypes.DeregisterParams({ + operator: testOperator.key.addr, + avs: oldAVS, // Using old AVS that no longer matches + operatorSetIds: operatorSetIds + }); vm.prank(testOperator.key.addr); vm.expectRevert(bytes4(keccak256("InvalidAVS()"))); - IAllocationManager(coreDeployment.allocationManager).deregisterFromOperatorSets( - deregisterParams - ); + IAllocationManager(coreDeployment.allocationManager) + .deregisterFromOperatorSets(deregisterParams); } } @@ -659,9 +661,7 @@ contract SlashingRegistryCoordinator_CreateSlashableStakeQuorum is super.setUp(); operatorSetParams = ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 10, - kickBIPsOfOperatorStake: 5000, - kickBIPsOfTotalStake: 100 + maxOperatorCount: 10, kickBIPsOfOperatorStake: 5000, kickBIPsOfTotalStake: 100 }); } @@ -831,9 +831,7 @@ contract SlashingRegistryCoordinator_CreateTotalDelegatedStakeQuorum is } } -contract SlashingRegistryCoordinator_RegisterOperator is - SlashingRegistryCoordinatorUnitTestSetup -{ +contract SlashingRegistryCoordinator_RegisterOperator is SlashingRegistryCoordinatorUnitTestSetup { using EnumerableSet for EnumerableSet.Bytes32Set; Operator internal testOperator; @@ -849,20 +847,21 @@ contract SlashingRegistryCoordinator_RegisterOperator is IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = createPubkeyRegistrationParams(testOperator, testOperator.key.addr); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: new uint32[](1), - data: abi.encode( - ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, "socket:8545", pubkeyParams - ) - }); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), + operatorSetIds: new uint32[](1), + data: abi.encode( + ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, + "socket:8545", + pubkeyParams + ) + }); registerParams.operatorSetIds[0] = 0; // Use quorum 0 vm.prank(testOperator.key.addr); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - testOperator.key.addr, registerParams - ); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(testOperator.key.addr, registerParams); ISlashingRegistryCoordinator.OperatorInfo memory operatorInfo = slashingRegistryCoordinator.getOperator(testOperator.key.addr); @@ -879,62 +878,65 @@ contract SlashingRegistryCoordinator_RegisterOperator is IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = createPubkeyRegistrationParams(testOperator, testOperator.key.addr); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: new uint32[](1), - data: abi.encode( - ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, "socket:8545", pubkeyParams - ) - }); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), + operatorSetIds: new uint32[](1), + data: abi.encode( + ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, + "socket:8545", + pubkeyParams + ) + }); registerParams.operatorSetIds[0] = 0; // Use quorum 0 vm.prank(testOperator.key.addr); vm.expectRevert(bytes4(keccak256("CurrentlyPaused()"))); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - testOperator.key.addr, registerParams - ); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(testOperator.key.addr, registerParams); } function test_RevertsWhen_EmptyQuorumNumbers() public { IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = createPubkeyRegistrationParams(testOperator, testOperator.key.addr); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: new uint32[](0), // Empty array - data: abi.encode( - ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, "socket:8545", pubkeyParams - ) - }); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), + operatorSetIds: new uint32[](0), // Empty array + data: abi.encode( + ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, + "socket:8545", + pubkeyParams + ) + }); vm.prank(testOperator.key.addr); vm.expectRevert(); // Should revert due to empty quorum numbers - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - testOperator.key.addr, registerParams - ); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(testOperator.key.addr, registerParams); } function test_RevertsWhen_InvalidQuorum() public { IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = createPubkeyRegistrationParams(testOperator, testOperator.key.addr); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: new uint32[](1), - data: abi.encode( - ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, "socket:8545", pubkeyParams - ) - }); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), + operatorSetIds: new uint32[](1), + data: abi.encode( + ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, + "socket:8545", + pubkeyParams + ) + }); registerParams.operatorSetIds[0] = 99; // Use non-existent quorum vm.prank(testOperator.key.addr); vm.expectRevert(); // Should revert due to invalid quorum - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - testOperator.key.addr, registerParams - ); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(testOperator.key.addr, registerParams); } function test_RevertsWhen_AlreadyRegisteredForQuorum() public { @@ -943,21 +945,22 @@ contract SlashingRegistryCoordinator_RegisterOperator is IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = createPubkeyRegistrationParams(testOperator, testOperator.key.addr); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: new uint32[](1), - data: abi.encode( - ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, "socket:8545", pubkeyParams - ) - }); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), + operatorSetIds: new uint32[](1), + data: abi.encode( + ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, + "socket:8545", + pubkeyParams + ) + }); registerParams.operatorSetIds[0] = 0; // Use quorum 0 vm.prank(testOperator.key.addr); vm.expectRevert(); // Should revert because operator is already registered for this quorum - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - testOperator.key.addr, registerParams - ); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(testOperator.key.addr, registerParams); } function test_RevertsWhen_NotAllocationManager() public { @@ -980,11 +983,11 @@ contract SlashingRegistryCoordinator_RegisterOperator is function test_RevertsWhen_MaxOperatorCountReached() public { ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 2, // Only allow 2 operators - kickBIPsOfOperatorStake: 0, - kickBIPsOfTotalStake: 0 - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 2, // Only allow 2 operators + kickBIPsOfOperatorStake: 0, + kickBIPsOfTotalStake: 0 + }); vm.prank(proxyAdminOwner); slashingRegistryCoordinator.createTotalDelegatedStakeQuorum( @@ -1007,20 +1010,21 @@ contract SlashingRegistryCoordinator_RegisterOperator is IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = createPubkeyRegistrationParams(operator3, operator3.key.addr); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: operatorSetIds, - data: abi.encode( - ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, "socket3:8545", pubkeyParams - ) - }); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), + operatorSetIds: operatorSetIds, + data: abi.encode( + ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, + "socket3:8545", + pubkeyParams + ) + }); vm.prank(operator3.key.addr); vm.expectRevert(MaxOperatorCountReached.selector); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - operator3.key.addr, registerParams - ); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(operator3.key.addr, registerParams); _verifyOperatorStatus( operator1.key.addr, ISlashingRegistryCoordinatorTypes.OperatorStatus.REGISTERED @@ -1058,17 +1062,16 @@ contract SlashingRegistryCoordinator_DeregisterOperator is } function test_deregisterOperator() public { - IAllocationManagerTypes.DeregisterParams memory deregisterParams = IAllocationManagerTypes - .DeregisterParams({ - operator: testOperator.key.addr, - avs: address(serviceManager), - operatorSetIds: operatorSetIds - }); + IAllocationManagerTypes.DeregisterParams memory deregisterParams = + IAllocationManagerTypes.DeregisterParams({ + operator: testOperator.key.addr, + avs: address(serviceManager), + operatorSetIds: operatorSetIds + }); vm.prank(testOperator.key.addr); - IAllocationManager(coreDeployment.allocationManager).deregisterFromOperatorSets( - deregisterParams - ); + IAllocationManager(coreDeployment.allocationManager) + .deregisterFromOperatorSets(deregisterParams); ISlashingRegistryCoordinator.OperatorInfo memory operatorInfo = slashingRegistryCoordinator.getOperator(testOperator.key.addr); @@ -1079,55 +1082,52 @@ contract SlashingRegistryCoordinator_DeregisterOperator is } function test_emitsDeregisteredEvent() public { - IAllocationManagerTypes.DeregisterParams memory deregisterParams = IAllocationManagerTypes - .DeregisterParams({ - operator: testOperator.key.addr, - avs: address(serviceManager), - operatorSetIds: operatorSetIds - }); + IAllocationManagerTypes.DeregisterParams memory deregisterParams = + IAllocationManagerTypes.DeregisterParams({ + operator: testOperator.key.addr, + avs: address(serviceManager), + operatorSetIds: operatorSetIds + }); vm.expectEmit(true, true, true, true); emit OperatorDeregistered(testOperator.key.addr, testOperatorId); vm.prank(testOperator.key.addr); - IAllocationManager(coreDeployment.allocationManager).deregisterFromOperatorSets( - deregisterParams - ); + IAllocationManager(coreDeployment.allocationManager) + .deregisterFromOperatorSets(deregisterParams); } function test_RevertsWhen_Paused() public { vm.prank(pauser); slashingRegistryCoordinator.pause(2); // PAUSED_DEREGISTER_OPERATOR = 2 - IAllocationManagerTypes.DeregisterParams memory deregisterParams = IAllocationManagerTypes - .DeregisterParams({ - operator: testOperator.key.addr, - avs: address(serviceManager), - operatorSetIds: operatorSetIds - }); + IAllocationManagerTypes.DeregisterParams memory deregisterParams = + IAllocationManagerTypes.DeregisterParams({ + operator: testOperator.key.addr, + avs: address(serviceManager), + operatorSetIds: operatorSetIds + }); vm.prank(testOperator.key.addr); vm.expectRevert(bytes4(keccak256("CurrentlyPaused()"))); - IAllocationManager(coreDeployment.allocationManager).deregisterFromOperatorSets( - deregisterParams - ); + IAllocationManager(coreDeployment.allocationManager) + .deregisterFromOperatorSets(deregisterParams); } function test_RevertsWhen_NotRegistered() public { address nonRegisteredOperator = address(0xdead); - IAllocationManagerTypes.DeregisterParams memory deregisterParams = IAllocationManagerTypes - .DeregisterParams({ - operator: nonRegisteredOperator, - avs: address(serviceManager), - operatorSetIds: operatorSetIds - }); + IAllocationManagerTypes.DeregisterParams memory deregisterParams = + IAllocationManagerTypes.DeregisterParams({ + operator: nonRegisteredOperator, + avs: address(serviceManager), + operatorSetIds: operatorSetIds + }); vm.prank(nonRegisteredOperator); vm.expectRevert(bytes4(keccak256("NotMemberOfSet()"))); - IAllocationManager(coreDeployment.allocationManager).deregisterFromOperatorSets( - deregisterParams - ); + IAllocationManager(coreDeployment.allocationManager) + .deregisterFromOperatorSets(deregisterParams); } function test_RevertsWhen_IncorrectQuorums() public { @@ -1135,18 +1135,17 @@ contract SlashingRegistryCoordinator_DeregisterOperator is uint32[] memory incorrectOperatorSetIds = new uint32[](1); incorrectOperatorSetIds[0] = 99; // Non-existent quorum - IAllocationManagerTypes.DeregisterParams memory deregisterParams = IAllocationManagerTypes - .DeregisterParams({ - operator: testOperator.key.addr, - avs: address(serviceManager), - operatorSetIds: incorrectOperatorSetIds - }); + IAllocationManagerTypes.DeregisterParams memory deregisterParams = + IAllocationManagerTypes.DeregisterParams({ + operator: testOperator.key.addr, + avs: address(serviceManager), + operatorSetIds: incorrectOperatorSetIds + }); vm.prank(testOperator.key.addr); vm.expectRevert(); - IAllocationManager(coreDeployment.allocationManager).deregisterFromOperatorSets( - deregisterParams - ); + IAllocationManager(coreDeployment.allocationManager) + .deregisterFromOperatorSets(deregisterParams); } function test_RevertsWhen_NotAllocationManager() public { @@ -1172,31 +1171,31 @@ contract SlashingRegistryCoordinator_DeregisterOperator is IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = createPubkeyRegistrationParams(testOperator, testOperator.key.addr); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: additionalOperatorSetIds, - data: abi.encode( - ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, "socket:8545", pubkeyParams - ) - }); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), + operatorSetIds: additionalOperatorSetIds, + data: abi.encode( + ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, + "socket:8545", + pubkeyParams + ) + }); vm.prank(testOperator.key.addr); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - testOperator.key.addr, registerParams - ); - - IAllocationManagerTypes.DeregisterParams memory deregisterParams = IAllocationManagerTypes - .DeregisterParams({ - operator: testOperator.key.addr, - avs: address(serviceManager), - operatorSetIds: operatorSetIds // Contains only quorum 0 - }); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(testOperator.key.addr, registerParams); + + IAllocationManagerTypes.DeregisterParams memory deregisterParams = + IAllocationManagerTypes.DeregisterParams({ + operator: testOperator.key.addr, + avs: address(serviceManager), + operatorSetIds: operatorSetIds // Contains only quorum 0 + }); vm.prank(testOperator.key.addr); - IAllocationManager(coreDeployment.allocationManager).deregisterFromOperatorSets( - deregisterParams - ); + IAllocationManager(coreDeployment.allocationManager) + .deregisterFromOperatorSets(deregisterParams); ISlashingRegistryCoordinator.OperatorInfo memory operatorInfo = slashingRegistryCoordinator.getOperator(testOperator.key.addr); @@ -1272,11 +1271,11 @@ contract SlashingRegistryCoordinator_SetOperatorSetParams is function test_setOperatorSetParams() public { ISlashingRegistryCoordinatorTypes.OperatorSetParam memory newParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 20, - kickBIPsOfOperatorStake: 1000, // 10% - kickBIPsOfTotalStake: 500 // 5% - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 20, + kickBIPsOfOperatorStake: 1000, // 10% + kickBIPsOfTotalStake: 500 // 5% + }); vm.prank(proxyAdminOwner); slashingRegistryCoordinator.setOperatorSetParams(quorumNumber, newParams); @@ -1290,11 +1289,9 @@ contract SlashingRegistryCoordinator_SetOperatorSetParams is function test_RevertsWhen_CallerNotOwner() public { ISlashingRegistryCoordinatorTypes.OperatorSetParam memory newParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 20, - kickBIPsOfOperatorStake: 1000, - kickBIPsOfTotalStake: 500 - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 20, kickBIPsOfOperatorStake: 1000, kickBIPsOfTotalStake: 500 + }); vm.prank(address(1)); vm.expectRevert("Ownable: caller is not the owner"); @@ -1303,11 +1300,9 @@ contract SlashingRegistryCoordinator_SetOperatorSetParams is function test_emitsOperatorSetParamsUpdatedEvent() public { ISlashingRegistryCoordinatorTypes.OperatorSetParam memory newParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 20, - kickBIPsOfOperatorStake: 1000, - kickBIPsOfTotalStake: 500 - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 20, kickBIPsOfOperatorStake: 1000, kickBIPsOfTotalStake: 500 + }); vm.expectEmit(true, true, true, true); emit OperatorSetParamsUpdated(quorumNumber, newParams); @@ -1319,11 +1314,9 @@ contract SlashingRegistryCoordinator_SetOperatorSetParams is function test_RevertsWhen_QuorumDoesNotExist() public { // Define new operator set params ISlashingRegistryCoordinatorTypes.OperatorSetParam memory newParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 20, - kickBIPsOfOperatorStake: 1000, - kickBIPsOfTotalStake: 500 - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 20, kickBIPsOfOperatorStake: 1000, kickBIPsOfTotalStake: 500 + }); /// Quorum 1 doesn't exist yet vm.prank(proxyAdminOwner); @@ -1350,12 +1343,13 @@ contract SlashingRegistryCoordinator_EjectOperator is SlashingRegistryCoordinato quorumNumbers[0] = bytes1(uint8(0)); vm.prank(serviceManager); - IPermissionController(coreDeployment.permissionController).setAppointee( - address(serviceManager), - address(slashingRegistryCoordinator), - address(coreDeployment.allocationManager), - AllocationManager.deregisterFromOperatorSets.selector - ); + IPermissionController(coreDeployment.permissionController) + .setAppointee( + address(serviceManager), + address(slashingRegistryCoordinator), + address(coreDeployment.allocationManager), + AllocationManager.deregisterFromOperatorSets.selector + ); registerOperatorInSlashingRegistryCoordinator(testOperator, "socket:8545", operatorSetIds); } @@ -1402,20 +1396,21 @@ contract SlashingRegistryCoordinator_EjectOperator is SlashingRegistryCoordinato IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = createPubkeyRegistrationParams(testOperator, testOperator.key.addr); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: operatorSetIds, - data: abi.encode( - ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, "socket:8545", pubkeyParams - ) - }); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), + operatorSetIds: operatorSetIds, + data: abi.encode( + ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, + "socket:8545", + pubkeyParams + ) + }); vm.prank(testOperator.key.addr); vm.expectRevert(bytes4(keccak256("EjectionCooldownNotElapsed()"))); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - testOperator.key.addr, registerParams - ); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(testOperator.key.addr, registerParams); } function test_CanRegisterAfterEjectionCooldown() public { @@ -1427,14 +1422,16 @@ contract SlashingRegistryCoordinator_EjectOperator is SlashingRegistryCoordinato IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = createPubkeyRegistrationParams(testOperator, testOperator.key.addr); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: operatorSetIds, - data: abi.encode( - ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, "socket:8545", pubkeyParams - ) - }); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), + operatorSetIds: operatorSetIds, + data: abi.encode( + ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, + "socket:8545", + pubkeyParams + ) + }); /// TODO: EjectionCooldown is somewhat pointless based on this uint32 deallocationDelay = @@ -1442,19 +1439,16 @@ contract SlashingRegistryCoordinator_EjectOperator is SlashingRegistryCoordinato vm.roll(block.number + deallocationDelay + 1); OperatorSet memory operatorSet = OperatorSet(address(serviceManager), operatorSetIds[0]); - bool isMember = IAllocationManager(coreDeployment.allocationManager).isMemberOfOperatorSet( - testOperator.key.addr, operatorSet - ); + bool isMember = IAllocationManager(coreDeployment.allocationManager) + .isMemberOfOperatorSet(testOperator.key.addr, operatorSet); assertFalse(isMember); vm.prank(testOperator.key.addr); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - testOperator.key.addr, registerParams - ); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(testOperator.key.addr, registerParams); - isMember = IAllocationManager(coreDeployment.allocationManager).isMemberOfOperatorSet( - testOperator.key.addr, operatorSet - ); + isMember = IAllocationManager(coreDeployment.allocationManager) + .isMemberOfOperatorSet(testOperator.key.addr, operatorSet); assertTrue(isMember); ISlashingRegistryCoordinator.OperatorInfo memory operatorInfo = @@ -1477,19 +1471,20 @@ contract SlashingRegistryCoordinator_EjectOperator is SlashingRegistryCoordinato IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = createPubkeyRegistrationParams(testOperator, testOperator.key.addr); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: additionalOperatorSetIds, - data: abi.encode( - ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, "socket:8545", pubkeyParams - ) - }); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), + operatorSetIds: additionalOperatorSetIds, + data: abi.encode( + ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, + "socket:8545", + pubkeyParams + ) + }); vm.prank(testOperator.key.addr); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - testOperator.key.addr, registerParams - ); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(testOperator.key.addr, registerParams); bytes memory multiQuorumNumbers = new bytes(2); multiQuorumNumbers[0] = bytes1(uint8(0)); @@ -1518,9 +1513,7 @@ contract SlashingRegistryCoordinator_EjectOperator is SlashingRegistryCoordinato } } -contract SlashingRegistryCoordinator_RegisterWithChurn is - SlashingRegistryCoordinatorUnitTestSetup -{ +contract SlashingRegistryCoordinator_RegisterWithChurn is SlashingRegistryCoordinatorUnitTestSetup { using EnumerableSet for EnumerableSet.Bytes32Set; OperatorSetParam operatorSetParams; @@ -1542,9 +1535,7 @@ contract SlashingRegistryCoordinator_RegisterWithChurn is _useDelegationManagerHarness(); operatorSetParams = ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 4, - kickBIPsOfOperatorStake: 5000, - kickBIPsOfTotalStake: 5000 + maxOperatorCount: 4, kickBIPsOfOperatorStake: 5000, kickBIPsOfTotalStake: 5000 }); testOperator = operatorsByID[operatorIds.at(0)]; operatorToKick = operatorsByID[operatorIds.at(1)]; @@ -1591,12 +1582,13 @@ contract SlashingRegistryCoordinator_RegisterWithChurn is registerOperatorInSlashingRegistryCoordinator(extraOperator3, "socket:8545", operatorSetIds); vm.prank(serviceManager); - IPermissionController(coreDeployment.permissionController).setAppointee( - address(serviceManager), - address(slashingRegistryCoordinator), - address(coreDeployment.allocationManager), - AllocationManager.deregisterFromOperatorSets.selector - ); + IPermissionController(coreDeployment.permissionController) + .setAppointee( + address(serviceManager), + address(slashingRegistryCoordinator), + address(coreDeployment.allocationManager), + AllocationManager.deregisterFromOperatorSets.selector + ); } function _signChurnApproval( @@ -1612,9 +1604,7 @@ contract SlashingRegistryCoordinator_RegisterWithChurn is (uint8 v, bytes32 r, bytes32 s) = vm.sign(churnApproverPrivateKey, digestHash); return ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry({ - signature: abi.encodePacked(r, s, v), - salt: salt, - expiry: expiry + signature: abi.encodePacked(r, s, v), salt: salt, expiry: expiry }); } @@ -1627,8 +1617,7 @@ contract SlashingRegistryCoordinator_RegisterWithChurn is for (uint256 i = 0; i < quorumNumbers.length; i++) { operatorKickParams[i] = ISlashingRegistryCoordinatorTypes.OperatorKickParam({ - operator: operatorToKick, - quorumNumber: uint8(quorumNumbers[i]) + operator: operatorToKick, quorumNumber: uint8(quorumNumbers[i]) }); } @@ -1644,27 +1633,26 @@ contract SlashingRegistryCoordinator_RegisterWithChurn is IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = createPubkeyRegistrationParams(operator, operator.key.addr); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: new uint32[](quorumNumbers.length), - data: abi.encode( - ISlashingRegistryCoordinatorTypes.RegistrationType.CHURN, - socket, - pubkeyParams, - operatorKickParams, - churnApproverSignature - ) - }); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), + operatorSetIds: new uint32[](quorumNumbers.length), + data: abi.encode( + ISlashingRegistryCoordinatorTypes.RegistrationType.CHURN, + socket, + pubkeyParams, + operatorKickParams, + churnApproverSignature + ) + }); for (uint256 i = 0; i < quorumNumbers.length; i++) { registerParams.operatorSetIds[i] = uint8(quorumNumbers[i]); } vm.prank(operator.key.addr); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - operator.key.addr, registerParams - ); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(operator.key.addr, registerParams); } function _setupChurnTest( @@ -1730,14 +1718,17 @@ contract SlashingRegistryCoordinator_RegisterWithChurn is ISlashingRegistryCoordinatorTypes.OperatorKickParam[] memory operatorKickParams = new ISlashingRegistryCoordinatorTypes.OperatorKickParam[](1); operatorKickParams[0] = ISlashingRegistryCoordinatorTypes.OperatorKickParam({ - operator: operatorToKick.key.addr, - quorumNumber: uint8(1) + operator: operatorToKick.key.addr, quorumNumber: uint8(1) }); ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory churnApproverSignature = - _signChurnApproval( - testOperator.key.addr, testOperatorId, operatorKickParams, defaultSalt, defaultExpiry - ); + _signChurnApproval( + testOperator.key.addr, + testOperatorId, + operatorKickParams, + defaultSalt, + defaultExpiry + ); _setOperatorWeight(testOperator.key.addr, registeringStake); _setOperatorWeight(operatorToKick.key.addr, operatorToKickStake); @@ -1745,18 +1736,18 @@ contract SlashingRegistryCoordinator_RegisterWithChurn is IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = createPubkeyRegistrationParams(testOperator, testOperator.key.addr); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: new uint32[](twoQuorumNumbers.length), - data: abi.encode( - ISlashingRegistryCoordinatorTypes.RegistrationType.CHURN, - "socket:8545", - pubkeyParams, - operatorKickParams, - churnApproverSignature - ) - }); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), + operatorSetIds: new uint32[](twoQuorumNumbers.length), + data: abi.encode( + ISlashingRegistryCoordinatorTypes.RegistrationType.CHURN, + "socket:8545", + pubkeyParams, + operatorKickParams, + churnApproverSignature + ) + }); for (uint256 i = 0; i < twoQuorumNumbers.length; i++) { registerParams.operatorSetIds[i] = uint8(twoQuorumNumbers[i]); @@ -1764,9 +1755,8 @@ contract SlashingRegistryCoordinator_RegisterWithChurn is vm.prank(testOperator.key.addr); vm.expectRevert(abi.encodeWithSignature("InputLengthMismatch()")); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - testOperator.key.addr, registerParams - ); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(testOperator.key.addr, registerParams); } function test_registerOperatorWithChurn_revert_churnApproverSaltUsed() public { @@ -1776,50 +1766,47 @@ contract SlashingRegistryCoordinator_RegisterWithChurn is ISlashingRegistryCoordinatorTypes.OperatorKickParam[] memory operatorKickParams = new ISlashingRegistryCoordinatorTypes.OperatorKickParam[](quorumNumbers.length); operatorKickParams[0] = ISlashingRegistryCoordinatorTypes.OperatorKickParam({ - operator: operatorToKick.key.addr, - quorumNumber: uint8(quorumNumbers[0]) + operator: operatorToKick.key.addr, quorumNumber: uint8(quorumNumbers[0]) }); ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory churnApproverSignature = - _signChurnApproval( - testOperator.key.addr, - testOperatorId, - operatorKickParams, - bytes32(uint256(1)), // Salt 1 - defaultExpiry - ); + _signChurnApproval( + testOperator.key.addr, + testOperatorId, + operatorKickParams, + bytes32(uint256(1)), // Salt 1 + defaultExpiry + ); IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = createPubkeyRegistrationParams(testOperator, testOperator.key.addr); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: new uint32[](quorumNumbers.length), - data: abi.encode( - ISlashingRegistryCoordinatorTypes.RegistrationType.CHURN, - "socket:8545", - pubkeyParams, - operatorKickParams, - churnApproverSignature - ) - }); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), + operatorSetIds: new uint32[](quorumNumbers.length), + data: abi.encode( + ISlashingRegistryCoordinatorTypes.RegistrationType.CHURN, + "socket:8545", + pubkeyParams, + operatorKickParams, + churnApproverSignature + ) + }); for (uint256 i = 0; i < quorumNumbers.length; i++) { registerParams.operatorSetIds[i] = uint8(quorumNumbers[i]); } vm.prank(testOperator.key.addr); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - testOperator.key.addr, registerParams - ); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(testOperator.key.addr, registerParams); Operator memory anotherOperator = extraOperator1; _setOperatorWeight(anotherOperator.key.addr, registeringStake * 2); operatorKickParams[0] = ISlashingRegistryCoordinatorTypes.OperatorKickParam({ - operator: operatorToKick.key.addr, - quorumNumber: uint8(quorumNumbers[0]) + operator: operatorToKick.key.addr, quorumNumber: uint8(quorumNumbers[0]) }); churnApproverSignature = _signChurnApproval( @@ -1850,9 +1837,8 @@ contract SlashingRegistryCoordinator_RegisterWithChurn is vm.prank(anotherOperator.key.addr); vm.expectRevert(abi.encodeWithSignature("AlreadyMemberOfSet()")); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - anotherOperator.key.addr, registerParams - ); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(anotherOperator.key.addr, registerParams); } function test_registerOperatorWithChurn_revert_cannotChurnSelf() public { @@ -1867,25 +1853,29 @@ contract SlashingRegistryCoordinator_RegisterWithChurn is }); ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory churnApproverSignature = - _signChurnApproval( - testOperator.key.addr, testOperatorId, operatorKickParams, defaultSalt, defaultExpiry - ); + _signChurnApproval( + testOperator.key.addr, + testOperatorId, + operatorKickParams, + defaultSalt, + defaultExpiry + ); IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = createPubkeyRegistrationParams(testOperator, testOperator.key.addr); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: new uint32[](quorumNumbers.length), - data: abi.encode( - ISlashingRegistryCoordinatorTypes.RegistrationType.CHURN, - "socket:8545", - pubkeyParams, - operatorKickParams, - churnApproverSignature - ) - }); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), + operatorSetIds: new uint32[](quorumNumbers.length), + data: abi.encode( + ISlashingRegistryCoordinatorTypes.RegistrationType.CHURN, + "socket:8545", + pubkeyParams, + operatorKickParams, + churnApproverSignature + ) + }); for (uint256 i = 0; i < quorumNumbers.length; i++) { registerParams.operatorSetIds[i] = uint8(quorumNumbers[i]); @@ -1893,9 +1883,8 @@ contract SlashingRegistryCoordinator_RegisterWithChurn is vm.prank(testOperator.key.addr); vm.expectRevert(abi.encodeWithSignature("CannotChurnSelf()")); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - testOperator.key.addr, registerParams - ); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(testOperator.key.addr, registerParams); } function test_registerOperatorWithChurn_revert_quorumOperatorCountMismatch() public { @@ -1910,29 +1899,29 @@ contract SlashingRegistryCoordinator_RegisterWithChurn is }); ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory churnApproverSignature = - _signChurnApproval( - testOperator.key.addr, - testOperatorId, - operatorKickParams, - bytes32(uint256(2)), // Different salt from previous tests - defaultExpiry - ); + _signChurnApproval( + testOperator.key.addr, + testOperatorId, + operatorKickParams, + bytes32(uint256(2)), // Different salt from previous tests + defaultExpiry + ); IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = createPubkeyRegistrationParams(testOperator, testOperator.key.addr); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: new uint32[](quorumNumbers.length), - data: abi.encode( - ISlashingRegistryCoordinatorTypes.RegistrationType.CHURN, - "socket:8545", - pubkeyParams, - operatorKickParams, - churnApproverSignature - ) - }); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), + operatorSetIds: new uint32[](quorumNumbers.length), + data: abi.encode( + ISlashingRegistryCoordinatorTypes.RegistrationType.CHURN, + "socket:8545", + pubkeyParams, + operatorKickParams, + churnApproverSignature + ) + }); for (uint256 i = 0; i < quorumNumbers.length; i++) { registerParams.operatorSetIds[i] = uint8(quorumNumbers[i]); @@ -1940,9 +1929,8 @@ contract SlashingRegistryCoordinator_RegisterWithChurn is vm.prank(testOperator.key.addr); vm.expectRevert(abi.encodeWithSignature("QuorumOperatorCountMismatch()")); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - testOperator.key.addr, registerParams - ); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(testOperator.key.addr, registerParams); } /// @dev Asserts that an operator cannot be churned out if it is not registered for the quorum @@ -1957,9 +1945,7 @@ contract SlashingRegistryCoordinator_RegisterWithChurn is IStakeRegistryTypes.StrategyParams({strategy: mockStrategy, multiplier: 1 ether}); operatorSetParams = ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 1, - kickBIPsOfOperatorStake: 5000, - kickBIPsOfTotalStake: 5000 + maxOperatorCount: 1, kickBIPsOfOperatorStake: 5000, kickBIPsOfTotalStake: 5000 }); vm.startPrank(proxyAdminOwner); @@ -1982,37 +1968,36 @@ contract SlashingRegistryCoordinator_RegisterWithChurn is }); ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory churnApproverSignature = - _signChurnApproval( - testOperator.key.addr, - testOperatorId, - operatorKickParams, - bytes32(uint256(4)), - defaultExpiry - ); + _signChurnApproval( + testOperator.key.addr, + testOperatorId, + operatorKickParams, + bytes32(uint256(4)), + defaultExpiry + ); IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = createPubkeyRegistrationParams(testOperator, testOperator.key.addr); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: new uint32[](1), - data: abi.encode( - ISlashingRegistryCoordinatorTypes.RegistrationType.CHURN, - "socket:8545", - pubkeyParams, - operatorKickParams, - churnApproverSignature - ) - }); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), + operatorSetIds: new uint32[](1), + data: abi.encode( + ISlashingRegistryCoordinatorTypes.RegistrationType.CHURN, + "socket:8545", + pubkeyParams, + operatorKickParams, + churnApproverSignature + ) + }); registerParams.operatorSetIds[0] = uint32(2); vm.prank(testOperator.key.addr); vm.expectRevert(abi.encodeWithSignature("OperatorNotRegisteredForQuorum()")); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - testOperator.key.addr, registerParams - ); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(testOperator.key.addr, registerParams); } } @@ -2063,12 +2048,13 @@ contract SlashingRegistryCoordinator_UpdateOperators is SlashingRegistryCoordina _setOperatorWeight(testOperator2.key.addr, defaultStake); vm.prank(serviceManager); - IPermissionController(coreDeployment.permissionController).setAppointee( - address(serviceManager), - address(slashingRegistryCoordinator), - address(coreDeployment.allocationManager), - AllocationManager.deregisterFromOperatorSets.selector - ); + IPermissionController(coreDeployment.permissionController) + .setAppointee( + address(serviceManager), + address(slashingRegistryCoordinator), + address(coreDeployment.allocationManager), + AllocationManager.deregisterFromOperatorSets.selector + ); } function test_updateOperators() public { @@ -2274,12 +2260,13 @@ contract SlashingRegistryCoordinator_UpdateOperatorsForQuorum is _setOperatorWeight(testOperator2.key.addr, defaultStake); vm.prank(serviceManager); - IPermissionController(coreDeployment.permissionController).setAppointee( - address(serviceManager), - address(slashingRegistryCoordinator), - address(coreDeployment.allocationManager), - AllocationManager.deregisterFromOperatorSets.selector - ); + IPermissionController(coreDeployment.permissionController) + .setAppointee( + address(serviceManager), + address(slashingRegistryCoordinator), + address(coreDeployment.allocationManager), + AllocationManager.deregisterFromOperatorSets.selector + ); } function test_updateOperators() public { diff --git a/test/unit/StakeRegistryUnit.t.sol b/test/unit/StakeRegistryUnit.t.sol index 31b125065..44947ff75 100644 --- a/test/unit/StakeRegistryUnit.t.sol +++ b/test/unit/StakeRegistryUnit.t.sol @@ -130,7 +130,10 @@ contract StakeRegistryUnitTests is MockAVSDeployer, IStakeRegistryEvents { * Create `numStrats` dummy strategies with multiplier of 1 for each. * Returns quorumNumber that was just initialized */ - function _initializeQuorum(uint96 minimumStake, uint256 numStrats) internal returns (uint8) { + function _initializeQuorum( + uint96 minimumStake, + uint256 numStrats + ) internal returns (uint8) { uint8 quorumNumber = nextQuorum; IStakeRegistryTypes.StrategyParams[] memory strategyParams = @@ -442,10 +445,8 @@ contract StakeRegistryUnitTests is MockAVSDeployer, IStakeRegistryEvents { IStakeRegistry.StakeUpdate memory prev, IStakeRegistry.StakeUpdate memory cur ) internal pure returns (bool) { - return ( - prev.stake == cur.stake && prev.updateBlockNumber == cur.updateBlockNumber - && prev.nextUpdateBlockNumber == cur.nextUpdateBlockNumber - ); + return (prev.stake == cur.stake && prev.updateBlockNumber == cur.updateBlockNumber + && prev.nextUpdateBlockNumber == cur.nextUpdateBlockNumber); } /// @dev Return the minimum stakes required for a list of quorums @@ -528,17 +529,27 @@ contract StakeRegistryUnitTests is MockAVSDeployer, IStakeRegistryEvents { return historyLengths; } - function _calculateDelta(uint96 prev, uint96 cur) internal view returns (int256) { + function _calculateDelta( + uint96 prev, + uint96 cur + ) internal view returns (int256) { return stakeRegistry.calculateDelta({prev: prev, cur: cur}); } - function _applyDelta(uint96 value, int256 delta) internal view returns (uint96) { + function _applyDelta( + uint96 value, + int256 delta + ) internal view returns (uint96) { return stakeRegistry.applyDelta({value: value, delta: delta}); } /// @dev Uses `rand` to return a random uint, with a range given by `min` and `max` (inclusive) /// @return `min` <= result <= `max` - function _randUint(bytes32 rand, uint256 min, uint256 max) internal pure returns (uint256) { + function _randUint( + bytes32 rand, + uint256 min, + uint256 max + ) internal pure returns (uint256) { // hashing makes for more uniform randomness rand = keccak256(abi.encodePacked(rand)); @@ -721,7 +732,10 @@ contract StakeRegistryUnitTests_Config is StakeRegistryUnitTests { * @dev Initializes a quorum with StrategyParams with fuzzed multipliers inputs and corresponding * strategy addresses. */ - function testFuzz_initializeQuorum(uint8 quorumNumber, uint96 minimumStake) public { + function testFuzz_initializeQuorum( + uint8 quorumNumber, + uint96 minimumStake + ) public { quorumNumber = uint8(bound(uint256(quorumNumber), nextQuorum, type(uint8).max)); // Create multipliers array with bounded length @@ -1081,7 +1095,11 @@ contract StakeRegistryUnitTests_Config is StakeRegistryUnitTests { } // Expected events emitted - uint8 quorumNumber = _initializeQuorum(0, /* minimumStake */ numStrategiesToAdd); + uint8 quorumNumber = _initializeQuorum( + 0, + /* minimumStake */ + numStrategiesToAdd + ); for (uint256 i = 0; i < strategyIndices.length; i++) { (IStrategy strategy,) = stakeRegistry.strategyParams(quorumNumber, strategyIndices[i]); cheats.expectEmit(true, true, true, true, address(stakeRegistry)); @@ -1418,8 +1436,9 @@ contract StakeRegistryUnitTests_Register is StakeRegistryUnitTests { RegisterSetup memory setup = setups[i]; cheats.prank(address(registryCoordinator)); - (uint96[] memory resultingStakes, uint96[] memory totalStakes) = stakeRegistry - .registerOperator(setup.operator, setup.operatorId, setup.quorumNumbers); + (uint96[] memory resultingStakes, uint96[] memory totalStakes) = stakeRegistry.registerOperator( + setup.operator, setup.operatorId, setup.quorumNumbers + ); /// Read ending state IStakeRegistry.StakeUpdate[] memory newOperatorStakes = @@ -1617,8 +1636,10 @@ contract StakeRegistryUnitTests_Register is StakeRegistryUnitTests { ); // Validate previous entry was updated correctly - IStakeRegistry.StakeUpdate memory prevUpdate = stakeRegistry - .getTotalStakeUpdateAtIndex(quorumNumber, prevHistoryLengths[j] - 1); + IStakeRegistry.StakeUpdate memory prevUpdate = + stakeRegistry.getTotalStakeUpdateAtIndex( + quorumNumber, prevHistoryLengths[j] - 1 + ); assertTrue( prevUpdate.stake < newTotalStakes[j].stake, "previous update should have lower stake than latest" @@ -2024,8 +2045,10 @@ contract StakeRegistryUnitTests_Deregister is StakeRegistryUnitTests { "latest update should not have next update block" ); - IStakeRegistry.StakeUpdate memory prevUpdate = stakeRegistry - .getTotalStakeUpdateAtIndex(quorumNumber, prevHistoryLengths[j] - 1); + IStakeRegistry.StakeUpdate memory prevUpdate = + stakeRegistry.getTotalStakeUpdateAtIndex( + quorumNumber, prevHistoryLengths[j] - 1 + ); // Validate previous entry was updated correctly assertTrue( prevUpdate.stake > newTotalStakes[j].stake, @@ -2075,8 +2098,9 @@ contract StakeRegistryUnitTests_StakeUpdates is StakeRegistryUnitTests { } function test_updateOperatorStake_Revert_WhenNotRegistryCoordinator() public { - UpdateSetup memory setup = - _fuzz_setupUpdateOperatorStake({registeredFor: initializedQuorumBitmap, fuzzy_Delta: 0}); + UpdateSetup memory setup = _fuzz_setupUpdateOperatorStake({ + registeredFor: initializedQuorumBitmap, fuzzy_Delta: 0 + }); cheats.expectRevert(IStakeRegistryErrors.OnlySlashingRegistryCoordinator.selector); stakeRegistry.updateOperatorsStake( @@ -2088,8 +2112,9 @@ contract StakeRegistryUnitTests_StakeUpdates is StakeRegistryUnitTests { bytes32 rand ) public { // Create a new operator registered for all quorums - UpdateSetup memory setup = - _fuzz_setupUpdateOperatorStake({registeredFor: initializedQuorumBitmap, fuzzy_Delta: 0}); + UpdateSetup memory setup = _fuzz_setupUpdateOperatorStake({ + registeredFor: initializedQuorumBitmap, fuzzy_Delta: 0 + }); // Get a list of valid quorums ending in an invalid quorum number bytes memory invalidQuorums = _fuzz_getInvalidQuorums(rand); @@ -2114,8 +2139,7 @@ contract StakeRegistryUnitTests_StakeUpdates is StakeRegistryUnitTests { int8 stakeDelta ) public { UpdateSetup memory setup = _fuzz_setupUpdateOperatorStake({ - registeredFor: initializedQuorumBitmap, - fuzzy_Delta: stakeDelta + registeredFor: initializedQuorumBitmap, fuzzy_Delta: stakeDelta }); // Get starting state @@ -2326,8 +2350,7 @@ contract StakeRegistryUnitTests_StakeUpdates is StakeRegistryUnitTests { uint256 startBlock = block.number; for (uint256 j = 1; j <= totalBlocks; j++) { UpdateSetup memory setup = _fuzz_setupUpdateOperatorStake({ - registeredFor: initializedQuorumBitmap, - fuzzy_Delta: stakeDelta + registeredFor: initializedQuorumBitmap, fuzzy_Delta: stakeDelta }); // Get starting state @@ -2471,7 +2494,10 @@ contract StakeRegistryUnitTests_StakeUpdates is StakeRegistryUnitTests { * getStakeHistory * */ - function testFuzz_getStakeHistory(uint192 quorumBitmap, uint16 additionalStake) public { + function testFuzz_getStakeHistory( + uint192 quorumBitmap, + uint16 additionalStake + ) public { // Setup - select a new operator and set their weight to each quorum's minimum plus some additional RegisterSetup memory setup = _fuzz_setupRegisterOperator(quorumBitmap, additionalStake); @@ -2805,9 +2831,7 @@ contract StakeRegistryUnitTests_weightOfOperatorForQuorum is StakeRegistryUnitTe for (uint256 i = 0; i < strategyParams.length; i++) { multipliers[i] = uint96( _randUint({ - rand: bytes32(uint256(multipliers[i])), - min: 0, - max: 1000 * WEIGHTING_DIVISOR + rand: bytes32(uint256(multipliers[i])), min: 0, max: 1000 * WEIGHTING_DIVISOR }) ); shares[i] = uint96(_randUint({rand: bytes32(uint256(shares[i])), min: 0, max: 10e20})); @@ -2822,7 +2846,10 @@ contract StakeRegistryUnitTests_weightOfOperatorForQuorum is StakeRegistryUnitTe cheats.prank(address(registryCoordinator)); uint8 quorumNumber = nextQuorum; stakeRegistry.initializeDelegatedStakeQuorum( - quorumNumber, 0, /* minimumStake */ strategyParams + quorumNumber, + 0, + /* minimumStake */ + strategyParams ); // set the operator shares @@ -2871,7 +2898,10 @@ contract StakeRegistryUnitTests_weightOfOperatorForQuorum is StakeRegistryUnitTe cheats.prank(address(registryCoordinator)); uint8 quorumNumber = nextQuorum; stakeRegistry.initializeDelegatedStakeQuorum( - quorumNumber, 0, /* minimumStake */ strategyParams + quorumNumber, + 0, + /* minimumStake */ + strategyParams ); // set the operator shares diff --git a/test/unit/TaskAVSRegistrarBaseUnit.t.sol b/test/unit/TaskAVSRegistrarBaseUnit.t.sol index d3a853ebf..2ee15bb87 100644 --- a/test/unit/TaskAVSRegistrarBaseUnit.t.sol +++ b/test/unit/TaskAVSRegistrarBaseUnit.t.sol @@ -2,12 +2,15 @@ pragma solidity ^0.8.27; import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; -import {TransparentUpgradeableProxy} from - "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; -import {ITransparentUpgradeableProxy} from - "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + TransparentUpgradeableProxy +} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { + ITransparentUpgradeableProxy +} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; import {TaskAVSRegistrarBase} from "../../src/avs/task/TaskAVSRegistrarBase.sol"; @@ -18,12 +21,14 @@ import {ITaskAVSRegistrarBaseEvents} from "../../src/interfaces/ITaskAVSRegistra import {MockTaskAVSRegistrar} from "../mocks/MockTaskAVSRegistrar.sol"; import {MockEigenLayerDeployer} from "./middlewareV2/MockDeployer.sol"; import {IAllowlist} from "../../src/interfaces/IAllowlist.sol"; -import {OperatorSet} from - "../../lib/eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; +import { + OperatorSet +} from "../../lib/eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; import {IAllowlistErrors} from "../../src/interfaces/IAllowlist.sol"; import {IAllowlistEvents} from "../../src/interfaces/IAllowlist.sol"; -import {IAVSRegistrar} from - "../../lib/eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; +import { + IAVSRegistrar +} from "../../lib/eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; import {IAVSRegistrarInternal} from "../../src/interfaces/IAVSRegistrarInternal.sol"; // Base test contract with common setup @@ -396,7 +401,10 @@ contract TaskAVSRegistrarBaseUnitTests_setAvsConfig is TaskAVSRegistrarBaseUnitT registrar.setAvsConfig(config); } - function testFuzz_setAvsConfig(uint32 aggregatorId, uint8 numExecutors) public { + function testFuzz_setAvsConfig( + uint32 aggregatorId, + uint8 numExecutors + ) public { // Bound inputs vm.assume(numExecutors > 0 && numExecutors <= 10); vm.assume(aggregatorId > 0); @@ -726,7 +734,10 @@ contract TaskAVSRegistrarBaseUnitTests_Allowlist is TaskAVSRegistrarBaseUnitTest } // Helper function to add operators to allowlist - function _addOperatorToAllowlist(OperatorSet memory operatorSet, address operator) internal { + function _addOperatorToAllowlist( + OperatorSet memory operatorSet, + address operator + ) internal { vm.prank(owner); registrar.addOperatorToAllowlist(operatorSet, operator); } diff --git a/test/unit/UpgradeableProxyLib.sol b/test/unit/UpgradeableProxyLib.sol index 981c9e7e2..abf0b0b83 100644 --- a/test/unit/UpgradeableProxyLib.sol +++ b/test/unit/UpgradeableProxyLib.sol @@ -28,12 +28,19 @@ library UpgradeableProxyLib { return address(new TransparentUpgradeableProxy(emptyContract, admin, "")); } - function upgrade(address proxy, address impl) internal { + function upgrade( + address proxy, + address impl + ) internal { ProxyAdmin admin = getProxyAdmin(proxy); admin.upgrade(ITransparentUpgradeableProxy(payable(proxy)), impl); } - function upgradeAndCall(address proxy, address impl, bytes memory initData) internal { + function upgradeAndCall( + address proxy, + address impl, + bytes memory initData + ) internal { ProxyAdmin admin = getProxyAdmin(proxy); admin.upgradeAndCall(ITransparentUpgradeableProxy(payable(proxy)), impl, initData); } diff --git a/test/unit/VetoableSlasher.t.sol b/test/unit/VetoableSlasher.t.sol index c06616b39..fdf1e9f03 100644 --- a/test/unit/VetoableSlasher.t.sol +++ b/test/unit/VetoableSlasher.t.sol @@ -21,17 +21,20 @@ import { } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import {EmptyContract} from "eigenlayer-contracts/src/test/mocks/EmptyContract.sol"; import {AllocationManager} from "eigenlayer-contracts/src/contracts/core/AllocationManager.sol"; -import {PermissionController} from - "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; +import { + PermissionController +} from "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; import {PauserRegistry} from "eigenlayer-contracts/src/contracts/permissions/PauserRegistry.sol"; import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol"; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol"; import {DelegationMock} from "../mocks/DelegationMock.sol"; import {SlashingRegistryCoordinator} from "../../src/SlashingRegistryCoordinator.sol"; -import {ISlashingRegistryCoordinatorTypes} from - "../../src/interfaces/ISlashingRegistryCoordinator.sol"; +import { + ISlashingRegistryCoordinatorTypes +} from "../../src/interfaces/ISlashingRegistryCoordinator.sol"; import {IBLSApkRegistry, IBLSApkRegistryTypes} from "../../src/interfaces/IBLSApkRegistry.sol"; import {IIndexRegistry} from "../../src/interfaces/IIndexRegistry.sol"; import {ISocketRegistry} from "../../src/interfaces/ISocketRegistry.sol"; @@ -144,16 +147,14 @@ contract VetoableSlasherTest is Test { vm.stopPrank(); vm.startPrank(strategyManagerOwner); - IStrategyManager(coreDeployment.strategyManager).setStrategyWhitelister( - coreDeployment.strategyFactory - ); + IStrategyManager(coreDeployment.strategyManager) + .setStrategyWhitelister(coreDeployment.strategyFactory); vm.stopPrank(); vm.startPrank(proxyAdminOwner); mockStrategy = IStrategy( - StrategyFactory(coreDeployment.strategyFactory).deployNewStrategy( - IERC20(address(mockToken)) - ) + StrategyFactory(coreDeployment.strategyFactory) + .deployNewStrategy(IERC20(address(mockToken))) ); MiddlewareDeployLib.MiddlewareDeployConfig memory middlewareConfig; @@ -182,14 +183,14 @@ contract VetoableSlasherTest is Test { middlewareConfig.stakeRegistry.stakeType = IStakeRegistryTypes.StakeType(1); middlewareConfig.blsApkRegistry.initialOwner = proxyAdminOwner; - MiddlewareDeployLib.MiddlewareDeployData memory middlewareDeployments = MiddlewareDeployLib - .deployMiddleware( - address(proxyAdmin), - coreDeployment.allocationManager, - coreDeployment.strategyManager, - address(pauserRegistry), - middlewareConfig - ); + MiddlewareDeployLib.MiddlewareDeployData memory middlewareDeployments = + MiddlewareDeployLib.deployMiddleware( + address(proxyAdmin), + coreDeployment.allocationManager, + coreDeployment.strategyManager, + address(pauserRegistry), + middlewareConfig + ); vm.stopPrank(); vetoableSlasher = VetoableSlasher(middlewareDeployments.instantSlasher); @@ -224,26 +225,29 @@ contract VetoableSlasherTest is Test { vm.startPrank(serviceManager); - PermissionController(coreDeployment.permissionController).setAppointee( - address(serviceManager), - address(slashingRegistryCoordinator), - coreDeployment.allocationManager, - bytes4(keccak256("createOperatorSets(address,(uint32,address[],address)[])")) - ); - - PermissionController(coreDeployment.permissionController).setAppointee( - address(serviceManager), - address(slashingRegistryCoordinator), - coreDeployment.allocationManager, - AllocationManager.deregisterFromOperatorSets.selector - ); - - PermissionController(coreDeployment.permissionController).setAppointee( - address(serviceManager), - proxyAdminOwner, - coreDeployment.allocationManager, - AllocationManager.updateAVSMetadataURI.selector - ); + PermissionController(coreDeployment.permissionController) + .setAppointee( + address(serviceManager), + address(slashingRegistryCoordinator), + coreDeployment.allocationManager, + bytes4(keccak256("createOperatorSets(address,(uint32,address[],address)[])")) + ); + + PermissionController(coreDeployment.permissionController) + .setAppointee( + address(serviceManager), + address(slashingRegistryCoordinator), + coreDeployment.allocationManager, + AllocationManager.deregisterFromOperatorSets.selector + ); + + PermissionController(coreDeployment.permissionController) + .setAppointee( + address(serviceManager), + proxyAdminOwner, + coreDeployment.allocationManager, + AllocationManager.updateAVSMetadataURI.selector + ); vm.stopPrank(); @@ -260,16 +264,13 @@ contract VetoableSlasherTest is Test { IStakeRegistryTypes.StrategyParams({strategy: mockStrategy, multiplier: 1 ether}); ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = - ISlashingRegistryCoordinatorTypes.OperatorSetParam({ - maxOperatorCount: 10, - kickBIPsOfOperatorStake: 0, - kickBIPsOfTotalStake: 0 - }); + ISlashingRegistryCoordinatorTypes.OperatorSetParam({ + maxOperatorCount: 10, kickBIPsOfOperatorStake: 0, kickBIPsOfTotalStake: 0 + }); vm.startPrank(proxyAdminOwner); - IAllocationManager(coreDeployment.allocationManager).updateAVSMetadataURI( - serviceManager, "fake-avs-metadata" - ); + IAllocationManager(coreDeployment.allocationManager) + .updateAVSMetadataURI(serviceManager, "fake-avs-metadata"); slashingRegistryCoordinator.createSlashableStakeQuorum( operatorSetParams, 1 ether, strategyParams, 0, address(vetoableSlasher) ); @@ -391,21 +392,18 @@ contract VetoableSlasherTest is Test { function test_fulfillSlashingRequest() public { vm.startPrank(operatorWallet.key.addr); - IDelegationManager(coreDeployment.delegationManager).registerAsOperator( - address(0), 1, "metadata" - ); + IDelegationManager(coreDeployment.delegationManager) + .registerAsOperator(address(0), 1, "metadata"); uint256 depositAmount = 1 ether; mockToken.mint(operatorWallet.key.addr, depositAmount); mockToken.approve(address(coreDeployment.strategyManager), depositAmount); - IStrategyManager(coreDeployment.strategyManager).depositIntoStrategy( - mockStrategy, mockToken, depositAmount - ); + IStrategyManager(coreDeployment.strategyManager) + .depositIntoStrategy(mockStrategy, mockToken, depositAmount); uint32 minDelay = 1; - IAllocationManager(coreDeployment.allocationManager).setAllocationDelay( - operatorWallet.key.addr, minDelay - ); + IAllocationManager(coreDeployment.allocationManager) + .setAllocationDelay(operatorWallet.key.addr, minDelay); vm.stopPrank(); vm.roll(block.number + ALLOCATION_CONFIGURATION_DELAY + 1); @@ -421,11 +419,13 @@ contract VetoableSlasherTest is Test { vm.startPrank(serviceManager); IAllocationManagerTypes.CreateSetParams[] memory createParams = new IAllocationManagerTypes.CreateSetParams[](1); - createParams[0] = - IAllocationManagerTypes.CreateSetParams({operatorSetId: 0, strategies: allocStrategies}); - IAllocationManager(coreDeployment.allocationManager).setAVSRegistrar( - address(serviceManager), IAVSRegistrar(address(slashingRegistryCoordinator)) - ); + createParams[0] = IAllocationManagerTypes.CreateSetParams({ + operatorSetId: 0, strategies: allocStrategies + }); + IAllocationManager(coreDeployment.allocationManager) + .setAVSRegistrar( + address(serviceManager), IAVSRegistrar(address(slashingRegistryCoordinator)) + ); vm.stopPrank(); vm.startPrank(operatorWallet.key.addr); @@ -433,14 +433,11 @@ contract VetoableSlasherTest is Test { IAllocationManagerTypes.AllocateParams[] memory allocParams = new IAllocationManagerTypes.AllocateParams[](1); allocParams[0] = IAllocationManagerTypes.AllocateParams({ - operatorSet: operatorSet, - strategies: allocStrategies, - newMagnitudes: magnitudes + operatorSet: operatorSet, strategies: allocStrategies, newMagnitudes: magnitudes }); - IAllocationManager(coreDeployment.allocationManager).modifyAllocations( - operatorWallet.key.addr, allocParams - ); + IAllocationManager(coreDeployment.allocationManager) + .modifyAllocations(operatorWallet.key.addr, allocParams); vm.roll(block.number + 100); uint32[] memory operatorSetIds = new uint32[](1); @@ -448,34 +445,30 @@ contract VetoableSlasherTest is Test { bytes32 messageHash = slashingRegistryCoordinator.calculatePubkeyRegistrationMessageHash( operatorWallet.key.addr ); - IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = IBLSApkRegistryTypes - .PubkeyRegistrationParams({ - pubkeyRegistrationSignature: SigningKeyOperationsLib.sign( - operatorWallet.signingKey, messageHash - ), - pubkeyG1: operatorWallet.signingKey.publicKeyG1, - pubkeyG2: operatorWallet.signingKey.publicKeyG2 - }); + IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = + IBLSApkRegistryTypes.PubkeyRegistrationParams({ + pubkeyRegistrationSignature: SigningKeyOperationsLib.sign( + operatorWallet.signingKey, messageHash + ), + pubkeyG1: operatorWallet.signingKey.publicKeyG1, + pubkeyG2: operatorWallet.signingKey.publicKeyG2 + }); bytes memory registrationData = abi.encode( ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, "socket", pubkeyParams ); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: operatorSetIds, - data: registrationData - }); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - operatorWallet.key.addr, registerParams - ); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), operatorSetIds: operatorSetIds, data: registrationData + }); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(operatorWallet.key.addr, registerParams); vm.stopPrank(); vm.roll(block.number + 100); - IAllocationManagerTypes.SlashingParams memory params = IAllocationManagerTypes - .SlashingParams({ + IAllocationManagerTypes.SlashingParams memory params = IAllocationManagerTypes.SlashingParams({ operator: operatorWallet.key.addr, operatorSetId: 0, strategies: allocStrategies, @@ -511,8 +504,7 @@ contract VetoableSlasherTest is Test { IStrategy[] memory allocStrategies = new IStrategy[](1); allocStrategies[0] = mockStrategy; - IAllocationManagerTypes.SlashingParams memory params = IAllocationManagerTypes - .SlashingParams({ + IAllocationManagerTypes.SlashingParams memory params = IAllocationManagerTypes.SlashingParams({ operator: operatorWallet.key.addr, operatorSetId: 0, strategies: allocStrategies, @@ -535,8 +527,7 @@ contract VetoableSlasherTest is Test { IStrategy[] memory allocStrategies = new IStrategy[](1); allocStrategies[0] = mockStrategy; - IAllocationManagerTypes.SlashingParams memory params = IAllocationManagerTypes - .SlashingParams({ + IAllocationManagerTypes.SlashingParams memory params = IAllocationManagerTypes.SlashingParams({ operator: operatorWallet.key.addr, operatorSetId: 0, strategies: allocStrategies, @@ -601,21 +592,18 @@ contract VetoableSlasherTest is Test { // Helper function to set up operator for slashing test function _setupOperatorForSlashing() internal returns (bytes32) { vm.startPrank(operatorWallet.key.addr); - IDelegationManager(coreDeployment.delegationManager).registerAsOperator( - address(0), 1, "metadata" - ); + IDelegationManager(coreDeployment.delegationManager) + .registerAsOperator(address(0), 1, "metadata"); uint256 depositAmount = 2 ether; mockToken.mint(operatorWallet.key.addr, depositAmount); mockToken.approve(address(coreDeployment.strategyManager), depositAmount); - IStrategyManager(coreDeployment.strategyManager).depositIntoStrategy( - mockStrategy, mockToken, depositAmount - ); + IStrategyManager(coreDeployment.strategyManager) + .depositIntoStrategy(mockStrategy, mockToken, depositAmount); uint32 minDelay = 1; - IAllocationManager(coreDeployment.allocationManager).setAllocationDelay( - operatorWallet.key.addr, minDelay - ); + IAllocationManager(coreDeployment.allocationManager) + .setAllocationDelay(operatorWallet.key.addr, minDelay); vm.stopPrank(); vm.roll(block.number + ALLOCATION_CONFIGURATION_DELAY + 1); @@ -631,11 +619,13 @@ contract VetoableSlasherTest is Test { vm.startPrank(serviceManager); IAllocationManagerTypes.CreateSetParams[] memory createParams = new IAllocationManagerTypes.CreateSetParams[](1); - createParams[0] = - IAllocationManagerTypes.CreateSetParams({operatorSetId: 0, strategies: allocStrategies}); - IAllocationManager(coreDeployment.allocationManager).setAVSRegistrar( - address(serviceManager), IAVSRegistrar(address(slashingRegistryCoordinator)) - ); + createParams[0] = IAllocationManagerTypes.CreateSetParams({ + operatorSetId: 0, strategies: allocStrategies + }); + IAllocationManager(coreDeployment.allocationManager) + .setAVSRegistrar( + address(serviceManager), IAVSRegistrar(address(slashingRegistryCoordinator)) + ); vm.stopPrank(); vm.startPrank(operatorWallet.key.addr); @@ -643,14 +633,11 @@ contract VetoableSlasherTest is Test { IAllocationManagerTypes.AllocateParams[] memory allocParams = new IAllocationManagerTypes.AllocateParams[](1); allocParams[0] = IAllocationManagerTypes.AllocateParams({ - operatorSet: operatorSet, - strategies: allocStrategies, - newMagnitudes: magnitudes + operatorSet: operatorSet, strategies: allocStrategies, newMagnitudes: magnitudes }); - IAllocationManager(coreDeployment.allocationManager).modifyAllocations( - operatorWallet.key.addr, allocParams - ); + IAllocationManager(coreDeployment.allocationManager) + .modifyAllocations(operatorWallet.key.addr, allocParams); vm.roll(block.number + 100); uint32[] memory operatorSetIds = new uint32[](1); @@ -658,28 +645,25 @@ contract VetoableSlasherTest is Test { bytes32 messageHash = slashingRegistryCoordinator.calculatePubkeyRegistrationMessageHash( operatorWallet.key.addr ); - IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = IBLSApkRegistryTypes - .PubkeyRegistrationParams({ - pubkeyRegistrationSignature: SigningKeyOperationsLib.sign( - operatorWallet.signingKey, messageHash - ), - pubkeyG1: operatorWallet.signingKey.publicKeyG1, - pubkeyG2: operatorWallet.signingKey.publicKeyG2 - }); + IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = + IBLSApkRegistryTypes.PubkeyRegistrationParams({ + pubkeyRegistrationSignature: SigningKeyOperationsLib.sign( + operatorWallet.signingKey, messageHash + ), + pubkeyG1: operatorWallet.signingKey.publicKeyG1, + pubkeyG2: operatorWallet.signingKey.publicKeyG2 + }); bytes memory registrationData = abi.encode( ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, "socket", pubkeyParams ); - IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes - .RegisterParams({ - avs: address(serviceManager), - operatorSetIds: operatorSetIds, - data: registrationData - }); - IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets( - operatorWallet.key.addr, registerParams - ); + IAllocationManagerTypes.RegisterParams memory registerParams = + IAllocationManagerTypes.RegisterParams({ + avs: address(serviceManager), operatorSetIds: operatorSetIds, data: registrationData + }); + IAllocationManager(coreDeployment.allocationManager) + .registerForOperatorSets(operatorWallet.key.addr, registerParams); vm.stopPrank(); vm.roll(block.number + 100); diff --git a/test/unit/middlewareV2/AVSRegistrarAllowlistUnit.t.sol b/test/unit/middlewareV2/AVSRegistrarAllowlistUnit.t.sol index 0670d89cf..0e0ee4300 100644 --- a/test/unit/middlewareV2/AVSRegistrarAllowlistUnit.t.sol +++ b/test/unit/middlewareV2/AVSRegistrarAllowlistUnit.t.sol @@ -3,8 +3,9 @@ pragma solidity ^0.8.27; import "./AVSRegistrarBase.t.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; -import {AVSRegistrarWithAllowlist} from - "src/middlewareV2/registrar/presets/AVSRegistrarWithAllowlist.sol"; +import { + AVSRegistrarWithAllowlist +} from "src/middlewareV2/registrar/presets/AVSRegistrarWithAllowlist.sol"; import {IAllowlistErrors, IAllowlistEvents} from "src/interfaces/IAllowlist.sol"; contract AVSRegistrarWithAllowlistUnitTests is @@ -36,7 +37,10 @@ contract AVSRegistrarWithAllowlistUnitTests is ); } - function _addOperatorToAllowlist(address operator, uint32[] memory operatorSetIds) internal { + function _addOperatorToAllowlist( + address operator, + uint32[] memory operatorSetIds + ) internal { for (uint32 i; i < operatorSetIds.length; ++i) { cheats.prank(allowlistAdmin); avsRegistrarWithAllowlist.addOperatorToAllowlist( @@ -171,9 +175,7 @@ contract AVSRegistrarWithAllowlistUnitTests_removeOperatorFromAllowlist is } } -contract AVSRegistrarAllowistUnitTest_getRegisteredOperators is - AVSRegistrarWithAllowlistUnitTests -{ +contract AVSRegistrarAllowistUnitTest_getRegisteredOperators is AVSRegistrarWithAllowlistUnitTests { using ArrayLib for *; function testFuzz_correctness( @@ -211,9 +213,7 @@ contract AVSRegistrarAllowistUnitTest_getRegisteredOperators is } } -contract AVSRegistrarWithAllowlistUnitTests_registerOperator is - AVSRegistrarWithAllowlistUnitTests -{ +contract AVSRegistrarWithAllowlistUnitTests_registerOperator is AVSRegistrarWithAllowlistUnitTests { using ArrayLib for *; function testFuzz_revert_notAllocationManager( diff --git a/test/unit/middlewareV2/AVSRegistrarAsIdentifierUnit.t.sol b/test/unit/middlewareV2/AVSRegistrarAsIdentifierUnit.t.sol index 19e02cfd2..9ec7c8988 100644 --- a/test/unit/middlewareV2/AVSRegistrarAsIdentifierUnit.t.sol +++ b/test/unit/middlewareV2/AVSRegistrarAsIdentifierUnit.t.sol @@ -3,16 +3,21 @@ pragma solidity ^0.8.27; import "./AVSRegistrarBase.t.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; -import {PermissionController} from - "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; -import {AVSRegistrarAsIdentifier} from - "src/middlewareV2/registrar/presets/AVSRegistrarAsIdentifier.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; -import {TransparentUpgradeableProxy} from - "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + PermissionController +} from "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; +import { + AVSRegistrarAsIdentifier +} from "src/middlewareV2/registrar/presets/AVSRegistrarAsIdentifier.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + TransparentUpgradeableProxy +} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import {AllocationManager} from "eigenlayer-contracts/src/contracts/core/AllocationManager.sol"; contract AVSRegistrarAsIdentifierUnitTests is AVSRegistrarBase { @@ -272,9 +277,7 @@ contract AVSRegistrarAsIdentifierUnitTests_registerOperator is AVSRegistrarAsIde } } -contract AVSRegistrarAsIdentifierUnitTests_deregisterOperator is - AVSRegistrarAsIdentifierUnitTests -{ +contract AVSRegistrarAsIdentifierUnitTests_deregisterOperator is AVSRegistrarAsIdentifierUnitTests { using ArrayLib for *; function testFuzz_revert_notAllocationManager( diff --git a/test/unit/middlewareV2/AVSRegistrarBase.t.sol b/test/unit/middlewareV2/AVSRegistrarBase.t.sol index beb4f73bb..7886c9f34 100644 --- a/test/unit/middlewareV2/AVSRegistrarBase.t.sol +++ b/test/unit/middlewareV2/AVSRegistrarBase.t.sol @@ -1,13 +1,15 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {TransparentUpgradeableProxy} from - "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { + TransparentUpgradeableProxy +} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import {MockEigenLayerDeployer} from "./MockDeployer.sol"; import {IAVSRegistrarErrors, IAVSRegistrarEvents} from "src/interfaces/IAVSRegistrarInternal.sol"; import {AVSRegistrar} from "src/middlewareV2/registrar/AVSRegistrar.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; import { OperatorSet, @@ -47,7 +49,10 @@ abstract contract AVSRegistrarBase is _deployMockEigenLayer(); } - function _registerKey(address operator, uint32[] memory operatorSetIds) internal { + function _registerKey( + address operator, + uint32[] memory operatorSetIds + ) internal { for (uint32 i; i < operatorSetIds.length; ++i) { keyRegistrarMock.setIsRegistered( operator, OperatorSet({avs: AVS, id: operatorSetIds[i]}), true diff --git a/test/unit/middlewareV2/AVSRegistrarSocketUnit.t.sol b/test/unit/middlewareV2/AVSRegistrarSocketUnit.t.sol index 2b486eb80..1b62cef8e 100644 --- a/test/unit/middlewareV2/AVSRegistrarSocketUnit.t.sol +++ b/test/unit/middlewareV2/AVSRegistrarSocketUnit.t.sol @@ -2,10 +2,13 @@ pragma solidity ^0.8.27; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; -import {PermissionControllerMixin} from - "eigenlayer-contracts/src/contracts/mixins/PermissionControllerMixin.sol"; +import { + PermissionControllerMixin +} from "eigenlayer-contracts/src/contracts/mixins/PermissionControllerMixin.sol"; import "./AVSRegistrarBase.t.sol"; -import {AVSRegistrarWithSocket} from "src/middlewareV2/registrar/presets/AVSRegistrarWithSocket.sol"; +import { + AVSRegistrarWithSocket +} from "src/middlewareV2/registrar/presets/AVSRegistrarWithSocket.sol"; import {ISocketRegistryEvents, ISocketRegistryV2} from "src/interfaces/ISocketRegistryV2.sol"; contract AVSRegistrarSocketUnitTests is AVSRegistrarBase, ISocketRegistryEvents { diff --git a/test/unit/middlewareV2/AllowlistUnit.t.sol b/test/unit/middlewareV2/AllowlistUnit.t.sol index 8964eeba9..802d53483 100644 --- a/test/unit/middlewareV2/AllowlistUnit.t.sol +++ b/test/unit/middlewareV2/AllowlistUnit.t.sol @@ -2,8 +2,9 @@ pragma solidity ^0.8.27; import "forge-std/Test.sol"; -import {TransparentUpgradeableProxy} from - "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { + TransparentUpgradeableProxy +} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; import {Allowlist} from "src/middlewareV2/registrar/modules/Allowlist.sol"; @@ -88,7 +89,10 @@ contract AllowlistUnitTests is Test, IAllowlistErrors, IAllowlistEvents { alternativeOperatorSet = OperatorSet({avs: avs2, id: 1}); } - function _addOperatorToAllowlist(address operator, OperatorSet memory operatorSet) internal { + function _addOperatorToAllowlist( + address operator, + OperatorSet memory operatorSet + ) internal { cheats.prank(allowlistOwner); allowlist.addOperatorToAllowlist(operatorSet, operator); } diff --git a/test/unit/middlewareV2/BN254TableCalculatorBaseUnit.t.sol b/test/unit/middlewareV2/BN254TableCalculatorBaseUnit.t.sol index e799215cc..95ba1bfb7 100644 --- a/test/unit/middlewareV2/BN254TableCalculatorBaseUnit.t.sol +++ b/test/unit/middlewareV2/BN254TableCalculatorBaseUnit.t.sol @@ -11,21 +11,24 @@ import { BN254, IOperatorTableCalculatorTypes } from "eigenlayer-contracts/src/contracts/interfaces/IOperatorTableCalculator.sol"; -import {IBN254CertificateVerifierTypes} from - "eigenlayer-contracts/src/contracts/interfaces/IBN254CertificateVerifier.sol"; +import { + IBN254CertificateVerifierTypes +} from "eigenlayer-contracts/src/contracts/interfaces/IBN254CertificateVerifier.sol"; import {IBN254TableCalculator} from "../../../src/interfaces/IBN254TableCalculator.sol"; import { OperatorSet, OperatorSetLib } from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; import {BLSWallet, OperatorWalletLib} from "test/utils/OperatorWalletLib.sol"; -import {BN254TableCalculatorBase} from - "../../../src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol"; +import { + BN254TableCalculatorBase +} from "../../../src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol"; import {MockEigenLayerDeployer} from "./MockDeployer.sol"; import {Random} from "test/utils/Random.sol"; import {Merkle} from "eigenlayer-contracts/src/contracts/libraries/Merkle.sol"; -import {LeafCalculatorMixin} from - "eigenlayer-contracts/src/contracts/mixins/LeafCalculatorMixin.sol"; +import { + LeafCalculatorMixin +} from "eigenlayer-contracts/src/contracts/mixins/LeafCalculatorMixin.sol"; // Mock implementation for testing abstract contract contract BN254TableCalculatorBaseHarness is BN254TableCalculatorBase { @@ -573,9 +576,7 @@ contract BN254TableCalculatorBaseUnitTests_getOperatorSetWeights is * @title BN254TableCalculatorBaseUnitTests_getOperatorWeights * @notice Unit tests for BN254TableCalculatorBase.getOperatorWeights */ -contract BN254TableCalculatorBaseUnitTests_getOperatorWeights is - BN254TableCalculatorBaseUnitTests -{ +contract BN254TableCalculatorBaseUnitTests_getOperatorWeights is BN254TableCalculatorBaseUnitTests { function test_operatorExists() public { // Set operators and weights address[] memory operators = new address[](3); @@ -634,7 +635,10 @@ contract BN254TableCalculatorBaseUnitTests_getOperatorWeights is assertEq(op1Weights.length, 0, "Should return empty array for empty set"); } - function testFuzz_getOperatorWeights(address operator, uint256 weight) public { + function testFuzz_getOperatorWeights( + address operator, + uint256 weight + ) public { weight = bound(weight, 0, 1e18); // Set single operator diff --git a/test/unit/middlewareV2/BN254TableCalculatorUnit.t.sol b/test/unit/middlewareV2/BN254TableCalculatorUnit.t.sol index e286e4a10..a4aed673d 100644 --- a/test/unit/middlewareV2/BN254TableCalculatorUnit.t.sol +++ b/test/unit/middlewareV2/BN254TableCalculatorUnit.t.sol @@ -5,12 +5,14 @@ import { KeyRegistrar, IKeyRegistrarTypes } from "eigenlayer-contracts/src/contracts/permissions/KeyRegistrar.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; -import {IOperatorTableCalculatorTypes} from - "eigenlayer-contracts/src/contracts/interfaces/IOperatorTableCalculator.sol"; +import { + IOperatorTableCalculatorTypes +} from "eigenlayer-contracts/src/contracts/interfaces/IOperatorTableCalculator.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import { OperatorSet, @@ -18,8 +20,9 @@ import { } from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; import {BN254} from "eigenlayer-contracts/src/contracts/libraries/BN254.sol"; -import {BN254TableCalculator} from - "../../../src/middlewareV2/tableCalculator/BN254TableCalculator.sol"; +import { + BN254TableCalculator +} from "../../../src/middlewareV2/tableCalculator/BN254TableCalculator.sol"; import {MockEigenLayerDeployer} from "./MockDeployer.sol"; import "test/utils/Random.sol"; @@ -279,7 +282,10 @@ contract BN254TableCalculatorUnitTests_getOperatorWeights is BN254TableCalculato assertEq(resultWeights[0][0], 1000, "Weight should match"); } - function testFuzz_getOperatorWeights(uint8 numOperators, uint256 baseWeight) public { + function testFuzz_getOperatorWeights( + uint8 numOperators, + uint256 baseWeight + ) public { numOperators = uint8(bound(numOperators, 1, 10)); baseWeight = bound(baseWeight, 1, 1e18); diff --git a/test/unit/middlewareV2/BN254TableCalculatorWithCapsUnit.t.sol b/test/unit/middlewareV2/BN254TableCalculatorWithCapsUnit.t.sol index 4890001d3..5f1e209c2 100644 --- a/test/unit/middlewareV2/BN254TableCalculatorWithCapsUnit.t.sol +++ b/test/unit/middlewareV2/BN254TableCalculatorWithCapsUnit.t.sol @@ -5,23 +5,28 @@ import { KeyRegistrar, IKeyRegistrarTypes } from "eigenlayer-contracts/src/contracts/permissions/KeyRegistrar.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import { OperatorSet, OperatorSetLib } from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; -import {PermissionControllerMixin} from - "eigenlayer-contracts/src/contracts/mixins/PermissionControllerMixin.sol"; +import { + PermissionControllerMixin +} from "eigenlayer-contracts/src/contracts/mixins/PermissionControllerMixin.sol"; -import {BN254TableCalculatorWithCaps} from - "../../../src/middlewareV2/tableCalculator/unaudited/BN254TableCalculatorWithCaps.sol"; -import {BN254TableCalculatorBase} from - "../../../src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol"; +import { + BN254TableCalculatorWithCaps +} from "../../../src/middlewareV2/tableCalculator/unaudited/BN254TableCalculatorWithCaps.sol"; +import { + BN254TableCalculatorBase +} from "../../../src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol"; import {MockEigenLayerDeployer} from "./MockDeployer.sol"; /** diff --git a/test/unit/middlewareV2/BN254WeightedTableCalculatorUnit.t.sol b/test/unit/middlewareV2/BN254WeightedTableCalculatorUnit.t.sol index 1883df8d2..5894ccafe 100644 --- a/test/unit/middlewareV2/BN254WeightedTableCalculatorUnit.t.sol +++ b/test/unit/middlewareV2/BN254WeightedTableCalculatorUnit.t.sol @@ -5,23 +5,28 @@ import { KeyRegistrar, IKeyRegistrarTypes } from "eigenlayer-contracts/src/contracts/permissions/KeyRegistrar.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import { OperatorSet, OperatorSetLib } from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; -import {PermissionControllerMixin} from - "eigenlayer-contracts/src/contracts/mixins/PermissionControllerMixin.sol"; +import { + PermissionControllerMixin +} from "eigenlayer-contracts/src/contracts/mixins/PermissionControllerMixin.sol"; -import {BN254WeightedTableCalculator} from - "../../../src/middlewareV2/tableCalculator/unaudited/BN254WeightedTableCalculator.sol"; -import {BN254TableCalculatorBase} from - "../../../src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol"; +import { + BN254WeightedTableCalculator +} from "../../../src/middlewareV2/tableCalculator/unaudited/BN254WeightedTableCalculator.sol"; +import { + BN254TableCalculatorBase +} from "../../../src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol"; import {MockEigenLayerDeployer} from "./MockDeployer.sol"; // Harness to test internal functions @@ -33,10 +38,7 @@ contract BN254WeightedTableCalculatorHarness is BN254WeightedTableCalculator { uint256 _LOOKAHEAD_BLOCKS ) BN254WeightedTableCalculator( - _keyRegistrar, - _allocationManager, - _permissionController, - _LOOKAHEAD_BLOCKS + _keyRegistrar, _allocationManager, _permissionController, _LOOKAHEAD_BLOCKS ) {} diff --git a/test/unit/middlewareV2/ECDSATableCalculatorBaseUnit.t.sol b/test/unit/middlewareV2/ECDSATableCalculatorBaseUnit.t.sol index e3a415e95..b746cc376 100644 --- a/test/unit/middlewareV2/ECDSATableCalculatorBaseUnit.t.sol +++ b/test/unit/middlewareV2/ECDSATableCalculatorBaseUnit.t.sol @@ -7,8 +7,9 @@ import { } from "eigenlayer-contracts/src/contracts/permissions/KeyRegistrar.sol"; import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; -import {IOperatorTableCalculatorTypes} from - "eigenlayer-contracts/src/contracts/interfaces/IOperatorTableCalculator.sol"; +import { + IOperatorTableCalculatorTypes +} from "eigenlayer-contracts/src/contracts/interfaces/IOperatorTableCalculator.sol"; import {IECDSATableCalculator} from "../../../src/interfaces/IECDSATableCalculator.sol"; import { OperatorSet, @@ -16,8 +17,9 @@ import { } from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; import {SlashingLib} from "eigenlayer-contracts/src/contracts/libraries/SlashingLib.sol"; import {AllocationManagerMock} from "eigenlayer-contracts/src/test/mocks/AllocationManagerMock.sol"; -import {ECDSATableCalculatorBase} from - "../../../src/middlewareV2/tableCalculator/ECDSATableCalculatorBase.sol"; +import { + ECDSATableCalculatorBase +} from "../../../src/middlewareV2/tableCalculator/ECDSATableCalculatorBase.sol"; import {MockEigenLayerDeployer} from "./MockDeployer.sol"; import "test/utils/Random.sol"; @@ -519,7 +521,10 @@ contract ECDSATableCalculatorBaseUnitTests_calculateOperatorTableBytes is assertEq(decodedInfos.length, 0, "Should encode empty array"); } - function testFuzz_encodesCorrectly(Randomness r, uint256 weight) public rand(r) { + function testFuzz_encodesCorrectly( + Randomness r, + uint256 weight + ) public rand(r) { weight = r.Uint256() % 1e18 + 1; // 1 to 1e18 // Register operator @@ -674,9 +679,7 @@ contract ECDSATableCalculatorBaseUnitTests_getOperatorSetWeights is * @title ECDSATableCalculatorBaseUnitTests_getOperatorWeights * @notice Unit tests for ECDSATableCalculatorBase.getOperatorWeights */ -contract ECDSATableCalculatorBaseUnitTests_getOperatorWeights is - ECDSATableCalculatorBaseUnitTests -{ +contract ECDSATableCalculatorBaseUnitTests_getOperatorWeights is ECDSATableCalculatorBaseUnitTests { function test_operatorExists() public { // Set operators and weights address[] memory operators = new address[](3); @@ -798,7 +801,10 @@ contract ECDSATableCalculatorBaseUnitTests_getOperatorWeights is assertEq(diffWeights.length, 0, "Different operator should return empty array"); } - function testFuzz_multipleOperators(Randomness r, uint8 numOperators) public rand(r) { + function testFuzz_multipleOperators( + Randomness r, + uint8 numOperators + ) public rand(r) { numOperators = uint8(r.Uint256() % 10 + 1); // 1-10 operators address[] memory operators = new address[](numOperators); diff --git a/test/unit/middlewareV2/ECDSATableCalculatorUnit.t.sol b/test/unit/middlewareV2/ECDSATableCalculatorUnit.t.sol index 1260f3aeb..db1ab22d2 100644 --- a/test/unit/middlewareV2/ECDSATableCalculatorUnit.t.sol +++ b/test/unit/middlewareV2/ECDSATableCalculatorUnit.t.sol @@ -5,20 +5,23 @@ import { KeyRegistrar, IKeyRegistrarTypes } from "eigenlayer-contracts/src/contracts/permissions/KeyRegistrar.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; -import {IOperatorTableCalculatorTypes} from - "eigenlayer-contracts/src/contracts/interfaces/IOperatorTableCalculator.sol"; +import { + IOperatorTableCalculatorTypes +} from "eigenlayer-contracts/src/contracts/interfaces/IOperatorTableCalculator.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import { OperatorSet, OperatorSetLib } from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; -import {ECDSATableCalculator} from - "../../../src/middlewareV2/tableCalculator/ECDSATableCalculator.sol"; +import { + ECDSATableCalculator +} from "../../../src/middlewareV2/tableCalculator/ECDSATableCalculator.sol"; import {MockEigenLayerDeployer} from "./MockDeployer.sol"; import "test/utils/Random.sol"; @@ -292,7 +295,10 @@ contract ECDSATableCalculatorUnitTests_getOperatorWeights is ECDSATableCalculato assertEq(resultWeights[0][0], 1000, "Weight should match"); } - function testFuzz_getOperatorWeights(uint8 numOperators, uint256 baseWeight) public { + function testFuzz_getOperatorWeights( + uint8 numOperators, + uint256 baseWeight + ) public { numOperators = uint8(bound(numOperators, 1, 10)); baseWeight = bound(baseWeight, 1, 1e18); diff --git a/test/unit/middlewareV2/MockDeployer.sol b/test/unit/middlewareV2/MockDeployer.sol index 8cb02176a..077a199fb 100644 --- a/test/unit/middlewareV2/MockDeployer.sol +++ b/test/unit/middlewareV2/MockDeployer.sol @@ -4,10 +4,12 @@ pragma solidity ^0.8.27; import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; import {KeyRegistrar} from "eigenlayer-contracts/src/contracts/permissions/KeyRegistrar.sol"; -import {PermissionController} from - "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + PermissionController +} from "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {AllocationManagerMock} from "test/mocks/AllocationManagerMock.sol"; import "test/mocks/KeyRegistrarMock.sol"; diff --git a/test/utils/BLSMockAVSDeployer.sol b/test/utils/BLSMockAVSDeployer.sol index 701fd320b..f1bfa908a 100644 --- a/test/utils/BLSMockAVSDeployer.sol +++ b/test/utils/BLSMockAVSDeployer.sol @@ -31,23 +31,23 @@ contract BLSMockAVSDeployer is MockAVSDeployer { function _setAggregatePublicKeysAndSignature() internal { // aggSignerPrivKey*g2 aggSignerApkG2.X[1] = - 19101821850089705274637533855249918363070101489527618151493230256975900223847; + 19101821850089705274637533855249918363070101489527618151493230256975900223847; aggSignerApkG2.X[0] = - 5334410886741819556325359147377682006012228123419628681352847439302316235957; + 5334410886741819556325359147377682006012228123419628681352847439302316235957; aggSignerApkG2.Y[1] = - 354176189041917478648604979334478067325821134838555150300539079146482658331; + 354176189041917478648604979334478067325821134838555150300539079146482658331; aggSignerApkG2.Y[0] = - 4185483097059047421902184823581361466320657066600218863748375739772335928910; + 4185483097059047421902184823581361466320657066600218863748375739772335928910; // 100*aggSignerPrivKey*g2 oneHundredQuorumApkG2.X[1] = - 6187649255575786743153792867265230878737103598736372524337965086852090105771; + 6187649255575786743153792867265230878737103598736372524337965086852090105771; oneHundredQuorumApkG2.X[0] = - 5334877400925935887383922877430837542135722474116902175395820705628447222839; + 5334877400925935887383922877430837542135722474116902175395820705628447222839; oneHundredQuorumApkG2.Y[1] = - 4668116328019846503695710811760363536142902258271850958815598072072236299223; + 4668116328019846503695710811760363536142902258271850958815598072072236299223; oneHundredQuorumApkG2.Y[0] = - 21446056442597180561077194011672151329458819211586246807143487001691968661015; + 21446056442597180561077194011672151329458819211586246807143487001691968661015; sigma = BN254.hashToG1(msgHash).scalar_mul(aggSignerPrivKey); } @@ -101,8 +101,7 @@ contract BLSMockAVSDeployer is MockAVSDeployer { uint256 numNonSigners, uint256 quorumBitmap ) internal returns (uint32, BLSSignatureChecker.NonSignerStakesAndSignature memory) { - (uint256[] memory signerPrivateKeys, uint256[] memory nonSignerPrivateKeys) = - _generateSignerAndNonSignerPrivateKeys( + (uint256[] memory signerPrivateKeys, uint256[] memory nonSignerPrivateKeys) = _generateSignerAndNonSignerPrivateKeys( pseudoRandomNumber, maxOperatorsToRegister - numNonSigners, numNonSigners ); bytes memory quorumNumbers = BitmapUtils.bitmapToBytesArray(quorumBitmap); @@ -153,23 +152,23 @@ contract BLSMockAVSDeployer is MockAVSDeployer { _registerOperatorWithCoordinator(operators[i], quorumBitmap, pubkeys[i], defaultStake); } - uint32 referenceBlockNumber = registrationBlockNumber - + blocksBetweenRegistrations * uint32(maxOperatorsToRegister) + 1; + uint32 referenceBlockNumber = registrationBlockNumber + blocksBetweenRegistrations + * uint32(maxOperatorsToRegister) + 1; cheats.roll(referenceBlockNumber + 100); OperatorStateRetriever.CheckSignaturesIndices memory checkSignaturesIndices = - operatorStateRetriever.getCheckSignaturesIndices( - registryCoordinator, referenceBlockNumber, quorumNumbers, nonSignerOperatorIds - ); + operatorStateRetriever.getCheckSignaturesIndices( + registryCoordinator, referenceBlockNumber, quorumNumbers, nonSignerOperatorIds + ); nonSignerStakesAndSignature.nonSignerQuorumBitmapIndices = - checkSignaturesIndices.nonSignerQuorumBitmapIndices; + checkSignaturesIndices.nonSignerQuorumBitmapIndices; nonSignerStakesAndSignature.apkG2 = aggSignerApkG2; nonSignerStakesAndSignature.sigma = sigma; nonSignerStakesAndSignature.quorumApkIndices = checkSignaturesIndices.quorumApkIndices; nonSignerStakesAndSignature.totalStakeIndices = checkSignaturesIndices.totalStakeIndices; nonSignerStakesAndSignature.nonSignerStakeIndices = - checkSignaturesIndices.nonSignerStakeIndices; + checkSignaturesIndices.nonSignerStakeIndices; return (referenceBlockNumber, nonSignerStakesAndSignature); } diff --git a/test/utils/BN256G2.sol b/test/utils/BN256G2.sol index 9d407b41b..6636316dc 100644 --- a/test/utils/BN256G2.sol +++ b/test/utils/BN256G2.sol @@ -98,7 +98,11 @@ library BN256G2 { return FIELD_MODULUS; } - function submod(uint256 a, uint256 b, uint256 n) internal pure returns (uint256) { + function submod( + uint256 a, + uint256 b, + uint256 n + ) internal pure returns (uint256) { return addmod(a, n - b, n); } @@ -114,7 +118,11 @@ library BN256G2 { ); } - function _FQ2Muc(uint256 xx, uint256 xy, uint256 c) internal pure returns (uint256, uint256) { + function _FQ2Muc( + uint256 xx, + uint256 xy, + uint256 c + ) internal pure returns (uint256, uint256) { return (mulmod(xx, c, FIELD_MODULUS), mulmod(xy, c, FIELD_MODULUS)); } @@ -146,7 +154,10 @@ library BN256G2 { return _FQ2Mul(xx, xy, yx, yy); } - function _FQ2Inv(uint256 x, uint256 y) internal view returns (uint256, uint256) { + function _FQ2Inv( + uint256 x, + uint256 y + ) internal view returns (uint256, uint256) { uint256 inv = _modInv( addmod(mulmod(y, y, FIELD_MODULUS), mulmod(x, x, FIELD_MODULUS), FIELD_MODULUS), FIELD_MODULUS @@ -172,7 +183,10 @@ library BN256G2 { return yyx == 0 && yyy == 0; } - function _modInv(uint256 a, uint256 n) internal view returns (uint256 result) { + function _modInv( + uint256 a, + uint256 n + ) internal view returns (uint256 result) { bool success; assembly ("memory-safe") { let freemem := mload(0x40) @@ -219,11 +233,11 @@ library BN256G2 { ) internal pure returns (uint256[6] memory pt3) { if (pt1zx == 0 && pt1zy == 0) { (pt3[PTXX], pt3[PTXY], pt3[PTYX], pt3[PTYY], pt3[PTZX], pt3[PTZY]) = - (pt2xx, pt2xy, pt2yx, pt2yy, pt2zx, pt2zy); + (pt2xx, pt2xy, pt2yx, pt2yy, pt2zx, pt2zy); return pt3; } else if (pt2zx == 0 && pt2zy == 0) { (pt3[PTXX], pt3[PTXY], pt3[PTYX], pt3[PTYY], pt3[PTZX], pt3[PTZY]) = - (pt1xx, pt1xy, pt1yx, pt1yy, pt1zx, pt1zy); + (pt1xx, pt1xy, pt1yx, pt1yy, pt1zx, pt1zy); return pt3; } diff --git a/test/utils/CoreDeployLib.sol b/test/utils/CoreDeployLib.sol index 53ec6591d..d9d4b0a97 100644 --- a/test/utils/CoreDeployLib.sol +++ b/test/utils/CoreDeployLib.sol @@ -4,10 +4,12 @@ pragma solidity ^0.8.12; import {Vm} from "forge-std/Vm.sol"; import {stdJson} from "forge-std/StdJson.sol"; import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; -import {TransparentUpgradeableProxy} from - "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; -import {AllocationManagerView} from - "eigenlayer-contracts/src/contracts/core/AllocationManagerView.sol"; +import { + TransparentUpgradeableProxy +} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { + AllocationManagerView +} from "eigenlayer-contracts/src/contracts/core/AllocationManagerView.sol"; import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; import {DelegationManager} from "eigenlayer-contracts/src/contracts/core/DelegationManager.sol"; import {StrategyManager} from "eigenlayer-contracts/src/contracts/core/StrategyManager.sol"; @@ -17,8 +19,9 @@ import {RewardsCoordinator} from "eigenlayer-contracts/src/contracts/core/Reward import {StrategyBase} from "eigenlayer-contracts/src/contracts/strategies/StrategyBase.sol"; import {EigenPod} from "eigenlayer-contracts/src/contracts/pods/EigenPod.sol"; import {IETHPOSDeposit} from "eigenlayer-contracts/src/contracts/interfaces/IETHPOSDeposit.sol"; -import {StrategyBaseTVLLimits} from - "eigenlayer-contracts/src/contracts/strategies/StrategyBaseTVLLimits.sol"; +import { + StrategyBaseTVLLimits +} from "eigenlayer-contracts/src/contracts/strategies/StrategyBaseTVLLimits.sol"; import {PauserRegistry} from "eigenlayer-contracts/src/contracts/permissions/PauserRegistry.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; @@ -26,25 +29,31 @@ import { ISignatureUtilsMixin, ISignatureUtilsMixinTypes } from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; import {IBeacon} from "@openzeppelin/contracts/proxy/beacon/IBeacon.sol"; -import {IAllocationManagerView} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManagerView +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol"; import {IEigenPodManager} from "eigenlayer-contracts/src/contracts/interfaces/IEigenPodManager.sol"; import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol"; import {StrategyFactory} from "eigenlayer-contracts/src/contracts/strategies/StrategyFactory.sol"; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {AllocationManager} from "eigenlayer-contracts/src/contracts/core/AllocationManager.sol"; -import {PermissionController} from - "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; -import {IRewardsCoordinatorTypes} from - "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; +import { + PermissionController +} from "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; +import { + IRewardsCoordinatorTypes +} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; import {UpgradeableProxyLib} from "../unit/UpgradeableProxyLib.sol"; @@ -342,7 +351,8 @@ library CoreDeployLib { allocationManager: IAllocationManager(deployments.allocationManager), pauserRegistry: IPauserRegistry(deployments.pauserRegistry), permissionController: IPermissionController(deployments.permissionController), - CALCULATION_INTERVAL_SECONDS: config.rewardsCoordinator.calculationIntervalSeconds, + CALCULATION_INTERVAL_SECONDS: config.rewardsCoordinator + .calculationIntervalSeconds, MAX_REWARDS_DURATION: config.rewardsCoordinator.maxRewardsDuration, MAX_RETROACTIVE_LENGTH: config.rewardsCoordinator.maxRetroactiveLength, MAX_FUTURE_LENGTH: config.rewardsCoordinator.maxFutureLength, diff --git a/test/utils/MiddlewareDeployLib.sol b/test/utils/MiddlewareDeployLib.sol index 47848184f..d26591816 100644 --- a/test/utils/MiddlewareDeployLib.sol +++ b/test/utils/MiddlewareDeployLib.sol @@ -2,18 +2,22 @@ pragma solidity ^0.8.12; import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; -import {TransparentUpgradeableProxy} from - "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { + TransparentUpgradeableProxy +} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; +import { + IAllocationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol"; import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol"; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; -import {PermissionController} from - "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; +import { + PermissionController +} from "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; import {InstantSlasher} from "../../src/slashers/InstantSlasher.sol"; import {SlashingRegistryCoordinator} from "../../src/SlashingRegistryCoordinator.sol"; import {SocketRegistry} from "../../src/SocketRegistry.sol"; @@ -39,10 +43,12 @@ import { IRegistryCoordinator, IRegistryCoordinatorTypes } from "../../src/RegistryCoordinator.sol"; -import {IRewardsCoordinator} from - "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; -import {IPermissionController} from - "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; +import { + IRewardsCoordinator +} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; +import { + IPermissionController +} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; import {IServiceManager} from "../../src/interfaces/IServiceManager.sol"; library MiddlewareDeployLib { @@ -259,20 +265,20 @@ library MiddlewareDeployLib { address admin ) internal { IRegistryCoordinatorTypes.SlashingRegistryParams memory slashingParams = - IRegistryCoordinatorTypes.SlashingRegistryParams({ - stakeRegistry: IStakeRegistry(deployment.stakeRegistry), - blsApkRegistry: IBLSApkRegistry(deployment.blsApkRegistry), - indexRegistry: IIndexRegistry(deployment.indexRegistry), - socketRegistry: ISocketRegistry(deployment.socketRegistry), - allocationManager: IAllocationManager(allocationManager), - pauserRegistry: IPauserRegistry(deployment.pauserRegistry) - }); + IRegistryCoordinatorTypes.SlashingRegistryParams({ + stakeRegistry: IStakeRegistry(deployment.stakeRegistry), + blsApkRegistry: IBLSApkRegistry(deployment.blsApkRegistry), + indexRegistry: IIndexRegistry(deployment.indexRegistry), + socketRegistry: ISocketRegistry(deployment.socketRegistry), + allocationManager: IAllocationManager(allocationManager), + pauserRegistry: IPauserRegistry(deployment.pauserRegistry) + }); IRegistryCoordinatorTypes.RegistryCoordinatorParams memory params = - IRegistryCoordinatorTypes.RegistryCoordinatorParams({ - serviceManager: IServiceManager(deployment.serviceManager), - slashingParams: slashingParams - }); + IRegistryCoordinatorTypes.RegistryCoordinatorParams({ + serviceManager: IServiceManager(deployment.serviceManager), + slashingParams: slashingParams + }); address impl = address(new RegistryCoordinator(params)); bytes memory registryCoordinatorUpgradeCall = abi.encodeCall( diff --git a/test/utils/MockAVSDeployer.sol b/test/utils/MockAVSDeployer.sol index 114502e18..4a86a7cdc 100644 --- a/test/utils/MockAVSDeployer.sol +++ b/test/utils/MockAVSDeployer.sol @@ -3,8 +3,9 @@ pragma solidity ^0.8.27; import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; -import {ITransparentUpgradeableProxy} from - "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { + ITransparentUpgradeableProxy +} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import {EigenStrategy} from "eigenlayer-contracts/src/contracts/strategies/EigenStrategy.sol"; import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol"; @@ -50,13 +51,16 @@ import {RewardsCoordinatorMock} from "../mocks/RewardsCoordinatorMock.sol"; import {PermissionControllerMock} from "../mocks/PermissionControllerMock.sol"; import {RewardsCoordinator} from "eigenlayer-contracts/src/contracts/core/RewardsCoordinator.sol"; -import {PermissionController} from - "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; +import { + PermissionController +} from "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol"; import {AllocationManager} from "eigenlayer-contracts/src/contracts/core/AllocationManager.sol"; -import {IRewardsCoordinator} from - "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; -import {AllocationManagerView} from - "eigenlayer-contracts/src/contracts/core/AllocationManagerView.sol"; +import { + IRewardsCoordinator +} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; +import { + AllocationManagerView +} from "eigenlayer-contracts/src/contracts/core/AllocationManagerView.sol"; import {BLSApkRegistryHarness} from "../harnesses/BLSApkRegistryHarness.sol"; import {EmptyContract} from "eigenlayer-contracts/src/test/mocks/EmptyContract.sol"; @@ -309,8 +313,7 @@ contract MockAVSDeployer is Test { ); serviceManager.initialize({ - initialOwner: registryCoordinatorOwner, - rewardsInitiator: proxyAdminOwner + initialOwner: registryCoordinatorOwner, rewardsInitiator: proxyAdminOwner }); // set the public key for an operator, using harnessed function to bypass checks @@ -487,8 +490,8 @@ contract MockAVSDeployer is Test { for (uint256 i = 0; i < operatorMetadatas.length; i++) { // limit to 16 quorums so we don't run out of gas, make them all register for quorum 0 as well operatorMetadatas[i].quorumBitmap = uint256( - keccak256(abi.encodePacked("quorumBitmap", pseudoRandomNumber, i)) - ) & (1 << maxQuorumsToRegisterFor - 1) | 1; + keccak256(abi.encodePacked("quorumBitmap", pseudoRandomNumber, i)) + ) & (1 << maxQuorumsToRegisterFor - 1) | 1; operatorMetadatas[i].operator = _incrementAddress(defaultOperator, i); operatorMetadatas[i].pubkey = BN254.hashToG1(keccak256(abi.encodePacked("pubkey", pseudoRandomNumber, i))); @@ -554,11 +557,17 @@ contract MockAVSDeployer is Test { return uint96(actualWeight); } - function _incrementAddress(address start, uint256 inc) internal pure returns (address) { + function _incrementAddress( + address start, + uint256 inc + ) internal pure returns (address) { return address(uint160(uint256(uint160(start) + inc))); } - function _incrementBytes32(bytes32 start, uint256 inc) internal pure returns (bytes32) { + function _incrementBytes32( + bytes32 start, + uint256 inc + ) internal pure returns (bytes32) { return bytes32(uint256(start) + inc); } @@ -574,9 +583,7 @@ contract MockAVSDeployer is Test { ); (uint8 v, bytes32 r, bytes32 s) = vm.sign(churnApproverPrivateKey, digestHash); return ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry({ - signature: abi.encodePacked(r, s, v), - expiry: expiry, - salt: salt + signature: abi.encodePacked(r, s, v), expiry: expiry, salt: salt }); } diff --git a/test/utils/OperatorLib.sol b/test/utils/OperatorLib.sol index 1b7ebb57c..439b5d060 100644 --- a/test/utils/OperatorLib.sol +++ b/test/utils/OperatorLib.sol @@ -9,15 +9,17 @@ import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IStakeRegistry} from "../../src/interfaces/IStakeRegistry.sol"; -import {ISlashingRegistryCoordinatorTypes} from - "../../src/interfaces/ISlashingRegistryCoordinator.sol"; +import { + ISlashingRegistryCoordinatorTypes +} from "../../src/interfaces/ISlashingRegistryCoordinator.sol"; import {IRegistryCoordinator} from "../../src/RegistryCoordinator.sol"; import {OperatorStateRetriever} from "../../src/OperatorStateRetriever.sol"; import {RegistryCoordinator} from "../../src/RegistryCoordinator.sol"; import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; -import {IDelegationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { + IDelegationManager +} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; import { ISignatureUtilsMixin, ISignatureUtilsMixinTypes @@ -141,7 +143,11 @@ library OperatorLib { ); } - function mintMockTokens(Operator memory operator, address token, uint256 amount) internal { + function mintMockTokens( + Operator memory operator, + address token, + uint256 amount + ) internal { ERC20Mock(token).mint(operator.key.addr, amount); } @@ -163,7 +169,10 @@ library OperatorLib { return shares; } - function registerAsOperator(Operator memory operator, address delegationManager) internal { + function registerAsOperator( + Operator memory operator, + address delegationManager + ) internal { IDelegationManager delegationManagerInstance = IDelegationManager(delegationManager); delegationManagerInstance.registerAsOperator(operator.key.addr, 0, ""); @@ -182,8 +191,10 @@ library OperatorLib { bytes32 salt = keccak256(abi.encodePacked(block.timestamp, operator.key.addr)); uint256 expiry = block.timestamp + 1 hours; - bytes32 operatorRegistrationDigestHash = avsDirectoryInstance - .calculateOperatorAVSRegistrationDigestHash(operator.key.addr, serviceManager, salt, expiry); + bytes32 operatorRegistrationDigestHash = + avsDirectoryInstance.calculateOperatorAVSRegistrationDigestHash( + operator.key.addr, serviceManager, salt, expiry + ); bytes memory signature = signWithOperatorKey(operator, operatorRegistrationDigestHash); // Get the pubkey registration message hash that needs to be signed @@ -194,19 +205,17 @@ library OperatorLib { BN254.G1Point memory blsSig = signMessage(operator.signingKey, pubkeyRegistrationMessageHash); - IBLSApkRegistryTypes.PubkeyRegistrationParams memory params = IBLSApkRegistryTypes - .PubkeyRegistrationParams({ - pubkeyG1: operator.signingKey.publicKeyG1, - pubkeyG2: operator.signingKey.publicKeyG2, - pubkeyRegistrationSignature: blsSig - }); + IBLSApkRegistryTypes.PubkeyRegistrationParams memory params = + IBLSApkRegistryTypes.PubkeyRegistrationParams({ + pubkeyG1: operator.signingKey.publicKeyG1, + pubkeyG2: operator.signingKey.publicKeyG2, + pubkeyRegistrationSignature: blsSig + }); ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry memory operatorSignature = - ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry({ - signature: signature, - salt: salt, - expiry: expiry - }); + ISignatureUtilsMixinTypes.SignatureWithSaltAndExpiry({ + signature: signature, salt: salt, expiry: expiry + }); // Convert quorumNumbers to bytes using BitmapUtils uint256 quorumBitmap = 0; @@ -254,12 +263,12 @@ library OperatorLib { BN254.G1Point memory signature = signMessage(operator.signingKey, pubkeyRegistrationMessageHash); - IBLSApkRegistryTypes.PubkeyRegistrationParams memory blsParams = IBLSApkRegistryTypes - .PubkeyRegistrationParams({ - pubkeyG1: operator.signingKey.publicKeyG1, - pubkeyG2: operator.signingKey.publicKeyG2, - pubkeyRegistrationSignature: signature - }); + IBLSApkRegistryTypes.PubkeyRegistrationParams memory blsParams = + IBLSApkRegistryTypes.PubkeyRegistrationParams({ + pubkeyG1: operator.signingKey.publicKeyG1, + pubkeyG2: operator.signingKey.publicKeyG2, + pubkeyRegistrationSignature: signature + }); registrationParamsData = abi.encode( ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, @@ -267,8 +276,9 @@ library OperatorLib { blsParams ); - IAllocationManagerTypes.RegisterParams memory params = IAllocationManagerTypes - .RegisterParams({avs: avs, operatorSetIds: operatorSetIds, data: registrationParamsData}); + IAllocationManagerTypes.RegisterParams memory params = IAllocationManagerTypes.RegisterParams({ + avs: avs, operatorSetIds: operatorSetIds, data: registrationParamsData + }); // Register the operator in the Allocation Manager allocationManagerInstance.registerForOperatorSets(operator.key.addr, params); @@ -282,8 +292,10 @@ library OperatorLib { ) internal { IAllocationManager allocationManagerInstance = IAllocationManager(allocationManager); - IAllocationManagerTypes.DeregisterParams memory params = IAllocationManagerTypes - .DeregisterParams({operator: operator.key.addr, avs: avs, operatorSetIds: operatorSetIds}); + IAllocationManagerTypes.DeregisterParams memory params = + IAllocationManagerTypes.DeregisterParams({ + operator: operator.key.addr, avs: avs, operatorSetIds: operatorSetIds + }); // Deregister the operator in the Allocation Manager allocationManagerInstance.deregisterFromOperatorSets(params); diff --git a/test/utils/OperatorWalletLib.sol b/test/utils/OperatorWalletLib.sol index 036fecf8f..e2fac5057 100644 --- a/test/utils/OperatorWalletLib.sol +++ b/test/utils/OperatorWalletLib.sol @@ -25,7 +25,10 @@ struct Operator { library OperatorKeyOperationsLib { Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code"))))); - function sign(Wallet memory wallet, bytes32 digest) internal pure returns (bytes memory) { + function sign( + Wallet memory wallet, + bytes32 digest + ) internal pure returns (bytes memory) { (uint8 v, bytes32 r, bytes32 s) = vm.sign(wallet.privateKey, digest); return abi.encodePacked(r, s, v); } diff --git a/test/utils/Random.sol b/test/utils/Random.sol index bb5a2bcc5..8ccffe447 100644 --- a/test/utils/Random.sol +++ b/test/utils/Random.sol @@ -9,7 +9,6 @@ library Random { /// ----------------------------------------------------------------------- /// Constants /// ----------------------------------------------------------------------- - /// @dev Equivalent to: `uint256(keccak256("RANDOMNESS.SEED"))`. uint256 constant SEED = 0x93bfe7cafd9427243dc4fe8c6e706851eb6696ba8e48960dd74ecc96544938ce; @@ -46,7 +45,11 @@ library Random { /// Native Types /// ----------------------------------------------------------------------- - function Int256(Randomness r, int256 min, int256 max) internal returns (int256) { + function Int256( + Randomness r, + int256 min, + int256 max + ) internal returns (int256) { return max <= min ? min : r.Int256() % (max - min) + min; } @@ -56,7 +59,11 @@ library Random { return r.unwrap() % 2 == 0 ? int256(r.Uint256()) : -int256(r.Uint256()); } - function Int128(Randomness r, int128 min, int128 max) internal returns (int128) { + function Int128( + Randomness r, + int128 min, + int128 max + ) internal returns (int128) { return int128(Int256(r, min, max)); } @@ -66,7 +73,11 @@ library Random { return int128(Int256(r)); } - function Int64(Randomness r, int64 min, int64 max) internal returns (int64) { + function Int64( + Randomness r, + int64 min, + int64 max + ) internal returns (int64) { return int64(Int256(r, min, max)); } @@ -76,11 +87,19 @@ library Random { return int64(Int256(r)); } - function Int32(Randomness r, int32 min, int32 max) internal returns (int32) { + function Int32( + Randomness r, + int32 min, + int32 max + ) internal returns (int32) { return int32(Int256(r, min, max)); } - function Uint256(Randomness r, uint256 min, uint256 max) internal returns (uint256) { + function Uint256( + Randomness r, + uint256 min, + uint256 max + ) internal returns (uint256) { return max <= min ? min : r.Uint256() % (max - min) + min; } @@ -90,7 +109,11 @@ library Random { return r.shuffle().unwrap(); } - function Uint128(Randomness r, uint128 min, uint128 max) internal returns (uint128) { + function Uint128( + Randomness r, + uint128 min, + uint128 max + ) internal returns (uint128) { return uint128(Uint256(r, min, max)); } @@ -100,7 +123,11 @@ library Random { return uint128(Uint256(r)); } - function Uint64(Randomness r, uint64 min, uint64 max) internal returns (uint64) { + function Uint64( + Randomness r, + uint64 min, + uint64 max + ) internal returns (uint64) { return uint64(Uint256(r, min, max)); } @@ -110,7 +137,11 @@ library Random { return uint64(Uint256(r)); } - function Uint32(Randomness r, uint32 min, uint32 max) internal returns (uint32) { + function Uint32( + Randomness r, + uint32 min, + uint32 max + ) internal returns (uint32) { return uint32(Uint256(r, min, max)); } diff --git a/test/utils/SignatureCompaction.sol b/test/utils/SignatureCompaction.sol index eac87690e..5c243c88b 100644 --- a/test/utils/SignatureCompaction.sol +++ b/test/utils/SignatureCompaction.sol @@ -8,7 +8,11 @@ library SignatureCompaction { bytes32 internal constant HALF_CURVE_ORDER = 0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0; - function ecrecoverPacked(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { + function ecrecoverPacked( + bytes32 hash, + bytes32 r, + bytes32 vs + ) internal pure returns (address) { (address recovered, ECDSA.RecoverError err) = ECDSA.tryRecover(hash, r, vs); require(err == ECDSA.RecoverError.NoError, "error in ecrecoverPacked"); return recovered; @@ -26,7 +30,10 @@ library SignatureCompaction { } //same as above, except doesn't take 'r' as argument since it is unneeded - function packVS(bytes32 s, uint8 v) internal pure returns (bytes32) { + function packVS( + bytes32 s, + uint8 v + ) internal pure returns (bytes32) { require(s <= HALF_CURVE_ORDER, "malleable signature, s too high"); //v parity is a single bit, encoded as either v = 27 or v = 28 -- in order to recover the bit we subtract 27 return bytes32(uint256(bytes32(uint256(v) - 27) << 255) | uint256(s));