Skip to content

Commit 5bb0fda

Browse files
committed
multisig
1 parent 5084f3a commit 5bb0fda

File tree

1 file changed

+51
-28
lines changed

1 file changed

+51
-28
lines changed

contracts/test/helpers/Utils.sol

+51-28
Original file line numberDiff line numberDiff line change
@@ -9,61 +9,84 @@ import {OPSuccinctL2OutputOracle} from "src/OPSuccinctL2OutputOracle.sol";
99

1010
contract Utils is Test, JSONDecoder {
1111
function deployWithConfig(Config memory cfg) public returns (address) {
12-
address OPSuccinctL2OutputOracleImpl = address(new OPSuccinctL2OutputOracle());
12+
address OPSuccinctL2OutputOracleImpl = address(
13+
new OPSuccinctL2OutputOracle()
14+
);
1315
address l2OutputOracleProxy = address(new Proxy(address(this)));
1416

1517
// Upgrade the proxy to point to the implementation and call initialize().
1618
// 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+
);
1825

1926
// Transfer ownership of proxy to owner specified in the config.
2027
Proxy(payable(l2OutputOracleProxy)).changeAdmin(cfg.owner);
2128

2229
return l2OutputOracleProxy;
2330
}
2431

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 {
2838
// require that the verifier gateway is deployed
2939
require(
3040
address(cfg.verifierGateway).code.length > 0,
3141
"OPSuccinctL2OutputOracleUpgrader: verifier gateway not deployed"
3242
);
3343

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+
});
4354

4455
// If we are spoofing the admin (used in testing), start prank.
4556
if (_spoofedAdmin != address(0)) vm.startPrank(_spoofedAdmin);
4657

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+
4780
Proxy(payable(l2OutputOracleProxy)).upgradeToAndCall(
4881
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
6283
);
6384
}
6485

6586
// 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) {
6790
string memory root = vm.projectRoot();
6891
string memory path = string.concat(root, "/", filepath);
6992
string memory json = vm.readFile(path);

0 commit comments

Comments
 (0)