Skip to content

Commit 798dd43

Browse files
feat: redistribution upgrade scripts (#1517)
**Motivation:** Need updated upgrade scripts without slash escrow **Modifications:** - Remove slash escrow - Add source chain conditionals - Blacklisted eigen and beigen tokens **Result:** Working upgrade scripts --------- Co-authored-by: clandestine.eth <[email protected]>
1 parent 49b3484 commit 798dd43

File tree

9 files changed

+146
-134
lines changed

9 files changed

+146
-134
lines changed

script/releases/Env.sol

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,14 @@ library Env {
356356
/**
357357
* Helpers
358358
*/
359+
function isSourceChain() internal view returns (bool) {
360+
return _envBool("SOURCE_CHAIN");
361+
}
362+
363+
function isDestinationChain() internal view returns (bool) {
364+
return _envBool("DESTINATION_CHAIN");
365+
}
366+
359367
function _deployedInstance(string memory name, uint256 idx) private view returns (address) {
360368
return ZEnvHelpers.state().deployedInstance(name, idx);
361369
}
@@ -414,6 +422,12 @@ library Env {
414422
return ZEnvHelpers.state().envU16(key);
415423
}
416424

425+
function _envBool(
426+
string memory key
427+
) private view returns (bool) {
428+
return ZEnvHelpers.state().envBool(key);
429+
}
430+
417431
address internal constant VM_ADDRESS = address(uint160(uint256(keccak256("hevm cheat code"))));
418432
Vm internal constant vm = Vm(VM_ADDRESS);
419433

script/releases/v.1.5.0-redistribution/1-deployContracts.s.sol

Lines changed: 57 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
1010

1111
/**
1212
* Purpose: use an EOA to deploy all of the new contracts for this upgrade.
13-
* This upgrade deploys a `SlashEscrowFactory` and a `SlashEscrow`. In addition it also upgrades:
13+
* This upgrades:
1414
* - `AllocationManager`
1515
* - `DelegationManager`
1616
* - `StrategyManager`
@@ -21,48 +21,11 @@ contract Deploy is EOADeployer {
2121
using Env for *;
2222

2323
function _runAsEOA() internal override {
24-
vm.startBroadcast();
25-
26-
/// SlashEscrow
27-
deployImpl({name: type(SlashEscrow).name, deployedTo: address(new SlashEscrow())});
28-
29-
/// SlashEscrowFactory
30-
31-
// For the `SlashEscrowFactory`, we use a different proxy admin where the community multisig is the admin
32-
address communityMultisig = Env.communityMultisig();
33-
ProxyAdmin proxyAdmin = new ProxyAdmin();
34-
proxyAdmin.transferOwnership(communityMultisig);
35-
36-
deployImpl({
37-
name: type(SlashEscrowFactory).name,
38-
deployedTo: address(
39-
new SlashEscrowFactory({
40-
_allocationManager: Env.proxy.allocationManager(),
41-
_strategyManager: Env.proxy.strategyManager(),
42-
_pauserRegistry: Env.impl.pauserRegistry(),
43-
_slashEscrowImplementation: Env.impl.slashEscrow(),
44-
_version: Env.deployVersion()
45-
})
46-
)
47-
});
24+
if (!Env.isSourceChain()) {
25+
return;
26+
}
4827

49-
deployProxy({
50-
name: type(SlashEscrowFactory).name,
51-
deployedTo: address(
52-
new TransparentUpgradeableProxy({
53-
_logic: address(Env.impl.slashEscrowFactory()),
54-
admin_: address(proxyAdmin),
55-
_data: abi.encodeCall(
56-
SlashEscrowFactory.initialize,
57-
(
58-
Env.executorMultisig(), // initialOwner
59-
0, // initialPausedStatus
60-
Env.SLASH_ESCROW_DELAY() // initialGlobalDelayBlocks
61-
)
62-
)
63-
})
64-
)
65-
});
28+
vm.startBroadcast();
6629

6730
// Core contracts: AllocationManager, DelegationManager, StrategyManager, EigenPodManager, Strategies
6831

@@ -72,6 +35,7 @@ contract Deploy is EOADeployer {
7235
deployedTo: address(
7336
new AllocationManager({
7437
_delegation: Env.proxy.delegationManager(),
38+
_eigenStrategy: Env.proxy.eigenStrategy(),
7539
_pauserRegistry: Env.impl.pauserRegistry(),
7640
_permissionController: Env.proxy.permissionController(),
7741
_DEALLOCATION_DELAY: Env.MIN_WITHDRAWAL_DELAY(),
@@ -102,8 +66,8 @@ contract Deploy is EOADeployer {
10266
name: type(StrategyManager).name,
10367
deployedTo: address(
10468
new StrategyManager({
69+
_allocationManager: Env.proxy.allocationManager(),
10570
_delegation: Env.proxy.delegationManager(),
106-
_slashEscrowFactory: Env.proxy.slashEscrowFactory(),
10771
_pauserRegistry: Env.impl.pauserRegistry(),
10872
_version: Env.deployVersion()
10973
})
@@ -159,20 +123,17 @@ contract Deploy is EOADeployer {
159123
)
160124
});
161125

162-
vm.stopBroadcast();
126+
// TODO: Blacklist EIGEN from StrategyFactory.
163127

164-
// Update environment variables
165-
zUpdate("slashEscrowProxyAdmin", address(proxyAdmin));
128+
vm.stopBroadcast();
166129
}
167130

168131
function testScript() public virtual {
169-
_runAsEOA();
132+
if (!Env.isSourceChain()) {
133+
return;
134+
}
170135

171-
// Validate slashEscrowFactory-specific variable
172-
SlashEscrowFactory slashEscrowFactory = Env.proxy.slashEscrowFactory();
173-
assertTrue(slashEscrowFactory.owner() == Env.executorMultisig(), "sef.owner invalid");
174-
assertTrue(slashEscrowFactory.paused() == 0, "sef.paused invalid");
175-
assertTrue(slashEscrowFactory.getGlobalEscrowDelay() == Env.SLASH_ESCROW_DELAY(), "sef.globalDelay invalid");
136+
_runAsEOA();
176137

177138
_validateNewImplAddresses({areMatching: false});
178139
_validateProxyAdmins();
@@ -189,22 +150,33 @@ contract Deploy is EOADeployer {
189150
function _validateNewImplAddresses(
190151
bool areMatching
191152
) internal view {
192-
/// can't check `SlashEscrowFactory` because it wasn't previously deployed
193-
194153
function (bool, string memory) internal pure assertion = areMatching ? _assertTrue : _assertFalse;
195154

155+
// AllocationManager
156+
assertion(
157+
_getProxyImpl(address(Env.proxy.allocationManager())) == address(Env.impl.allocationManager()),
158+
"allocationManager impl failed"
159+
);
160+
161+
// DelegationManager
196162
assertion(
197163
_getProxyImpl(address(Env.proxy.delegationManager())) == address(Env.impl.delegationManager()),
198164
"delegationManager impl failed"
199165
);
200166

167+
// StrategyManager
201168
assertion(
202-
_getProxyImpl(address(Env.proxy.allocationManager())) == address(Env.impl.allocationManager()),
203-
"allocationManager impl failed"
169+
_getProxyImpl(address(Env.proxy.strategyManager())) == address(Env.impl.strategyManager()),
170+
"strategyManager impl failed"
204171
);
205172

206-
/// strategies/
173+
// EigenPodManager
174+
assertion(
175+
_getProxyImpl(address(Env.proxy.eigenPodManager())) == address(Env.impl.eigenPodManager()),
176+
"eigenPodManager impl failed"
177+
);
207178

179+
// Strategies
208180
assertion(
209181
_getProxyImpl(address(Env.proxy.eigenStrategy())) == address(Env.impl.eigenStrategy()),
210182
"eigenStrategy impl failed"
@@ -225,26 +197,26 @@ contract Deploy is EOADeployer {
225197
}
226198

227199
/// @dev Ensure each deployed TUP/beacon is owned by the proxyAdmin/executorMultisig
228-
/// @dev Ensure the `SlashEscrowProxyAdmin` is owned by the slashEscrowProxyAdmin/communityMultisig
229200
function _validateProxyAdmins() internal view {
230201
address pa = Env.proxyAdmin();
231-
address slashEscrowProxyAdmin = Env.slashEscrowProxyAdmin();
232-
assertFalse(slashEscrowProxyAdmin == pa, "slashEscrowProxyAdmin invalid");
233202

203+
// AllocationManager
234204
assertTrue(
235-
_getProxyAdmin(address(Env.proxy.delegationManager())) == pa, "delegationManager proxyAdmin incorrect"
205+
_getProxyAdmin(address(Env.proxy.allocationManager())) == pa, "allocationManager proxyAdmin incorrect"
236206
);
237207

208+
// DelegationManager
238209
assertTrue(
239-
_getProxyAdmin(address(Env.proxy.allocationManager())) == pa, "allocationManager proxyAdmin incorrect"
210+
_getProxyAdmin(address(Env.proxy.delegationManager())) == pa, "delegationManager proxyAdmin incorrect"
240211
);
241212

213+
// StrategyManager
242214
assertTrue(_getProxyAdmin(address(Env.proxy.strategyManager())) == pa, "strategyManager proxyAdmin incorrect");
243215

216+
// EigenPodManager
244217
assertTrue(_getProxyAdmin(address(Env.proxy.eigenPodManager())) == pa, "eigenPodManager proxyAdmin incorrect");
245218

246-
/// strategies/
247-
219+
// Strategies
248220
assertTrue(_getProxyAdmin(address(Env.proxy.eigenStrategy())) == pa, "eigenStrategy proxyAdmin incorrect");
249221

250222
assertTrue(Env.beacon.strategyBase().owner() == Env.executorMultisig(), "strategyBase beacon owner incorrect");
@@ -256,29 +228,25 @@ contract Deploy is EOADeployer {
256228
"strategyBaseTVLLimits proxyAdmin incorrect"
257229
);
258230
}
259-
260-
// SlashEscrowProxyAdmin - proxyAdmin is unique and its admin is the community multisig
261-
assertTrue(
262-
_getSlashEscrowProxyAdmin(address(Env.proxy.slashEscrowFactory())) == slashEscrowProxyAdmin,
263-
"slashEscrowFactory proxyAdmin incorrect"
264-
);
265-
assertTrue(
266-
Ownable(address(slashEscrowProxyAdmin)).owner() == Env.communityMultisig(),
267-
"slashEscrowProxyAdmin owner incorrect"
268-
);
269231
}
270232

271233
/// @dev Validate the immutables set in the new implementation constructors
272234
function _validateImplConstructors() internal view {
273-
// SlashEscrow has no constructor
235+
// AllocationManager
274236
{
275-
SlashEscrowFactory slashEscrowFactory = Env.impl.slashEscrowFactory();
276-
assertTrue(slashEscrowFactory.allocationManager() == Env.proxy.allocationManager(), "sef.alm invalid");
277-
assertTrue(slashEscrowFactory.strategyManager() == Env.proxy.strategyManager(), "sef.sm invalid");
278-
assertTrue(slashEscrowFactory.pauserRegistry() == Env.impl.pauserRegistry(), "sef.pR invalid");
279-
assertTrue(slashEscrowFactory.slashEscrowImplementation() == Env.impl.slashEscrow(), "sef.se invalid");
237+
AllocationManager allocationManager = Env.impl.allocationManager();
238+
assertTrue(allocationManager.delegation() == Env.proxy.delegationManager(), "alm.dm invalid");
239+
assertTrue(allocationManager.eigenStrategy() == Env.proxy.eigenStrategy(), "alm.es invalid");
240+
assertTrue(allocationManager.pauserRegistry() == Env.impl.pauserRegistry(), "alm.pR invalid");
241+
assertTrue(allocationManager.permissionController() == Env.proxy.permissionController(), "alm.pc invalid");
242+
assertTrue(allocationManager.DEALLOCATION_DELAY() == Env.MIN_WITHDRAWAL_DELAY(), "alm.deallocDelay invalid");
243+
assertTrue(
244+
allocationManager.ALLOCATION_CONFIGURATION_DELAY() == Env.ALLOCATION_CONFIGURATION_DELAY(),
245+
"alm.configDelay invalid"
246+
);
280247
}
281248

249+
// DelegationManager
282250
{
283251
DelegationManager delegation = Env.impl.delegationManager();
284252
assertTrue(delegation.strategyManager() == Env.proxy.strategyManager(), "dm.sm invalid");
@@ -291,25 +259,14 @@ contract Deploy is EOADeployer {
291259
);
292260
}
293261

294-
{
295-
AllocationManager allocationManager = Env.impl.allocationManager();
296-
assertTrue(allocationManager.delegation() == Env.proxy.delegationManager(), "alm.dm invalid");
297-
assertTrue(allocationManager.pauserRegistry() == Env.impl.pauserRegistry(), "alm.pR invalid");
298-
assertTrue(allocationManager.permissionController() == Env.proxy.permissionController(), "alm.pc invalid");
299-
assertTrue(allocationManager.DEALLOCATION_DELAY() == Env.MIN_WITHDRAWAL_DELAY(), "alm.deallocDelay invalid");
300-
assertTrue(
301-
allocationManager.ALLOCATION_CONFIGURATION_DELAY() == Env.ALLOCATION_CONFIGURATION_DELAY(),
302-
"alm.configDelay invalid"
303-
);
304-
}
305-
262+
// StrategyManager
306263
{
307264
StrategyManager strategyManager = Env.impl.strategyManager();
308265
assertTrue(strategyManager.delegation() == Env.proxy.delegationManager(), "sm.dm invalid");
309-
assertTrue(strategyManager.slashEscrowFactory() == Env.proxy.slashEscrowFactory(), "sm.sef invalid");
310266
assertTrue(strategyManager.pauserRegistry() == Env.impl.pauserRegistry(), "sm.pR invalid");
311267
}
312268

269+
// EigenPodManager
313270
{
314271
EigenPodManager eigenPodManager = Env.impl.eigenPodManager();
315272
assertTrue(eigenPodManager.ethPOS() == Env.ethPOS(), "epm.ethPOS invalid");
@@ -318,8 +275,8 @@ contract Deploy is EOADeployer {
318275
assertTrue(eigenPodManager.pauserRegistry() == Env.impl.pauserRegistry(), "epm.pR invalid");
319276
}
320277

278+
// Strategies
321279
{
322-
/// strategies/
323280
EigenStrategy eigenStrategy = Env.impl.eigenStrategy();
324281
assertTrue(eigenStrategy.strategyManager() == Env.proxy.strategyManager(), "eigStrat.sm invalid");
325282
assertTrue(eigenStrategy.pauserRegistry() == Env.impl.pauserRegistry(), "eigStrat.pR invalid");
@@ -340,27 +297,27 @@ contract Deploy is EOADeployer {
340297
function _validateImplsInitialized() internal {
341298
bytes memory errInit = "Initializable: contract is already initialized";
342299

343-
SlashEscrowFactory slashEscrowFactory = Env.impl.slashEscrowFactory();
344-
vm.expectRevert(errInit);
345-
slashEscrowFactory.initialize(address(0), 0, 0);
346-
300+
// AllocationManager
347301
AllocationManager allocationManager = Env.impl.allocationManager();
348302
vm.expectRevert(errInit);
349303
allocationManager.initialize(0);
350304

305+
// DelegationManager
351306
DelegationManager delegation = Env.impl.delegationManager();
352307
vm.expectRevert(errInit);
353308
delegation.initialize(0);
354309

310+
// StrategyManager
355311
StrategyManager strategyManager = Env.impl.strategyManager();
356312
vm.expectRevert(errInit);
357313
strategyManager.initialize(address(0), address(0), 0);
358314

315+
// EigenPodManager
359316
EigenPodManager eigenPodManager = Env.impl.eigenPodManager();
360317
vm.expectRevert(errInit);
361318
eigenPodManager.initialize(address(0), 0);
362319

363-
/// strategies/
320+
// Strategies
364321
EigenStrategy eigenStrategy = Env.impl.eigenStrategy();
365322
vm.expectRevert(errInit);
366323
eigenStrategy.initialize(IEigen(address(0)), IBackingEigen(address(0)));
@@ -378,9 +335,8 @@ contract Deploy is EOADeployer {
378335
// On future upgrades, just tick the major/minor/patch to validate
379336
string memory expected = Env.deployVersion();
380337

381-
assertEq(Env.impl.slashEscrowFactory().version(), expected, "slashEscrowFactory version mismatch");
382-
assertEq(Env.impl.delegationManager().version(), expected, "delegationManager version mismatch");
383338
assertEq(Env.impl.allocationManager().version(), expected, "allocationManager version mismatch");
339+
assertEq(Env.impl.delegationManager().version(), expected, "delegationManager version mismatch");
384340
assertEq(Env.impl.strategyManager().version(), expected, "strategyManager version mismatch");
385341
assertEq(Env.impl.eigenPodManager().version(), expected, "eigenPodManager version mismatch");
386342
assertEq(Env.impl.eigenStrategy().version(), expected, "eigenStrategy version mismatch");
@@ -402,12 +358,6 @@ contract Deploy is EOADeployer {
402358
return ProxyAdmin(Env.proxyAdmin()).getProxyAdmin(ITransparentUpgradeableProxy(proxy));
403359
}
404360

405-
function _getSlashEscrowProxyAdmin(
406-
address proxy
407-
) internal view returns (address) {
408-
return ProxyAdmin(Env.slashEscrowProxyAdmin()).getProxyAdmin(ITransparentUpgradeableProxy(proxy));
409-
}
410-
411361
function _assertTrue(bool b, string memory err) private pure {
412362
assertTrue(b, err);
413363
}

script/releases/v.1.5.0-redistribution/2-queueUpgrade.s.sol

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {Deploy} from "./1-deployContracts.s.sol";
55
import "../Env.sol";
66

77
import {MultisigBuilder} from "zeus-templates/templates/MultisigBuilder.sol";
8-
import "zeus-templates/utils/Encode.sol";
8+
import {MultisigCall, Encode} from "zeus-templates/utils/Encode.sol";
99

1010
import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol";
1111

@@ -21,6 +21,10 @@ contract QueueUpgrade is MultisigBuilder, Deploy {
2121
using Encode for *;
2222

2323
function _runAsMultisig() internal virtual override prank(Env.opsMultisig()) {
24+
if (!Env.isSourceChain()) {
25+
return;
26+
}
27+
2428
bytes memory calldata_to_executor = _getCalldataToExecutor();
2529

2630
TimelockController timelock = Env.timelockController();
@@ -91,6 +95,10 @@ contract QueueUpgrade is MultisigBuilder, Deploy {
9195
}
9296

9397
function testScript() public virtual override {
98+
if (!Env.isSourceChain()) {
99+
return;
100+
}
101+
94102
runAsEOA();
95103

96104
TimelockController timelock = Env.timelockController();

0 commit comments

Comments
 (0)