1+ // SPDX-License-Identifier: BUSL-1.1
2+ pragma solidity ^ 0.8.12 ;
3+
4+ import {EOADeployer} from "zeus-templates/templates/EOADeployer.sol " ;
5+ import "../Env.sol " ;
6+
7+ import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol " ;
8+ import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol " ;
9+ import "@openzeppelin/contracts/token/ERC20/IERC20.sol " ;
10+ import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol " ;
11+
12+ contract Deploy is EOADeployer {
13+ using Env for * ;
14+
15+ function _runAsEOA () internal override {
16+ vm.startBroadcast ();
17+ deployImpl ({
18+ name: type (AllocationManager).name,
19+ deployedTo: address (new AllocationManager ({
20+ _delegation: Env.proxy.delegationManager (),
21+ _pauserRegistry: Env.impl.pauserRegistry (),
22+ _permissionController: Env.proxy.permissionController (),
23+ _DEALLOCATION_DELAY: Env.MIN_WITHDRAWAL_DELAY (),
24+ _ALLOCATION_CONFIGURATION_DELAY: Env.ALLOCATION_CONFIGURATION_DELAY ()
25+ }))
26+ });
27+
28+ deployImpl ({
29+ name: type (DelegationManager).name,
30+ deployedTo: address (new DelegationManager ({
31+ _strategyManager: Env.proxy.strategyManager (),
32+ _eigenPodManager: Env.proxy.eigenPodManager (),
33+ _allocationManager: Env.proxy.allocationManager (),
34+ _pauserRegistry: Env.impl.pauserRegistry (),
35+ _permissionController: Env.proxy.permissionController (),
36+ _MIN_WITHDRAWAL_DELAY: Env.MIN_WITHDRAWAL_DELAY ()
37+ }))
38+ });
39+
40+ vm.stopBroadcast ();
41+ }
42+
43+ function testDeploy () public virtual {
44+ _runAsEOA ();
45+ _validateNewImplAddresses (false );
46+ _validateImplConstructors ();
47+ _validateImplsInitialized ();
48+ }
49+
50+
51+ /// @dev Validate that the `Env.impl` addresses are updated to be distinct from what the proxy
52+ /// admin reports as the current implementation address.
53+ ///
54+ /// Note: The upgrade script can call this with `areMatching == true` to check that these impl
55+ /// addresses _are_ matches.
56+ function _validateNewImplAddresses (bool areMatching ) internal view {
57+ function (address , address , string memory ) internal pure assertion =
58+ areMatching ? _assertMatch : _assertNotMatch;
59+
60+
61+ assertion (
62+ _getProxyImpl (address (Env.proxy.delegationManager ())),
63+ address (Env.impl.delegationManager ()),
64+ "delegationManager impl failed "
65+ );
66+
67+ assertion (
68+ _getProxyImpl (address (Env.proxy.allocationManager ())),
69+ address (Env.impl.allocationManager ()),
70+ "allocationManager impl failed "
71+ );
72+ }
73+
74+ /// @dev Validate the immutables set in the new implementation constructors
75+ function _validateImplConstructors () internal view {
76+ AllocationManager allocationManager = Env.impl.allocationManager ();
77+ assertTrue (allocationManager.delegation () == Env.proxy.delegationManager (), "alm.dm invalid " );
78+ assertTrue (allocationManager.pauserRegistry () == Env.impl.pauserRegistry (), "alm.pR invalid " );
79+ assertTrue (allocationManager.permissionController () == Env.proxy.permissionController (), "alm.pc invalid " );
80+ assertTrue (allocationManager.DEALLOCATION_DELAY () == Env.MIN_WITHDRAWAL_DELAY (), "alm.deallocDelay invalid " );
81+ assertTrue (allocationManager.ALLOCATION_CONFIGURATION_DELAY () == Env.ALLOCATION_CONFIGURATION_DELAY (), "alm.configDelay invalid " );
82+
83+
84+ DelegationManager delegation = Env.impl.delegationManager ();
85+ assertTrue (delegation.strategyManager () == Env.proxy.strategyManager (), "dm.sm invalid " );
86+ assertTrue (delegation.eigenPodManager () == Env.proxy.eigenPodManager (), "dm.epm invalid " );
87+ assertTrue (delegation.allocationManager () == Env.proxy.allocationManager (), "dm.alm invalid " );
88+ assertTrue (delegation.pauserRegistry () == Env.impl.pauserRegistry (), "dm.pR invalid " );
89+ assertTrue (delegation.permissionController () == Env.proxy.permissionController (), "dm.pc invalid " );
90+ assertTrue (delegation.minWithdrawalDelayBlocks () == Env.MIN_WITHDRAWAL_DELAY (), "dm.withdrawalDelay invalid " );
91+ }
92+
93+ /// @dev Call initialize on all deployed implementations to ensure initializers are disabled
94+ function _validateImplsInitialized () internal {
95+ bytes memory errInit = "Initializable: contract is already initialized " ;
96+
97+ AllocationManager allocationManager = Env.impl.allocationManager ();
98+ vm.expectRevert (errInit);
99+ allocationManager.initialize (address (0 ), 0 );
100+
101+ DelegationManager delegation = Env.impl.delegationManager ();
102+ vm.expectRevert (errInit);
103+ delegation.initialize (address (0 ), 0 );
104+ }
105+
106+ /// @dev Query and return `proxyAdmin.getProxyImplementation(proxy)`
107+ function _getProxyImpl (address proxy ) internal view returns (address ) {
108+ return ProxyAdmin (Env.proxyAdmin ()).getProxyImplementation (ITransparentUpgradeableProxy (proxy));
109+ }
110+
111+ /// @dev Query and return `proxyAdmin.getProxyAdmin(proxy)`
112+ function _getProxyAdmin (address proxy ) internal view returns (address ) {
113+ return ProxyAdmin (Env.proxyAdmin ()).getProxyAdmin (ITransparentUpgradeableProxy (proxy));
114+ }
115+
116+ function _assertMatch (address a , address b , string memory err ) private pure {
117+ assertEq (a, b, err);
118+ }
119+
120+ function _assertNotMatch (address a , address b , string memory err ) private pure {
121+ assertNotEq (a, b, err);
122+ }
123+ }
0 commit comments