Skip to content

Commit

Permalink
feat: add service manager contract
Browse files Browse the repository at this point in the history
  • Loading branch information
AnshuJalan committed Jun 15, 2024
1 parent 1d3d0b6 commit 3b7a8bd
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
51 changes: 51 additions & 0 deletions SmartContracts/src/avs/PreconfServiceManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;

import {IPreconfServiceManager} from "../interfaces/IPreconfServiceManager.sol";
import {IPreconfTaskManager} from "../interfaces/IPreconfTaskManager.sol";
import {ISlasher} from "../interfaces/eigenlayer-mvp/ISlasher.sol";
import {
IAVSDirectory,
IRegistryCoordinator,
IRewardsCoordinator,
IStakeRegistry,
ServiceManagerBase
} from "eigenlayer-middleware/ServiceManagerBase.sol";

contract PreconfServiceManager is ServiceManagerBase, IPreconfServiceManager {
IPreconfTaskManager internal immutable preconfTaskManager;
ISlasher internal immutable slasher;

mapping(address operator => uint256 timestamp) public stakeLockedUntil;

constructor(
IAVSDirectory _avsDirectory,
IRewardsCoordinator _rewardsCoordinator,
IRegistryCoordinator _registryCoordinator,
IStakeRegistry _stakeRegistry,
IPreconfTaskManager _taskManager,
ISlasher _slasher
) ServiceManagerBase(_avsDirectory, _rewardsCoordinator, _registryCoordinator, _stakeRegistry) {
preconfTaskManager = _taskManager;
slasher = _slasher;
}

modifier onlyPreconfTaskManager() {
if (msg.sender != address(preconfTaskManager)) {
revert IPreconfServiceManager.SenderIsNotPreconfTaskManager(msg.sender);
}
_;
}

function lockStakeUntil(address operator, uint256 timestamp) external onlyPreconfTaskManager {
stakeLockedUntil[operator] = timestamp;
emit StakeLockedUntil(operator, timestamp);
}

function slashOperator(address operator) external onlyPreconfTaskManager {
if (slasher.isOperatorSlashed(operator)) {
revert IPreconfServiceManager.OperatorAlreadySlashed(operator);
}
slasher.slashOperator(operator);
}
}
2 changes: 1 addition & 1 deletion SmartContracts/src/interfaces/IPreconfTaskManager.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;

interface PreconfTaskManager {
interface IPreconfTaskManager {
event LookaheadUpdated(bytes lookahead);
event ProvedIncorrectPreconfirmation(address indexed preconfer, uint256 indexed blockId, address indexed disputer);
event ProvedIncorrectLookahead(address indexed poster, uint256 indexed slot, address indexed disputer);
Expand Down

0 comments on commit 3b7a8bd

Please sign in to comment.