-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSlashingManager.sol
44 lines (37 loc) · 1.38 KB
/
SlashingManager.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "./Interfaces/IStakingRegistry.sol";
contract SlashingManager {
error NotSlasher();
address public immutable SLASHER_ADDRESS;
event SlashClients(uint256 indexed instanceId);
/// @notice Constructor for SlashingManager
/// @param _slasherAddress Address of slasher
constructor(address _slasherAddress) {
SLASHER_ADDRESS = _slasherAddress;
}
/// @notice Function to slash client stake
/// @dev This function is used to slash client stake
/// @param _clientAddress Address of malicious client
/// @param _stakingRegistry Address of staking registry
function slash(
address[] calldata _clientAddress,
uint256 _instanceId,
address _stakingRegistry
) external {
if (msg.sender != SLASHER_ADDRESS) {
revert NotSlasher();
}
IStakingRegistry stakingRegistry = IStakingRegistry(_stakingRegistry);
for (uint256 i = 0; i < _clientAddress.length; i++) {
stakingRegistry.slashStake(_clientAddress[i]);
}
emit SlashClients(_instanceId);
}
/// @notice Function to get slasher address
/// @dev This function is used to get slasher address
/// @return Address of slasher
function getSlasherAddress() external view returns (address) {
return SLASHER_ADDRESS;
}
}