-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy and Initialize L1 System Config
- Loading branch information
Showing
3 changed files
with
71 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity =0.8.24; | ||
|
||
import {Script} from "forge-std/Script.sol"; | ||
import {SystemConfig} from "../../src/L1/system-contract/SystemConfig.sol"; // adjust the relative path as necessary | ||
import {console} from "forge-std/console.sol"; | ||
|
||
contract DeployL1SystemConfig is Script { | ||
function run() external { | ||
// Retrieve the deployer private key from environment variables | ||
uint256 deployerKey = vm.envUint("L1_DEPLOYER_PRIVATE_KEY"); | ||
// Read the intended owner from an environment variable (for example, L1_SCROLL_OWNER_ADDR) | ||
address ownerAddr = vm.envAddress("L1_SCROLL_OWNER_ADDR"); | ||
|
||
vm.startBroadcast(deployerKey); | ||
|
||
// Deploy the SystemConfig contract with the specified owner. | ||
SystemConfig sysConfig = new SystemConfig(ownerAddr); | ||
|
||
console.log("Deployed SystemConfig at address:", address(sysConfig)); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity =0.8.24; | ||
|
||
import { Script } from "forge-std/Script.sol"; | ||
import { SystemConfig } from "../../src/L1/system-contract/SystemConfig.sol"; | ||
import { ScrollOwner } from "../../src/misc/ScrollOwner.sol"; // Adjust this path as needed | ||
|
||
/** | ||
* @title InitializeL1SystemConfig | ||
* @notice Configures the deployed SystemConfig contract. | ||
* This script grants the Security Council (as defined by L1_SECURITY_COUNCIL_ADDR) | ||
* access to call updateSigner() on the SystemConfig contract with no delay. | ||
*/ | ||
contract InitializeL1SystemConfig is Script { | ||
function run() external { | ||
// Retrieve required environment variables. | ||
uint256 deployerKey = vm.envUint("L1_DEPLOYER_PRIVATE_KEY"); | ||
address systemConfigAddr = vm.envAddress("SYSTEM_CONTRACT_ADDR"); | ||
address securityCouncilAddr = vm.envAddress("L1_SECURITY_COUNCIL_ADDR"); | ||
address scrollOwnerAddr = vm.envAddress("L1_SCROLL_OWNER_ADDR"); | ||
|
||
// Compute the role hash for the Security Council with no delay. | ||
bytes32 SECURITY_COUNCIL_NO_DELAY_ROLE = keccak256("SECURITY_COUNCIL_NO_DELAY_ROLE"); | ||
|
||
vm.startBroadcast(deployerKey); | ||
|
||
// Instantiate the ScrollOwner contract instance which manages access control. | ||
ScrollOwner owner = ScrollOwner(payable(scrollOwnerAddr)); | ||
// Instantiate the already-deployed SystemConfig contract. | ||
SystemConfig sys = SystemConfig(systemConfigAddr); | ||
|
||
// Prepare a single-element array containing the function selector for updateSigner. | ||
bytes4[] memory selectors = new bytes4[](1); | ||
selectors[0] = sys.updateSigner.selector; | ||
|
||
// Grant the SECURITY_COUNCIL_NO_DELAY_ROLE permission on SystemConfig, | ||
// so that the Security Council address can call updateSigner() with no delay. | ||
owner.updateAccess( | ||
systemConfigAddr, // Address of the SystemConfig contract. | ||
selectors, // The function selectors (only updateSigner here). | ||
SECURITY_COUNCIL_NO_DELAY_ROLE, | ||
true // Grant access. | ||
); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |