Skip to content

Commit 504bca2

Browse files
authored
feat: move addresses to constructor (#397)
1 parent fda0aa6 commit 504bca2

File tree

8 files changed

+16
-49
lines changed

8 files changed

+16
-49
lines changed

src/interfaces/IInstantSlasher.sol

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ import {ISlasher} from "./ISlasher.sol";
99
/// @notice A slashing contract that immediately executes slashing requests without any delay or veto period
1010
/// @dev Extends base interfaces to provide access controlled slashing functionality
1111
interface IInstantSlasher is ISlasher {
12-
/// @notice Initializes the contract with a slasher address
13-
/// @param _slasher Address authorized to create and fulfill slashing requests
14-
function initialize(
15-
address _slasher
16-
) external;
17-
1812
/// @notice Immediately executes a slashing request
1913
/// @param _slashingParams Parameters defining the slashing request including operator and amount
2014
/// @dev Can only be called by the authorized slasher

src/interfaces/IVetoableSlasher.sol

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ interface IVetoableSlasher is
6363
/// @notice Address of the committee that has veto power over slashing requests
6464
function vetoCommittee() external view returns (address);
6565

66-
/// @notice Initializes the contract with a veto committee and slasher address
67-
/// @param _vetoCommittee Address of the committee that can veto slashing requests
68-
/// @param _slasher Address authorized to create and fulfill slashing requests
69-
function initialize(address _vetoCommittee, address _slasher) external;
70-
7166
/// @notice Queues a new slashing request
7267
/// @param params Parameters defining the slashing request including operator and amount
7368
/// @dev Can only be called by the authorized slasher

src/slashers/InstantSlasher.sol

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,7 @@ contract InstantSlasher is IInstantSlasher, SlasherBase {
1616
IAllocationManager _allocationManager,
1717
ISlashingRegistryCoordinator _slashingRegistryCoordinator,
1818
address _slasher
19-
) SlasherBase(_allocationManager, _slashingRegistryCoordinator) {}
20-
21-
/// @inheritdoc IInstantSlasher
22-
function initialize(
23-
address _slasher
24-
) external override initializer {
25-
__SlasherBase_init(_slasher);
26-
}
19+
) SlasherBase(_allocationManager, _slashingRegistryCoordinator, _slasher) {}
2720

2821
/// @inheritdoc IInstantSlasher
2922
function fulfillSlashingRequest(

src/slashers/VetoableSlasher.sol

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ contract VetoableSlasher is IVetoableSlasher, SlasherBase {
1616
uint32 public immutable override vetoWindowBlocks;
1717

1818
/// @inheritdoc IVetoableSlasher
19-
address public override vetoCommittee;
19+
address public immutable override vetoCommittee;
2020

2121
/// @notice Mapping of request IDs to their corresponding slashing request details
2222
mapping(uint256 => IVetoableSlasherTypes.VetoableSlashingRequest) public slashingRequests;
@@ -30,17 +30,11 @@ contract VetoableSlasher is IVetoableSlasher, SlasherBase {
3030
constructor(
3131
IAllocationManager _allocationManager,
3232
ISlashingRegistryCoordinator _slashingRegistryCoordinator,
33+
address _slasher,
34+
address _vetoCommittee,
3335
uint32 _vetoWindowBlocks
34-
) SlasherBase(_allocationManager, _slashingRegistryCoordinator) {
36+
) SlasherBase(_allocationManager, _slashingRegistryCoordinator, _slasher) {
3537
vetoWindowBlocks = _vetoWindowBlocks;
36-
}
37-
38-
/// @inheritdoc IVetoableSlasher
39-
function initialize(
40-
address _vetoCommittee,
41-
address _slasher
42-
) external virtual override initializer {
43-
__SlasherBase_init(_slasher);
4438
vetoCommittee = _vetoCommittee;
4539
}
4640

src/slashers/base/SlasherBase.sol

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// SPDX-License-Identifier: BUSL-1.1
22
pragma solidity ^0.8.27;
33

4-
import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";
54
import {SlasherStorage, ISlashingRegistryCoordinator} from "./SlasherStorage.sol";
65
import {
76
IAllocationManagerTypes,
@@ -12,7 +11,7 @@ import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy
1211
/// @title SlasherBase
1312
/// @notice Base contract for implementing slashing functionality in EigenLayer middleware
1413
/// @dev Provides core slashing functionality and interfaces with EigenLayer's AllocationManager
15-
abstract contract SlasherBase is Initializable, SlasherStorage {
14+
abstract contract SlasherBase is SlasherStorage {
1615
/// @notice Ensures only the authorized slasher can call certain functions
1716
modifier onlySlasher() {
1817
_checkSlasher(msg.sender);
@@ -22,20 +21,12 @@ abstract contract SlasherBase is Initializable, SlasherStorage {
2221
/// @notice Constructs the base slasher contract
2322
/// @param _allocationManager The EigenLayer allocation manager contract
2423
/// @param _registryCoordinator The registry coordinator for this middleware
24+
/// @param _slasher The address of the slasher
2525
constructor(
2626
IAllocationManager _allocationManager,
27-
ISlashingRegistryCoordinator _registryCoordinator
28-
) SlasherStorage(_allocationManager, _registryCoordinator) {
29-
_disableInitializers();
30-
}
31-
32-
/// @notice Initializes the slasher contract with authorized slasher address
33-
/// @param _slasher Address authorized to create and fulfill slashing requests
34-
function __SlasherBase_init(
27+
ISlashingRegistryCoordinator _registryCoordinator,
3528
address _slasher
36-
) internal onlyInitializing {
37-
slasher = _slasher;
38-
}
29+
) SlasherStorage(_allocationManager, _registryCoordinator, _slasher) {}
3930

4031
/// @notice Internal function to execute a slashing request
4132
/// @param _requestId The ID of the slashing request to fulfill

src/slashers/base/SlasherStorage.sol

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,19 @@ abstract contract SlasherStorage is ISlasher {
2020
IAllocationManager public immutable allocationManager;
2121
/// @notice the SlashingRegistryCoordinator for this AVS
2222
ISlashingRegistryCoordinator public immutable slashingRegistryCoordinator;
23-
24-
address public slasher;
23+
/// @notice the address of the slasher
24+
address public immutable slasher;
2525

2626
uint256 public nextRequestId;
2727

2828
constructor(
2929
IAllocationManager _allocationManager,
30-
ISlashingRegistryCoordinator _slashingRegistryCoordinator
30+
ISlashingRegistryCoordinator _slashingRegistryCoordinator,
31+
address _slasher
3132
) {
3233
allocationManager = _allocationManager;
3334
slashingRegistryCoordinator = _slashingRegistryCoordinator;
35+
slasher = _slasher;
3436
}
3537

3638
uint256[48] private __gap;

test/unit/InstantSlasher.t.sol

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ contract InstantSlasherTest is Test {
250250
);
251251
vm.stopPrank();
252252

253-
instantSlasher.initialize(slasher);
254-
255253
vm.startPrank(serviceManager);
256254
PermissionController(coreDeployment.permissionController).setAppointee(
257255
address(serviceManager),

test/unit/VetoableSlasher.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ contract VetoableSlasherTest is Test {
239239
vetoableSlasherImplementation = new VetoableSlasher(
240240
IAllocationManager(coreDeployment.allocationManager),
241241
ISlashingRegistryCoordinator(slashingRegistryCoordinator),
242+
slasher,
243+
vetoCommittee,
242244
vetoWindowBlocks
243245
);
244246

@@ -255,8 +257,6 @@ contract VetoableSlasherTest is Test {
255257
);
256258
vm.stopPrank();
257259

258-
vetoableSlasher.initialize(vetoCommittee, slasher);
259-
260260
vm.startPrank(serviceManager);
261261
PermissionController(coreDeployment.permissionController).setAppointee(
262262
address(serviceManager),

0 commit comments

Comments
 (0)