-
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 10 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
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
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,204 @@ | ||
| // SPDX-FileCopyrightText: 2025 IEXEC BLOCKCHAIN TECH <[email protected]> | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| pragma solidity ^0.8.22; | ||
|
|
||
| import {BeginTransferAdminRole, AcceptAdminRole} from "../../script/TransferAdminRole.s.sol"; | ||
| import {TestHelperOz5} from "@layerzerolabs/test-devtools-evm-foundry/contracts/TestHelperOz5.sol"; | ||
|
|
||
| import {IAccessControlDefaultAdminRules} from | ||
| "@openzeppelin/contracts/access/extensions/IAccessControlDefaultAdminRules.sol"; | ||
| import {TestUtils} from "./utils/TestUtils.sol"; | ||
| import {RLCLiquidityUnifier} from "../../src/RLCLiquidityUnifier.sol"; | ||
| import {RLCCrosschainToken} from "../../src/RLCCrosschainToken.sol"; | ||
| import {IexecLayerZeroBridge} from "../../src/bridges/layerZero/IexecLayerZeroBridge.sol"; | ||
| import {Deploy as RLCLiquidityUnifierDeployScript} from "../../script/RLCLiquidityUnifier.s.sol"; | ||
| import {Deploy as RLCCrosschainTokenDeployScript} from "../../script/RLCCrosschainToken.s.sol"; | ||
| import {CreateX} from "@createx/contracts/CreateX.sol"; | ||
|
|
||
| // Test wrapper contract to expose internal functions | ||
| contract TestableBeginTransferAdminRole is BeginTransferAdminRole { | ||
zguesmi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| function publicBeginTransfer(address contractAddress, address newAdmin, string memory contractName) public { | ||
| beginTransfer(contractAddress, newAdmin, contractName); | ||
| } | ||
|
|
||
| function publicBeginTransferAsAdmin( | ||
| address contractAddress, | ||
| address newAdmin, | ||
| string memory contractName, | ||
| address admin | ||
| ) public { | ||
| vm.startPrank(admin); | ||
| beginTransfer(contractAddress, newAdmin, contractName); | ||
| vm.stopPrank(); | ||
| } | ||
|
|
||
| function publicValidateAdminTransfer(address currentDefaultAdmin, address newAdmin) public pure { | ||
| validateAdminTransfer(currentDefaultAdmin, newAdmin); | ||
| } | ||
| } | ||
|
|
||
| // Test wrapper contract to expose internal functions | ||
| contract TestableAcceptAdminRole is AcceptAdminRole { | ||
| function publicAcceptContractAdmin(address contractAddress, string memory contractName) public { | ||
| acceptContractAdmin(contractAddress, contractName); | ||
| } | ||
|
|
||
| function publicAcceptContractAdminAsUser(address contractAddress, string memory contractName, address user) | ||
| public | ||
| { | ||
| vm.startPrank(user); | ||
| acceptContractAdmin(contractAddress, contractName); | ||
| vm.stopPrank(); | ||
| } | ||
| } | ||
|
|
||
| contract TransferAdminRoleScriptTest is TestHelperOz5 { | ||
| using TestUtils for *; | ||
|
|
||
| TestableBeginTransferAdminRole private beginTransferScript; | ||
| TestableAcceptAdminRole private acceptAdminScript; | ||
|
|
||
| // Test addresses | ||
| address private newAdmin = makeAddr("newAdmin"); | ||
| address private admin = makeAddr("admin"); | ||
| address private upgrader = makeAddr("upgrader"); | ||
| address private pauser = makeAddr("pauser"); | ||
| uint16 private sourceEndpointId = 1; | ||
| uint16 private targetEndpointId = 2; | ||
| RLCLiquidityUnifier rlcLiquidityUnifier; | ||
| RLCCrosschainToken rlcCrosschainToken; | ||
|
|
||
| TestUtils.DeploymentResult deployment; | ||
|
|
||
| RLCLiquidityUnifierDeployScript private liquidityUnifierDeployer; | ||
| RLCCrosschainTokenDeployScript private crosschainTokenDeployer; | ||
|
|
||
| function setUp() public virtual override { | ||
| super.setUp(); | ||
| setUpEndpoints(2, LibraryType.UltraLightNode); | ||
| deployment = TestUtils.setupDeployment( | ||
| TestUtils.DeploymentParams({ | ||
| iexecLayerZeroBridgeContractName: "IexecLayerZeroBridge", | ||
| lzEndpointSource: endpoints[sourceEndpointId], | ||
| lzEndpointDestination: endpoints[targetEndpointId], | ||
| initialAdmin: admin, | ||
| initialUpgrader: upgrader, | ||
| initialPauser: pauser | ||
| }) | ||
| ); | ||
| rlcLiquidityUnifier = deployment.rlcLiquidityUnifier; | ||
| rlcCrosschainToken = deployment.rlcCrosschainToken; | ||
|
|
||
| beginTransferScript = new TestableBeginTransferAdminRole(); | ||
| acceptAdminScript = new TestableAcceptAdminRole(); | ||
|
|
||
| // Label contracts for better debugging | ||
| vm.label(address(rlcLiquidityUnifier), "RLCLiquidityUnifier"); | ||
| vm.label(address(rlcCrosschainToken), "RLCCrosschainToken"); | ||
| vm.label(admin, "admin"); | ||
| vm.label(newAdmin, "newAdmin"); | ||
gfournierPro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| // ====== revert scenarios checks ====== | ||
zguesmi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| function test_RevertWhen_NewAdminIsZeroAddress() public { | ||
| vm.startPrank(admin); | ||
zguesmi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| vm.expectRevert("BeginTransferAdminRole: new admin cannot be zero address"); | ||
| beginTransferScript.publicBeginTransfer(address(rlcLiquidityUnifier), address(0), "RLCLiquidityUnifier"); | ||
| vm.stopPrank(); | ||
| } | ||
|
|
||
| function test_RevertWhen_NewAdminIsSameAsCurrentAdmin() public { | ||
| vm.startPrank(admin); | ||
| vm.expectRevert("BeginTransferAdminRole: New admin must be different from current admin"); | ||
| beginTransferScript.publicBeginTransfer(address(rlcLiquidityUnifier), admin, "RLCLiquidityUnifier"); | ||
| vm.stopPrank(); | ||
| } | ||
|
|
||
| function test_RevertWhen_NotAuthorizedToTransferAdmin() public { | ||
| address unauthorizedUser = makeAddr("unauthorizedUser"); | ||
| vm.startPrank(unauthorizedUser); | ||
| vm.expectRevert(); // Should revert with access control error | ||
zguesmi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| beginTransferScript.publicBeginTransfer(address(rlcLiquidityUnifier), newAdmin, "RLCLiquidityUnifier"); | ||
| vm.stopPrank(); | ||
| } | ||
|
|
||
| function test_RevertWhen_WrongAddressTriesToAcceptAdmin() public { | ||
zguesmi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| beginTransferScript.publicBeginTransferAsAdmin( | ||
| address(rlcLiquidityUnifier), newAdmin, "RLCLiquidityUnifier", admin | ||
| ); | ||
|
|
||
| // Try to accept with wrong address using the script wrapper | ||
| address wrongAddress = makeAddr("wrongAddress"); | ||
|
|
||
| vm.expectRevert(); // Should revert because only pending admin can accept | ||
| acceptAdminScript.publicAcceptContractAdminAsUser( | ||
| address(rlcLiquidityUnifier), "RLCLiquidityUnifier", wrongAddress | ||
| ); | ||
| } | ||
|
|
||
| // ====== BeginTransferAdminRole.validateAdminTransfer ====== | ||
| function test_ValidateAdminTransfer() public { | ||
| // Test the validation function directly | ||
| vm.startPrank(admin); | ||
zguesmi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Should not revert with valid inputs | ||
| beginTransferScript.publicValidateAdminTransfer(admin, newAdmin); | ||
|
|
||
| // Should revert with zero address | ||
| vm.expectRevert("BeginTransferAdminRole: new admin cannot be zero address"); | ||
| beginTransferScript.publicValidateAdminTransfer(admin, address(0)); | ||
|
|
||
| // Should revert when new admin is same as current | ||
| vm.expectRevert("BeginTransferAdminRole: New admin must be different from current admin"); | ||
| beginTransferScript.publicValidateAdminTransfer(admin, admin); | ||
|
|
||
| vm.stopPrank(); | ||
| } | ||
|
|
||
| // ====== BeginTransferAdminRole.beginTransfer ====== | ||
| function test_BeginTransferAdminRole_LiquidityUnifier() public { | ||
zguesmi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| assertEq(IAccessControlDefaultAdminRules(address(rlcLiquidityUnifier)).defaultAdmin(), admin); | ||
| beginTransferScript.publicBeginTransferAsAdmin( | ||
| address(rlcLiquidityUnifier), newAdmin, "RLCLiquidityUnifier", admin | ||
| ); | ||
| // Verify that the admin transfer has been initiated | ||
| (address pendingAdmin,) = IAccessControlDefaultAdminRules(address(rlcLiquidityUnifier)).pendingDefaultAdmin(); | ||
| assertEq(pendingAdmin, newAdmin); | ||
|
|
||
| // Current admin should still be the initial admin until acceptance | ||
| assertEq(IAccessControlDefaultAdminRules(address(rlcLiquidityUnifier)).defaultAdmin(), admin); | ||
| } | ||
|
|
||
| function test_BeginTransferAdminRole_CrosschainToken() public { | ||
| assertEq(IAccessControlDefaultAdminRules(address(rlcCrosschainToken)).defaultAdmin(), admin); | ||
| beginTransferScript.publicBeginTransferAsAdmin( | ||
| address(rlcCrosschainToken), newAdmin, "RLCCrosschainToken", admin | ||
| ); | ||
|
|
||
| // Verify that the admin transfer has been initiated | ||
| (address pendingAdmin,) = IAccessControlDefaultAdminRules(address(rlcCrosschainToken)).pendingDefaultAdmin(); | ||
| assertEq(pendingAdmin, newAdmin); | ||
| } | ||
|
|
||
| // ====== AcceptAdminRole.acceptContractAdmin ====== | ||
| function test_AcceptAdminRole_LiquidityUnifier() public { | ||
| beginTransferScript.publicBeginTransferAsAdmin( | ||
| address(rlcLiquidityUnifier), newAdmin, "RLCLiquidityUnifier", admin | ||
| ); | ||
|
|
||
| // Get the delay schedule and wait for it to pass | ||
| (, uint48 acceptSchedule) = IAccessControlDefaultAdminRules(address(rlcLiquidityUnifier)).pendingDefaultAdmin(); | ||
| vm.warp(acceptSchedule + 1); // Wait until after the scheduled time | ||
|
|
||
| // Now accept as the new admin using the script wrapper | ||
| acceptAdminScript.publicAcceptContractAdminAsUser(address(rlcLiquidityUnifier), "RLCLiquidityUnifier", newAdmin); | ||
|
|
||
| // Verify that the admin transfer has been completed | ||
| assertEq(IAccessControlDefaultAdminRules(address(rlcLiquidityUnifier)).defaultAdmin(), newAdmin); | ||
|
|
||
| // Pending admin should be reset to zero | ||
| (address pendingAdmin,) = IAccessControlDefaultAdminRules(address(rlcLiquidityUnifier)).pendingDefaultAdmin(); | ||
| assertEq(pendingAdmin, address(0)); | ||
| } | ||
| } | ||
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.