@@ -52,34 +52,41 @@ contract SlashEscrowFactory is Initializable, SlashEscrowFactoryStorage, Ownable
52
52
*/
53
53
54
54
/// @inheritdoc ISlashEscrowFactory
55
- function initiateSlashEscrow (
56
- OperatorSet calldata operatorSet ,
57
- uint256 slashId ,
58
- IStrategy strategy
59
- ) external virtual {
55
+ function initiateSlashEscrow (OperatorSet calldata operatorSet , uint256 slashId , IStrategy strategy ) external {
60
56
require (msg .sender == address (strategyManager), OnlyStrategyManager ());
61
57
62
58
// Create storage pointers for readability.
63
- EnumerableSet.Bytes32Set storage pendingOperatorSets = _pendingOperatorSets;
64
59
EnumerableSet.UintSet storage pendingSlashIds = _pendingSlashIds[operatorSet.key ()];
65
60
EnumerableSet.AddressSet storage pendingStrategiesForSlashId =
66
61
_pendingStrategiesForSlashId[operatorSet.key ()][slashId];
67
62
68
- // Add the slash ID, operator set, and strategy to their respective pending sets.
69
- pendingSlashIds.add (slashId);
70
- pendingOperatorSets.add (operatorSet.key ());
63
+ // Note: Since this function can be called multiple times for the same operatorSet/slashId, we check
64
+ // if the slash escrow is already deployed. If it is not, we deploy it and update the pending mappings.
65
+ if (! isDeployedSlashEscrow (operatorSet, slashId)) {
66
+ // Deploy the `SlashEscrow`.
67
+ _deploySlashEscrow (operatorSet, slashId);
68
+
69
+ // Update the pending mappings
70
+ _pendingOperatorSets.add (operatorSet.key ());
71
+ pendingSlashIds.add (slashId);
72
+
73
+ // Set the start block for the slash ID.
74
+ _slashIdToStartBlock[operatorSet.key ()][slashId] = uint32 (block .number );
75
+ }
76
+
77
+ // Add the strategy to the pending strategies for the slash ID.
71
78
pendingStrategiesForSlashId.add (address (strategy));
72
79
73
- // Set the start block for the slash ID.
74
- _slashIdToStartBlock[ operatorSet. key ()][ slashId] = uint32 ( block . number );
80
+ // Emit the start escrow event. We can use the block.number here because all strategies
81
+ // in a given operatorSet/ slashId will have their escrow initiated in the same transaction.
75
82
emit StartEscrow (operatorSet, slashId, strategy, uint32 (block .number ));
76
83
}
77
84
78
85
/// @inheritdoc ISlashEscrowFactory
79
86
function releaseSlashEscrow (
80
87
OperatorSet calldata operatorSet ,
81
88
uint256 slashId
82
- ) external virtual onlyWhenNotPaused (PAUSED_RELEASE_ESCROW) {
89
+ ) external onlyWhenNotPaused (PAUSED_RELEASE_ESCROW) {
83
90
address redistributionRecipient = allocationManager.getRedistributionRecipient (operatorSet);
84
91
85
92
// If the redistribution recipient is not the default burn address...
@@ -99,25 +106,8 @@ contract SlashEscrowFactory is Initializable, SlashEscrowFactoryStorage, Ownable
99
106
// the tokens from being released).
100
107
strategyManager.decreaseBurnOrRedistributableShares (operatorSet, slashId);
101
108
102
- // Deploy the counterfactual `SlashEscrow`.
103
- ISlashEscrow slashEscrow = deploySlashEscrow (operatorSet, slashId);
104
-
105
- // Release the slashEscrow
106
- _processSlashEscrow (operatorSet, slashId, slashEscrow, redistributionRecipient);
107
- }
108
-
109
- /// @inheritdoc ISlashEscrowFactory
110
- function deploySlashEscrow (OperatorSet calldata operatorSet , uint256 slashId ) public returns (ISlashEscrow) {
111
- ISlashEscrow slashEscrow = getSlashEscrow (operatorSet, slashId);
112
-
113
- // If the slash escrow is not deployed...
114
- if (! isDeployedSlashEscrow (slashEscrow)) {
115
- return ISlashEscrow (
116
- address (slashEscrowImplementation).cloneDeterministic (computeSlashEscrowSalt (operatorSet, slashId))
117
- );
118
- }
119
-
120
- return slashEscrow;
109
+ // Release the slashEscrow. The `SlashEscrow` is deployed in `initiateSlashEscrow`.
110
+ _processSlashEscrow (operatorSet, slashId, getSlashEscrow (operatorSet, slashId), redistributionRecipient);
121
111
}
122
112
123
113
/**
@@ -127,14 +117,14 @@ contract SlashEscrowFactory is Initializable, SlashEscrowFactoryStorage, Ownable
127
117
*/
128
118
129
119
/// @inheritdoc ISlashEscrowFactory
130
- function pauseEscrow (OperatorSet calldata operatorSet , uint256 slashId ) external virtual onlyPauser {
120
+ function pauseEscrow (OperatorSet calldata operatorSet , uint256 slashId ) external onlyPauser {
131
121
_checkNewPausedStatus (operatorSet, slashId, true );
132
122
_paused[operatorSet.key ()][slashId] = true ;
133
123
emit EscrowPaused (operatorSet, slashId);
134
124
}
135
125
136
126
/// @inheritdoc ISlashEscrowFactory
137
- function unpauseEscrow (OperatorSet calldata operatorSet , uint256 slashId ) external virtual onlyUnpauser {
127
+ function unpauseEscrow (OperatorSet calldata operatorSet , uint256 slashId ) external onlyUnpauser {
138
128
_checkNewPausedStatus (operatorSet, slashId, false );
139
129
_paused[operatorSet.key ()][slashId] = false ;
140
130
emit EscrowUnpaused (operatorSet, slashId);
@@ -228,6 +218,16 @@ contract SlashEscrowFactory is Initializable, SlashEscrowFactoryStorage, Ownable
228
218
require (_paused[operatorSet.key ()][slashId] != newPauseStatus, IPausable.InvalidNewPausedStatus ());
229
219
}
230
220
221
+ /**
222
+ * @notice Deploys a `SlashEscrow`
223
+ * @param operatorSet The operator set whose slash escrow is being deployed.
224
+ * @param slashId The slash ID of the slash escrow that is being deployed.
225
+ * @dev The slash escrow is deployed in `initiateSlashEscrow`
226
+ */
227
+ function _deploySlashEscrow (OperatorSet calldata operatorSet , uint256 slashId ) internal {
228
+ address (slashEscrowImplementation).cloneDeterministic (computeSlashEscrowSalt (operatorSet, slashId));
229
+ }
230
+
231
231
/**
232
232
*
233
233
* GETTERS
0 commit comments