@@ -17,6 +17,21 @@ import { Solarray } from "scripts/libraries/Solarray.sol";
17
17
// since they are set to the initial proxy admin owner.
18
18
contract DeploySuperchain2 is Script {
19
19
struct Input {
20
+ // Role inputs.
21
+ address guardian;
22
+ address protocolVersionsOwner;
23
+ address superchainProxyAdminOwner;
24
+ // Other inputs.
25
+ bool paused;
26
+ bytes32 recommendedProtocolVersion;
27
+ bytes32 requiredProtocolVersion;
28
+ }
29
+
30
+ /// @notice InternalInput is created based on Input by converting the bytes32 protocol versions to ProtocolVersion types
31
+ //
32
+ // ProtocolVersion type is based on uint256 which conflicts with downstream types (like e.g. ProtocolVersion from op-geth)
33
+ // so to keep the ABI externally compatible, we expose it simply as bytes32
34
+ struct InternalInput {
20
35
// Role inputs.
21
36
address guardian;
22
37
address protocolVersionsOwner;
@@ -40,7 +55,9 @@ contract DeploySuperchain2 is Script {
40
55
// -------- Core Deployment Methods --------
41
56
42
57
function run (Input memory _input ) public returns (Output memory output_ ) {
43
- assertValidInput (_input);
58
+ InternalInput memory internalInput = toInternalInput (_input);
59
+
60
+ assertValidInput (internalInput);
44
61
45
62
// Notice that we do not do any explicit verification here that inputs are set. This is because
46
63
// the verification happens elsewhere:
@@ -52,23 +69,23 @@ contract DeploySuperchain2 is Script {
52
69
// additional verification logic.
53
70
54
71
// Deploy the proxy admin, with the owner set to the deployer.
55
- deploySuperchainProxyAdmin (_input , output_);
72
+ deploySuperchainProxyAdmin (internalInput , output_);
56
73
57
74
// Deploy and initialize the superchain contracts.
58
- deploySuperchainImplementationContracts (_input , output_);
59
- deployAndInitializeSuperchainConfig (_input , output_);
60
- deployAndInitializeProtocolVersions (_input , output_);
75
+ deploySuperchainImplementationContracts (internalInput , output_);
76
+ deployAndInitializeSuperchainConfig (internalInput , output_);
77
+ deployAndInitializeProtocolVersions (internalInput , output_);
61
78
62
79
// Transfer ownership of the ProxyAdmin from the deployer to the specified owner.
63
- transferProxyAdminOwnership (_input , output_);
80
+ transferProxyAdminOwnership (internalInput , output_);
64
81
65
82
// Output assertions, to make sure outputs were assigned correctly.
66
- assertValidOutput (_input , output_);
83
+ assertValidOutput (internalInput , output_);
67
84
}
68
85
69
86
// -------- Deployment Steps --------
70
87
71
- function deploySuperchainProxyAdmin (Input memory , Output memory _output ) internal {
88
+ function deploySuperchainProxyAdmin (InternalInput memory , Output memory _output ) private {
72
89
// Deploy the proxy admin, with the owner set to the deployer.
73
90
// We explicitly specify the deployer as `msg.sender` because for testing we deploy this script from a test
74
91
// contract. If we provide no argument, the foundry default sender would be the broadcaster during test, but the
@@ -85,7 +102,7 @@ contract DeploySuperchain2 is Script {
85
102
_output.superchainProxyAdmin = superchainProxyAdmin;
86
103
}
87
104
88
- function deploySuperchainImplementationContracts (Input memory , Output memory _output ) internal {
105
+ function deploySuperchainImplementationContracts (InternalInput memory , Output memory _output ) private {
89
106
// Deploy implementation contracts.
90
107
ISuperchainConfig superchainConfigImpl = ISuperchainConfig (
91
108
DeployUtils.createDeterministic ({
@@ -109,9 +126,7 @@ contract DeploySuperchain2 is Script {
109
126
_output.protocolVersionsImpl = protocolVersionsImpl;
110
127
}
111
128
112
- function deployAndInitializeSuperchainConfig (Input memory _input , Output memory _output ) internal {
113
- assertValidGuardianInput (_input);
114
-
129
+ function deployAndInitializeSuperchainConfig (InternalInput memory _input , Output memory _output ) private {
115
130
address guardian = _input.guardian;
116
131
bool paused = _input.paused;
117
132
@@ -138,9 +153,7 @@ contract DeploySuperchain2 is Script {
138
153
_output.superchainConfigProxy = superchainConfigProxy;
139
154
}
140
155
141
- function deployAndInitializeProtocolVersions (Input memory _input , Output memory _output ) internal {
142
- assertValidProtocolInput (_input);
143
-
156
+ function deployAndInitializeProtocolVersions (InternalInput memory _input , Output memory _output ) private {
144
157
address protocolVersionsOwner = _input.protocolVersionsOwner;
145
158
ProtocolVersion requiredProtocolVersion = _input.requiredProtocolVersion;
146
159
ProtocolVersion recommendedProtocolVersion = _input.recommendedProtocolVersion;
@@ -171,9 +184,7 @@ contract DeploySuperchain2 is Script {
171
184
_output.protocolVersionsProxy = protocolVersionsProxy;
172
185
}
173
186
174
- function transferProxyAdminOwnership (Input memory _input , Output memory _output ) internal {
175
- assertValidProxyInput (_input);
176
-
187
+ function transferProxyAdminOwnership (InternalInput memory _input , Output memory _output ) private {
177
188
address superchainProxyAdminOwner = _input.superchainProxyAdminOwner;
178
189
179
190
IProxyAdmin superchainProxyAdmin = _output.superchainProxyAdmin;
@@ -183,17 +194,8 @@ contract DeploySuperchain2 is Script {
183
194
superchainProxyAdmin.transferOwnership (superchainProxyAdminOwner);
184
195
}
185
196
186
- function assertValidInput (Input memory _input ) internal pure {
187
- assertValidGuardianInput (_input);
188
- assertValidProxyInput (_input);
189
- assertValidProtocolInput (_input);
190
- }
191
-
192
- function assertValidGuardianInput (Input memory _input ) internal pure {
197
+ function assertValidInput (InternalInput memory _input ) internal pure {
193
198
require (_input.guardian != address (0 ), "DeploySuperchain: guardian not set " );
194
- }
195
-
196
- function assertValidProtocolInput (Input memory _input ) internal pure {
197
199
require (_input.protocolVersionsOwner != address (0 ), "DeploySuperchain: protocolVersionsOwner not set " );
198
200
require (
199
201
ProtocolVersion.unwrap (_input.requiredProtocolVersion) != 0 ,
@@ -203,20 +205,17 @@ contract DeploySuperchain2 is Script {
203
205
ProtocolVersion.unwrap (_input.recommendedProtocolVersion) != 0 ,
204
206
"DeploySuperchain: recommendedProtocolVersion not set "
205
207
);
206
- }
207
-
208
- function assertValidProxyInput (Input memory _input ) internal pure {
209
208
require (_input.superchainProxyAdminOwner != address (0 ), "DeploySuperchain: superchainProxyAdminOwner not set " );
210
209
}
211
210
212
- function assertValidOutput (Input memory _input , Output memory _output ) public {
211
+ function assertValidOutput (InternalInput memory _input , Output memory _output ) public {
213
212
assertValidContractAddresses (_input, _output);
214
213
assertValidSuperchainProxyAdmin (_input, _output);
215
214
assertValidSuperchainConfig (_input, _output);
216
215
assertValidProtocolVersions (_input, _output);
217
216
}
218
217
219
- function assertValidContractAddresses (Input memory , Output memory _output ) internal {
218
+ function assertValidContractAddresses (InternalInput memory , Output memory _output ) internal {
220
219
address [] memory addrs = Solarray.addresses (
221
220
address (_output.superchainProxyAdmin),
222
221
address (_output.superchainConfigImpl),
@@ -238,11 +237,11 @@ contract DeploySuperchain2 is Script {
238
237
// sol-style-malformed-require
239
238
}
240
239
241
- function assertValidSuperchainProxyAdmin (Input memory _input , Output memory _output ) internal view {
240
+ function assertValidSuperchainProxyAdmin (InternalInput memory _input , Output memory _output ) internal view {
242
241
require (_output.superchainProxyAdmin.owner () == _input.superchainProxyAdminOwner, "SPA-10 " );
243
242
}
244
243
245
- function assertValidSuperchainConfig (Input memory _input , Output memory _output ) internal {
244
+ function assertValidSuperchainConfig (InternalInput memory _input , Output memory _output ) internal {
246
245
// Proxy checks.
247
246
ISuperchainConfig superchainConfig = _output.superchainConfigProxy;
248
247
DeployUtils.assertInitialized ({
@@ -270,7 +269,7 @@ contract DeploySuperchain2 is Script {
270
269
require (superchainConfig.paused () == false , "SUPCON-60 " );
271
270
}
272
271
273
- function assertValidProtocolVersions (Input memory _input , Output memory _output ) internal {
272
+ function assertValidProtocolVersions (InternalInput memory _input , Output memory _output ) internal {
274
273
// Proxy checks.
275
274
IProtocolVersions pv = _output.protocolVersionsProxy;
276
275
DeployUtils.assertInitialized ({ _contractAddress: address (pv), _isProxy: true , _slot: 0 , _offset: 0 });
@@ -294,4 +293,15 @@ contract DeploySuperchain2 is Script {
294
293
require (ProtocolVersion.unwrap (pv.required ()) == 0 , "PV-70 " );
295
294
require (ProtocolVersion.unwrap (pv.recommended ()) == 0 , "PV-80 " );
296
295
}
296
+
297
+ function toInternalInput (Input memory _input ) internal pure returns (InternalInput memory input_ ) {
298
+ input_ = InternalInput (
299
+ _input.guardian,
300
+ _input.protocolVersionsOwner,
301
+ _input.superchainProxyAdminOwner,
302
+ _input.paused,
303
+ ProtocolVersion.wrap (uint256 (_input.recommendedProtocolVersion)),
304
+ ProtocolVersion.wrap (uint256 (_input.requiredProtocolVersion))
305
+ );
306
+ }
297
307
}
0 commit comments