Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 Aug 4, 2025
2379869
refactor: Clean up TransferAdminRole and AcceptAdminRole scripts for …
gfournierPro Aug 4, 2025
07c4d7b
refactor: Remove dependency on build-and-test from transfer admin rol…
gfournierPro Aug 4, 2025
484c6be
refactor: Update admin retrieval methods to use defaultAdmin for cons…
gfournierPro Aug 7, 2025
266e94c
feat: Add NEW_ADMIN configuration to .env.template for admin setup
gfournierPro Aug 7, 2025
f83d5d7
feat: Implement admin transfer validation in TransferAdminRole script
gfournierPro Aug 7, 2025
2bbfac6
refactor: Rename parameter for clarity in validateAdminTransfer function
gfournierPro Aug 7, 2025
7328144
feat: Add workflow for transferring default admin role
gfournierPro Aug 7, 2025
1707f23
feat: Update Makefile and workflow to use new admin transfer command
gfournierPro Aug 7, 2025
d2c4479
feat: Rename TransferAdminRole script to BeginTransferAdminRole for c…
gfournierPro Aug 7, 2025
ea6801f
feat: Refactor admin transfer functions for improved clarity and logging
gfournierPro Aug 7, 2025
fcc0607
feat: Update transfer-admin-role workflow to use input for new admin …
gfournierPro Aug 7, 2025
34eb919
feat: Update admin transfer workflow to use NEW_DEFAULT_ADMIN variable
gfournierPro Aug 7, 2025
749a8bf
fix: forge fmt
gfournierPro Aug 7, 2025
40ab8c3
Merge branch 'main' into feature/transfer-admin-script
gfournierPro Aug 7, 2025
9835548
feat: Enhance admin role transfer scripts with conditional logic for …
gfournierPro Aug 7, 2025
6c65563
feat: Update admin role transfer scripts to use IAccessControlDefault…
gfournierPro Aug 7, 2025
632d8ff
refactor: Simplify admin contract instance variable naming in transfe…
gfournierPro Aug 7, 2025
6853fef
fix: Add zero address check for new admin in validateAdminTransfer fu…
gfournierPro Aug 7, 2025
2fb7dfb
refactor: Replace transferContractAdmin calls with beginTransfer for …
gfournierPro Aug 7, 2025
122c285
fix: forge fmt
gfournierPro Aug 7, 2025
5552f3e
fix: Remove zero address check for new admin in BeginTransferAdminRol…
gfournierPro Aug 7, 2025
8ad0628
feat: Add TransferAdminRoleScript test suite with validation and tran…
gfournierPro Aug 8, 2025
dcced88
Merge branch 'main' into feature/transfer-admin-script
gfournierPro Aug 8, 2025
0fc947e
fix: forge fmt
gfournierPro Aug 8, 2025
982a700
fix: Update test/units/TransferAdminRoleScript.t.sol
gfournierPro Aug 8, 2025
75528a0
refactor: Rename test wrapper contracts for clarity and consistency
gfournierPro Aug 8, 2025
8514c7e
refactor: Reorganize revert scenario tests in TransferAdminRoleScript…
gfournierPro Aug 8, 2025
9d1c452
refactor: Remove unused RLCCrosschainToken variable and related test
gfournierPro Aug 8, 2025
42251ee
test: Add revert scenario for wrong address in AcceptAdminRole
gfournierPro Aug 8, 2025
dfda2cd
refactor: Rename public functions in test harnesses for clarity
gfournierPro Aug 11, 2025
2743dd4
test: Add integration tests for TransferAdminRole script with mocked …
gfournierPro Aug 11, 2025
a3c8e88
refactor: Simplify test harnesses by removing unnecessary functions a…
gfournierPro Aug 11, 2025
7931ece
refactor: Make functions virtual in TransferAdminRole scripts for ext…
gfournierPro Aug 11, 2025
b38d231
test: Enhance BeginTransfer and AcceptAdminRole tests with approval s…
gfournierPro Aug 11, 2025
cef039a
refactor: Remove TransferAdminRoleScriptIntegration test file to stre…
gfournierPro Aug 11, 2025
e353cc0
fix: forge fmt
gfournierPro Aug 11, 2025
b5229b9
refactor: Introduce helper functions for admin transfer process and s…
gfournierPro Aug 11, 2025
a7254a8
refactor: Remove unnecessary console logging from AcceptAdminRoleHarness
gfournierPro Aug 11, 2025
2c3d917
refactor: Remove unused import from TransferAdminRoleScript test file
gfournierPro Aug 11, 2025
4e62e76
refactor: Simplify admin role transfer process by introducing helper …
gfournierPro Aug 11, 2025
66cf967
feat: Add emptyConfigParams function to initialize common configurati…
gfournierPro Aug 11, 2025
bb43519
refactor: Simplify admin role transfer tests by removing harness cont…
gfournierPro Aug 11, 2025
5451587
refactor: Remove unused console import and improve test function stru…
gfournierPro Aug 11, 2025
59be92d
feat: Remove intermediate external call function & clean
zguesmi Aug 11, 2025
bf0f0c0
refactor: Add TODO comment to check if setup-matrix is needed
gfournierPro Aug 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ ETHERSCAN_API_KEY=
# ===========================================
# Recipient address for cross-chain transfers
RECIPIENT_ADDRESS=

# ===========================================
# ADMIN CONFIGURATION
# ===========================================
NEW_DEFAULT_ADMIN=
44 changes: 44 additions & 0 deletions .github/workflows/transfer-admin-role.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Transfer Default Admin Role

on:
workflow_dispatch:
inputs:
network:
description: 'Network to transfer admin role on'
required: true
type: choice
options:
- ethereum
- arbitrum
- sepolia
- arbitrum_sepolia
Comment on lines +11 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use mainnets & testnets here

default: sepolia
new_default_admin_address:
description: 'New admin address'
required: true
type: string

jobs:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use matrix here to made that on multiple network as it was made for configuration script

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure we can transmit the ownership to the same wallet (multi-sig) address other all networks ? @zguesmi

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's better to do each chain separately to avoid issues. For example if we use a multisig that is not available on a specific network.

# TODO: check if setup-matrix is needed
transfer-admin:
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 default admin role
env:
ADMIN_PRIVATE_KEY: ${{ secrets.ADMIN_PRIVATE_KEY }}
CHAIN: ${{ inputs.network }}
RPC_URL: ${{ secrets.RPC_URL }}
NEW_DEFAULT_ADMIN: ${{ inputs.new_default_admin_address }}
run: make begin-default-admin-transfer
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,25 @@ send-tokens-to-ethereum-mainnet:
--account $(ACCOUNT) \
--broadcast \
-vvv

#
# Admin role transfer operations
#

# Transfer admin role for a single chain
begin-default-admin-transfer: # CHAIN, RPC_URL, NEW_DEFAULT_ADMIN
@echo "Transferring admin role on $(CHAIN) to: $(NEW_DEFAULT_ADMIN)"
CHAIN=$(CHAIN) NEW_DEFAULT_ADMIN=$(NEW_DEFAULT_ADMIN) forge script script/TransferAdminRole.s.sol:BeginTransferAdminRole \
--rpc-url $(RPC_URL) \
$$(if [ "$(CI)" = "true" ]; then echo "--private-key $(ADMIN_PRIVATE_KEY)"; else echo "--account $(ACCOUNT)"; fi) \
--broadcast \
-vvv

# Accept admin role for a single chain (run by new admin)
accept-default-admin-transfer: # CHAIN, RPC_URL
@echo "Accepting admin role on $(CHAIN)"
CHAIN=$(CHAIN) forge script script/TransferAdminRole.s.sol:AcceptAdminRole \
--rpc-url $(RPC_URL) \
$$(if [ "$(CI)" = "true" ]; then echo "--private-key $(NEW_DEFAULT_ADMIN_PRIVATE_KEY)"; else echo "--account $(ACCOUNT)"; fi) \
--broadcast \
-vvv
125 changes: 125 additions & 0 deletions script/TransferAdminRole.s.sol
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
// SPDX-FileCopyrightText: 2025 IEXEC BLOCKCHAIN TECH <[email protected]>
// 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 {IAccessControlDefaultAdminRules} from
"@openzeppelin/contracts/access/extensions/IAccessControlDefaultAdminRules.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 BeginTransferAdminRole
* @dev Script to transfer the default admin role to a new admin address
* for all deployed smart contracts on the current chain.
*/
contract BeginTransferAdminRole is Script {
/**
* @notice Transfers the default admin role to a new admin for all contracts on the current chain
* @dev This function automatically detects which contracts are deployed on the current chain
* based on the configuration and transfers admin roles accordingly
*/
function run() external virtual {
address newAdmin = vm.envAddress("NEW_DEFAULT_ADMIN");
string memory chain = vm.envString("CHAIN");
console.log("Starting admin role transfer on chain:", chain);
console.log("New admin address:", newAdmin);

ConfigLib.CommonConfigParams memory params = ConfigLib.readCommonConfig(chain);
vm.startBroadcast();
beginTransferForAllContracts(params, newAdmin);
vm.stopBroadcast();
}
/**
* @notice Validates that the new admin is different from the current admin
* @param currentDefaultAdmin The current admin address
* @param newAdmin The new admin address
*/

function validateAdminTransfer(address currentDefaultAdmin, address newAdmin) internal pure {
require(newAdmin != address(0), "BeginTransferAdminRole: new admin cannot be zero address");
require(
newAdmin != currentDefaultAdmin, "BeginTransferAdminRole: New admin must be different from current admin"
);
}

/**
* @notice Begins the admin transfer process for all relevant contracts
* @param params The configuration parameters for the current chain
* @param newAdmin The new admin address
*/
function beginTransferForAllContracts(ConfigLib.CommonConfigParams memory params, address newAdmin) internal {
if (params.approvalRequired) {
beginTransfer(params.rlcLiquidityUnifierAddress, newAdmin, "RLCLiquidityUnifier");
} else {
beginTransfer(params.rlcCrosschainTokenAddress, newAdmin, "RLCCrosschainToken");
}
beginTransfer(params.iexecLayerZeroBridgeAddress, newAdmin, "IexecLayerZeroBridge");
}

/**
* @notice Transfers the default admin role for any contract implementing IAccessControlDefaultAdminRules
* @param contractAddress The address of the contract
* @param newAdmin The new admin address
* @param contractName The name of the contract for logging purposes
*/
function beginTransfer(address contractAddress, address newAdmin, string memory contractName) public virtual {
IAccessControlDefaultAdminRules contractInstance = IAccessControlDefaultAdminRules(contractAddress);

address currentAdmin = contractInstance.defaultAdmin();
console.log("Current admin for", contractName, ":", currentAdmin);
validateAdminTransfer(currentAdmin, newAdmin);
contractInstance.beginDefaultAdminTransfer(newAdmin);
console.log("Admin transfer initiated for", contractName, "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 BeginTransferAdminRole 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 virtual {
string memory chain = vm.envString("CHAIN");
console.log("Accepting admin role transfer on chain:", chain);
ConfigLib.CommonConfigParams memory params = ConfigLib.readCommonConfig(chain);

vm.startBroadcast();
acceptAdminRoleTransfer(params);
vm.stopBroadcast();
}

/**
* @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 acceptAdminRoleTransfer(ConfigLib.CommonConfigParams memory params) internal {
if (params.approvalRequired) {
acceptContractAdmin(params.rlcLiquidityUnifierAddress, "RLCLiquidityUnifier");
} else {
acceptContractAdmin(params.rlcCrosschainTokenAddress, "RLCCrosschainToken");
}
acceptContractAdmin(params.iexecLayerZeroBridgeAddress, "IexecLayerZeroBridge");
}

/**
* @notice Accepts the default admin role transfer for any contract implementing IAccessControlDefaultAdminRules
* @param contractAddress The address of the contract
* @param contractName The name of the contract for logging purposes
*/
function acceptContractAdmin(address contractAddress, string memory contractName) internal virtual {
console.log("Accepting admin role for", contractName, "at:", contractAddress);
IAccessControlDefaultAdminRules contractInstance = IAccessControlDefaultAdminRules(contractAddress);
contractInstance.acceptDefaultAdminTransfer();
console.log("New admin for", contractName, ":", contractInstance.defaultAdmin());
}
}
Loading