-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add admin role to shared bridge (#727)
- Loading branch information
1 parent
5853c3a
commit 446d391
Showing
5 changed files
with
103 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,13 @@ import {IL1ERC20Bridge} from "./IL1ERC20Bridge.sol"; | |
/// @author Matter Labs | ||
/// @custom:security-contact [email protected] | ||
interface IL1SharedBridge { | ||
/// @notice pendingAdmin is changed | ||
/// @dev Also emitted when new admin is accepted and in this case, `newPendingAdmin` would be zero address | ||
event NewPendingAdmin(address indexed oldPendingAdmin, address indexed newPendingAdmin); | ||
|
||
/// @notice Admin changed | ||
event NewAdmin(address indexed oldAdmin, address indexed newAdmin); | ||
|
||
event LegacyDepositInitiated( | ||
uint256 indexed chainId, | ||
bytes32 indexed l2DepositTxHash, | ||
|
@@ -151,4 +158,12 @@ interface IL1SharedBridge { | |
function bridgehubConfirmL2Transaction(uint256 _chainId, bytes32 _txDataHash, bytes32 _txHash) external; | ||
|
||
function receiveEth(uint256 _chainId) external payable; | ||
|
||
/// @notice Starts the transfer of admin rights. Only the current admin can propose a new pending one. | ||
/// @notice New admin can accept admin rights by calling `acceptAdmin` function. | ||
/// @param _newPendingAdmin Address of the new admin | ||
function setPendingAdmin(address _newPendingAdmin) external; | ||
|
||
/// @notice Accepts transfer of admin rights. Only pending admin can accept the role. | ||
function acceptAdmin() external; | ||
} |
26 changes: 26 additions & 0 deletions
26
l1-contracts/test/foundry/unit/concrete/Bridges/L1SharedBridge/L1SharedBridgeAdmin.t.sol
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,26 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import {L1SharedBridgeTest} from "./_L1SharedBridge_Shared.t.sol"; | ||
|
||
/// We are testing all the specified revert and require cases. | ||
contract L1SharedBridgeAdminTest is L1SharedBridgeTest { | ||
uint256 internal randomChainId = 123456; | ||
|
||
function testAdminCanInitializeChainGovernance() public { | ||
address randomL2Bridge = makeAddr("randomL2Bridge"); | ||
|
||
vm.prank(admin); | ||
sharedBridge.initializeChainGovernance(randomChainId, randomL2Bridge); | ||
|
||
assertEq(sharedBridge.l2BridgeAddress(randomChainId), randomL2Bridge); | ||
} | ||
|
||
function testAdminCanNotReinitializeChainGovernance() public { | ||
address randomNewBridge = makeAddr("randomNewBridge"); | ||
|
||
vm.expectRevert("Ownable: caller is not the owner"); | ||
vm.prank(admin); | ||
sharedBridge.reinitializeChainGovernance(randomChainId, randomNewBridge); | ||
} | ||
} |
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