Skip to content
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

feat: add onlyOwner to Registry::upgrade #7899

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 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);
}
}
Loading