Skip to content

Commit

Permalink
feat: add onlyOwner to Registry::upgrade (#7899)
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind authored Aug 12, 2024
1 parent 09e317d commit 7dc19db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion l1-contracts/src/core/messagebridge/Registry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ contract Registry is IRegistry, Ownable {

/**
* @notice Creates a new snapshot of the registry
*
* @dev Only callable by the owner
* @dev Reverts if the rollup is already registered
* todo: this function must be permissioned with some kind of governance/voting/authority
*
* @param _rollup - The address of the rollup contract
* @param _inbox - The address of the inbox contract
* @param _outbox - The address of the outbox contract
Expand All @@ -109,6 +111,7 @@ contract Registry is IRegistry, Ownable {
function upgrade(address _rollup, address _inbox, address _outbox)
public
override(IRegistry)
onlyOwner
returns (uint256)
{
(, bool exists) = _getVersionFor(_rollup);
Expand Down
10 changes: 8 additions & 2 deletions l1-contracts/test/Registry.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
pragma solidity >=0.8.18;

import {Test} from "forge-std/Test.sol";
import {IInbox} from "../src/core/interfaces/messagebridge/IInbox.sol";
import {Inbox} from "../src/core/messagebridge/Inbox.sol";
import {Ownable} from "@oz/access/Ownable.sol";
import {Registry} from "../src/core/messagebridge/Registry.sol";
import {Errors} from "../src/core/libraries/Errors.sol";

Expand Down Expand Up @@ -64,4 +63,11 @@ contract RegistryTest is Test {
vm.expectRevert(abi.encodeWithSelector(Errors.Registry__RollupNotRegistered.selector, rollup));
registry.getVersionFor(rollup);
}

function testRevertUpgradeAsNonOwner(address _owner) public {
vm.assume(_owner != registry.owner());
vm.expectRevert(abi.encodeWithSelector(Ownable.OwnableUnauthorizedAccount.selector, _owner));
vm.prank(_owner);
registry.upgrade(DEAD, DEAD, DEAD);
}
}

0 comments on commit 7dc19db

Please sign in to comment.