-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add transfer admin role workflow and scripts for multi-chain su… #90
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
c221857
feat: Add transfer admin role workflow and scripts for multi-chain su…
gfournierPro 2379869
refactor: Clean up TransferAdminRole and AcceptAdminRole scripts for …
gfournierPro 07c4d7b
refactor: Remove dependency on build-and-test from transfer admin rol…
gfournierPro 484c6be
refactor: Update admin retrieval methods to use defaultAdmin for cons…
gfournierPro 266e94c
feat: Add NEW_ADMIN configuration to .env.template for admin setup
gfournierPro f83d5d7
feat: Implement admin transfer validation in TransferAdminRole script
gfournierPro 2bbfac6
refactor: Rename parameter for clarity in validateAdminTransfer function
gfournierPro 7328144
feat: Add workflow for transferring default admin role
gfournierPro 1707f23
feat: Update Makefile and workflow to use new admin transfer command
gfournierPro d2c4479
feat: Rename TransferAdminRole script to BeginTransferAdminRole for c…
gfournierPro ea6801f
feat: Refactor admin transfer functions for improved clarity and logging
gfournierPro fcc0607
feat: Update transfer-admin-role workflow to use input for new admin …
gfournierPro 34eb919
feat: Update admin transfer workflow to use NEW_DEFAULT_ADMIN variable
gfournierPro 749a8bf
fix: forge fmt
gfournierPro 40ab8c3
Merge branch 'main' into feature/transfer-admin-script
gfournierPro 9835548
feat: Enhance admin role transfer scripts with conditional logic for …
gfournierPro 6c65563
feat: Update admin role transfer scripts to use IAccessControlDefault…
gfournierPro 632d8ff
refactor: Simplify admin contract instance variable naming in transfe…
gfournierPro 6853fef
fix: Add zero address check for new admin in validateAdminTransfer fu…
gfournierPro 2fb7dfb
refactor: Replace transferContractAdmin calls with beginTransfer for …
gfournierPro 122c285
fix: forge fmt
gfournierPro 5552f3e
fix: Remove zero address check for new admin in BeginTransferAdminRol…
gfournierPro 8ad0628
feat: Add TransferAdminRoleScript test suite with validation and tran…
gfournierPro dcced88
Merge branch 'main' into feature/transfer-admin-script
gfournierPro 0fc947e
fix: forge fmt
gfournierPro 982a700
fix: Update test/units/TransferAdminRoleScript.t.sol
gfournierPro 75528a0
refactor: Rename test wrapper contracts for clarity and consistency
gfournierPro 8514c7e
refactor: Reorganize revert scenario tests in TransferAdminRoleScript…
gfournierPro 9d1c452
refactor: Remove unused RLCCrosschainToken variable and related test
gfournierPro 42251ee
test: Add revert scenario for wrong address in AcceptAdminRole
gfournierPro dfda2cd
refactor: Rename public functions in test harnesses for clarity
gfournierPro 2743dd4
test: Add integration tests for TransferAdminRole script with mocked …
gfournierPro a3c8e88
refactor: Simplify test harnesses by removing unnecessary functions a…
gfournierPro 7931ece
refactor: Make functions virtual in TransferAdminRole scripts for ext…
gfournierPro b38d231
test: Enhance BeginTransfer and AcceptAdminRole tests with approval s…
gfournierPro cef039a
refactor: Remove TransferAdminRoleScriptIntegration test file to stre…
gfournierPro e353cc0
fix: forge fmt
gfournierPro b5229b9
refactor: Introduce helper functions for admin transfer process and s…
gfournierPro a7254a8
refactor: Remove unnecessary console logging from AcceptAdminRoleHarness
gfournierPro 2c3d917
refactor: Remove unused import from TransferAdminRoleScript test file
gfournierPro 4e62e76
refactor: Simplify admin role transfer process by introducing helper …
gfournierPro 66cf967
feat: Add emptyConfigParams function to initialize common configurati…
gfournierPro bb43519
refactor: Simplify admin role transfer tests by removing harness cont…
gfournierPro 5451587
refactor: Remove unused console import and improve test function stru…
gfournierPro 59be92d
feat: Remove intermediate external call function & clean
zguesmi bf0f0c0
refactor: Add TODO comment to check if setup-matrix is needed
gfournierPro 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| name: Transfer Admin Role | ||
zguesmi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| network: | ||
| description: 'Network to transfer admin role on' | ||
| required: true | ||
| type: choice | ||
| options: | ||
| - ethereum | ||
| - arbitrum | ||
| - sepolia | ||
| - arbitrum_sepolia | ||
| default: sepolia | ||
|
|
||
| jobs: | ||
| transfer-admin: | ||
| needs: build-and-test | ||
gfournierPro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
gfournierPro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| runs-on: ubuntu-latest | ||
| environment: ${{ inputs.network }} | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Install Foundry | ||
| uses: foundry-rs/foundry-toolchain@v1 | ||
| with: | ||
| version: stable | ||
| cache: true | ||
|
|
||
| - name: Transfer admin role | ||
zguesmi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| env: | ||
| ADMIN_PRIVATE_KEY: ${{ secrets.ADMIN_PRIVATE_KEY }} | ||
| CHAIN: ${{ inputs.network }} | ||
| RPC_URL: ${{ secrets.RPC_URL }} | ||
| NEW_ADMIN: ${{ vars.NEW_ADMIN_ADDRESS }} | ||
zguesmi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| run: | | ||
| make transfer-admin-single-chain | ||
zguesmi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
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
gfournierPro marked this conversation as resolved.
Show resolved
Hide resolved
gfournierPro marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it could be nice to move run() function as the first function of each contracts
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
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,155 @@ | ||
| // SPDX-FileCopyrightText: 2025 IEXEC BLOCKCHAIN TECH <contact@iex.ec> | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| pragma solidity ^0.8.22; | ||
|
|
||
| import {Script} from "forge-std/Script.sol"; | ||
| import {console} from "forge-std/console.sol"; | ||
| import {AccessControlDefaultAdminRulesUpgradeable} from | ||
| "@openzeppelin/contracts-upgradeable/access/extensions/AccessControlDefaultAdminRulesUpgradeable.sol"; | ||
| import {ConfigLib} from "./lib/ConfigLib.sol"; | ||
| import {RLCLiquidityUnifier} from "../src/RLCLiquidityUnifier.sol"; | ||
| import {RLCCrosschainToken} from "../src/RLCCrosschainToken.sol"; | ||
| import {IexecLayerZeroBridge} from "../src/bridges/layerZero/IexecLayerZeroBridge.sol"; | ||
|
|
||
| /** | ||
| * @title TransferAdminRole | ||
| * @dev Script to transfer the default admin role to a new admin address | ||
| * for all deployed smart contracts on the current chain. | ||
| */ | ||
| contract TransferAdminRole is Script { | ||
| /** | ||
| * @notice Transfers the default admin role to a new admin for all contracts on the current chain | ||
| * @param newAdmin The address that will become the new default admin | ||
| * @dev This function automatically detects which contracts are deployed on the current chain | ||
| * based on the configuration and transfers admin roles accordingly | ||
| */ | ||
| function run(address newAdmin) external { | ||
| require(newAdmin != address(0), "TransferAdminRole: New admin cannot be zero address"); | ||
|
|
||
| string memory chain = vm.envString("CHAIN"); | ||
gfournierPro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| console.log("Starting admin role transfer on chain:", chain); | ||
| console.log("New admin address:", newAdmin); | ||
|
|
||
| ConfigLib.CommonConfigParams memory params = ConfigLib.readCommonConfig(chain); | ||
|
|
||
| vm.startBroadcast(); | ||
| if (params.approvalRequired) { | ||
| transferRLCLiquidityUnifierAdmin(params.rlcLiquidityUnifierAddress, newAdmin); | ||
| } else { | ||
| transferRLCCrosschainTokenAdmin(params.rlcCrosschainTokenAddress, newAdmin); | ||
| } | ||
| transferIexecLayerZeroBridgeAdmin(params.iexecLayerZeroBridgeAddress, newAdmin); | ||
| vm.stopBroadcast(); | ||
| } | ||
|
|
||
| /** | ||
| * @notice Transfers admin role for RLCLiquidityUnifier contract | ||
| * @param contractAddress The address of the RLCLiquidityUnifier contract | ||
| * @param newAdmin The new admin address | ||
| */ | ||
| function transferRLCLiquidityUnifierAdmin(address contractAddress, address newAdmin) internal { | ||
| RLCLiquidityUnifier liquidityUnifier = RLCLiquidityUnifier(contractAddress); | ||
|
|
||
| address currentAdmin = liquidityUnifier.owner(); | ||
gfournierPro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
gfournierPro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| console.log("Current admin:", currentAdmin); | ||
|
|
||
| liquidityUnifier.beginDefaultAdminTransfer(newAdmin); | ||
| console.log("Admin transfer initiated for RLCLiquidityUnifier at:", contractAddress); | ||
| } | ||
|
|
||
| /** | ||
| * @notice Transfers admin role for RLCCrosschainToken contract | ||
| * @param contractAddress The address of the RLCCrosschainToken contract | ||
| * @param newAdmin The new admin address | ||
| */ | ||
| function transferRLCCrosschainTokenAdmin(address contractAddress, address newAdmin) internal { | ||
| RLCCrosschainToken crosschainToken = RLCCrosschainToken(contractAddress); | ||
|
|
||
| address currentAdmin = crosschainToken.owner(); | ||
gfournierPro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
gfournierPro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| console.log("Current admin:", currentAdmin); | ||
|
|
||
| crosschainToken.beginDefaultAdminTransfer(newAdmin); | ||
| console.log("Admin transfer initiated for RLCCrosschainToken at:", contractAddress); | ||
| } | ||
|
|
||
| /** | ||
| * @notice Transfers admin role for IexecLayerZeroBridge contract | ||
| * @param contractAddress The address of the IexecLayerZeroBridge contract | ||
| * @param newAdmin The new admin address | ||
| */ | ||
| function transferIexecLayerZeroBridgeAdmin(address contractAddress, address newAdmin) internal { | ||
| IexecLayerZeroBridge bridge = IexecLayerZeroBridge(contractAddress); | ||
|
|
||
| address currentAdmin = bridge.owner(); | ||
gfournierPro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| console.log("Current admin:", currentAdmin); | ||
|
|
||
| bridge.beginDefaultAdminTransfer(newAdmin); | ||
| console.log("Admin transfer initiated for IexecLayerZeroBridge at:", contractAddress); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @title AcceptAdminRole | ||
| * @dev Script to accept the default admin role transfer for all contracts on the current chain. | ||
| * This script should be run by the new admin after the TransferAdminRole script has been executed. | ||
| */ | ||
| contract AcceptAdminRole is Script { | ||
| /** | ||
| * @notice Accepts the default admin role transfer for all contracts on the current chain | ||
| * @dev This function should be called by the new admin to complete the transfer process | ||
| */ | ||
| function run() external { | ||
| string memory chain = vm.envString("CHAIN"); | ||
| console.log("Accepting admin role transfer on chain:", chain); | ||
| ConfigLib.CommonConfigParams memory params = ConfigLib.readCommonConfig(chain); | ||
|
|
||
| vm.startBroadcast(); | ||
| if (params.approvalRequired) { | ||
| acceptRLCLiquidityUnifierAdmin(params.rlcLiquidityUnifierAddress); | ||
| } else { | ||
| acceptRLCCrosschainTokenAdmin(params.rlcCrosschainTokenAddress); | ||
| } | ||
| acceptIexecLayerZeroBridgeAdmin(params.iexecLayerZeroBridgeAddress); | ||
| vm.stopBroadcast(); | ||
| } | ||
|
|
||
| /** | ||
| * @notice Accepts admin role for RLCLiquidityUnifier contract | ||
| * @param contractAddress The address of the RLCLiquidityUnifier contract | ||
| */ | ||
| function acceptRLCLiquidityUnifierAdmin(address contractAddress) internal { | ||
| console.log("Accepting admin role for RLCLiquidityUnifier at:", contractAddress); | ||
|
|
||
| RLCLiquidityUnifier liquidityUnifier = RLCLiquidityUnifier(contractAddress); | ||
|
|
||
| liquidityUnifier.acceptDefaultAdminTransfer(); | ||
| console.log("New admin:", liquidityUnifier.owner()); | ||
gfournierPro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /** | ||
| * @notice Accepts admin role for RLCCrosschainToken contract | ||
| * @param contractAddress The address of the RLCCrosschainToken contract | ||
| */ | ||
| function acceptRLCCrosschainTokenAdmin(address contractAddress) internal { | ||
| console.log("Accepting admin role for RLCCrosschainToken at:", contractAddress); | ||
|
|
||
| RLCCrosschainToken crosschainToken = RLCCrosschainToken(contractAddress); | ||
|
|
||
| crosschainToken.acceptDefaultAdminTransfer(); | ||
| console.log("New admin:", crosschainToken.owner()); | ||
gfournierPro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /** | ||
| * @notice Accepts admin role for IexecLayerZeroBridge contract | ||
| * @param contractAddress The address of the IexecLayerZeroBridge contract | ||
| */ | ||
| function acceptIexecLayerZeroBridgeAdmin(address contractAddress) internal { | ||
| console.log("Accepting admin role for IexecLayerZeroBridge at:", contractAddress); | ||
|
|
||
| IexecLayerZeroBridge bridge = IexecLayerZeroBridge(contractAddress); | ||
|
|
||
| bridge.acceptDefaultAdminTransfer(); | ||
| console.log("New admin:", bridge.owner()); | ||
gfournierPro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
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.