@@ -9,61 +9,84 @@ import {OPSuccinctL2OutputOracle} from "src/OPSuccinctL2OutputOracle.sol";
9
9
10
10
contract Utils is Test , JSONDecoder {
11
11
function deployWithConfig (Config memory cfg ) public returns (address ) {
12
- address OPSuccinctL2OutputOracleImpl = address (new OPSuccinctL2OutputOracle ());
12
+ address OPSuccinctL2OutputOracleImpl = address (
13
+ new OPSuccinctL2OutputOracle ()
14
+ );
13
15
address l2OutputOracleProxy = address (new Proxy (address (this )));
14
16
15
17
// Upgrade the proxy to point to the implementation and call initialize().
16
18
// Override the starting output root and timestmp with the passed values.
17
- upgradeAndInitialize (OPSuccinctL2OutputOracleImpl, cfg, l2OutputOracleProxy, address (0 ));
19
+ upgradeAndInitialize (
20
+ OPSuccinctL2OutputOracleImpl,
21
+ cfg,
22
+ l2OutputOracleProxy,
23
+ address (0 )
24
+ );
18
25
19
26
// Transfer ownership of proxy to owner specified in the config.
20
27
Proxy (payable (l2OutputOracleProxy)).changeAdmin (cfg.owner);
21
28
22
29
return l2OutputOracleProxy;
23
30
}
24
31
25
- function upgradeAndInitialize (address impl , Config memory cfg , address l2OutputOracleProxy , address _spoofedAdmin )
26
- public
27
- {
32
+ function upgradeAndInitialize (
33
+ address impl ,
34
+ Config memory cfg ,
35
+ address l2OutputOracleProxy ,
36
+ address _spoofedAdmin
37
+ ) public {
28
38
// require that the verifier gateway is deployed
29
39
require (
30
40
address (cfg.verifierGateway).code.length > 0 ,
31
41
"OPSuccinctL2OutputOracleUpgrader: verifier gateway not deployed "
32
42
);
33
43
34
- OPSuccinctL2OutputOracle.InitParams memory initParams = OPSuccinctL2OutputOracle.InitParams ({
35
- chainId: cfg.chainId,
36
- verifierGateway: cfg.verifierGateway,
37
- aggregationVkey: cfg.aggregationVkey,
38
- rangeVkeyCommitment: cfg.rangeVkeyCommitment,
39
- owner: cfg.owner,
40
- startingOutputRoot: cfg.startingOutputRoot,
41
- rollupConfigHash: cfg.rollupConfigHash
42
- });
44
+ OPSuccinctL2OutputOracle.InitParams
45
+ memory initParams = OPSuccinctL2OutputOracle.InitParams ({
46
+ chainId: cfg.chainId,
47
+ verifierGateway: cfg.verifierGateway,
48
+ aggregationVkey: cfg.aggregationVkey,
49
+ rangeVkeyCommitment: cfg.rangeVkeyCommitment,
50
+ owner: cfg.owner,
51
+ startingOutputRoot: cfg.startingOutputRoot,
52
+ rollupConfigHash: cfg.rollupConfigHash
53
+ });
43
54
44
55
// If we are spoofing the admin (used in testing), start prank.
45
56
if (_spoofedAdmin != address (0 )) vm.startPrank (_spoofedAdmin);
46
57
58
+ bytes memory upgradeCalldata = abi.encodeCall (
59
+ OPSuccinctL2OutputOracle.initialize,
60
+ (
61
+ cfg.submissionInterval,
62
+ cfg.l2BlockTime,
63
+ cfg.startingBlockNumber,
64
+ cfg.startingTimestamp,
65
+ cfg.proposer,
66
+ cfg.challenger,
67
+ cfg.finalizationPeriod,
68
+ initParams
69
+ )
70
+ );
71
+
72
+ // Raw calldata for a call by a multisig.
73
+ bytes memory multisigCalldata = abi.encodeWithSelector (
74
+ Proxy.upgradeToAndCall.selector ,
75
+ impl,
76
+ upgradeCalldata
77
+ );
78
+ console.logBytes (multisigCalldata);
79
+
47
80
Proxy (payable (l2OutputOracleProxy)).upgradeToAndCall (
48
81
impl,
49
- abi.encodeCall (
50
- OPSuccinctL2OutputOracle.initialize,
51
- (
52
- cfg.submissionInterval,
53
- cfg.l2BlockTime,
54
- cfg.startingBlockNumber,
55
- cfg.startingTimestamp,
56
- cfg.proposer,
57
- cfg.challenger,
58
- cfg.finalizationPeriod,
59
- initParams
60
- )
61
- )
82
+ upgradeCalldata
62
83
);
63
84
}
64
85
65
86
// Read the config from the json file.
66
- function readJson (string memory filepath ) public view returns (Config memory ) {
87
+ function readJson (
88
+ string memory filepath
89
+ ) public view returns (Config memory ) {
67
90
string memory root = vm.projectRoot ();
68
91
string memory path = string .concat (root, "/ " , filepath);
69
92
string memory json = vm.readFile (path);
0 commit comments