Skip to content

Commit a11adb7

Browse files
committed
docs: edit edge cases
1 parent 8184cf4 commit a11adb7

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

docs/core/accounting/SharesAccountingEdgeCases.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,29 @@ This document is meant to explore and analyze the different mathematical operati
1010
* [Shares Accounting](./SharesAccounting.md)
1111

1212

13-
## Fully Slashed for a Strategy (100% slashed)
13+
## Fully Slashed for a Strategy
1414

15-
Within the context of a single Strategy, recall that the deposit scaling factor $k_n$ is defined as the following:
15+
Within the context of a single Strategy, recall that updates to the deposit scaling factor $k_n$ are defined as the following:
1616

1717
$$
1818
k_{n+1} = \frac{s_n k_n m_n + d_n}{s_{n+1} l_{n+1} m_{n+1}}=\frac{s_n k_n l_n m_n + d_n}{(s_n+d_n)l_nm_n}
1919
$$
2020

21-
We can see here that calculating $k_{n+1}$ can give us a divide by 0 error if $l_n$ or $m_n$ are equal to 0. \
22-
This situation occurs when an operator is 100% slashed for a given Strategy and their max magnitude $m_n = 0$.
23-
Alternatively for a staker, if they have been slashed enough to have a beacon chain slashing factor of $l_n = 0$ then they will also be in the same situation.
21+
We can see here that calculating $k_{n+1}$ can give us a divide by 0 error if any of $(s_n + d_n)$, $l_n$, or $m_n$ are equal to 0. The $(s_n + d_n) = 0$ case should not arise because the `EigenPodManager` and `StrategyManager` will not report share increases in this case. However, the other two terms may reach 0:
22+
* When an operator is 100% slashed for a given strategy and their max magnitude $m_n = 0$
23+
* When a staker's `EigenPod` native ETH balance is 0 _and_ their validators have all been slashed such that $l_n = 0$
2424

25-
In either case, we know that since either the operator was fully slashed or the staker was fully slashed for beaconChainETHStrategy then
26-
$a_n$ = 0.
25+
In these cases, updates to a staker's deposit scaling factor will encounter a division by 0 error. In either case, we know that since either the operator was fully slashed or the staker was fully slashed for the `beaconChainETHStrategy` then their withdrawable shares $a_n = 0$.
2726

28-
If $m_n = 0$ then any further deposits for a staker delegated to said operator are blocked and they cannot update their deposit shares $s_n$.
29-
As a staker who has existing depositShares, delegating to an operator who is fully slashed for that strategy will result in a revert. However, the staker can still delegate to the operator if they don't contain any shares for the Strategy which has a 0 max magnitude $m_n$. This is because delegation in EigenLayer is all or nothing of staker assets delegated to the operator.
30-
Undelegating from a fully slashed operator is still possible and a staker can redeposit more assets by undelegating or redelegating.
27+
In practice, if $m_n = 0$ for a given operator, then:
28+
1. Any staker who is already delegated to this operator _will be unable to deposit additional assets into the corresponding strategy_
29+
2. Any staker that currently holds deposit shares in this strategy and is NOT delegated to the operator _will be unable to delegate to the operator_
30+
31+
Note that in the first case, it _is_ possible for the staker to undelegate, queue, and complete withdrawals - though as $a_n = 0$, they will not receive any withdrawable shares as a result.
32+
33+
Additionally, if $l_n = 0$ for a given staker in the beacon chain ETH strategy, then **any further deposits of ETH or restaking of validators will not yield shares in EigenLayer.** This should only occur in extraordinary circumstances, as a beacon chain slashing factor of 0 means that a staker both has ~0 assets in their `EigenPod`, and ALL of their validators have been ~100% slashed on the beacon chain - something that happens only when coordinated groups of validators are slashed. If this case occurs, an `EigenPod` is essentially bricked - the pod owner should NOT send ETH to the pod, and should NOT point additional validators at the pod.
34+
35+
These are all expected edge cases and their occurances and side effects are within acceptable tolerances.
3136

3237
## Upper Bound on Deposit Scaling Factor $k_n$
3338

@@ -48,19 +53,15 @@ function calcWithdrawable(
4853
}
4954
```
5055

51-
`depositShares` are the staker’s shares $s_n$ in storage. We know this can at max be 1e38 - 1 as this is the max total shares we allow in a strategy.
52-
$l_n ≤ 1e18$ and $m_n ≤ 1e18$ as they are montonically decreasing values. So a `mulWad` of the `slashingFactor` operation should never result in a overflow, it will
53-
always result in a smaller or equal number.
54-
The question now comes to `depositShares.mulWad(dsf.scalingFactor())` and whether this term will overflow a uint256. Let's examine the math behind this more below.
56+
`depositShares` are the staker’s shares $s_n$ in storage. We know this can at max be 1e38 - 1 as this is the max total shares we allow in a strategy. $l_n ≤ 1e18$ and $m_n ≤ 1e18$ as they are montonically decreasing values. So a `mulWad` of the `slashingFactor` operation should never result in a overflow, it will always result in a smaller or equal number.
5557

56-
The function `SlashingLib.updateDepositScalingFactor` is doing the below calculation.
58+
The question now comes to `depositShares.mulWad(dsf.scalingFactor())` and whether this term will overflow a `uint256`. Let's examine the math behind this. The function `SlashingLib.update` performs the following calculation:
5759

5860
$$
5961
k_{n+1} =\frac{s_n k_n l_n m_n + d_n}{(s_n+d_n)l_nm_n}
6062
$$
6163

62-
Now lets just do some analysis on k in this equation \
63-
Assumptions:
64+
Assuming:
6465
- $k_0 = 1$
6566
- 0 < $l_0$ ≤ 1 and is monotonically decreasing but doesn’t reach 0
6667
- 0 < $m_0$ ≤ 1 and is monotonically decreasing but doesn’t reach 0
@@ -105,6 +106,7 @@ k_{1e38-1} \approx (1e38-1)\cdot 1e36 < 1e74
105106
$$
106107

107108
After 1e38-1 iterations/deposits, the upper bound on k we calculate is 1e74 in the _worst_ case scenario. This is technically possible if as a staker, you are delegated to an operator for the beaconChainStrategy where your operator has been slashed 99.9999999…% for native ETH but also as a staker you have had proportional EigenPod balance decreases up to 99.9999999…..%.
109+
108110
The max shares of 1e38-1 also accommodates the entire supply of ETH as well (only needs 27 bits). For normal StrategyManager strategies, ${l_n} = 1$ and ${k_n}$ would not grow nearly to the same extent.
109111

110112
Clearly this value of 1e74 for ${k_n}$ fits within a uint256 storage slot.

0 commit comments

Comments
 (0)