Skip to content

Commit 6a0cd47

Browse files
8sunyuanypatil12
authored andcommitted
refactor: async burning (#1001)
* refactor: burning * chore: fmt * chore: update storage report * chore: update readme * refactor: add burnableShares for epm storage * chore: update storage report
1 parent 84faf29 commit 6a0cd47

20 files changed

+267
-132
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ surya mdreport surya_report.md ./src/contracts/**/*.sol
102102
make bindings
103103
```
104104

105+
### Generate updated Storage Report
106+
107+
To update the storage reports in `/docs/storage-report` run:
108+
109+
```bash
110+
make storage-report
111+
```
112+
105113
## Deployments
106114

107115
### Current Mainnet Deployment

docs/core/AllocationManager.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ Once slashing is processed for a strategy, [slashed stake is burned via the `Del
623623
* If the `allocation` now has a `currentMagnitude` of 0:
624624
* Removes `strategy` from the `allocatedStrategies[operator][operatorSetKey]` list
625625
* If this list now has a length of 0, remove `operatorSetKey` from `allocatedSets[operator]`
626-
* Calls [`DelegationManager.burnOperatorShares`](./DelegationManager.md#burnoperatorshares)
626+
* Calls [`DelegationManager.slashOperatorShares`](./DelegationManager.md#slashoperatorshares)
627627
* Emit an `OperatorSlashed` event
628628

629629
*Requirements*:

docs/storage-report/EigenPodManager.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
|---------------------------------+----------------------------------------------------------------------------+------+--------+-------+--------------------------------------------------------|
3333
| _beaconChainSlashingFactor | mapping(address => struct IEigenPodManagerTypes.BeaconChainSlashingFactor) | 157 | 0 | 32 | src/contracts/pods/EigenPodManager.sol:EigenPodManager |
3434
|---------------------------------+----------------------------------------------------------------------------+------+--------+-------+--------------------------------------------------------|
35-
| __gap | uint256[43] | 158 | 0 | 1376 | src/contracts/pods/EigenPodManager.sol:EigenPodManager |
35+
| burnableETHShares | uint256 | 158 | 0 | 32 | src/contracts/pods/EigenPodManager.sol:EigenPodManager |
36+
|---------------------------------+----------------------------------------------------------------------------+------+--------+-------+--------------------------------------------------------|
37+
| __gap | uint256[42] | 159 | 0 | 1344 | src/contracts/pods/EigenPodManager.sol:EigenPodManager |
3638
|---------------------------------+----------------------------------------------------------------------------+------+--------+-------+--------------------------------------------------------|
3739
| _status | uint256 | 201 | 0 | 32 | src/contracts/pods/EigenPodManager.sol:EigenPodManager |
3840
|---------------------------------+----------------------------------------------------------------------------+------+--------+-------+--------------------------------------------------------|

docs/storage-report/EigenPodManagerStorage.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
|---------------------------------+----------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------|
1717
| _beaconChainSlashingFactor | mapping(address => struct IEigenPodManagerTypes.BeaconChainSlashingFactor) | 6 | 0 | 32 | src/contracts/pods/EigenPodManagerStorage.sol:EigenPodManagerStorage |
1818
|---------------------------------+----------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------|
19-
| __gap | uint256[43] | 7 | 0 | 1376 | src/contracts/pods/EigenPodManagerStorage.sol:EigenPodManagerStorage |
19+
| burnableETHShares | uint256 | 7 | 0 | 32 | src/contracts/pods/EigenPodManagerStorage.sol:EigenPodManagerStorage |
20+
|---------------------------------+----------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------|
21+
| __gap | uint256[42] | 8 | 0 | 1344 | src/contracts/pods/EigenPodManagerStorage.sol:EigenPodManagerStorage |
2022
╰---------------------------------+----------------------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------╯
2123

docs/storage-report/StrategyManager.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
|----------------------------------------------------------+------------------------------------------------------------+------+--------+-------+--------------------------------------------------------|
4545
| __deprecated_thirdPartyTransfersForbidden | mapping(contract IStrategy => bool) | 211 | 0 | 32 | src/contracts/core/StrategyManager.sol:StrategyManager |
4646
|----------------------------------------------------------+------------------------------------------------------------+------+--------+-------+--------------------------------------------------------|
47-
| __gap | uint256[39] | 212 | 0 | 1248 | src/contracts/core/StrategyManager.sol:StrategyManager |
47+
| burnableShares | mapping(contract IStrategy => uint256) | 212 | 0 | 32 | src/contracts/core/StrategyManager.sol:StrategyManager |
48+
|----------------------------------------------------------+------------------------------------------------------------+------+--------+-------+--------------------------------------------------------|
49+
| __gap | uint256[38] | 213 | 0 | 1216 | src/contracts/core/StrategyManager.sol:StrategyManager |
4850
╰----------------------------------------------------------+------------------------------------------------------------+------+--------+-------+--------------------------------------------------------╯
4951

docs/storage-report/StrategyManagerStorage.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
|----------------------------------------------------------+------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------|
2525
| __deprecated_thirdPartyTransfersForbidden | mapping(contract IStrategy => bool) | 10 | 0 | 32 | src/contracts/core/StrategyManagerStorage.sol:StrategyManagerStorage |
2626
|----------------------------------------------------------+------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------|
27-
| __gap | uint256[39] | 11 | 0 | 1248 | src/contracts/core/StrategyManagerStorage.sol:StrategyManagerStorage |
27+
| burnableShares | mapping(contract IStrategy => uint256) | 11 | 0 | 32 | src/contracts/core/StrategyManagerStorage.sol:StrategyManagerStorage |
28+
|----------------------------------------------------------+------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------|
29+
| __gap | uint256[38] | 12 | 0 | 1216 | src/contracts/core/StrategyManagerStorage.sol:StrategyManagerStorage |
2830
╰----------------------------------------------------------+------------------------------------------------------------+------+--------+-------+----------------------------------------------------------------------╯
2931

src/contracts/core/AllocationManager.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ contract AllocationManager is
132132

133133
_updateMaxMagnitude(params.operator, params.strategies[i], info.maxMagnitude);
134134

135-
// 6. Decrease and burn operators shares in the DelegationManager
136-
delegation.burnOperatorShares({
135+
// 6. Slash operators shares in the DelegationManager
136+
delegation.slashOperatorShares({
137137
operator: params.operator,
138138
strategy: params.strategies[i],
139139
prevMaxMagnitude: prevMaxMagnitude,

src/contracts/core/DelegationManager.sol

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ contract DelegationManager is
275275
}
276276

277277
/// @inheritdoc IDelegationManager
278-
function burnOperatorShares(
278+
function slashOperatorShares(
279279
address operator,
280280
IStrategy strategy,
281281
uint64 prevMaxMagnitude,
@@ -307,11 +307,9 @@ contract DelegationManager is
307307
sharesToDecrease: operatorSharesSlashed
308308
});
309309

310-
// NOTE: native ETH shares will be burned by a different mechanism in a future release
311-
if (strategy != beaconChainETHStrategy) {
312-
strategyManager.burnShares(strategy, totalDepositSharesToBurn);
313-
emit OperatorSharesBurned(operator, strategy, totalDepositSharesToBurn);
314-
}
310+
IShareManager shareManager = _getShareManager(strategy);
311+
// NOTE: for beaconChainETHStrategy, increased burnable shares currently have no mechanism for burning
312+
shareManager.increaseBurnableShares(strategy, totalDepositSharesToBurn);
315313
}
316314

317315
/**

src/contracts/core/StrategyManager.sol

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,19 @@ contract StrategyManager is
140140
strategy.withdraw(staker, token, shares);
141141
}
142142

143+
/// @inheritdoc IShareManager
144+
function increaseBurnableShares(IStrategy strategy, uint256 addedSharesToBurn) external onlyDelegationManager {
145+
burnableShares[strategy] += addedSharesToBurn;
146+
emit BurnableSharesIncreased(strategy, addedSharesToBurn);
147+
}
148+
143149
/// @inheritdoc IStrategyManager
144-
function burnShares(IStrategy strategy, uint256 sharesToBurn) external onlyDelegationManager {
150+
function burnShares(
151+
IStrategy strategy
152+
) external nonReentrant {
153+
uint256 sharesToBurn = burnableShares[strategy];
154+
burnableShares[strategy] = 0;
155+
emit BurnableSharesDecreased(strategy, sharesToBurn);
145156
// burning shares is functionally the same as withdrawing but with different destination address
146157
strategy.withdraw(DEFAULT_BURN_ADDRESS, strategy.underlyingToken(), sharesToBurn);
147158
}

src/contracts/core/StrategyManagerStorage.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ abstract contract StrategyManagerStorage is IStrategyManager {
6969
/// @dev Do not remove, deprecated storage.
7070
mapping(IStrategy strategy => bool) private __deprecated_thirdPartyTransfersForbidden;
7171

72+
/// @notice Returns the amount of `shares` that have been slashed on EigenLayer but not burned yet.
73+
mapping(IStrategy strategy => uint256) public burnableShares;
74+
7275
// Construction
7376

7477
/**
@@ -85,5 +88,5 @@ abstract contract StrategyManagerStorage is IStrategyManager {
8588
* variables without shifting down storage in the inheritance chain.
8689
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
8790
*/
88-
uint256[39] private __gap;
91+
uint256[38] private __gap;
8992
}

0 commit comments

Comments
 (0)