From 6c8f1ec0d7179179664c1f14267598c969b6ce70 Mon Sep 17 00:00:00 2001 From: Kresh Date: Fri, 27 Dec 2024 17:52:00 +0400 Subject: [PATCH] refactor: temp remove minPower --- .../SelfRegisterEd25519Middleware.sol | 2 +- .../SelfRegisterMiddleware.sol | 2 +- .../SelfRegisterSqrtTaskMiddleware.sol | 2 +- .../operators/SelfRegisterOperators.sol | 25 ++----------------- .../operators/ISelfRegisterOperators.sol | 1 - 5 files changed, 5 insertions(+), 27 deletions(-) diff --git a/src/examples/self-register-network/SelfRegisterEd25519Middleware.sol b/src/examples/self-register-network/SelfRegisterEd25519Middleware.sol index cdf77f0..8f64090 100644 --- a/src/examples/self-register-network/SelfRegisterEd25519Middleware.sol +++ b/src/examples/self-register-network/SelfRegisterEd25519Middleware.sol @@ -52,7 +52,7 @@ contract SelfRegisterEd25519Middleware is address owner ) internal initializer { __BaseMiddleware_init(network, slashingWindow, vaultRegistry, operatorRegistry, operatorNetOptin, reader); - __SelfRegisterOperators_init("SelfRegisterEd25519Middleware", 0); + __SelfRegisterOperators_init("SelfRegisterEd25519Middleware"); __OwnableAccessManager_init(owner); } } diff --git a/src/examples/self-register-network/SelfRegisterMiddleware.sol b/src/examples/self-register-network/SelfRegisterMiddleware.sol index ef3cedf..d205782 100644 --- a/src/examples/self-register-network/SelfRegisterMiddleware.sol +++ b/src/examples/self-register-network/SelfRegisterMiddleware.sol @@ -52,7 +52,7 @@ contract SelfRegisterMiddleware is address owner ) internal initializer { __BaseMiddleware_init(network, slashingWindow, vaultRegistry, operatorRegistry, operatorNetOptIn, reader); - __SelfRegisterOperators_init("SelfRegisterMiddleware", 0); + __SelfRegisterOperators_init("SelfRegisterMiddleware"); __OwnableAccessManager_init(owner); } } diff --git a/src/examples/sqrt-task-network/SelfRegisterSqrtTaskMiddleware.sol b/src/examples/sqrt-task-network/SelfRegisterSqrtTaskMiddleware.sol index 0874c9f..ae6ed35 100644 --- a/src/examples/sqrt-task-network/SelfRegisterSqrtTaskMiddleware.sol +++ b/src/examples/sqrt-task-network/SelfRegisterSqrtTaskMiddleware.sol @@ -85,7 +85,7 @@ contract SelfRegisterSqrtTaskMiddleware is INetworkRegistry(networkRegistry).registerNetwork(); __BaseMiddleware_init(address(this), slashingWindow, vaultRegistry, operatorRegistry, operatorNetOptin, reader); __OwnableAccessManager_init(owner); - __SelfRegisterOperators_init("SelfRegisterSqrtTaskMiddleware", 0); + __SelfRegisterOperators_init("SelfRegisterSqrtTaskMiddleware"); } function createTask(uint256 value, address validator) external returns (uint256 taskIndex) { diff --git a/src/extensions/operators/SelfRegisterOperators.sol b/src/extensions/operators/SelfRegisterOperators.sol index ea7d4f9..9b5bc48 100644 --- a/src/extensions/operators/SelfRegisterOperators.sol +++ b/src/extensions/operators/SelfRegisterOperators.sol @@ -35,7 +35,6 @@ abstract contract SelfRegisterOperators is BaseOperators, SigManager, EIP712Upgr keccak256("UnpauseOperatorVault(address operator,address vault,uint256 nonce)"); struct SelfRegisterOperatorsStorage { - uint256 minPower; mapping(address => uint256) nonces; } @@ -51,14 +50,11 @@ abstract contract SelfRegisterOperators is BaseOperators, SigManager, EIP712Upgr } /** - * @notice Initializes the contract with EIP712 domain separator and minimum power threshold + * @notice Initializes the contract with EIP712 domain separator * @param name The name to use for the EIP712 domain separator - * @param _minPower The minimum power threshold */ - function __SelfRegisterOperators_init(string memory name, uint256 _minPower) internal onlyInitializing { + function __SelfRegisterOperators_init(string memory name) internal onlyInitializing { __EIP712_init(name, "1"); - SelfRegisterOperatorsStorage storage $ = _getSelfRegisterOperatorsStorage(); - $.minPower = _minPower; } function nonces( @@ -72,7 +68,6 @@ abstract contract SelfRegisterOperators is BaseOperators, SigManager, EIP712Upgr */ function registerOperator(bytes memory key, address vault, bytes memory signature) external virtual { _verifyKey(msg.sender, key, signature); - _checkMinPower(msg.sender, vault); _registerOperatorImpl(msg.sender, key, vault); } @@ -87,7 +82,6 @@ abstract contract SelfRegisterOperators is BaseOperators, SigManager, EIP712Upgr bytes memory keySignature ) public virtual { _verifyKey(operator, key, keySignature); - _checkMinPower(operator, vault); SelfRegisterOperatorsStorage storage $ = _getSelfRegisterOperatorsStorage(); _verifyEIP712( operator, @@ -269,21 +263,6 @@ abstract contract SelfRegisterOperators is BaseOperators, SigManager, EIP712Upgr _unpauseOperatorVaultImpl(operator, vault); } - function _checkMinPower(address operator, address vault) internal view { - SelfRegisterOperatorsStorage storage $ = _getSelfRegisterOperatorsStorage(); - address[] memory vaults = _activeVaults(); - uint160[] memory subnetworks = _activeSubnetworks(); - uint256 power = _getOperatorPower(operator, vaults, subnetworks); - if (address(vault) != address(0)) { - vaults = new address[](1); - vaults[0] = vault; - power += _getOperatorPower(operator, vaults, subnetworks); - } - if (power < $.minPower) { - revert NotEnoughPower(); - } - } - /** * @notice Verifies a key signature * @param operator The address of the operator diff --git a/src/interfaces/extensions/operators/ISelfRegisterOperators.sol b/src/interfaces/extensions/operators/ISelfRegisterOperators.sol index c55c018..9a6fe8b 100644 --- a/src/interfaces/extensions/operators/ISelfRegisterOperators.sol +++ b/src/interfaces/extensions/operators/ISelfRegisterOperators.sol @@ -7,7 +7,6 @@ pragma solidity ^0.8.25; */ interface ISelfRegisterOperators { error InvalidSignature(); - error NotEnoughPower(); /** * @notice Returns the nonce for an operator address