Skip to content

Commit

Permalink
chore: add timelocked owner (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnshuJalan authored Jan 8, 2025
1 parent a68af76 commit c46e659
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 12 deletions.
41 changes: 29 additions & 12 deletions packages/protocol/script/layer1/DeployProtocolOnL1.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.24;

import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/governance/TimelockController.sol";
import "@risc0/contracts/groth16/RiscZeroGroth16Verifier.sol";
import { SP1Verifier as SuccinctVerifier } from "@sp1-contracts/src/v3.0.0-rc3/SP1VerifierPlonk.sol";

Expand Down Expand Up @@ -59,18 +60,33 @@ contract DeployProtocolOnL1 is DeployCapability {
function run() external broadcast {
addressNotNull(vm.envAddress("TAIKO_L2_ADDRESS"), "TAIKO_L2_ADDRESS");
addressNotNull(vm.envAddress("L2_SIGNAL_SERVICE"), "L2_SIGNAL_SERVICE");
addressNotNull(vm.envAddress("CONTRACT_OWNER"), "CONTRACT_OWNER");

require(vm.envBytes32("L2_GENESIS_HASH") != 0, "L2_GENESIS_HASH");
address contractOwner = vm.envAddress("CONTRACT_OWNER");

address[] memory executors = vm.envAddress("OWNER_MULTISIG_SIGNERS", ",");

address ownerMultisig = vm.envAddress("OWNER_MULTISIG");
addressNotNull(ownerMultisig, "ownerMultisig");

address[] memory proposers = new address[](1);
proposers[0] = ownerMultisig;

// Setup timelock controller with 45 day (86400 seconds * 45) delay
address timelockController = address(
new TimelockController(86400 * 45, proposers, executors, address(0))
);
address contractOwner = timelockController;

address verifierOwner = vm.envAddress("VERIFIER_OWNER");
addressNotNull(verifierOwner, "verifierOwner");

// ---------------------------------------------------------------
// Deploy shared contracts
(address sharedAddressManager) = deploySharedContracts(contractOwner);
console2.log("sharedAddressManager: ", sharedAddressManager);
// ---------------------------------------------------------------
// Deploy rollup contracts
address rollupAddressManager = deployRollupContracts(sharedAddressManager, contractOwner);
address rollupAddressManager = deployRollupContracts(sharedAddressManager, contractOwner, verifierOwner);

// ---------------------------------------------------------------
// Signal service need to authorize the new rollup
Expand Down Expand Up @@ -244,7 +260,8 @@ contract DeployProtocolOnL1 is DeployCapability {

function deployRollupContracts(
address _sharedAddressManager,
address owner
address owner,
address verifierOwner
)
internal
returns (address rollupAddressManager)
Expand Down Expand Up @@ -303,7 +320,7 @@ contract DeployProtocolOnL1 is DeployCapability {
deployProxy({
name: "tier_sgx",
impl: address(new SgxVerifier()),
data: abi.encodeCall(SgxVerifier.init, (owner, rollupAddressManager)),
data: abi.encodeCall(SgxVerifier.init, (verifierOwner, rollupAddressManager)),
registerTo: rollupAddressManager
});

Expand Down Expand Up @@ -364,7 +381,7 @@ contract DeployProtocolOnL1 is DeployCapability {
name: "automata_dcap_attestation",
impl: automateDcapV3AttestationImpl,
data: abi.encodeCall(
AutomataDcapV3Attestation.init, (owner, address(sigVerifyLib), address(pemCertChainLib))
AutomataDcapV3Attestation.init, (verifierOwner, address(sigVerifyLib), address(pemCertChainLib))
),
registerTo: rollupAddressManager
});
Expand All @@ -374,20 +391,20 @@ contract DeployProtocolOnL1 is DeployCapability {
console2.log("PemCertChainLib", address(pemCertChainLib));
console2.log("AutomataDcapVaAttestation", automataProxy);

deployZKVerifiers(owner, rollupAddressManager);
deployZKVerifiers(verifierOwner, rollupAddressManager);

// Deploy composite verifier
deployProxy({
name: "tier_two_of_three",
impl: address(new TwoOfThreeVerifier()),
data: abi.encodeCall(ComposeVerifier.init, (owner, rollupAddressManager)),
data: abi.encodeCall(ComposeVerifier.init, (verifierOwner, rollupAddressManager)),
registerTo: rollupAddressManager
});
}

// deploy both sp1 & risc0 verifiers.
// using function to avoid stack too deep error
function deployZKVerifiers(address owner, address rollupAddressManager) private {
function deployZKVerifiers(address verifierOwner, address rollupAddressManager) private {
// Deploy r0 groth16 verifier
RiscZeroGroth16Verifier verifier =
new RiscZeroGroth16Verifier(ControlID.CONTROL_ROOT, ControlID.BN254_CONTROL_ID);
Expand All @@ -396,7 +413,7 @@ contract DeployProtocolOnL1 is DeployCapability {
deployProxy({
name: "tier_zkvm_risc0",
impl: address(new Risc0Verifier()),
data: abi.encodeCall(Risc0Verifier.init, (owner, rollupAddressManager)),
data: abi.encodeCall(Risc0Verifier.init, (verifierOwner, rollupAddressManager)),
registerTo: rollupAddressManager
});

Expand All @@ -407,7 +424,7 @@ contract DeployProtocolOnL1 is DeployCapability {
deployProxy({
name: "tier_zkvm_sp1",
impl: address(new SP1Verifier()),
data: abi.encodeCall(SP1Verifier.init, (owner, rollupAddressManager)),
data: abi.encodeCall(SP1Verifier.init, (verifierOwner, rollupAddressManager)),
registerTo: rollupAddressManager
});
}
Expand Down Expand Up @@ -436,4 +453,4 @@ contract DeployProtocolOnL1 is DeployCapability {
function addressNotNull(address addr, string memory err) private pure {
require(addr != address(0), err);
}
}
}
3 changes: 3 additions & 0 deletions packages/protocol/script/layer1/deploy_protocol_on_l1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ L2_SIGNAL_SERVICE=0x7633740000000000000000000000000000000005 \
CONTRACT_OWNER=0x8943545177806ED17B9F23F0a21ee5948eCaa776 \
SHARED_ADDRESS_MANAGER=0x0000000000000000000000000000000000000000 \
L2_GENESIS_HASH=0x00e5e4522f1520280092094a73023c0fc52c2d032d91b3a09c03a375f6afa826 \
OWNER_MULTISIG=0x1237810000000000000000000000000000000001 \
OWNER_MULTISIG_SIGNERS="0x1237810000000000000000000000000000000002,0x1237810000000000000000000000000000000003,0x1237810000000000000000000000000000000004" \
VERIFIER_OWNER=0x1237810000000000000000000000000000000002 \
PAUSE_TAIKO_L1=false \
PAUSE_BRIDGE=false \
NUM_MIN_MAJORITY_GUARDIANS=7 \
Expand Down
22 changes: 22 additions & 0 deletions packages/protocol/script/shared/ChangeOwners.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "forge-std/src/Script.sol";
import "forge-std/src/console2.sol";
import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";

import "src/shared/common/AddressManager.sol";

contract ChangeOwners is Script {
uint256 public adminPrivateKey = vm.envUint("PRIVATE_KEY");
address public newOwner = vm.envAddress("NEW_OWNER");

function run() external {
address[] memory contracts = vm.envAddress("CONTRACTS", ",");
vm.startBroadcast(adminPrivateKey);
for(uint i; i < contracts.length; ++i) {
OwnableUpgradeable(contracts[0]).transferOwnership(newOwner);
}
vm.stopBroadcast();
}
}
31 changes: 31 additions & 0 deletions packages/protocol/script/shared/DeployTimelockedOwner.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "@openzeppelin/contracts/governance/TimelockController.sol";
import "test/shared/DeployCapability.sol";

contract DeployTimelockedOwner is DeployCapability {
uint256 public deployerPrivKey = vm.envUint("PRIVATE_KEY");
function run() external {
require(deployerPrivKey != 0, "invalid deployer priv key");
vm.startBroadcast(deployerPrivKey);
address[] memory executors = vm.envAddress("OWNER_MULTISIG_SIGNERS", ",");

address ownerMultisig = vm.envAddress("OWNER_MULTISIG");
addressNotNull(ownerMultisig, "ownerMultisig");

address[] memory proposers = new address[](1);
proposers[0] = ownerMultisig;

// Setup timelock controller with 45 day (86400 seconds * 45) delay
address timelockController = address(
new TimelockController(86400 * 45, proposers, executors, address(0))
);
console2.log("Timelocked owner: ", timelockController);
vm.stopBroadcast();
}

function addressNotNull(address addr, string memory err) private pure {
require(addr != address(0), err);
}
}

0 comments on commit c46e659

Please sign in to comment.