Skip to content

Commit

Permalink
refactor: temp remove minPower
Browse files Browse the repository at this point in the history
  • Loading branch information
1kresh committed Dec 27, 2024
1 parent 0a5aefa commit 6c8f1ec
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
25 changes: 2 additions & 23 deletions src/extensions/operators/SelfRegisterOperators.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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(
Expand All @@ -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);
}

Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pragma solidity ^0.8.25;
*/
interface ISelfRegisterOperators {
error InvalidSignature();
error NotEnoughPower();

/**
* @notice Returns the nonce for an operator address
Expand Down

0 comments on commit 6c8f1ec

Please sign in to comment.