From 38dca520b6ab396507bca46b5e45417dca23fc05 Mon Sep 17 00:00:00 2001 From: steven Date: Wed, 23 Oct 2024 13:07:18 -0400 Subject: [PATCH] chore: organize and add interface --- src/interfaces/ISlasher.sol | 45 ++++++++++++++++++++++++++++ src/slashers/InstantSlasher.sol | 2 +- src/slashers/VetoableSlasher.sol | 16 ---------- src/slashers/base/SlasherBase.sol | 15 ---------- src/slashers/base/SlasherStorage.sol | 3 +- 5 files changed, 48 insertions(+), 33 deletions(-) create mode 100644 src/interfaces/ISlasher.sol diff --git a/src/interfaces/ISlasher.sol b/src/interfaces/ISlasher.sol new file mode 100644 index 00000000..e2d128f1 --- /dev/null +++ b/src/interfaces/ISlasher.sol @@ -0,0 +1,45 @@ + +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.12; + +import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; +import {IAllocationManager} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; + +interface ISlasherEvents { + event SlashingRequested( + uint256 indexed requestId, + address indexed operator, + uint32 indexed operatorSetId, + uint256 wadToSlash, + string description + ); + + event SlashingRequestCancelled(uint256 indexed requestId); + + event OperatorSlashed( + uint256 indexed slashingRequestId, + address indexed operator, + uint32 indexed operatorSetId, + IStrategy[] strategies, + uint256 wadToSlash, + string description + ); +} + +interface ISlasherTypes { + enum SlashingStatus { + Null, + Requested, + Completed, + Cancelled + } + + struct SlashingRequest { + IAllocationManager.SlashingParams params; + uint256 requestTimestamp; + SlashingStatus status; + } + +} + +interface ISlasher is ISlasherEvents, ISlasherTypes{} diff --git a/src/slashers/InstantSlasher.sol b/src/slashers/InstantSlasher.sol index 28a3d174..ab49cee8 100644 --- a/src/slashers/InstantSlasher.sol +++ b/src/slashers/InstantSlasher.sol @@ -14,7 +14,7 @@ contract InstantSlasher is SlasherBase { _; } - function initialize(address _serviceManager, address _slasher) public initializer { + function initialize(address _serviceManager, address _slasher) external initializer { __SlasherBase_init(_serviceManager); slasher = _slasher; } diff --git a/src/slashers/VetoableSlasher.sol b/src/slashers/VetoableSlasher.sol index 83c22a39..30cee811 100644 --- a/src/slashers/VetoableSlasher.sol +++ b/src/slashers/VetoableSlasher.sol @@ -6,28 +6,12 @@ import {SlasherBase} from "./base/SlasherBase.sol"; import {IAllocationManager} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; contract VetoableSlashing is SlasherBase { - struct SlashingRequest { - IAllocationManager.SlashingParams params; - uint256 requestTimestamp; - SlashingStatus status; - } - uint256 public constant VETO_PERIOD = 3 days; address public vetoCommittee; address public slasher; uint256 public nextRequestId; mapping(uint256 => SlashingRequest) public slashingRequests; - event SlashingRequested( - uint256 indexed requestId, - address indexed operator, - uint32 indexed operatorSetId, - uint256 wadToSlash, - string description - ); - - event SlashingRequestCancelled(uint256 indexed requestId); - modifier onlyVetoCommittee() { require(msg.sender == vetoCommittee, "VetoableSlashing: caller is not the veto committee"); _; diff --git a/src/slashers/base/SlasherBase.sol b/src/slashers/base/SlasherBase.sol index e176e158..55a706ad 100644 --- a/src/slashers/base/SlasherBase.sol +++ b/src/slashers/base/SlasherBase.sol @@ -8,21 +8,6 @@ import {IAllocationManagerTypes, IAllocationManager} from "eigenlayer-contracts/ import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; abstract contract SlasherBase is Initializable, SlasherStorage { - enum SlashingStatus { - Null, - Requested, - Completed, - Cancelled - } - - event OperatorSlashed( - uint256 indexed slashingRequestId, - address indexed operator, - uint32 indexed operatorSetId, - IStrategy[] strategies, - uint256 wadToSlash, - string description - ); function __SlasherBase_init(address _serviceManager) internal onlyInitializing { serviceManager = _serviceManager; diff --git a/src/slashers/base/SlasherStorage.sol b/src/slashers/base/SlasherStorage.sol index 1b3d61de..6cd0b9aa 100644 --- a/src/slashers/base/SlasherStorage.sol +++ b/src/slashers/base/SlasherStorage.sol @@ -1,7 +1,8 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.12; -contract SlasherStorage { +import {ISlasher} from "../../interfaces/ISlasher.sol"; +contract SlasherStorage is ISlasher { address public serviceManager; uint256[49] private __gap;