Skip to content

Commit c18b9b3

Browse files
committed
Deploy and Initialize L1 System Config
1 parent 03dc404 commit c18b9b3

File tree

3 files changed

+71
-19
lines changed

3 files changed

+71
-19
lines changed
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity =0.8.24;
3+
4+
import {Script} from "forge-std/Script.sol";
5+
import {SystemConfig} from "../../src/L1/system-contract/SystemConfig.sol"; // adjust the relative path as necessary
6+
import {console} from "forge-std/console.sol";
7+
8+
contract DeployL1SystemConfig is Script {
9+
function run() external {
10+
// Retrieve the deployer private key from environment variables
11+
uint256 deployerKey = vm.envUint("L1_DEPLOYER_PRIVATE_KEY");
12+
// Read the intended owner from an environment variable (for example, L1_SCROLL_OWNER_ADDR)
13+
address ownerAddr = vm.envAddress("L1_SCROLL_OWNER_ADDR");
14+
15+
vm.startBroadcast(deployerKey);
16+
17+
// Deploy the SystemConfig contract with the specified owner.
18+
SystemConfig sysConfig = new SystemConfig(ownerAddr);
19+
20+
console.log("Deployed SystemConfig at address:", address(sysConfig));
21+
22+
vm.stopBroadcast();
23+
}
24+
}

scripts/foundry/InitializeL1ScrollOwner.s.sol

-19
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import {ScrollChain} from "../../src/L1/rollup/ScrollChain.sol";
2121
import {ScrollOwner} from "../../src/misc/ScrollOwner.sol";
2222
import {Whitelist} from "../../src/L2/predeploys/Whitelist.sol";
2323

24-
import {SystemConfig} from "../../src/L1/system-contract/SystemConfig.sol";
25-
2624

2725
// solhint-disable max-states-count
2826
// solhint-disable state-visibility
@@ -279,21 +277,4 @@ contract InitializeL1ScrollOwner is Script {
279277
owner.updateAccess(L1_ENFORCED_TX_GATEWAY_PROXY_ADDR, _selectors, SCROLL_MULTISIG_NO_DELAY_ROLE, true);
280278
owner.updateAccess(L1_ENFORCED_TX_GATEWAY_PROXY_ADDR, _selectors, EMERGENCY_MULTISIG_NO_DELAY_ROLE, true);
281279
}
282-
283-
function configSystemContract() internal {
284-
// If we already have deployed it, just do:
285-
SystemConfig sys = SystemConfig(SYSTEM_CONTRACT_ADDR);
286-
287-
// sys has a normal constructor that set the "owner" to `ScrollOwner`.
288-
// Now we want to let the Security Council call `addSigner(...)` with no delay.
289-
bytes4[] memory selectors = new bytes4[](1);
290-
selectors[0] = sys.updateSigner.selector;
291-
292-
owner.updateAccess(
293-
SYSTEM_CONTRACT_ADDR, // the system contract
294-
selectors, // array of function selectors (onlyOwner)
295-
SECURITY_COUNCIL_NO_DELAY_ROLE,
296-
true
297-
);
298-
}
299280
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity =0.8.24;
3+
4+
import { Script } from "forge-std/Script.sol";
5+
import { SystemConfig } from "../../src/L1/system-contract/SystemConfig.sol";
6+
import { ScrollOwner } from "../../src/misc/ScrollOwner.sol"; // Adjust this path as needed
7+
8+
/**
9+
* @title InitializeL1SystemConfig
10+
* @notice Configures the deployed SystemConfig contract.
11+
* This script grants the Security Council (as defined by L1_SECURITY_COUNCIL_ADDR)
12+
* access to call updateSigner() on the SystemConfig contract with no delay.
13+
*/
14+
contract InitializeL1SystemConfig is Script {
15+
function run() external {
16+
// Retrieve required environment variables.
17+
uint256 deployerKey = vm.envUint("L1_DEPLOYER_PRIVATE_KEY");
18+
address systemConfigAddr = vm.envAddress("SYSTEM_CONTRACT_ADDR");
19+
address securityCouncilAddr = vm.envAddress("L1_SECURITY_COUNCIL_ADDR");
20+
address scrollOwnerAddr = vm.envAddress("L1_SCROLL_OWNER_ADDR");
21+
22+
// Compute the role hash for the Security Council with no delay.
23+
bytes32 SECURITY_COUNCIL_NO_DELAY_ROLE = keccak256("SECURITY_COUNCIL_NO_DELAY_ROLE");
24+
25+
vm.startBroadcast(deployerKey);
26+
27+
// Instantiate the ScrollOwner contract instance which manages access control.
28+
ScrollOwner owner = ScrollOwner(payable(scrollOwnerAddr));
29+
// Instantiate the already-deployed SystemConfig contract.
30+
SystemConfig sys = SystemConfig(systemConfigAddr);
31+
32+
// Prepare a single-element array containing the function selector for updateSigner.
33+
bytes4[] memory selectors = new bytes4[](1);
34+
selectors[0] = sys.updateSigner.selector;
35+
36+
// Grant the SECURITY_COUNCIL_NO_DELAY_ROLE permission on SystemConfig,
37+
// so that the Security Council address can call updateSigner() with no delay.
38+
owner.updateAccess(
39+
systemConfigAddr, // Address of the SystemConfig contract.
40+
selectors, // The function selectors (only updateSigner here).
41+
SECURITY_COUNCIL_NO_DELAY_ROLE,
42+
true // Grant access.
43+
);
44+
45+
vm.stopBroadcast();
46+
}
47+
}

0 commit comments

Comments
 (0)