Skip to content

Commit

Permalink
feat: add simiple slasher starting point
Browse files Browse the repository at this point in the history
  • Loading branch information
stevennevins committed Oct 10, 2024
1 parent c8a8e16 commit 9d5c200
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/interfaces/IServiceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity >=0.5.0;
import {IRewardsCoordinator} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol";
import {IServiceManagerUI} from "./IServiceManagerUI.sol";
import {ISignatureUtils} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtils.sol";
import {IAllocationManagerTypes} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol";

/**
* @title Minimal interface for a ServiceManager-type contract that forms the single point for an AVS to push updates to EigenLayer
Expand Down Expand Up @@ -44,6 +45,8 @@ interface IServiceManager is IServiceManagerUI {
*/
function deregisterOperatorFromOperatorSets(address operator, uint32[] calldata operatorSetIds) external;

function slashOperator(IAllocationManagerTypes.SlashingParams memory params) external;

// EVENTS
event RewardsInitiatorUpdated(address prevRewardsInitiator, address newRewardsInitiator);
event SlasherUpdated(address prevSlasher, address newSlasher);
Expand Down
33 changes: 33 additions & 0 deletions src/slashers/SimpleSlasher.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";
import {IServiceManager} from "../interfaces/IServiceManager.sol";
import {SlasherStorage} from "./SlasherStorage.sol";
import {IAllocationManagerTypes} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol";
import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol";

contract SimpleSlasher is Initializable, SlasherStorage {
function initialize(address _serviceManager) public initializer {
serviceManager = _serviceManager;
}

function slashOperator(
address operator,
uint32 operatorSetId,
IStrategy[] memory strategies,
uint256 wadToSlash,
string memory description
) external {

IAllocationManagerTypes.SlashingParams memory params = IAllocationManagerTypes.SlashingParams({
operator: operator,
operatorSetId: operatorSetId,
strategies: strategies,
wadToSlash: wadToSlash,
description: description
});

IServiceManager(serviceManager).slashOperator(params);
}
}
8 changes: 8 additions & 0 deletions src/slashers/SlasherStorage.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

contract SlasherStorage {
address public serviceManager;

uint256[49] private __gap;
}
5 changes: 5 additions & 0 deletions test/mocks/ECDSAServiceManagerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.12;

import "../../src/unaudited/ECDSAServiceManagerBase.sol";
import {IAllocationManagerTypes} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol";

contract ECDSAServiceManagerMock is ECDSAServiceManagerBase {
constructor(
Expand Down Expand Up @@ -34,4 +35,8 @@ contract ECDSAServiceManagerMock is ECDSAServiceManagerBase {
) external {}

function deregisterOperatorFromOperatorSets(address operator, uint32[] calldata operatorSetIds) external{}

function slashOperator(IAllocationManagerTypes.SlashingParams memory params) external override {
// Mock implementation - no actual slashing occurs
}
}

0 comments on commit 9d5c200

Please sign in to comment.