Skip to content

Commit

Permalink
Deploy and Initialize L1 System Config
Browse files Browse the repository at this point in the history
  • Loading branch information
ranchalp committed Jan 20, 2025
1 parent 03dc404 commit c18b9b3
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 19 deletions.
24 changes: 24 additions & 0 deletions scripts/foundry/DeployL1SystemConfig.s.sol
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();
}
}
19 changes: 0 additions & 19 deletions scripts/foundry/InitializeL1ScrollOwner.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import {ScrollChain} from "../../src/L1/rollup/ScrollChain.sol";
import {ScrollOwner} from "../../src/misc/ScrollOwner.sol";
import {Whitelist} from "../../src/L2/predeploys/Whitelist.sol";

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


// solhint-disable max-states-count
// solhint-disable state-visibility
Expand Down Expand Up @@ -279,21 +277,4 @@ contract InitializeL1ScrollOwner is Script {
owner.updateAccess(L1_ENFORCED_TX_GATEWAY_PROXY_ADDR, _selectors, SCROLL_MULTISIG_NO_DELAY_ROLE, true);
owner.updateAccess(L1_ENFORCED_TX_GATEWAY_PROXY_ADDR, _selectors, EMERGENCY_MULTISIG_NO_DELAY_ROLE, true);
}

function configSystemContract() internal {
// If we already have deployed it, just do:
SystemConfig sys = SystemConfig(SYSTEM_CONTRACT_ADDR);

// sys has a normal constructor that set the "owner" to `ScrollOwner`.
// Now we want to let the Security Council call `addSigner(...)` with no delay.
bytes4[] memory selectors = new bytes4[](1);
selectors[0] = sys.updateSigner.selector;

owner.updateAccess(
SYSTEM_CONTRACT_ADDR, // the system contract
selectors, // array of function selectors (onlyOwner)
SECURITY_COUNCIL_NO_DELAY_ROLE,
true
);
}
}
47 changes: 47 additions & 0 deletions scripts/foundry/InitializeL1SystemConfig.sol
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();
}
}

0 comments on commit c18b9b3

Please sign in to comment.