From b1211b4bc0a127623a2d9170cd6b1db389425383 Mon Sep 17 00:00:00 2001 From: "clandestine.eth" <96172957+0xClandestine@users.noreply.github.com> Date: Thu, 24 Jul 2025 10:18:37 -0400 Subject: [PATCH 1/7] fix(I-06): remove many unused imports (#513) **Motivation:** Middleware contains tons of unused imports, which reduces code clarity. **Modifications:** - Used `forge lint src --only-lint unused-import` to remove all unused imports from `src`. **Result:** Improved clarity. --- script/utils/OperatorSetUpgradeLib.sol | 2 -- src/RegistryCoordinator.sol | 15 +-------------- src/RegistryCoordinatorStorage.sol | 11 +---------- src/ServiceManagerBase.sol | 11 ++--------- src/SlashingRegistryCoordinator.sol | 2 -- src/SlashingRegistryCoordinatorStorage.sol | 9 ++------- src/SocketRegistry.sol | 1 - src/StakeRegistryStorage.sol | 5 +---- src/interfaces/IECDSAStakeRegistry.sol | 8 ++------ src/interfaces/IRegistryCoordinator.sol | 6 ++---- src/interfaces/IServiceManager.sol | 10 ---------- src/interfaces/IServiceManagerUI.sol | 6 ++---- src/middlewareV2/registrar/AVSRegistrar.sol | 5 +---- src/middlewareV2/registrar/modules/Allowlist.sol | 1 - .../presets/AVSRegistrarAsIdentifier.sol | 2 -- .../registrar/presets/AVSRegistrarWithSocket.sol | 4 ---- src/slashers/InstantSlasher.sol | 1 - src/slashers/VetoableSlasher.sol | 1 - src/slashers/base/SlasherBase.sol | 2 -- .../BLSSigCheckOperatorStateRetriever.sol | 1 - src/unaudited/ECDSAServiceManagerBase.sol | 7 ++----- src/unaudited/ECDSAStakeRegistry.sol | 6 ++---- .../examples/ECDSAStakeRegistryEqualWeight.sol | 4 ---- .../examples/ECDSAStakeRegistryPermissioned.sol | 6 ++---- test/harnesses/RegistryCoordinatorHarness.t.sol | 12 ++++++++++-- 25 files changed, 30 insertions(+), 108 deletions(-) diff --git a/script/utils/OperatorSetUpgradeLib.sol b/script/utils/OperatorSetUpgradeLib.sol index 05db27342..adaf8a23c 100644 --- a/script/utils/OperatorSetUpgradeLib.sol +++ b/script/utils/OperatorSetUpgradeLib.sol @@ -2,8 +2,6 @@ pragma solidity ^0.8.0; // Deploy L2AVS proxy -import {TransparentUpgradeableProxy} 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"; diff --git a/src/RegistryCoordinator.sol b/src/RegistryCoordinator.sol index eca146d96..2bf5a5f45 100644 --- a/src/RegistryCoordinator.sol +++ b/src/RegistryCoordinator.sol @@ -1,28 +1,15 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol"; -import { - IAllocationManager, - OperatorSet -} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; -import {ISignatureUtilsMixin} from - "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; import {ISemVerMixin} from "eigenlayer-contracts/src/contracts/interfaces/ISemVerMixin.sol"; import {SemVerMixin} from "eigenlayer-contracts/src/contracts/mixins/SemVerMixin.sol"; -import {IBLSApkRegistry, IBLSApkRegistryTypes} from "./interfaces/IBLSApkRegistry.sol"; -import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol"; -import {IIndexRegistry} from "./interfaces/IIndexRegistry.sol"; -import {IServiceManager} from "./interfaces/IServiceManager.sol"; +import {IBLSApkRegistryTypes} from "./interfaces/IBLSApkRegistry.sol"; import { IRegistryCoordinator, IRegistryCoordinatorTypes } from "./interfaces/IRegistryCoordinator.sol"; -import {ISocketRegistry} from "./interfaces/ISocketRegistry.sol"; import {BitmapUtils} from "./libraries/BitmapUtils.sol"; import {SlashingRegistryCoordinator} from "./SlashingRegistryCoordinator.sol"; -import {ISlashingRegistryCoordinator} from "./interfaces/ISlashingRegistryCoordinator.sol"; -import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol"; import {RegistryCoordinatorStorage} from "./RegistryCoordinatorStorage.sol"; /** diff --git a/src/RegistryCoordinatorStorage.sol b/src/RegistryCoordinatorStorage.sol index e278d8787..8b1a55c70 100644 --- a/src/RegistryCoordinatorStorage.sol +++ b/src/RegistryCoordinatorStorage.sol @@ -1,17 +1,8 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol"; -import {IAllocationManager} from - "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; -import {IBLSApkRegistry, IBLSApkRegistryTypes} from "./interfaces/IBLSApkRegistry.sol"; -import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol"; -import {IIndexRegistry} from "./interfaces/IIndexRegistry.sol"; import {IServiceManager} from "./interfaces/IServiceManager.sol"; -import { - IRegistryCoordinator, IRegistryCoordinatorTypes -} from "./interfaces/IRegistryCoordinator.sol"; -import {ISocketRegistry} from "./interfaces/ISocketRegistry.sol"; +import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol"; abstract contract RegistryCoordinatorStorage is IRegistryCoordinator { /** diff --git a/src/ServiceManagerBase.sol b/src/ServiceManagerBase.sol index 37fdb0acb..086fa14cc 100644 --- a/src/ServiceManagerBase.sol +++ b/src/ServiceManagerBase.sol @@ -1,15 +1,11 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; -import { - ISignatureUtilsMixin, - 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 {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import {IRewardsCoordinator} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; import { @@ -18,9 +14,6 @@ import { } from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IPermissionController} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol"; -import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol"; -import {Pausable} from "eigenlayer-contracts/src/contracts/permissions/Pausable.sol"; -import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol"; import {ServiceManagerBaseStorage} from "./ServiceManagerBaseStorage.sol"; import {IServiceManager} from "./interfaces/IServiceManager.sol"; diff --git a/src/SlashingRegistryCoordinator.sol b/src/SlashingRegistryCoordinator.sol index 226a9ddc0..1b4ad47f7 100644 --- a/src/SlashingRegistryCoordinator.sol +++ b/src/SlashingRegistryCoordinator.sol @@ -8,10 +8,8 @@ import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; import { IAllocationManager, - OperatorSet, IAllocationManagerTypes } from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; -import {ISemVerMixin} from "eigenlayer-contracts/src/contracts/interfaces/ISemVerMixin.sol"; import {AllocationManager} from "eigenlayer-contracts/src/contracts/core/AllocationManager.sol"; import {SemVerMixin} from "eigenlayer-contracts/src/contracts/mixins/SemVerMixin.sol"; diff --git a/src/SlashingRegistryCoordinatorStorage.sol b/src/SlashingRegistryCoordinatorStorage.sol index 98b1f782f..f843aa18e 100644 --- a/src/SlashingRegistryCoordinatorStorage.sol +++ b/src/SlashingRegistryCoordinatorStorage.sol @@ -4,13 +4,8 @@ pragma solidity ^0.8.27; import {IBLSApkRegistry} from "./interfaces/IBLSApkRegistry.sol"; import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol"; import {IIndexRegistry} from "./interfaces/IIndexRegistry.sol"; -import {IServiceManager} from "./interfaces/IServiceManager.sol"; -import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; -import { - IAllocationManager, - OperatorSet, - IAllocationManagerTypes -} 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"; diff --git a/src/SocketRegistry.sol b/src/SocketRegistry.sol index 919ee5e59..2e7df776e 100644 --- a/src/SocketRegistry.sol +++ b/src/SocketRegistry.sol @@ -4,7 +4,6 @@ pragma solidity ^0.8.12; import {ISlashingRegistryCoordinator} from "./interfaces/ISlashingRegistryCoordinator.sol"; import {ISocketRegistry} from "./interfaces/ISocketRegistry.sol"; import {SocketRegistryStorage} from "./SocketRegistryStorage.sol"; -import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; /** * @title A `Registry` that keeps track of operator sockets (arbitrary strings). diff --git a/src/StakeRegistryStorage.sol b/src/StakeRegistryStorage.sol index 24700aee0..db9bfba34 100644 --- a/src/StakeRegistryStorage.sol +++ b/src/StakeRegistryStorage.sol @@ -6,10 +6,7 @@ import {IDelegationManager} from import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; import {IAllocationManager} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; -import { - IStrategyManager, - IStrategy -} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol"; +import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol"; import {ISlashingRegistryCoordinator} from "./interfaces/ISlashingRegistryCoordinator.sol"; import {IStakeRegistry, IStakeRegistryTypes} from "./interfaces/IStakeRegistry.sol"; diff --git a/src/interfaces/IECDSAStakeRegistry.sol b/src/interfaces/IECDSAStakeRegistry.sol index 256854822..bcf49e78d 100644 --- a/src/interfaces/IECDSAStakeRegistry.sol +++ b/src/interfaces/IECDSAStakeRegistry.sol @@ -4,12 +4,8 @@ pragma solidity ^0.8.27; import {IERC1271Upgradeable} from "@openzeppelin-upgrades/contracts/interfaces/IERC1271Upgradeable.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; -import { - ISignatureUtilsMixin, - 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"; // TODO: many of these errors do not have test coverage. diff --git a/src/interfaces/IRegistryCoordinator.sol b/src/interfaces/IRegistryCoordinator.sol index 7dae857b8..88cb29f92 100644 --- a/src/interfaces/IRegistryCoordinator.sol +++ b/src/interfaces/IRegistryCoordinator.sol @@ -7,10 +7,8 @@ import { ISlashingRegistryCoordinatorEvents, ISlashingRegistryCoordinatorTypes } from "./ISlashingRegistryCoordinator.sol"; -import { - ISignatureUtilsMixin, - 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"; diff --git a/src/interfaces/IServiceManager.sol b/src/interfaces/IServiceManager.sol index 7f30b750f..d123dcee6 100644 --- a/src/interfaces/IServiceManager.sol +++ b/src/interfaces/IServiceManager.sol @@ -4,16 +4,6 @@ pragma solidity >=0.5.0; import {IRewardsCoordinator} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; import {IServiceManagerUI} from "./IServiceManagerUI.sol"; -import { - ISignatureUtilsMixin, - ISignatureUtilsMixinTypes -} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; -import {IAllocationManagerTypes} 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 {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; interface IServiceManagerErrors { /// @notice Thrown when a function is called by an address that is not the RegistryCoordinator. diff --git a/src/interfaces/IServiceManagerUI.sol b/src/interfaces/IServiceManagerUI.sol index cf825f507..a0d937787 100644 --- a/src/interfaces/IServiceManagerUI.sol +++ b/src/interfaces/IServiceManagerUI.sol @@ -1,10 +1,8 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; -import { - ISignatureUtilsMixin, - 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/middlewareV2/registrar/AVSRegistrar.sol b/src/middlewareV2/registrar/AVSRegistrar.sol index 2d3c92bfa..cb77d9a5b 100644 --- a/src/middlewareV2/registrar/AVSRegistrar.sol +++ b/src/middlewareV2/registrar/AVSRegistrar.sol @@ -9,10 +9,7 @@ import { OperatorSetLib, OperatorSet } from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; -import { - IKeyRegistrarTypes, - IKeyRegistrar -} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; +import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; import {AVSRegistrarStorage} from "./AVSRegistrarStorage.sol"; diff --git a/src/middlewareV2/registrar/modules/Allowlist.sol b/src/middlewareV2/registrar/modules/Allowlist.sol index 6dd6f2eff..4d11db527 100644 --- a/src/middlewareV2/registrar/modules/Allowlist.sol +++ b/src/middlewareV2/registrar/modules/Allowlist.sol @@ -9,7 +9,6 @@ import {OwnableUpgradeable} from import {EnumerableSetUpgradeable} from "openzeppelin-contracts-upgradeable/contracts/utils/structs/EnumerableSetUpgradeable.sol"; -import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol"; import { OperatorSet, OperatorSetLib diff --git a/src/middlewareV2/registrar/presets/AVSRegistrarAsIdentifier.sol b/src/middlewareV2/registrar/presets/AVSRegistrarAsIdentifier.sol index f4aa17b28..aa72353d2 100644 --- a/src/middlewareV2/registrar/presets/AVSRegistrarAsIdentifier.sol +++ b/src/middlewareV2/registrar/presets/AVSRegistrarAsIdentifier.sol @@ -11,8 +11,6 @@ import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyR import {AVSRegistrar} from "../AVSRegistrar.sol"; -import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol"; - /// @notice An AVSRegistrar that is the identifier for the AVS in EigenLayer core. /// @dev Once deployed, the `admin` will control other parameters of the AVS, such as creating operatorSets, slashing, etc. contract AVSRegistrarAsIdentifier is AVSRegistrar { diff --git a/src/middlewareV2/registrar/presets/AVSRegistrarWithSocket.sol b/src/middlewareV2/registrar/presets/AVSRegistrarWithSocket.sol index 53f077f79..14315a467 100644 --- a/src/middlewareV2/registrar/presets/AVSRegistrarWithSocket.sol +++ b/src/middlewareV2/registrar/presets/AVSRegistrarWithSocket.sol @@ -8,10 +8,6 @@ import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyR import {IAVSRegistrarWithSocket} from "../../../interfaces/IAVSRegistrarWithSocket.sol"; import {AVSRegistrar} from "../AVSRegistrar.sol"; import {SocketRegistry} from "../modules/SocketRegistry.sol"; -import { - OperatorSetLib, - OperatorSet -} from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; contract AVSRegistrarWithSocket is AVSRegistrar, SocketRegistry, IAVSRegistrarWithSocket { constructor( diff --git a/src/slashers/InstantSlasher.sol b/src/slashers/InstantSlasher.sol index fd4210f1f..c575e3606 100644 --- a/src/slashers/InstantSlasher.sol +++ b/src/slashers/InstantSlasher.sol @@ -1,7 +1,6 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import {IAllocationManager} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol"; diff --git a/src/slashers/VetoableSlasher.sol b/src/slashers/VetoableSlasher.sol index 18dcd5a83..ac64af7fd 100644 --- a/src/slashers/VetoableSlasher.sol +++ b/src/slashers/VetoableSlasher.sol @@ -1,7 +1,6 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import { IAllocationManager, OperatorSet diff --git a/src/slashers/base/SlasherBase.sol b/src/slashers/base/SlasherBase.sol index ccf85ec26..a9cac33d7 100644 --- a/src/slashers/base/SlasherBase.sol +++ b/src/slashers/base/SlasherBase.sol @@ -4,11 +4,9 @@ pragma solidity ^0.8.27; import {SlasherStorage, ISlashingRegistryCoordinator} from "./SlasherStorage.sol"; import { OperatorSet, - IAllocationManagerTypes, IAllocationManager } from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol"; -import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; /// @title SlasherBase /// @notice Base contract for implementing slashing functionality in EigenLayer middleware diff --git a/src/unaudited/BLSSigCheckOperatorStateRetriever.sol b/src/unaudited/BLSSigCheckOperatorStateRetriever.sol index 9333ff47a..118030f71 100644 --- a/src/unaudited/BLSSigCheckOperatorStateRetriever.sol +++ b/src/unaudited/BLSSigCheckOperatorStateRetriever.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.27; import {IBLSApkRegistry} from "../interfaces/IBLSApkRegistry.sol"; import {IBLSSignatureCheckerTypes} from "../interfaces/IBLSSignatureChecker.sol"; -import {IStakeRegistry} from "../interfaces/IStakeRegistry.sol"; import {IIndexRegistry} from "../interfaces/IIndexRegistry.sol"; import {ISlashingRegistryCoordinator} from "../interfaces/ISlashingRegistryCoordinator.sol"; import {BitmapUtils} from "../libraries/BitmapUtils.sol"; diff --git a/src/unaudited/ECDSAServiceManagerBase.sol b/src/unaudited/ECDSAServiceManagerBase.sol index 51fdf3467..191ca49a4 100644 --- a/src/unaudited/ECDSAServiceManagerBase.sol +++ b/src/unaudited/ECDSAServiceManagerBase.sol @@ -4,17 +4,14 @@ 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 { - ISignatureUtilsMixin, - 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 {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; -import {IStakeRegistry} from "../interfaces/IStakeRegistry.sol"; import {IRewardsCoordinator} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; import {IECDSAStakeRegistryTypes} from "../interfaces/IECDSAStakeRegistry.sol"; diff --git a/src/unaudited/ECDSAStakeRegistry.sol b/src/unaudited/ECDSAStakeRegistry.sol index cc8822613..884d7586a 100644 --- a/src/unaudited/ECDSAStakeRegistry.sol +++ b/src/unaudited/ECDSAStakeRegistry.sol @@ -9,10 +9,8 @@ import { import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import {IDelegationManager} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; -import { - ISignatureUtilsMixin, - ISignatureUtilsMixinTypes -} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.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"; diff --git a/src/unaudited/examples/ECDSAStakeRegistryEqualWeight.sol b/src/unaudited/examples/ECDSAStakeRegistryEqualWeight.sol index f3b0a6728..eafb32258 100644 --- a/src/unaudited/examples/ECDSAStakeRegistryEqualWeight.sol +++ b/src/unaudited/examples/ECDSAStakeRegistryEqualWeight.sol @@ -1,10 +1,6 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; -import { - ISignatureUtilsMixin, - ISignatureUtilsMixinTypes -} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; import {ECDSAStakeRegistryPermissioned} from "./ECDSAStakeRegistryPermissioned.sol"; import {IDelegationManager} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; diff --git a/src/unaudited/examples/ECDSAStakeRegistryPermissioned.sol b/src/unaudited/examples/ECDSAStakeRegistryPermissioned.sol index e7f55e633..219786ad9 100644 --- a/src/unaudited/examples/ECDSAStakeRegistryPermissioned.sol +++ b/src/unaudited/examples/ECDSAStakeRegistryPermissioned.sol @@ -1,10 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; -import { - ISignatureUtilsMixin, - 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"; diff --git a/test/harnesses/RegistryCoordinatorHarness.t.sol b/test/harnesses/RegistryCoordinatorHarness.t.sol index 4aa1dfa91..f580f0430 100644 --- a/test/harnesses/RegistryCoordinatorHarness.t.sol +++ b/test/harnesses/RegistryCoordinatorHarness.t.sol @@ -1,10 +1,18 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import "../../src/RegistryCoordinator.sol"; -import {ISocketRegistry} from "../../src/interfaces/ISocketRegistry.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"; + +import {IBLSApkRegistry, IBLSApkRegistryTypes} from "../../src/interfaces/IBLSApkRegistry.sol"; +import {IStakeRegistry} from "../../src/interfaces/IStakeRegistry.sol"; +import {IIndexRegistry} from "../../src/interfaces/IIndexRegistry.sol"; +import {IServiceManager} from "../../src/interfaces/IServiceManager.sol"; +import {ISocketRegistry} from "../../src/interfaces/ISocketRegistry.sol"; import {IRegistryCoordinatorTypes} from "../../src/interfaces/IRegistryCoordinator.sol"; +import "../../src/RegistryCoordinator.sol"; import "forge-std/Test.sol"; From 305e4e0954fbdc7bc2a5ce0ef3eb54b4fb019284 Mon Sep 17 00:00:00 2001 From: "clandestine.eth" <96172957+0xClandestine@users.noreply.github.com> Date: Thu, 24 Jul 2025 10:37:23 -0400 Subject: [PATCH 2/7] fix(I-03): rename `ISocketRegistry` -> `ISocketRegistryV2` (#511) **Motivation:** We now have two `ISocketRegistry` interfaces, and need to differentiate for clarity. **Modifications:** - Renamed **new** `ISocketRegistry` -> `ISocketRegistryV2` **Result:** Improved clarity. --- src/interfaces/IAVSRegistrarWithSocket.sol | 4 ++-- src/interfaces/ISocketRegistryV2.sol | 2 +- src/middlewareV2/registrar/modules/SocketRegistry.sol | 6 +++--- .../registrar/modules/SocketRegistryStorage.sol | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/interfaces/IAVSRegistrarWithSocket.sol b/src/interfaces/IAVSRegistrarWithSocket.sol index 7829a6397..39310ca9d 100644 --- a/src/interfaces/IAVSRegistrarWithSocket.sol +++ b/src/interfaces/IAVSRegistrarWithSocket.sol @@ -2,6 +2,6 @@ pragma solidity ^0.8.27; import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; -import {ISocketRegistry} from "./ISocketRegistryV2.sol"; +import {ISocketRegistryV2} from "./ISocketRegistryV2.sol"; -interface IAVSRegistrarWithSocket is IAVSRegistrar, ISocketRegistry {} +interface IAVSRegistrarWithSocket is IAVSRegistrar, ISocketRegistryV2 {} diff --git a/src/interfaces/ISocketRegistryV2.sol b/src/interfaces/ISocketRegistryV2.sol index 73b9256d7..a5014c9f6 100644 --- a/src/interfaces/ISocketRegistryV2.sol +++ b/src/interfaces/ISocketRegistryV2.sol @@ -14,7 +14,7 @@ interface ISocketRegistryEvents { event OperatorSocketSet(address indexed operator, string socket); } -interface ISocketRegistry is ISocketRegistryErrors, ISocketRegistryEvents { +interface ISocketRegistryV2 is ISocketRegistryErrors, ISocketRegistryEvents { /** * @notice Gets the socket for an operator. * @param operator The operator to get the socket for. diff --git a/src/middlewareV2/registrar/modules/SocketRegistry.sol b/src/middlewareV2/registrar/modules/SocketRegistry.sol index f255dbe96..19b47e46c 100644 --- a/src/middlewareV2/registrar/modules/SocketRegistry.sol +++ b/src/middlewareV2/registrar/modules/SocketRegistry.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; -import {ISocketRegistry} from "../../../interfaces/ISocketRegistryV2.sol"; +import {ISocketRegistryV2} from "../../../interfaces/ISocketRegistryV2.sol"; import {SocketRegistryStorage} from "./SocketRegistryStorage.sol"; import { OperatorSetLib, @@ -13,14 +13,14 @@ import { abstract contract SocketRegistry is SocketRegistryStorage { using OperatorSetLib for OperatorSet; - /// @inheritdoc ISocketRegistry + /// @inheritdoc ISocketRegistryV2 function getOperatorSocket( address operator ) external view returns (string memory) { return _operatorToSocket[operator]; } - /// @inheritdoc ISocketRegistry + /// @inheritdoc ISocketRegistryV2 function updateSocket(address operator, string memory socket) external { require(msg.sender == operator, CallerNotOperator()); _setOperatorSocket(operator, socket); diff --git a/src/middlewareV2/registrar/modules/SocketRegistryStorage.sol b/src/middlewareV2/registrar/modules/SocketRegistryStorage.sol index 5363fb6a3..8344fb967 100644 --- a/src/middlewareV2/registrar/modules/SocketRegistryStorage.sol +++ b/src/middlewareV2/registrar/modules/SocketRegistryStorage.sol @@ -1,13 +1,13 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.12; -import {ISocketRegistry} from "../../../interfaces/ISocketRegistryV2.sol"; +import {ISocketRegistryV2} from "../../../interfaces/ISocketRegistryV2.sol"; /** * @title Storage variables for the `SocketRegistry` contract. * @author Layr Labs, Inc. */ -abstract contract SocketRegistryStorage is ISocketRegistry { +abstract contract SocketRegistryStorage is ISocketRegistryV2 { /** * * STATE From 1057a8bea744cfb88ca99232dc31a9d41476fdbb Mon Sep 17 00:00:00 2001 From: Yash Patil <40046473+ypatil12@users.noreply.github.com> Date: Mon, 28 Jul 2025 10:56:15 -0400 Subject: [PATCH 3/7] fix(I-07): clarify expectation on `weights` array structure (#510) **Motivation:** If the `weights` array has a different length or stake composition, cert verification would silently fail. There is no way to enforce this for BN254. To opt for similar behavior, we clarify this in our natspec. **Modifications:** Update natspec/docs on risks of different array lengths. **Result:** Clearer code --------- Co-authored-by: Nadir Akhtar --- docs/middlewareV2/OperatorTableCalculator.md | 73 ++++++++++++------- .../BN254TableCalculatorBase.sol | 5 ++ .../ECDSATableCalculatorBase.sol | 4 + 3 files changed, 57 insertions(+), 25 deletions(-) diff --git a/docs/middlewareV2/OperatorTableCalculator.md b/docs/middlewareV2/OperatorTableCalculator.md index 88146d832..1b45b6867 100644 --- a/docs/middlewareV2/OperatorTableCalculator.md +++ b/docs/middlewareV2/OperatorTableCalculator.md @@ -48,13 +48,16 @@ The `ECDSATableCalculatorBase` provides base functionality for calculating ECDSA ```solidity /** - * @notice A struct that contains information about a single operator + * @notice A struct that contains information about a single operator for an ECDSA signing key * @param pubkey The address of the signing ECDSA key of the operator and not the operator address itself. - * This is read from the KeyRegistrar contract. * @param weights The weights of the operator for a single operatorSet - * @dev The `weights` array can be defined as a list of arbitrary groupings. For example, - * it can be [slashable_stake, delegated_stake, strategy_i_stake, ...] - * @dev The `weights` array should be the same length for each operator in the operatorSet. + * + * @dev The `weights` array can be defined as a list of arbitrary stake types. For example, + * it can be [slashable_stake, delegated_stake, strategy_i_stake, ...]. Each stake type is an index in the array + * + * @dev It is up to the AVS to define the `weights` array, which is used by the `IECDSACertificateVerifier` to verify Certificates + * + * @dev For each operator, the `weights` array should be the same length and composition, otherwise verification issues can arise */ struct ECDSAOperatorInfo { address pubkey; @@ -88,9 +91,10 @@ Calculates and returns an array of `ECDSAOperatorInfo` structs containing public ```solidity /** - * @notice Calculates the operator table bytes for a given operatorSet - * @param operatorSet The operatorSet to calculate the operator table for - * @return operatorTableBytes The encoded operator table bytes + * @notice Calculates the operator table, in bytes, for a given operatorSet + * @param operatorSet the operatorSet to calculate the operator table for + * @return operatorTableBytes the operatorTableBytes for the given operatorSet + * @dev The `operatorTableBytes` is used by the offchain multichain protocol to calculate and merkleize the operator table */ function calculateOperatorTableBytes( OperatorSet calldata operatorSet @@ -111,14 +115,21 @@ Returns the ABI-encoded bytes representation of the operator table, which is use * @notice Abstract function to get the operator weights for a given operatorSet * @param operatorSet The operatorSet to get the weights for * @return operators The addresses of the operators in the operatorSet - * @return weights The weights for each operator in the operatorSet + * @return weights The weights for each operator in the operatorSet, this is a 2D array where the first index is the operator + * and the second index is the type of weight + * @dev Each single `weights` array is as a list of arbitrary stake types. For example, + * it can be [slashable_stake, delegated_stake, strategy_i_stake, ...]. Each stake type is an index in the array + * @dev Must be implemented by derived contracts to define specific weight calculation logic + * @dev The certificate verification assumes the composition weights array for each operator is the same. + * If the length of the array is different or the stake types are different, then verification issues can arise, including + * verification failing silently for multiple operators with different weights structures */ function _getOperatorWeights( OperatorSet calldata operatorSet ) internal view virtual returns (address[] memory operators, uint256[][] memory weights); ``` -Must be implemented by derived contracts to define the weight calculation strategy. See [stakeWeighting](#stake-weighting) for more information. +Must be implemented by derived contracts to define the weight calculation strategy. See [stakeWeighting](#stake-weighting) for more information. **When implementing this function, AVSs must ensure that all operators have an identical weights structure and length types. Failure to do so can result in certificates being verified with silent failures.** An example integration is in [`ECDSATableCalculator`](../../src/middlewareV2/tableCalculator/ECDSATableCalculator.sol) @@ -134,11 +145,16 @@ The `BN254TableCalculatorBase` provides base functionality for calculating BN254 ```solidity /** - * @notice A struct that contains information about a single operator - * @param pubkey The G1 public key of the operator. - * @param weights The weights of the operator for a single operatorSet. - * @dev The `weights` array can be defined as a list of arbitrary groupings. For example, - * it can be [slashable_stake, delegated_stake, strategy_i_stake, ...] + * @notice A struct that contains information about a single operator for a given BN254 operatorSet + * @param pubkey The G1 public key of the operator + * @param weights The weights of the operator for a single operatorSet + * + * @dev The `weights` array is as a list of arbitrary stake types. For example, + * it can be [slashable_stake, delegated_stake, strategy_i_stake, ...]. Each stake type is an index in the array + * + * @dev It is up to the AVS to define the `weights` array, which is used by the `IBN254CertificateVerifier` to verify Certificates + * + * @dev For each operator, the `weights` array should be the same length and composition, otherwise verification issues can arise */ struct BN254OperatorInfo { BN254.G1Point pubkey; @@ -146,18 +162,18 @@ struct BN254OperatorInfo { } /** - * @notice A struct that contains information about all operators for a given operatorSet - * @param operatorInfoTreeRoot The root of the operatorInfo tree. Each leaf is a `BN254OperatorInfo` struct - * @param numOperators The number of operators in the operatorSet. - * @param aggregatePubkey The aggregate G1 public key of the operators in the operatorSet. - * @param totalWeights The total weights of the operators in the operatorSet. + * @notice A struct that contains information about all operators for a given BN254operatorSet + * @param operatorInfoTreeRoot The root of the operatorInfo tree + * @param numOperators The number of operators in the operatorSet + * @param aggregatePubkey The aggregate G1 public key of the operators in the operatorSet + * @param totalWeights The total stake weights of the operators in the operatorSet * * @dev The operatorInfoTreeRoot is the root of a merkle tree that contains the operatorInfos for each operator in the operatorSet. - * It is calculated in this function and used by the `IBN254CertificateVerifier` to verify stakes against the non-signing operators + * It is calculated on-chain by the `BN254TableCalculator` and used by the `IBN254CertificateVerifier` to verify stakes against the non-signing operators * - * @dev Retrieval of the `aggregatePubKey` depends on maintaining a key registry contract, see `BN254TableCalculatorBase` for an example implementation. + * @dev Retrieval of the `aggregatePubKey` depends on maintaining a key registry contract, see `KeyRegistrar` for an example implementation * - * @dev The `totalWeights` array should be the same length as each individual `weights` array in `operatorInfos`. + * @dev The `totalWeights` array should be the same length and composition as each individual `weights` array in `BN254OperatorInfo` */ struct BN254OperatorSetInfo { bytes32 operatorInfoTreeRoot; @@ -243,13 +259,20 @@ Returns an array of `BN254OperatorInfo` structs for all operators in the operato * @notice Abstract function to get the operator weights for a given operatorSet * @param operatorSet The operatorSet to get the weights for * @return operators The addresses of the operators in the operatorSet - * @return weights The weights for each operator in the operatorSet + * @return weights The weights for each operator in the operatorSet, this is a 2D array where the first index is the operator + * and the second index is the type of weight + * @dev Each single `weights` array is as a list of arbitrary stake types. For example, + * it can be [slashable_stake, delegated_stake, strategy_i_stake, ...]. Each stake type is an index in the array + * @dev Must be implemented by derived contracts to define specific weight calculation logic + * @dev The certificate verification assumes the composition weights array for each operator is the same. + * If the length of the array is different or the stake types are different, then verification issues can arise, including + * verification failing silently for multiple operators with different weights structures */ function _getOperatorWeights( OperatorSet calldata operatorSet ) internal view virtual returns (address[] memory operators, uint256[][] memory weights); ``` -Must be implemented by derived contracts to define the weight calculation strategy. Similar to ECDSA, weights are a 2D array supporting multiple weight types per operator. +Must be implemented by derived contracts to define the weight calculation strategy. Similar to ECDSA, weights are a 2D array supporting multiple weight types per operator. When implementing this function, AVSs must ensure that all operators have an identical weights structure and length types. Failure to do so can result in certificates being verified with silent failures. An example integration is defined in [`BN254TableCalculator`](../../src/middlewareV2/tableCalculator/BN254TableCalculator.sol). diff --git a/src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol b/src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol index 3eaf143e6..13c2d0d65 100644 --- a/src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol +++ b/src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol @@ -95,7 +95,12 @@ abstract contract BN254TableCalculatorBase is IBN254TableCalculator { * @return operators The addresses of the operators in the operatorSet * @return weights The weights for each operator in the operatorSet, this is a 2D array where the first index is the operator * and the second index is the type of weight + * @dev Each single `weights` array is as a list of arbitrary stake types. For example, + * it can be [slashable_stake, delegated_stake, strategy_i_stake, ...]. Each stake type is an index in the array * @dev Must be implemented by derived contracts to define specific weight calculation logic + * @dev The certificate verification assumes the composition weights array for each operator is the same. + * If the length of the array is different or the stake types are different, then verification issues can arise, including + * verification failing silently for multiple operators with different weights structures */ function _getOperatorWeights( OperatorSet calldata operatorSet diff --git a/src/middlewareV2/tableCalculator/ECDSATableCalculatorBase.sol b/src/middlewareV2/tableCalculator/ECDSATableCalculatorBase.sol index 422415597..7d365bbf4 100644 --- a/src/middlewareV2/tableCalculator/ECDSATableCalculatorBase.sol +++ b/src/middlewareV2/tableCalculator/ECDSATableCalculatorBase.sol @@ -71,7 +71,11 @@ abstract contract ECDSATableCalculatorBase is IECDSATableCalculator { * @return operators The addresses of the operators in the operatorSet * @return weights The weights for each operator in the operatorSet, this is a 2D array where the first index is the operator * and the second index is the type of weight + * @dev Each single `weights` array is as a list of arbitrary stake types. For example, + * it can be [slashable_stake, delegated_stake, strategy_i_stake, ...]. Each stake type is an index in the array * @dev Must be implemented by derived contracts to define specific weight calculation logic + * @dev The certificate verification assumes the composition weights array for each operator is the same. + * If the length of the array is different or the stake types are different, then verification issues can arise */ function _getOperatorWeights( OperatorSet calldata operatorSet From 8be71541b6d1d6d824c21d957485a4b1730e54f8 Mon Sep 17 00:00:00 2001 From: Yash Patil <40046473+ypatil12@users.noreply.github.com> Date: Mon, 28 Jul 2025 14:01:13 -0400 Subject: [PATCH 4/7] fix(I5): natspec (#516) **Motivation:** Update incorrect natspec **Modifications:** - Clarify `KeyRegistrar` usage - Clarify `calculateOperatorTable` usage **Result:** Clearer natspec --- src/interfaces/IBN254TableCalculator.sol | 2 +- src/interfaces/IECDSATableCalculator.sol | 2 +- src/middlewareV2/registrar/AVSRegistrar.sol | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/interfaces/IBN254TableCalculator.sol b/src/interfaces/IBN254TableCalculator.sol index 2ee9ec252..5383bdaf2 100644 --- a/src/interfaces/IBN254TableCalculator.sol +++ b/src/interfaces/IBN254TableCalculator.sol @@ -12,7 +12,7 @@ interface IBN254TableCalculator is IOperatorTableCalculator, IOperatorTableCalcu * @notice calculates the operatorInfos for a given operatorSet * @param operatorSet the operatorSet to calculate the operator table for * @return operatorSetInfo the operatorSetInfo for the given operatorSet - * @dev The output of this function is converted to bytes via the `calculateOperatorTableBytes` function + * @dev The output of this function is used by the multichain protocol to transport operator stake weights to destination chains */ function calculateOperatorTable( OperatorSet calldata operatorSet diff --git a/src/interfaces/IECDSATableCalculator.sol b/src/interfaces/IECDSATableCalculator.sol index 158d02805..d7f843cf4 100644 --- a/src/interfaces/IECDSATableCalculator.sol +++ b/src/interfaces/IECDSATableCalculator.sol @@ -12,7 +12,7 @@ interface IECDSATableCalculator is IOperatorTableCalculator, IOperatorTableCalcu * @notice calculates the operatorInfos for a given operatorSet * @param operatorSet the operatorSet to calculate the operator table for * @return operatorInfos the list of operatorInfos for the given operatorSet - * @dev The output of this function is converted to bytes via the `calculateOperatorTableBytes` function + * @dev The output of this function is used by the multichain protocol to transport operator stake weights to destination chains */ function calculateOperatorTable( OperatorSet calldata operatorSet diff --git a/src/middlewareV2/registrar/AVSRegistrar.sol b/src/middlewareV2/registrar/AVSRegistrar.sol index cb77d9a5b..db1014ac7 100644 --- a/src/middlewareV2/registrar/AVSRegistrar.sol +++ b/src/middlewareV2/registrar/AVSRegistrar.sol @@ -41,7 +41,7 @@ contract AVSRegistrar is Initializable, AVSRegistrarStorage { ) external virtual onlyAllocationManager { _beforeRegisterOperator(operator, operatorSetIds, data); - // Check that the operator has a valid key and update key if needed + // Check that the operator has a valid key _validateOperatorKeys(operator, operatorSetIds); _afterRegisterOperator(operator, operatorSetIds, data); @@ -81,10 +81,9 @@ contract AVSRegistrar is Initializable, AVSRegistrarStorage { */ /** - * @notice Validates that the operator has registered a key for the given operator sets + * @notice Validates that the operator has registered a key for the given operator sets in the `KeyRegistrar` * @param operator The operator to validate * @param operatorSetIds The operator sets to validate - * @dev This function assumes the operator has already registered a key in the Key Registrar */ function _validateOperatorKeys( address operator, From fc061e147936bf4c0fe3706d92c2271ee2e2c90b Mon Sep 17 00:00:00 2001 From: "clandestine.eth" <96172957+0xClandestine@users.noreply.github.com> Date: Mon, 28 Jul 2025 17:10:55 -0400 Subject: [PATCH 5/7] fix(I-04): make avs var stateful (#512) **Motivation:** The following natspec is present but isn't true and suggest improper use. ```solidity /// @dev The immutable avs address `AVSRegistrar` is NOT the address of the AVS in EigenLayer core. /// @dev The address of the AVS in EigenLayer core is the proxy contract, and it is set via the `initialize` function below. ``` **Modifications:** - Removed confusing comments - Made AVS var stateful and `AVSRegistrar` abstract **Result:** Improved clarity. --- src/interfaces/IAVSRegistrarInternal.sol | 5 +- src/middlewareV2/registrar/AVSRegistrar.sol | 17 ++-- .../registrar/AVSRegistrarStorage.sol | 13 ++- .../registrar/modules/Allowlist.sol | 8 +- .../presets/AVSRegistrarAsIdentifier.sol | 23 ++---- .../presets/AVSRegistrarWithAllowlist.sol | 13 +-- .../presets/AVSRegistrarWithSocket.sol | 9 ++- .../AVSRegistrarAllowlistUnit.t.sol | 12 +-- .../AVSRegistrarAsIdentifierUnit.t.sol | 81 +++++-------------- test/unit/middlewareV2/AVSRegistrarBase.t.sol | 15 ++++ .../middlewareV2/AVSRegistrarSocketUnit.t.sol | 12 +-- test/unit/middlewareV2/AVSRegistrarUnit.t.sol | 18 ++--- test/unit/middlewareV2/AllowlistUnit.t.sol | 12 ++- 13 files changed, 93 insertions(+), 145 deletions(-) diff --git a/src/interfaces/IAVSRegistrarInternal.sol b/src/interfaces/IAVSRegistrarInternal.sol index d5c6740b0..f3e2cf6f3 100644 --- a/src/interfaces/IAVSRegistrarInternal.sol +++ b/src/interfaces/IAVSRegistrarInternal.sol @@ -17,7 +17,4 @@ interface IAVSRegistrarEvents { } /// @notice Since we have already defined a public interface, we add the events and errors here -interface IAVSRegistrarInternal is IAVSRegistrarErrors, IAVSRegistrarEvents { - /// @notice Returns the address of the AVS in EigenLayer core - function getAVS() external view returns (address); -} +interface IAVSRegistrarInternal is IAVSRegistrarErrors, IAVSRegistrarEvents {} diff --git a/src/middlewareV2/registrar/AVSRegistrar.sol b/src/middlewareV2/registrar/AVSRegistrar.sol index db1014ac7..f650c21a4 100644 --- a/src/middlewareV2/registrar/AVSRegistrar.sol +++ b/src/middlewareV2/registrar/AVSRegistrar.sol @@ -16,7 +16,7 @@ import {AVSRegistrarStorage} from "./AVSRegistrarStorage.sol"; import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol"; /// @notice A minimal AVSRegistrar contract that is used to register/deregister operators for an AVS -contract AVSRegistrar is Initializable, AVSRegistrarStorage { +abstract contract AVSRegistrar is Initializable, AVSRegistrarStorage { using OperatorSetLib for OperatorSet; modifier onlyAllocationManager() { @@ -25,13 +25,19 @@ contract AVSRegistrar is Initializable, AVSRegistrarStorage { } constructor( - address _avs, IAllocationManager _allocationManager, IKeyRegistrar _keyRegistrar - ) AVSRegistrarStorage(_avs, _allocationManager, _keyRegistrar) { + ) AVSRegistrarStorage(_allocationManager, _keyRegistrar) { _disableInitializers(); } + /// @dev This initialization function MUST be added to a child's `initialize` function to avoid uninitialized storage. + function __AVSRegistrar_init( + address _avs + ) internal virtual { + avs = _avs; + } + /// @inheritdoc IAVSRegistrar function registerOperator( address operator, @@ -69,11 +75,6 @@ contract AVSRegistrar is Initializable, AVSRegistrarStorage { return _avs == avs; } - /// @inheritdoc IAVSRegistrarInternal - function getAVS() external view virtual returns (address) { - return avs; - } - /* * * INTERNAL FUNCTIONS diff --git a/src/middlewareV2/registrar/AVSRegistrarStorage.sol b/src/middlewareV2/registrar/AVSRegistrarStorage.sol index 185121615..f893d1fe9 100644 --- a/src/middlewareV2/registrar/AVSRegistrarStorage.sol +++ b/src/middlewareV2/registrar/AVSRegistrarStorage.sol @@ -15,18 +15,17 @@ abstract contract AVSRegistrarStorage is IAVSRegistrar, IAVSRegistrarInternal { * */ - /// @notice The AVS that this registrar is for - /// @dev In practice, the AVS address in EigenLayer core is address that initialized the Metadata URI. - address internal immutable avs; - /// @notice The allocation manager in EigenLayer core IAllocationManager public immutable allocationManager; /// @notice Pointer to the EigenLayer core Key Registrar IKeyRegistrar public immutable keyRegistrar; - constructor(address _avs, IAllocationManager _allocationManager, IKeyRegistrar _keyRegistrar) { - avs = _avs; + /// @notice The AVS that this registrar is for + /// @dev In practice, the AVS address in EigenLayer core is address that initialized the Metadata URI. + address public avs; + + constructor(IAllocationManager _allocationManager, IKeyRegistrar _keyRegistrar) { allocationManager = _allocationManager; keyRegistrar = _keyRegistrar; } @@ -36,5 +35,5 @@ abstract contract AVSRegistrarStorage is IAVSRegistrar, IAVSRegistrarInternal { * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ - uint256[50] private __GAP; + uint256[49] private __GAP; } diff --git a/src/middlewareV2/registrar/modules/Allowlist.sol b/src/middlewareV2/registrar/modules/Allowlist.sol index 4d11db527..7d44df7f4 100644 --- a/src/middlewareV2/registrar/modules/Allowlist.sol +++ b/src/middlewareV2/registrar/modules/Allowlist.sol @@ -18,13 +18,7 @@ abstract contract Allowlist is OwnableUpgradeable, AllowlistStorage { using OperatorSetLib for OperatorSet; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; - function initialize( - address _owner - ) public virtual initializer { - _initializeAllowlist(_owner); - } - - function _initializeAllowlist( + function __Allowlist_init( address _owner ) internal onlyInitializing { __Ownable_init(); diff --git a/src/middlewareV2/registrar/presets/AVSRegistrarAsIdentifier.sol b/src/middlewareV2/registrar/presets/AVSRegistrarAsIdentifier.sol index aa72353d2..cc926b4b5 100644 --- a/src/middlewareV2/registrar/presets/AVSRegistrarAsIdentifier.sol +++ b/src/middlewareV2/registrar/presets/AVSRegistrarAsIdentifier.sol @@ -1,14 +1,16 @@ // SPDX-License-Identifier: BUSL-1.1 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 {IAVSRegistrarInternal} from "../../../interfaces/IAVSRegistrarInternal.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"; import {AVSRegistrar} from "../AVSRegistrar.sol"; /// @notice An AVSRegistrar that is the identifier for the AVS in EigenLayer core. @@ -17,14 +19,11 @@ contract AVSRegistrarAsIdentifier is AVSRegistrar { /// @notice The permission controller for the AVS IPermissionController public immutable permissionController; - /// @dev The immutable avs address `AVSRegistrar` is NOT the address of the AVS in EigenLayer core. - /// @dev The address of the AVS in EigenLayer core is the proxy contract, and it is set via the `initialize` function below. constructor( - address _avs, IAllocationManager _allocationManager, IPermissionController _permissionController, IKeyRegistrar _keyRegistrar - ) AVSRegistrar(_avs, _allocationManager, _keyRegistrar) { + ) AVSRegistrar(_allocationManager, _keyRegistrar) { // Set the permission controller for future interactions permissionController = _permissionController; } @@ -36,6 +35,8 @@ contract AVSRegistrarAsIdentifier is AVSRegistrar { * @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 { + __AVSRegistrar_init(address(this)); + // Set the metadataURI and the registrar for the AVS to this registrar contract allocationManager.updateAVSMetadataURI(address(this), metadataURI); allocationManager.setAVSRegistrar(address(this), this); @@ -43,16 +44,4 @@ contract AVSRegistrarAsIdentifier is AVSRegistrar { // Set the admin for the AVS permissionController.addPendingAdmin(address(this), admin); } - - /// @inheritdoc IAVSRegistrar - function supportsAVS( - address _avs - ) public view override returns (bool) { - return _avs == address(this); - } - - /// @inheritdoc IAVSRegistrarInternal - function getAVS() external view override returns (address) { - return address(this); - } } diff --git a/src/middlewareV2/registrar/presets/AVSRegistrarWithAllowlist.sol b/src/middlewareV2/registrar/presets/AVSRegistrarWithAllowlist.sol index 470b7b340..8e85f9dd8 100644 --- a/src/middlewareV2/registrar/presets/AVSRegistrarWithAllowlist.sol +++ b/src/middlewareV2/registrar/presets/AVSRegistrarWithAllowlist.sol @@ -12,15 +12,16 @@ import {OperatorSet} from "eigenlayer-contracts/src/contracts/libraries/Operator contract AVSRegistrarWithAllowlist is AVSRegistrar, Allowlist, IAVSRegistrarWithAllowlist { constructor( - address _avs, IAllocationManager _allocationManager, IKeyRegistrar _keyRegistrar - ) AVSRegistrar(_avs, _allocationManager, _keyRegistrar) {} + ) AVSRegistrar(_allocationManager, _keyRegistrar) {} - function initialize( - address admin - ) public override initializer { - _initializeAllowlist(admin); + function initialize(address avs, address admin) external initializer { + // Initialize the AVSRegistrar + __AVSRegistrar_init(avs); + + // Initialize the allowlist + __Allowlist_init(admin); } /// @notice Before registering operator, check if the operator is in the allowlist diff --git a/src/middlewareV2/registrar/presets/AVSRegistrarWithSocket.sol b/src/middlewareV2/registrar/presets/AVSRegistrarWithSocket.sol index 14315a467..ebac2a2d8 100644 --- a/src/middlewareV2/registrar/presets/AVSRegistrarWithSocket.sol +++ b/src/middlewareV2/registrar/presets/AVSRegistrarWithSocket.sol @@ -11,10 +11,15 @@ import {SocketRegistry} from "../modules/SocketRegistry.sol"; contract AVSRegistrarWithSocket is AVSRegistrar, SocketRegistry, IAVSRegistrarWithSocket { constructor( - address _avs, IAllocationManager _allocationManager, IKeyRegistrar _keyRegistrar - ) AVSRegistrar(_avs, _allocationManager, _keyRegistrar) {} + ) AVSRegistrar(_allocationManager, _keyRegistrar) {} + + function initialize( + address avs + ) external initializer { + __AVSRegistrar_init(avs); + } /// @notice Set the socket for the operator /// @dev This function sets the socket even if the operator is already registered diff --git a/test/unit/middlewareV2/AVSRegistrarAllowlistUnit.t.sol b/test/unit/middlewareV2/AVSRegistrarAllowlistUnit.t.sol index c8c94998a..0670d89cf 100644 --- a/test/unit/middlewareV2/AVSRegistrarAllowlistUnit.t.sol +++ b/test/unit/middlewareV2/AVSRegistrarAllowlistUnit.t.sol @@ -19,7 +19,6 @@ contract AVSRegistrarWithAllowlistUnitTests is super.setUp(); avsRegistrarImplementation = new AVSRegistrarWithAllowlist( - AVS, IAllocationManager(address(allocationManagerMock)), IKeyRegistrar(address(keyRegistrarMock)) ); @@ -30,7 +29,7 @@ contract AVSRegistrarWithAllowlistUnitTests is address(avsRegistrarImplementation), address(proxyAdmin), abi.encodeWithSelector( - AVSRegistrarWithAllowlist.initialize.selector, address(this) + AVSRegistrarWithAllowlist.initialize.selector, AVS, address(this) ) ) ) @@ -57,7 +56,7 @@ contract AVSRegistrarWithAllowlistUnitTests_initialize is AVSRegistrarWithAllowl function test_revert_alreadyInitialized() public { cheats.expectRevert("Initializable: contract is already initialized"); - avsRegistrarWithAllowlist.initialize(allowlistAdmin); + avsRegistrarWithAllowlist.initialize(AVS, allowlistAdmin); } } @@ -346,11 +345,4 @@ contract AVSRegistrarWithAllowlistUnitTests_ViewFunctions is AVSRegistrarWithAll ); } } - - function test_getAVS() public { - // Should return the configured AVS address - assertEq( - avsRegistrarWithAllowlist.getAVS(), AVS, "getAVS: should return configured AVS address" - ); - } } diff --git a/test/unit/middlewareV2/AVSRegistrarAsIdentifierUnit.t.sol b/test/unit/middlewareV2/AVSRegistrarAsIdentifierUnit.t.sol index 046a052fe..879a1a3f6 100644 --- a/test/unit/middlewareV2/AVSRegistrarAsIdentifierUnit.t.sol +++ b/test/unit/middlewareV2/AVSRegistrarAsIdentifierUnit.t.sol @@ -24,7 +24,6 @@ contract AVSRegistrarAsIdentifierUnitTests is AVSRegistrarBase { // Deploy the implementation avsRegistrarImplementation = new AVSRegistrarAsIdentifier( - AVS, IAllocationManager(address(allocationManagerMock)), permissionController, IKeyRegistrar(address(keyRegistrarMock)) @@ -34,7 +33,11 @@ contract AVSRegistrarAsIdentifierUnitTests is AVSRegistrarBase { avsRegistrarAsIdentifier = AVSRegistrarAsIdentifier( address( new TransparentUpgradeableProxy( - address(avsRegistrarImplementation), address(proxyAdmin), "" + address(avsRegistrarImplementation), + address(proxyAdmin), + abi.encodeWithSelector( + AVSRegistrarAsIdentifier.initialize.selector, AVS, METADATA_URI + ) ) ) ); @@ -45,7 +48,6 @@ contract AVSRegistrarAsIdentifierUnitTests_constructor is AVSRegistrarAsIdentifi function test_constructor() public { // Deploy a new implementation to test constructor AVSRegistrarAsIdentifier impl = new AVSRegistrarAsIdentifier( - AVS, IAllocationManager(address(allocationManagerMock)), permissionController, IKeyRegistrar(address(keyRegistrarMock)) @@ -72,6 +74,14 @@ contract AVSRegistrarAsIdentifierUnitTests_constructor is AVSRegistrarAsIdentifi contract AVSRegistrarAsIdentifierUnitTests_initialize is AVSRegistrarAsIdentifierUnitTests { function test_initialize() public { + avsRegistrarAsIdentifier = AVSRegistrarAsIdentifier( + address( + new TransparentUpgradeableProxy( + address(avsRegistrarImplementation), address(proxyAdmin), "" + ) + ) + ); + // Mock the allocationManager calls vm.mockCall( address(allocationManagerMock), @@ -151,7 +161,7 @@ contract AVSRegistrarAsIdentifierUnitTests_initialize is AVSRegistrarAsIdentifie "" ); - avsRegistrarAsIdentifier.initialize(admin, METADATA_URI); + // avsRegistrarAsIdentifier.initialize(admin, METADATA_URI); // Try to initialize again vm.expectRevert("Initializable: contract is already initialized"); @@ -205,43 +215,9 @@ contract AVSRegistrarAsIdentifierUnitTests_supportsAVS is AVSRegistrarAsIdentifi } } -contract AVSRegistrarAsIdentifierUnitTests_getAVS is AVSRegistrarAsIdentifierUnitTests { - function test_getAVS() public { - // Should return the proxy address (self) since AVSRegistrarAsIdentifier overrides getAVS - assertEq( - avsRegistrarAsIdentifier.getAVS(), - address(avsRegistrarAsIdentifier), - "getAVS: should return self (proxy) address" - ); - } -} - contract AVSRegistrarAsIdentifierUnitTests_registerOperator is AVSRegistrarAsIdentifierUnitTests { using ArrayLib for *; - function setUp() public virtual override { - super.setUp(); - - // Initialize the contract - vm.mockCall( - address(allocationManagerMock), - abi.encodeWithSelector(IAllocationManager.updateAVSMetadataURI.selector), - "" - ); - vm.mockCall( - address(allocationManagerMock), - abi.encodeWithSelector(IAllocationManager.setAVSRegistrar.selector), - "" - ); - vm.mockCall( - address(permissionController), - abi.encodeWithSelector(IPermissionController.addPendingAdmin.selector), - "" - ); - - avsRegistrarAsIdentifier.initialize(admin, METADATA_URI); - } - function testFuzz_revert_notAllocationManager( address notAllocationManager ) public filterFuzzedAddressInputs(notAllocationManager) { @@ -279,14 +255,16 @@ contract AVSRegistrarAsIdentifierUnitTests_registerOperator is AVSRegistrarAsIde // Register keys for the operator - Note: using AVS as the avs address in the OperatorSet for (uint32 i; i < operatorSetIds.length; ++i) { keyRegistrarMock.setIsRegistered( - defaultOperator, OperatorSet({avs: AVS, id: operatorSetIds[i]}), true + defaultOperator, + OperatorSet({avs: address(avsRegistrarAsIdentifier), id: operatorSetIds[i]}), + true ); } // Register operator + vm.prank(address(allocationManagerMock)); vm.expectEmit(true, true, true, true); emit OperatorRegistered(defaultOperator, operatorSetIds); - vm.prank(address(allocationManagerMock)); avsRegistrarAsIdentifier.registerOperator( defaultOperator, address(avsRegistrarAsIdentifier), operatorSetIds, "0x" ); @@ -298,29 +276,6 @@ contract AVSRegistrarAsIdentifierUnitTests_deregisterOperator is { using ArrayLib for *; - function setUp() public virtual override { - super.setUp(); - - // Initialize the contract - vm.mockCall( - address(allocationManagerMock), - abi.encodeWithSelector(IAllocationManager.updateAVSMetadataURI.selector), - "" - ); - vm.mockCall( - address(allocationManagerMock), - abi.encodeWithSelector(IAllocationManager.setAVSRegistrar.selector), - "" - ); - vm.mockCall( - address(permissionController), - abi.encodeWithSelector(IPermissionController.addPendingAdmin.selector), - "" - ); - - avsRegistrarAsIdentifier.initialize(admin, METADATA_URI); - } - function testFuzz_revert_notAllocationManager( address notAllocationManager ) public filterFuzzedAddressInputs(notAllocationManager) { diff --git a/test/unit/middlewareV2/AVSRegistrarBase.t.sol b/test/unit/middlewareV2/AVSRegistrarBase.t.sol index 36c5a8e08..beb4f73bb 100644 --- a/test/unit/middlewareV2/AVSRegistrarBase.t.sol +++ b/test/unit/middlewareV2/AVSRegistrarBase.t.sol @@ -16,6 +16,21 @@ import { import {ArrayLib} from "eigenlayer-contracts/src/test/utils/ArrayLib.sol"; import "test/utils/Random.sol"; +contract AVSRegistrarImplementation is AVSRegistrar { + constructor( + IAllocationManager _allocationManager, + IKeyRegistrar _keyRegistrar + ) AVSRegistrar(_allocationManager, _keyRegistrar) { + _disableInitializers(); + } + + function initialize( + address _owner + ) external initializer { + __AVSRegistrar_init(_owner); + } +} + abstract contract AVSRegistrarBase is MockEigenLayerDeployer, IAVSRegistrarErrors, diff --git a/test/unit/middlewareV2/AVSRegistrarSocketUnit.t.sol b/test/unit/middlewareV2/AVSRegistrarSocketUnit.t.sol index fe1f8027c..295ec1635 100644 --- a/test/unit/middlewareV2/AVSRegistrarSocketUnit.t.sol +++ b/test/unit/middlewareV2/AVSRegistrarSocketUnit.t.sol @@ -20,7 +20,6 @@ contract AVSRegistrarSocketUnitTests is super.setUp(); avsRegistrarImplementation = new AVSRegistrarWithSocket( - AVS, IAllocationManager(address(allocationManagerMock)), IKeyRegistrar(address(keyRegistrarMock)) ); @@ -28,7 +27,9 @@ contract AVSRegistrarSocketUnitTests is avsRegistrarWithSocket = AVSRegistrarWithSocket( address( new TransparentUpgradeableProxy( - address(avsRegistrarImplementation), address(proxyAdmin), "" + address(avsRegistrarImplementation), + address(proxyAdmin), + abi.encodeWithSelector(AVSRegistrarWithSocket.initialize.selector, AVS) ) ) ); @@ -203,11 +204,4 @@ contract AVSRegistrarSocketUnitTests_ViewFunctions is AVSRegistrarSocketUnitTest ); } } - - function test_getAVS() public { - // Should return the configured AVS address - assertEq( - avsRegistrarWithSocket.getAVS(), AVS, "getAVS: should return configured AVS address" - ); - } } diff --git a/test/unit/middlewareV2/AVSRegistrarUnit.t.sol b/test/unit/middlewareV2/AVSRegistrarUnit.t.sol index 388e1630f..e75622319 100644 --- a/test/unit/middlewareV2/AVSRegistrarUnit.t.sol +++ b/test/unit/middlewareV2/AVSRegistrarUnit.t.sol @@ -8,16 +8,19 @@ contract AVSRegistrarUnitTests is AVSRegistrarBase { function setUp() public override { super.setUp(); - avsRegistrarImplementation = new AVSRegistrar( - AVS, - IAllocationManager(address(allocationManagerMock)), - IKeyRegistrar(address(keyRegistrarMock)) + avsRegistrarImplementation = AVSRegistrar( + new AVSRegistrarImplementation( + IAllocationManager(address(allocationManagerMock)), + IKeyRegistrar(address(keyRegistrarMock)) + ) ); avsRegistrar = AVSRegistrar( address( new TransparentUpgradeableProxy( - address(avsRegistrarImplementation), address(proxyAdmin), "" + address(avsRegistrarImplementation), + address(proxyAdmin), + abi.encodeWithSelector(AVSRegistrarImplementation.initialize.selector, AVS) ) ) ); @@ -130,9 +133,4 @@ contract AVSRegistrarUnitTests_ViewFunctions is AVSRegistrarUnitTests { ); } } - - function test_getAVS() public { - // Should return the configured AVS address - assertEq(avsRegistrar.getAVS(), AVS, "getAVS: should return configured AVS address"); - } } diff --git a/test/unit/middlewareV2/AllowlistUnit.t.sol b/test/unit/middlewareV2/AllowlistUnit.t.sol index 7cc33f7c9..8964eeba9 100644 --- a/test/unit/middlewareV2/AllowlistUnit.t.sol +++ b/test/unit/middlewareV2/AllowlistUnit.t.sol @@ -16,6 +16,12 @@ import {Random, Randomness} from "test/utils/Random.sol"; // Concrete implementation for testing contract AllowlistImplementation is Allowlist { + function initialize( + address _owner + ) external initializer { + __Allowlist_init(_owner); + } + function version() external pure returns (string memory) { return "1.0.0"; } @@ -70,7 +76,9 @@ contract AllowlistUnitTests is Test, IAllowlistErrors, IAllowlistEvents { new TransparentUpgradeableProxy( address(allowlistImplementation), address(proxyAdmin), - abi.encodeWithSelector(Allowlist.initialize.selector, allowlistOwner) + abi.encodeWithSelector( + AllowlistImplementation.initialize.selector, allowlistOwner + ) ) ) ); @@ -115,7 +123,7 @@ contract AllowlistUnitTests_initialize is AllowlistUnitTests { new TransparentUpgradeableProxy( address(allowlistImplementation), address(proxyAdmin), - abi.encodeWithSelector(Allowlist.initialize.selector, randomOwner) + abi.encodeWithSelector(AllowlistImplementation.initialize.selector, randomOwner) ) ) ); From f3580bde47cf650a15014fc8895d51342ffacb4a Mon Sep 17 00:00:00 2001 From: Yash Patil <40046473+ypatil12@users.noreply.github.com> Date: Tue, 29 Jul 2025 11:02:09 -0400 Subject: [PATCH 6/7] chore: rev submodule --- lib/eigenlayer-contracts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/eigenlayer-contracts b/lib/eigenlayer-contracts index a77bd0f03..6e423ccaa 160000 --- a/lib/eigenlayer-contracts +++ b/lib/eigenlayer-contracts @@ -1 +1 @@ -Subproject commit a77bd0f037bfb136065770f281e2dd34fba74866 +Subproject commit 6e423ccaa79fc292e8ed23ba87f2b691923cc31a From a6806d4e11516f4665c95f453ec88763a5e8935c Mon Sep 17 00:00:00 2001 From: Yash Patil <40046473+ypatil12@users.noreply.github.com> Date: Thu, 31 Jul 2025 16:41:34 -0400 Subject: [PATCH 7/7] chore: update taskavsregistrar base forpt1 findings chore: update test --- src/avs/task/TaskAVSRegistrarBase.sol | 7 ++- src/interfaces/ITaskAVSRegistrarBase.sol | 4 +- test/mocks/MockTaskAVSRegistrar.sol | 13 ++-- test/unit/TaskAVSRegistrarBaseUnit.t.sol | 78 +++++++++--------------- 4 files changed, 43 insertions(+), 59 deletions(-) diff --git a/src/avs/task/TaskAVSRegistrarBase.sol b/src/avs/task/TaskAVSRegistrarBase.sol index 5550ae29c..5cfa30572 100644 --- a/src/avs/task/TaskAVSRegistrarBase.sol +++ b/src/avs/task/TaskAVSRegistrarBase.sol @@ -24,27 +24,28 @@ abstract contract TaskAVSRegistrarBase is { /** * @dev Constructor that passes parameters to parent - * @param _avs The address of the AVS * @param _allocationManager The AllocationManager contract address * @param _keyRegistrar The KeyRegistrar contract address */ constructor( - address _avs, IAllocationManager _allocationManager, IKeyRegistrar _keyRegistrar - ) AVSRegistrarWithSocket(_avs, _allocationManager, _keyRegistrar) { + ) AVSRegistrarWithSocket(_allocationManager, _keyRegistrar) { _disableInitializers(); } /** * @dev Initializer for the upgradeable contract + * @param _avs The address of the AVS * @param _owner The owner of the contract * @param _initialConfig The initial AVS configuration */ function __TaskAVSRegistrarBase_init( + address _avs, address _owner, AvsConfig memory _initialConfig ) internal onlyInitializing { + __AVSRegistrar_init(_avs); __Ownable_init(); _transferOwnership(_owner); _setAvsConfig(_initialConfig); diff --git a/src/interfaces/ITaskAVSRegistrarBase.sol b/src/interfaces/ITaskAVSRegistrarBase.sol index cfc42b1eb..d2e9eed13 100644 --- a/src/interfaces/ITaskAVSRegistrarBase.sol +++ b/src/interfaces/ITaskAVSRegistrarBase.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.27; import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; import {IAVSRegistrarInternal} from "./IAVSRegistrarInternal.sol"; -import {ISocketRegistry} from "./ISocketRegistryV2.sol"; +import {ISocketRegistryV2} from "./ISocketRegistryV2.sol"; /** * @title ITaskAVSRegistrarBaseTypes @@ -59,7 +59,7 @@ interface ITaskAVSRegistrarBase is ITaskAVSRegistrarBaseEvents, IAVSRegistrar, IAVSRegistrarInternal, - ISocketRegistry + ISocketRegistryV2 { /** * @notice Sets the configuration for this AVS diff --git a/test/mocks/MockTaskAVSRegistrar.sol b/test/mocks/MockTaskAVSRegistrar.sol index 3466b9880..58892caa3 100644 --- a/test/mocks/MockTaskAVSRegistrar.sol +++ b/test/mocks/MockTaskAVSRegistrar.sol @@ -10,22 +10,25 @@ import {TaskAVSRegistrarBase} from "../../src/avs/task/TaskAVSRegistrarBase.sol" contract MockTaskAVSRegistrar is TaskAVSRegistrarBase { /** * @dev Constructor that passes parameters to parent TaskAVSRegistrarBase - * @param _avs The address of the AVS * @param _allocationManager The AllocationManager contract address * @param _keyRegistrar The KeyRegistrar contract address */ constructor( - address _avs, IAllocationManager _allocationManager, IKeyRegistrar _keyRegistrar - ) TaskAVSRegistrarBase(_avs, _allocationManager, _keyRegistrar) {} + ) TaskAVSRegistrarBase(_allocationManager, _keyRegistrar) {} /** * @dev Initializer that calls parent initializer + * @param _avs The address of the AVS * @param _owner The owner of the contract * @param _initialConfig The initial AVS configuration */ - function initialize(address _owner, AvsConfig memory _initialConfig) external initializer { - __TaskAVSRegistrarBase_init(_owner, _initialConfig); + function initialize( + address _avs, + address _owner, + AvsConfig memory _initialConfig + ) external initializer { + __TaskAVSRegistrarBase_init(_avs, _owner, _initialConfig); } } diff --git a/test/unit/TaskAVSRegistrarBaseUnit.t.sol b/test/unit/TaskAVSRegistrarBaseUnit.t.sol index 4bf0fc2f4..c24fdef46 100644 --- a/test/unit/TaskAVSRegistrarBaseUnit.t.sol +++ b/test/unit/TaskAVSRegistrarBaseUnit.t.sol @@ -57,14 +57,14 @@ contract TaskAVSRegistrarBaseUnitTests is // Deploy the registrar with proxy pattern proxyAdmin = new ProxyAdmin(); MockTaskAVSRegistrar registrarImpl = new MockTaskAVSRegistrar( - avs, - IAllocationManager(address(allocationManager)), - IKeyRegistrar(address(keyRegistrar)) + IAllocationManager(address(allocationManager)), IKeyRegistrar(address(keyRegistrar)) ); TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy( address(registrarImpl), address(proxyAdmin), - abi.encodeWithSelector(MockTaskAVSRegistrar.initialize.selector, owner, initialConfig) + abi.encodeWithSelector( + MockTaskAVSRegistrar.initialize.selector, avs, owner, initialConfig + ) ); registrar = MockTaskAVSRegistrar(address(proxy)); } @@ -139,17 +139,18 @@ contract TaskAVSRegistrarBaseUnitTests_Constructor is TaskAVSRegistrarBaseUnitTe // Deploy new registrar with proxy pattern ProxyAdmin newProxyAdmin = new ProxyAdmin(); MockTaskAVSRegistrar newRegistrarImpl = new MockTaskAVSRegistrar( - avs, - IAllocationManager(address(allocationManager)), - IKeyRegistrar(address(keyRegistrar)) + IAllocationManager(address(allocationManager)), IKeyRegistrar(address(keyRegistrar)) ); TransparentUpgradeableProxy newProxy = new TransparentUpgradeableProxy( address(newRegistrarImpl), address(newProxyAdmin), - abi.encodeWithSelector(MockTaskAVSRegistrar.initialize.selector, owner, config) + abi.encodeWithSelector(MockTaskAVSRegistrar.initialize.selector, avs, owner, config) ); MockTaskAVSRegistrar newRegistrar = MockTaskAVSRegistrar(address(newProxy)); + // Verify AVS was set + assertEq(newRegistrar.avs(), avs); + // Verify owner was set assertEq(newRegistrar.owner(), owner); @@ -168,9 +169,7 @@ contract TaskAVSRegistrarBaseUnitTests_Constructor is TaskAVSRegistrarBaseUnitTe // Deploy implementation ProxyAdmin newProxyAdmin = new ProxyAdmin(); MockTaskAVSRegistrar newRegistrarImpl = new MockTaskAVSRegistrar( - avs, - IAllocationManager(address(allocationManager)), - IKeyRegistrar(address(keyRegistrar)) + IAllocationManager(address(allocationManager)), IKeyRegistrar(address(keyRegistrar)) ); // Expect event during initialization @@ -181,7 +180,7 @@ contract TaskAVSRegistrarBaseUnitTests_Constructor is TaskAVSRegistrarBaseUnitTe new TransparentUpgradeableProxy( address(newRegistrarImpl), address(newProxyAdmin), - abi.encodeWithSelector(MockTaskAVSRegistrar.initialize.selector, owner, config) + abi.encodeWithSelector(MockTaskAVSRegistrar.initialize.selector, avs, owner, config) ); } @@ -191,9 +190,7 @@ contract TaskAVSRegistrarBaseUnitTests_Constructor is TaskAVSRegistrarBaseUnitTe // Deploy implementation ProxyAdmin newProxyAdmin = new ProxyAdmin(); MockTaskAVSRegistrar newRegistrarImpl = new MockTaskAVSRegistrar( - avs, - IAllocationManager(address(allocationManager)), - IKeyRegistrar(address(keyRegistrar)) + IAllocationManager(address(allocationManager)), IKeyRegistrar(address(keyRegistrar)) ); // Expect revert during initialization @@ -201,7 +198,7 @@ contract TaskAVSRegistrarBaseUnitTests_Constructor is TaskAVSRegistrarBaseUnitTe new TransparentUpgradeableProxy( address(newRegistrarImpl), address(newProxyAdmin), - abi.encodeWithSelector(MockTaskAVSRegistrar.initialize.selector, owner, config) + abi.encodeWithSelector(MockTaskAVSRegistrar.initialize.selector, avs, owner, config) ); } @@ -211,9 +208,7 @@ contract TaskAVSRegistrarBaseUnitTests_Constructor is TaskAVSRegistrarBaseUnitTe // Deploy implementation ProxyAdmin newProxyAdmin = new ProxyAdmin(); MockTaskAVSRegistrar newRegistrarImpl = new MockTaskAVSRegistrar( - avs, - IAllocationManager(address(allocationManager)), - IKeyRegistrar(address(keyRegistrar)) + IAllocationManager(address(allocationManager)), IKeyRegistrar(address(keyRegistrar)) ); // Expect revert during initialization @@ -221,7 +216,7 @@ contract TaskAVSRegistrarBaseUnitTests_Constructor is TaskAVSRegistrarBaseUnitTe new TransparentUpgradeableProxy( address(newRegistrarImpl), address(newProxyAdmin), - abi.encodeWithSelector(MockTaskAVSRegistrar.initialize.selector, owner, config) + abi.encodeWithSelector(MockTaskAVSRegistrar.initialize.selector, avs, owner, config) ); } @@ -231,9 +226,7 @@ contract TaskAVSRegistrarBaseUnitTests_Constructor is TaskAVSRegistrarBaseUnitTe // Deploy implementation ProxyAdmin newProxyAdmin = new ProxyAdmin(); MockTaskAVSRegistrar newRegistrarImpl = new MockTaskAVSRegistrar( - avs, - IAllocationManager(address(allocationManager)), - IKeyRegistrar(address(keyRegistrar)) + IAllocationManager(address(allocationManager)), IKeyRegistrar(address(keyRegistrar)) ); // Expect revert during initialization @@ -241,7 +234,7 @@ contract TaskAVSRegistrarBaseUnitTests_Constructor is TaskAVSRegistrarBaseUnitTe new TransparentUpgradeableProxy( address(newRegistrarImpl), address(newProxyAdmin), - abi.encodeWithSelector(MockTaskAVSRegistrar.initialize.selector, owner, config) + abi.encodeWithSelector(MockTaskAVSRegistrar.initialize.selector, avs, owner, config) ); } @@ -251,9 +244,7 @@ contract TaskAVSRegistrarBaseUnitTests_Constructor is TaskAVSRegistrarBaseUnitTe // Deploy implementation ProxyAdmin newProxyAdmin = new ProxyAdmin(); MockTaskAVSRegistrar newRegistrarImpl = new MockTaskAVSRegistrar( - avs, - IAllocationManager(address(allocationManager)), - IKeyRegistrar(address(keyRegistrar)) + IAllocationManager(address(allocationManager)), IKeyRegistrar(address(keyRegistrar)) ); // Expect revert during initialization @@ -261,7 +252,7 @@ contract TaskAVSRegistrarBaseUnitTests_Constructor is TaskAVSRegistrarBaseUnitTe new TransparentUpgradeableProxy( address(newRegistrarImpl), address(newProxyAdmin), - abi.encodeWithSelector(MockTaskAVSRegistrar.initialize.selector, owner, config) + abi.encodeWithSelector(MockTaskAVSRegistrar.initialize.selector, avs, owner, config) ); } } @@ -419,20 +410,18 @@ contract TaskAVSRegistrarBaseUnitTests_Upgradeable is TaskAVSRegistrarBaseUnitTe function test_Initialize_OnlyOnce() public { // Try to initialize again, should revert vm.expectRevert("Initializable: contract is already initialized"); - registrar.initialize(address(0x9999), _createValidAvsConfig()); + registrar.initialize(avs, address(0x9999), _createValidAvsConfig()); } function test_Implementation_CannotBeInitialized() public { // Deploy a new implementation MockTaskAVSRegistrar newImpl = new MockTaskAVSRegistrar( - avs, - IAllocationManager(address(allocationManager)), - IKeyRegistrar(address(keyRegistrar)) + IAllocationManager(address(allocationManager)), IKeyRegistrar(address(keyRegistrar)) ); // Try to initialize the implementation directly, should revert vm.expectRevert("Initializable: contract is already initialized"); - newImpl.initialize(owner, _createValidAvsConfig()); + newImpl.initialize(avs, owner, _createValidAvsConfig()); } function test_ProxyUpgrade() public { @@ -449,9 +438,7 @@ contract TaskAVSRegistrarBaseUnitTests_Upgradeable is TaskAVSRegistrarBaseUnitTe // Deploy new implementation (could have new functions/logic) MockTaskAVSRegistrar newImpl = new MockTaskAVSRegistrar( - avs, - IAllocationManager(address(allocationManager)), - IKeyRegistrar(address(keyRegistrar)) + IAllocationManager(address(allocationManager)), IKeyRegistrar(address(keyRegistrar)) ); // Upgrade proxy to new implementation @@ -476,9 +463,7 @@ contract TaskAVSRegistrarBaseUnitTests_Upgradeable is TaskAVSRegistrarBaseUnitTe // Deploy new implementation MockTaskAVSRegistrar newImpl = new MockTaskAVSRegistrar( - avs, - IAllocationManager(address(allocationManager)), - IKeyRegistrar(address(keyRegistrar)) + IAllocationManager(address(allocationManager)), IKeyRegistrar(address(keyRegistrar)) ); // Try to upgrade from non-owner, should revert @@ -526,9 +511,7 @@ contract TaskAVSRegistrarBaseUnitTests_Upgradeable is TaskAVSRegistrarBaseUnitTe // Deploy new implementation MockTaskAVSRegistrar newImpl = new MockTaskAVSRegistrar( - avs, - IAllocationManager(address(allocationManager)), - IKeyRegistrar(address(keyRegistrar)) + IAllocationManager(address(allocationManager)), IKeyRegistrar(address(keyRegistrar)) ); // Upgrade @@ -557,7 +540,6 @@ contract TaskAVSRegistrarBaseUnitTests_Upgradeable is TaskAVSRegistrarBaseUnitTe TransparentUpgradeableProxy uninitializedProxy = new TransparentUpgradeableProxy( address( new MockTaskAVSRegistrar( - avs, IAllocationManager(address(allocationManager)), IKeyRegistrar(address(keyRegistrar)) ) @@ -571,25 +553,23 @@ contract TaskAVSRegistrarBaseUnitTests_Upgradeable is TaskAVSRegistrarBaseUnitTe // Initialize it once AvsConfig memory config = _createValidAvsConfig(); - uninitializedRegistrar.initialize(owner, config); + uninitializedRegistrar.initialize(avs, owner, config); assertEq(uninitializedRegistrar.owner(), owner); // Try to initialize again, should fail vm.expectRevert("Initializable: contract is already initialized"); - uninitializedRegistrar.initialize(address(0x9999), config); + uninitializedRegistrar.initialize(avs, address(0x9999), config); } function test_DisableInitializers_InImplementation() public { // This test verifies that the implementation contract has initializers disabled MockTaskAVSRegistrar impl = new MockTaskAVSRegistrar( - avs, - IAllocationManager(address(allocationManager)), - IKeyRegistrar(address(keyRegistrar)) + IAllocationManager(address(allocationManager)), IKeyRegistrar(address(keyRegistrar)) ); // Try to initialize the implementation, should revert vm.expectRevert("Initializable: contract is already initialized"); - impl.initialize(owner, _createValidAvsConfig()); + impl.initialize(avs, owner, _createValidAvsConfig()); } }