Skip to content

Commit

Permalink
chore: appease linter
Browse files Browse the repository at this point in the history
  • Loading branch information
shaspitz committed Nov 7, 2024
1 parent c7b4e87 commit ba034ff
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 38 deletions.
5 changes: 1 addition & 4 deletions contracts/contracts/core/PreconfManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ contract PreconfManager is
__Pausable_init();

// Compute the domain separators
uint256 chainId;
assembly {
chainId := chainid()
}
uint256 chainId = block.chainid;
domainSeparatorPreconf = keccak256(
abi.encode(
keccak256(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,18 +324,18 @@ contract MevCommitMiddleware is IMevCommitMiddleware, MevCommitMiddlewareStorage
_setSlashPeriodSeconds(slashPeriodSeconds_);
}

/// @dev Sets the slash oracle, restricted to contract owner.
function setSlashOracle(address slashOracle_) external onlyOwner {
_setSlashOracle(slashOracle_);
}

/// @dev Checks if a vault would be valid with a given slashPeriodSeconds.
/// @return True if the vault would be valid, reverts otherwise.
function wouldVaultBeValidWith(address vault, uint256 potentialSLashPeriodSeconds) external view returns (bool) {
_validateVaultParams(vault, potentialSLashPeriodSeconds);
return true;
}

/// @dev Sets the slash oracle, restricted to contract owner.
function setSlashOracle(address slashOracle_) external onlyOwner {
_setSlashOracle(slashOracle_);
}

/// @notice Queries if a validator is opted-in to mev-commit through a vault.
/// @dev The oracle must continuously call this function for upcoming proposers, in order to maintain
/// the most recent (finalized) block timestamp that a validator was queried as "opted-in", see `captureTimestamp` in README.md.
Expand Down Expand Up @@ -476,35 +476,6 @@ contract MevCommitMiddleware is IMevCommitMiddleware, MevCommitMiddlewareStorage
emit VaultRegistered(vault, slashAmount);
}

function _validateVaultParams(address vault, uint256 slashPeriodSeconds) internal view {
IEntity delegator = IEntity(IVault(vault).delegator());
if (delegator.TYPE() == _FULL_RESTAKE_DELEGATOR_TYPE) {
revert FullRestakeDelegatorNotSupported(vault);
} else if (delegator.TYPE() != _NETWORK_RESTAKE_DELEGATOR_TYPE) {
revert UnknownDelegatorType(vault, delegator.TYPE());
}
IVaultStorage vaultContract = IVaultStorage(vault);
uint256 vaultEpochDurationSeconds = vaultContract.epochDuration();

address slasher = IVault(vault).slasher();
require(slasher != address(0), SlasherNotSetForVault(vault));
uint256 slasherType = IEntity(slasher).TYPE();
if (slasherType == _VETO_SLASHER_TYPE) {
IVetoSlasher vetoSlasher = IVetoSlasher(slasher);
uint256 vetoDuration = vetoSlasher.vetoDuration();
// For veto slashers, veto duration is repurposed as the phase in which the oracle can feasibly call `executeSlash`.
require(vetoDuration >= _MIN_VETO_DURATION, VetoDurationTooShort(vault, vetoDuration));
// Incorporate that veto duration will eat into portion of the epoch that oracle can feasibly request slashes.
vaultEpochDurationSeconds -= vetoDuration; /// @dev No underflow possible, vetoDuration must be less than epochDuration as enforced by VetoSlasher.sol.
require(vetoSlasher.resolver(_getSubnetwork(), new bytes(0)) == address(0),
VetoSlasherMustHaveZeroResolver(vault));
} else if (slasherType != _INSTANT_SLASHER_TYPE) {
revert UnknownSlasherType(vault, slasherType);
}
require(vaultEpochDurationSeconds > slashPeriodSeconds,
InvalidVaultEpochDuration(vault, vaultEpochDurationSeconds, slashPeriodSeconds));
}

function _updateSlashAmount(address vault, uint160 slashAmount) internal {
VaultRecord storage record = vaultRecords[vault];
require(record.exists, VaultNotRegistered(vault));
Expand Down Expand Up @@ -656,6 +627,35 @@ contract MevCommitMiddleware is IMevCommitMiddleware, MevCommitMiddlewareStorage
// solhint-disable-next-line no-empty-blocks
function _authorizeUpgrade(address) internal override onlyOwner {}

function _validateVaultParams(address vault, uint256 slashPeriodSeconds) internal view {
IEntity delegator = IEntity(IVault(vault).delegator());
if (delegator.TYPE() == _FULL_RESTAKE_DELEGATOR_TYPE) {
revert FullRestakeDelegatorNotSupported(vault);
} else if (delegator.TYPE() != _NETWORK_RESTAKE_DELEGATOR_TYPE) {
revert UnknownDelegatorType(vault, delegator.TYPE());
}
IVaultStorage vaultContract = IVaultStorage(vault);
uint256 vaultEpochDurationSeconds = vaultContract.epochDuration();

address slasher = IVault(vault).slasher();
require(slasher != address(0), SlasherNotSetForVault(vault));
uint256 slasherType = IEntity(slasher).TYPE();
if (slasherType == _VETO_SLASHER_TYPE) {
IVetoSlasher vetoSlasher = IVetoSlasher(slasher);
uint256 vetoDuration = vetoSlasher.vetoDuration();
// For veto slashers, veto duration is repurposed as the phase in which the oracle can feasibly call `executeSlash`.
require(vetoDuration >= _MIN_VETO_DURATION, VetoDurationTooShort(vault, vetoDuration));
// Incorporate that veto duration will eat into portion of the epoch that oracle can feasibly request slashes.
vaultEpochDurationSeconds -= vetoDuration; /// @dev No underflow possible, vetoDuration must be less than epochDuration as enforced by VetoSlasher.sol.
require(vetoSlasher.resolver(_getSubnetwork(), new bytes(0)) == address(0),
VetoSlasherMustHaveZeroResolver(vault));
} else if (slasherType != _INSTANT_SLASHER_TYPE) {
revert UnknownSlasherType(vault, slasherType);
}
require(vaultEpochDurationSeconds > slashPeriodSeconds,
InvalidVaultEpochDuration(vault, vaultEpochDurationSeconds, slashPeriodSeconds));
}

function _checkOperator(address operator) internal view {
require(operatorRegistry.isEntity(operator), OperatorNotEntity(operator));
OperatorRecord storage record = operatorRecords[operator];
Expand Down

0 comments on commit ba034ff

Please sign in to comment.