Skip to content

Commit de8c73d

Browse files
committed
docs: add slashing docs
1 parent e952db0 commit de8c73d

File tree

3 files changed

+222
-0
lines changed

3 files changed

+222
-0
lines changed

docs/slashing/InstantSlasher.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## InstantSlasher
2+
3+
| File | Type | Proxy |
4+
| -------- | -------- | -------- |
5+
| [`InstantSlasher.sol`](../src/InstantSlasher.sol) | Implementation | No |
6+
7+
The `InstantSlasher` is a concrete implementation of the `SlasherBase` contract that provides immediate execution of slashing requests without any delay or veto period. This contract should be used with caution, as slashing is a critical operation within an AVS. This implementation is reccomended if your AVS is mature, robust and the slashing conditions are well understood (i.e. those which do not arise from subjective or non-malicious reasons like a software bug)
8+
9+
*As of current implementation*:
10+
* This contract executes slashing requests immediately when initiated by the authorized slasher
11+
* No waiting period or veto mechanism is implemented
12+
* Each slashing request is assigned a unique ID
13+
14+
---
15+
16+
### Core Functionality
17+
18+
#### `fulfillSlashingRequest`
19+
```solidity
20+
function fulfillSlashingRequest(
21+
IAllocationManager.SlashingParams calldata _slashingParams
22+
)
23+
external
24+
virtual
25+
override(IInstantSlasher)
26+
onlySlasher
27+
```
28+
Immediately executes a slashing request against the specified operator.
29+
30+
*Entry Points*:
31+
* External calls from the authorized slasher
32+
33+
*Effects*:
34+
* Assigns a unique ID to the slashing request
35+
* Calls the internal `_fulfillSlashingRequest` function to execute the slashing action
36+
* Increments the `nextRequestId` counter for future requests
37+
38+
*Requirements*:
39+
* Caller MUST be the authorized slasher (enforced by `onlySlasher` modifier)
40+
* Slashing parameters must be valid

docs/slashing/SlasherBase.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
## SlasherBase
2+
3+
| File | Type | Proxy |
4+
| -------- | -------- | -------- |
5+
| [`SlasherBase.sol`](../src/base/SlasherBase.sol) | Abstract | No |
6+
7+
The `SlasherBase` is an abstract contract that provides core slashing functionality intended for AVSs to inherit. It serves as the foundation for implementing slashing mechanisms that interact with EigenLayer's `AllocationManager`. There are two implementations of this contract which are the [`VetoableSlasher`](./VetoableSlasher.md) and the [`InstantSlasher`](./InstantSlasher.md).
8+
9+
*As of current implementation*:
10+
* This contract provides the base functionality for slashing operators in EigenLayer based on certain conditions
11+
* Concrete implementations will determine when and how slashing is performed
12+
* The contract maintains a connection to the registry coordinator and the allocation manager
13+
14+
---
15+
16+
### Core Functionality
17+
18+
#### `constructor`
19+
```solidity
20+
constructor(
21+
IAllocationManager _allocationManager,
22+
ISlashingRegistryCoordinator _registryCoordinator,
23+
address _slasher
24+
)
25+
```
26+
Initializes the base slasher contract with essential components.
27+
28+
*Effects*:
29+
* Initializes the contract with references to the allocation manager, registry coordinator, and the authorized slasher address
30+
31+
*Requirements*:
32+
* Valid addresses must be provided for all parameters
33+
34+
#### `_fulfillSlashingRequest`
35+
```solidity
36+
function _fulfillSlashingRequest(
37+
uint256 _requestId,
38+
IAllocationManager.SlashingParams memory _params
39+
)
40+
internal
41+
virtual
42+
```
43+
Internal function that executes a slashing request by calling the `AllocationManager.slashOperator` method.
44+
45+
*Effects*:
46+
* Calls the allocation manager to slash the specified operator
47+
* Emits an `OperatorSlashed` event with details about the slashing action
48+
49+
*Requirements*:
50+
* The allocation manager must be properly set up
51+
* The slashing parameters must be valid
52+
53+
#### `_checkSlasher`
54+
```solidity
55+
function _checkSlasher(
56+
address account
57+
)
58+
internal
59+
view
60+
virtual
61+
```
62+
Internal function that verifies if an account is the authorized slasher.
63+
64+
*Effects*:
65+
* Reverts with an `OnlySlasher` error if the provided account is not the authorized slasher
66+
67+
*Requirements*:
68+
* The account must match the stored slasher address
69+
70+
### Modifiers
71+
72+
#### `onlySlasher`
73+
```solidity
74+
modifier onlySlasher()
75+
```
76+
Ensures that only the authorized slasher can call certain functions. This will commonly be set as the address of the AVS `ServiceManager` which would expose a permissioned or permissionless external function to call the slashing contract. Keeping the contracts decoupled allows for easier upgrade paths.
77+
78+
*Effects*:
79+
* Calls `_checkSlasher` to verify that the caller is the authorized slasher
80+
* Allows the function execution to proceed if the check passes

docs/slashing/VetoableSlasher.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
## VetoableSlasher
2+
3+
| File | Type | Proxy |
4+
| -------- | -------- | -------- |
5+
| [`VetoableSlasher.sol`](../src/VetoableSlasher.sol) | Implementation | No |
6+
7+
The `VetoableSlasher` is a concrete implementation of the [`SlasherBase`](./SlasherBase.md) contract that adds a veto mechanism to the slashing process. This implementation introduces a waiting period during which a designated veto committee can cancel slashing requests before they are executed. This slasher implementation is recommended for AVSs to use as their systems matures, to account for slashing faults that arise from subjective conditions or non-malicious reasons such as a software bug. As the AVSs matures and the slashing conditions become well defined, the instant slasher may be a suitable contract. It is reccomended to have your veto comittee to be comprised of a set of diverse subject matter experts.
8+
9+
*As of current implementation*:
10+
* Slashing requests are queued and can only be fulfilled after a configurable veto window has passed
11+
* A designated veto committee can cancel slashing requests during the veto window
12+
* Slashing requests have a status that tracks their lifecycle: Requested, Cancelled, or Completed
13+
14+
---
15+
16+
### Core Functionality
17+
18+
#### `queueSlashingRequest`
19+
```solidity
20+
function queueSlashingRequest(
21+
IAllocationManager.SlashingParams calldata params
22+
)
23+
external
24+
virtual
25+
override
26+
onlySlasher
27+
```
28+
Creates and queues a new slashing request that will be executable after the veto window has passed.
29+
30+
*Entry Points*:
31+
* External calls from the authorized slasher
32+
33+
*Effects*:
34+
* Assigns a unique ID to the slashing request
35+
* Creates a new slashing request with the provided parameters
36+
* Sets the request status to `Requested`
37+
* Stores the current block number as the request block
38+
* Emits a `SlashingRequested` event
39+
40+
*Requirements*:
41+
* Caller MUST be the authorized slasher (enforced by `onlySlasher` modifier)
42+
* Slashing parameters must be valid
43+
44+
#### `cancelSlashingRequest`
45+
```solidity
46+
function cancelSlashingRequest(
47+
uint256 requestId
48+
)
49+
external
50+
virtual
51+
override
52+
onlyVetoCommittee
53+
```
54+
Allows the veto committee to cancel a pending slashing request within the veto window.
55+
56+
*Entry Points*:
57+
* External calls from the veto committee
58+
59+
*Effects*:
60+
* Changes the request status from `Requested` to `Cancelled`
61+
* Emits a `SlashingRequestCancelled` event
62+
63+
*Requirements*:
64+
* Caller MUST be the veto committee (enforced by `onlyVetoCommittee` modifier)
65+
* The request MUST be in the `Requested` status
66+
* The current block number MUST be less than the request block plus the veto window
67+
68+
#### `fulfillSlashingRequest`
69+
```solidity
70+
function fulfillSlashingRequest(
71+
uint256 requestId
72+
)
73+
external
74+
virtual
75+
override
76+
onlySlasher
77+
```
78+
Executes a slashing request after the veto window has passed, if it has not been cancelled.
79+
80+
*Entry Points*:
81+
* External calls from the authorized slasher
82+
83+
*Effects*:
84+
* Changes the request status from `Requested` to `Completed`
85+
* Calls the internal `_fulfillSlashingRequest` function to execute the slashing action
86+
87+
*Requirements*:
88+
* Caller MUST be the authorized slasher (enforced by `onlySlasher` modifier)
89+
* The request MUST be in the `Requested` status
90+
* The veto window MUST have passed (current block number >= request block + veto window)
91+
92+
### Modifiers
93+
94+
#### `onlyVetoCommittee`
95+
```solidity
96+
modifier onlyVetoCommittee()
97+
```
98+
Ensures that only the veto committee can call certain functions.
99+
100+
*Effects*:
101+
* Calls `_checkVetoCommittee` to verify that the caller is the veto committee
102+
* Allows the function execution to proceed if the check passes

0 commit comments

Comments
 (0)