-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* rebase and fix prank in tests * readd tests * move function to rootbridge interface * add adaptor roles * make rootchain tests pass with adaptorroles * add root adaptor functions * add rootchain tests * integrate adaptor roles into child bridge adaptor * integrate update rootbridge adaptor for child chain * forge fmt * PR fixes * clean up PR for review * fmt * fix test name
- Loading branch information
Showing
22 changed files
with
1,007 additions
and
106 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,66 @@ | ||
// SPDX-License-Identifier: Apache 2.0 | ||
pragma solidity 0.8.19; | ||
|
||
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; | ||
|
||
/** | ||
* | ||
* @title AdaptorRoles.sol | ||
* @notice AdaptorRoles.sol is an abstract contract that defines the roles and permissions across the root and child chain adaptor contracts. | ||
* @dev This contract uses OpenZeppelin's AccessControl contract. This contract is abstract and is intended to be inherited by the root and child chain adaptor contracts. | ||
*/ | ||
abstract contract AdaptorRoles is AccessControlUpgradeable { | ||
// Roles | ||
/// @notice Role identifier for those who can update the bridge used by the adaptor. | ||
bytes32 public constant BRIDGE_MANAGER_ROLE = keccak256("BRIDGE_MANAGER"); | ||
|
||
/// @notice Role identifier for those who can update the gas service used by the adaptor. | ||
bytes32 public constant GAS_SERVICE_MANAGER_ROLE = keccak256("GAS_SERVICE_MANAGER"); | ||
|
||
/// @notice Role identifier for those who can update targeted bridge used by the adpator (e.g. target is child chain on root adaptors). | ||
bytes32 public constant TARGET_MANAGER_ROLE = keccak256("TARGET_MANAGER"); | ||
|
||
// Role granting functions | ||
/** | ||
* @notice Function to grant bridge manager role to an address | ||
*/ | ||
function grantBridgeManager(address account) external onlyRole(DEFAULT_ADMIN_ROLE) { | ||
grantRole(BRIDGE_MANAGER_ROLE, account); | ||
} | ||
|
||
/** | ||
* @notice Function to grant gas service manager role to an address | ||
*/ | ||
function grantGasServiceManager(address account) external onlyRole(DEFAULT_ADMIN_ROLE) { | ||
grantRole(GAS_SERVICE_MANAGER_ROLE, account); | ||
} | ||
|
||
/** | ||
* @notice Function to grant target manager role to an address | ||
*/ | ||
function grantTargetManagerRole(address account) external onlyRole(DEFAULT_ADMIN_ROLE) { | ||
grantRole(TARGET_MANAGER_ROLE, account); | ||
} | ||
|
||
// Role revoking functions | ||
/** | ||
* @notice Function to revoke bridge manager role from an address | ||
*/ | ||
function revokeBridgeManagerRole(address account) external onlyRole(DEFAULT_ADMIN_ROLE) { | ||
revokeRole(BRIDGE_MANAGER_ROLE, account); | ||
} | ||
|
||
/** | ||
* @notice Function to revoke gas service manager role from an address | ||
*/ | ||
function revokeGasServiceManagerRole(address account) external onlyRole(DEFAULT_ADMIN_ROLE) { | ||
revokeRole(GAS_SERVICE_MANAGER_ROLE, account); | ||
} | ||
|
||
/** | ||
* @notice Function to target manager role from an address | ||
*/ | ||
function revokeTargetMangaerRole(address account) external onlyRole(DEFAULT_ADMIN_ROLE) { | ||
revokeRole(TARGET_MANAGER_ROLE, account); | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -1,18 +1,57 @@ | ||
// SPDX-License-Identifier: Apache 2.0 | ||
pragma solidity 0.8.19; | ||
|
||
interface IChildAxelarBridgeAdaptor { | ||
/// @notice Initialization roles used by the adaptor. | ||
struct InitializationRoles { | ||
address defaultAdmin; // The address which will inherit `DEFAULT_ADMIN_ROLE`. | ||
address bridgeManager; // The address which will inherit `BRIDGE_MANAGER_ROLE`. | ||
address gasServiceManager; // The address which will inherit `GAS_SERVICE_MANAGER_ROLE`. | ||
address targetManager; // The address which will inherit `TARGET_MANAGER_ROLE`. | ||
} | ||
|
||
/** | ||
* @notice Update the child bridge | ||
* @param newChildBridge Address of new root bridge. | ||
* @dev Can only be called by BRIDGE_MANAGER_ROLE. | ||
*/ | ||
function updateChildBridge(address newChildBridge) external; | ||
|
||
/** | ||
* @notice Update the root chain name. | ||
* @param newRootChain Name of new root chain. | ||
* @dev Can only be called by TARGET_MANAGER_ROLE. | ||
*/ | ||
function updateRootChain(string memory newRootChain) external; | ||
|
||
/** | ||
* @notice Update the gas service. | ||
* @param newGasService Address of new gas service. | ||
* @dev Can only be called by GAS_SERVICE_MANAGER_ROLE. | ||
*/ | ||
function updateGasService(address newGasService) external; | ||
} | ||
|
||
interface IChildAxelarBridgeAdaptorErrors { | ||
/// @notice Error when a zero address is given when not valid. | ||
error ZeroAddress(); | ||
/// @notice Error when a message is sent with no gas payment. | ||
error NoGas(); | ||
/// @notice Error when the caller is not the bridge. | ||
error CallerNotBridge(); | ||
/// @notice Error when the root chain name is invalid. | ||
error InvalidRootChain(); | ||
} | ||
|
||
interface IChildAxelarBridgeAdaptorEvents { | ||
/// @notice Emitted when an Axelar message is sent to the root chain. | ||
event AxelarMessageSent(string indexed rootChain, string indexed rootBridgeAdaptor, bytes indexed payload); | ||
/// @notice Emitted when an Axelar message is received from the root chain. | ||
event AdaptorExecute(string sourceChain, string sourceAddress_, bytes payload_); | ||
/// @notice Emitted when the child bridge is updated. | ||
event ChildBridgeUpdated(address indexed oldRootBridge, address indexed newRootBridge); | ||
/// @notice Emitted when the root chain name is updated. | ||
event RootChainUpdated(string indexed oldChildChain, string indexed newChildChain); | ||
/// @notice Emitted when the gas service is updated. | ||
event GasServiceUpdated(address indexed oldGasService, address indexed newGasService); | ||
} |
Oops, something went wrong.