-
Notifications
You must be signed in to change notification settings - Fork 9
Feature/fly 2184 #424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Hakob23
wants to merge
16
commits into
v2.6.0
Choose a base branch
from
feature/FLY-2184
base: v2.6.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature/fly 2184 #424
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a462c0f
feat: add ChangeOwnerToTimelock script for ownership transfer
5419947
test: implement tests for ownership transfer and upgrade delay using …
3b6f0be
feat: add Timelock configuration for legacy LBC ownership in example.env
c6f5f90
feat: add timelockOwnership script for the split architecture
Hakob23 558e77a
test: add tests for Timelock ownership scripts
Hakob23 08ed784
refactor: simplify ChangeOwnerToTimelock script by removing unused pr…
Hakob23 cd5e795
feat: supporting multiple acceptor and proposer addresses and having …
Hakob23 0fb0607
test: modifying tests for multiple address config
Hakob23 5d9d9a8
Merge branch 'v2.6.0' into feature/FLY-2184
Hakob23 7eed076
refactor: remove unused DAO fee configuration and integrate PauseRegi…
Hakob23 1325b54
fmt: fix
Hakob23 abeb58a
feat: add rskRegtest configuration for proposers and executors in tim…
Hakob23 c07d54f
refactor: remove unused LiquidityBridgeContractV2 import from ChangeO…
Hakob23 9aece8a
refactor: remove prank call from test_ScriptTransfersProxyAdminToTime…
Hakob23 ae1273d
chore: update npm package
Luisfc68 8bcae27
fix: update LiquidityBridgeContractProxy initialization to use the cu…
Hakob23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,153 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity 0.8.25; | ||
|
|
||
| import {Script, console} from "lib/forge-std/src/Script.sol"; | ||
| import {HelperConfig} from "../HelperConfig.s.sol"; | ||
| import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol"; | ||
| import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; | ||
|
|
||
| /// @title ChangeOwnerToTimelock (Split Architecture) | ||
| /// @notice Deploys a TimelockController and transfers ownership of the shared | ||
| /// ProxyAdmin to it, gating contract upgrades behind a time delay. | ||
| /// @dev Only the ProxyAdmin is transferred to the timelock. The DEFAULT_ADMIN_ROLE | ||
| /// on individual contracts (CollateralManagement, PegIn, PegOut, FlyoverDiscovery) | ||
| /// is intentionally left unchanged so that time-sensitive operations like | ||
| /// emergency pause can be executed immediately. | ||
| /// Proposers and executors are read from timelock-roles.json, falling back | ||
| /// to the single-address config values if the file is not available. | ||
| contract ChangeOwnerToTimelock is Script { | ||
| error NoProposersConfigured(); | ||
| error NoExecutorsConfigured(); | ||
| error ProxyAdminAddressNotProvided(); | ||
| error ProxyAdminOwnerTransferFailed(); | ||
|
|
||
| function run() external { | ||
| HelperConfig helper = new HelperConfig(); | ||
| HelperConfig.FlyoverConfig memory cfg = helper.getFlyoverConfig(); | ||
| uint256 deployerKey = helper.getDeployerPrivateKey(); | ||
| vm.rememberKey(deployerKey); | ||
|
|
||
| address proxyAdminAddress = vm.envAddress("PROXY_ADMIN"); | ||
| if (proxyAdminAddress == address(0)) { | ||
| revert ProxyAdminAddressNotProvided(); | ||
| } | ||
|
|
||
| (address[] memory proposers, address[] memory executors) = _readRoles( | ||
| cfg | ||
| ); | ||
|
|
||
| vm.startBroadcast(deployerKey); | ||
| TimelockController timelock = execute( | ||
| proxyAdminAddress, | ||
| cfg.timelockMinDelay, | ||
| proposers, | ||
| executors, | ||
| cfg.timelockAdmin | ||
| ); | ||
| vm.stopBroadcast(); | ||
|
|
||
| _logFinalState(proxyAdminAddress, timelock, proposers, executors); | ||
| } | ||
|
|
||
| /// @notice Core logic: deploys a TimelockController and transfers ProxyAdmin | ||
| /// ownership to it. No console.log calls -- safe for broadcast. | ||
| function execute( | ||
| address proxyAdminAddress, | ||
| uint256 minDelay, | ||
| address[] memory proposers, | ||
| address[] memory executors, | ||
| address admin | ||
| ) public returns (TimelockController) { | ||
| if (proposers.length == 0) { | ||
| revert NoProposersConfigured(); | ||
| } | ||
| if (executors.length == 0) { | ||
| revert NoExecutorsConfigured(); | ||
| } | ||
|
|
||
| TimelockController timelock = new TimelockController( | ||
| minDelay, | ||
| proposers, | ||
| executors, | ||
| admin | ||
| ); | ||
|
|
||
| ProxyAdmin proxyAdmin = ProxyAdmin(proxyAdminAddress); | ||
| if (proxyAdmin.owner() != address(timelock)) { | ||
| proxyAdmin.transferOwnership(address(timelock)); | ||
| if (proxyAdmin.owner() != address(timelock)) { | ||
| revert ProxyAdminOwnerTransferFailed(); | ||
| } | ||
| } | ||
|
|
||
| return timelock; | ||
| } | ||
|
|
||
| function _readRoles( | ||
| HelperConfig.FlyoverConfig memory cfg | ||
| ) | ||
| internal | ||
| view | ||
| returns (address[] memory proposers, address[] memory executors) | ||
| { | ||
| string memory json = vm.readFile( | ||
| "script/deployment/timelock-roles.json" | ||
| ); | ||
| string memory networkKey = _networkKey(); | ||
|
|
||
| proposers = vm.parseJsonAddressArray( | ||
| json, | ||
| string.concat(".", networkKey, ".proposers") | ||
| ); | ||
| executors = vm.parseJsonAddressArray( | ||
| json, | ||
| string.concat(".", networkKey, ".executors") | ||
| ); | ||
|
|
||
Hakob23 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (proposers.length == 0 && cfg.timelockProposer != address(0)) { | ||
| proposers = new address[](1); | ||
| proposers[0] = cfg.timelockProposer; | ||
| } | ||
| if (executors.length == 0 && cfg.timelockExecutor != address(0)) { | ||
| executors = new address[](1); | ||
| executors[0] = cfg.timelockExecutor; | ||
| } | ||
| } | ||
|
|
||
| function _networkKey() internal view returns (string memory) { | ||
| uint256 chainId = block.chainid; | ||
| if (chainId == 30) return "rskMainnet"; | ||
| if (chainId == 31) return "rskTestnet"; | ||
| return "rskRegtest"; | ||
| } | ||
|
|
||
| function _logFinalState( | ||
| address proxyAdminAddress, | ||
| TimelockController timelock, | ||
| address[] memory proposers, | ||
| address[] memory executors | ||
| ) internal view { | ||
| console.log("=== Timelock ownership setup complete ==="); | ||
| console.log("Timelock:", address(timelock)); | ||
| console.log("Timelock minDelay:", timelock.getMinDelay()); | ||
| console.log("ProxyAdmin:", proxyAdminAddress); | ||
| console.log("ProxyAdmin owner:", ProxyAdmin(proxyAdminAddress).owner()); | ||
|
|
||
| bytes32 proposerRole = timelock.PROPOSER_ROLE(); | ||
| bytes32 executorRole = timelock.EXECUTOR_ROLE(); | ||
| for (uint256 i = 0; i < proposers.length; i++) { | ||
| console.log( | ||
| "Proposer:", | ||
| proposers[i], | ||
| timelock.hasRole(proposerRole, proposers[i]) | ||
| ); | ||
| } | ||
| for (uint256 i = 0; i < executors.length; i++) { | ||
| console.log( | ||
| "Executor:", | ||
| executors[i], | ||
| timelock.hasRole(executorRole, executors[i]) | ||
| ); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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,10 @@ | ||
| { | ||
| "rskMainnet": { | ||
| "proposers": ["0x633D1233eD6251108b61A8365CEEd271BF3e3C9b"], | ||
| "executors": ["0x633D1233eD6251108b61A8365CEEd271BF3e3C9b"] | ||
| }, | ||
| "rskTestnet": { | ||
| "proposers": ["0x27ad02ABf893F8e01f0089EDE607A76FbB3F1Cd3"], | ||
| "executors": ["0x27ad02ABf893F8e01f0089EDE607A76FbB3F1Cd3"] | ||
Hakob23 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.