-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSystemDeploy.s.sol
133 lines (119 loc) · 5.04 KB
/
SystemDeploy.s.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
pragma solidity 0.8.25;
import {MultisigProposal} from
"@forge-proposal-simulator/src/proposals/MultisigProposal.sol";
import {Addresses} from "@forge-proposal-simulator/addresses/Addresses.sol";
import {Guard} from "src/Guard.sol";
import {Timelock} from "src/Timelock.sol";
import {TimelockFactory} from "src/TimelockFactory.sol";
import {InstanceDeployer} from "src/InstanceDeployer.sol";
import {AddressCalculation} from "src/views/AddressCalculation.sol";
import {RecoverySpellFactory} from "src/RecoverySpellFactory.sol";
/// @notice system deployment contract
/// all contracts are permissionless
/// DO_PRINT=false DO_BUILD=false DO_RUN=false DO_DEPLOY=true DO_VALIDATE=true forge script src/deploy/SystemDeploy.s.sol:SystemDeploy --fork-url base -vvvvv
contract SystemDeploy is MultisigProposal {
bytes32 public salt =
0x0000000000000000000000000000000000000000000000000000000000003afe;
constructor() {
uint256[] memory chainIds = new uint256[](4);
chainIds[0] = 1;
chainIds[1] = 8453;
chainIds[2] = 84532;
chainIds[3] = 11155420;
addresses = new Addresses("./addresses", chainIds);
}
function name() public pure override returns (string memory) {
return "SYS_DEPLOY";
}
function description() public pure override returns (string memory) {
return "Deploy Factories, Instance Deployer, Guard and View contracts";
}
function deploy() public override {
if (!addresses.isAddressSet("TIMELOCK_FACTORY")) {
TimelockFactory factory = new TimelockFactory{salt: salt}();
addresses.addAddress("TIMELOCK_FACTORY", address(factory), true);
}
if (!addresses.isAddressSet("RECOVERY_SPELL_FACTORY")) {
RecoverySpellFactory recoveryFactory =
new RecoverySpellFactory{salt: salt}();
addresses.addAddress(
"RECOVERY_SPELL_FACTORY", address(recoveryFactory), true
);
}
if (!addresses.isAddressSet("GUARD")) {
Guard guard = new Guard{salt: salt}();
addresses.addAddress("GUARD", address(guard), true);
}
if (!addresses.isAddressSet("INSTANCE_DEPLOYER")) {
InstanceDeployer deployer = new InstanceDeployer{salt: salt}(
addresses.getAddress("SAFE_FACTORY"),
addresses.getAddress("SAFE_LOGIC"),
addresses.getAddress("TIMELOCK_FACTORY"),
addresses.getAddress("GUARD"),
addresses.getAddress("MULTICALL3")
);
addresses.addAddress("INSTANCE_DEPLOYER", address(deployer), true);
}
if (!addresses.isAddressSet("ADDRESS_CALCULATION")) {
AddressCalculation addressCalculation = new AddressCalculation{
salt: salt
}(addresses.getAddress("INSTANCE_DEPLOYER"));
addresses.addAddress(
"ADDRESS_CALCULATION", address(addressCalculation), true
);
}
}
function validate() public view override {
if (addresses.isAddressSet("TIMELOCK_FACTORY")) {
address factory = addresses.getAddress("TIMELOCK_FACTORY");
assertEq(
keccak256(factory.code),
keccak256(type(TimelockFactory).runtimeCode),
"Incorrect TimelockFactory Bytecode"
);
address guard = addresses.getAddress("GUARD");
assertEq(
keccak256(guard.code),
keccak256(type(Guard).runtimeCode),
"Incorrect Guard Bytecode"
);
address recoverySpellFactory =
addresses.getAddress("RECOVERY_SPELL_FACTORY");
assertEq(
keccak256(recoverySpellFactory.code),
keccak256(type(RecoverySpellFactory).runtimeCode),
"Incorrect RecoverySpellFactory Bytecode"
);
/// cannot check bytecode, following error is thrown when trying:
/// `"runtimeCode" is not available for contracts containing
/// immutable variables.`
InstanceDeployer deployer =
InstanceDeployer(addresses.getAddress("INSTANCE_DEPLOYER"));
assertEq(
deployer.safeProxyFactory(),
addresses.getAddress("SAFE_FACTORY"),
"incorrect safe proxy factory"
);
assertEq(
deployer.safeProxyLogic(),
addresses.getAddress("SAFE_LOGIC"),
"incorrect safe logic contract"
);
assertEq(
deployer.timelockFactory(),
addresses.getAddress("TIMELOCK_FACTORY"),
"incorrect timelock factory"
);
assertEq(
deployer.guard(),
addresses.getAddress("GUARD"),
"incorrect GUARD"
);
assertEq(
deployer.multicall3(),
addresses.getAddress("MULTICALL3"),
"incorrect MULTICALL3"
);
}
}
}