Skip to content

Commit

Permalink
use interface where it was used before
Browse files Browse the repository at this point in the history
  • Loading branch information
godzillaba committed Oct 21, 2024
1 parent 97e3103 commit cbc5c7d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/UpgradeExecRouteBuilder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity 0.8.16;

import "@arbitrum/nitro-contracts/src/precompiles/ArbSys.sol";
import "@offchainlabs/upgrade-executor/src/IUpgradeExecutor.sol";
import "@offchainlabs/upgrade-executor/src/UpgradeExecutor.sol";
import "./L1ArbitrumTimelock.sol";
import "./security-council-mgmt/Common.sol";

Expand Down Expand Up @@ -136,7 +136,7 @@ contract UpgradeExecRouteBuilder {
}

bytes memory executorData = abi.encodeWithSelector(
IUpgradeExecutor.execute.selector, actionAddresses[i], actionDatas[i]
UpgradeExecutor.execute.selector, actionAddresses[i], actionDatas[i]
);

// for L1, inbox is set to address(0):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import "../../../security-council-mgmt/interfaces/IGnosisSafe.sol";
import "../../address-registries/L2AddressRegistryInterfaces.sol";
import "./SecurityCouncilMgmtUpgradeLib.sol";
import "../../../interfaces/IArbitrumDAOConstitution.sol";
import "@offchainlabs/upgrade-executor/src/UpgradeExecutor.sol";
import "@offchainlabs/upgrade-executor/src/IUpgradeExecutor.sol";
import "../../../interfaces/ICoreTimelock.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/access/IAccessControl.sol";

contract GovernanceChainSCMgmtActivationAction {
IGnosisSafe public immutable newEmergencySecurityCouncil;
Expand Down Expand Up @@ -49,7 +50,7 @@ contract GovernanceChainSCMgmtActivationAction {
}

function perform() external {
UpgradeExecutor upgradeExecutor = UpgradeExecutor(l2AddressRegistry.coreGov().owner());
IUpgradeExecutor upgradeExecutor = IUpgradeExecutor(l2AddressRegistry.coreGov().owner());

// swap in new emergency security council
SecurityCouncilMgmtUpgradeLib.replaceEmergencySecurityCouncil({
Expand Down Expand Up @@ -116,11 +117,11 @@ contract GovernanceChainSCMgmtActivationAction {
// confirm updates
bytes32 EXECUTOR_ROLE = upgradeExecutor.EXECUTOR_ROLE();
require(
upgradeExecutor.hasRole(EXECUTOR_ROLE, address(newEmergencySecurityCouncil)),
IAccessControl(address(upgradeExecutor)).hasRole(EXECUTOR_ROLE, address(newEmergencySecurityCouncil)),
"NonGovernanceChainSCMgmtActivationAction: new emergency security council not set"
);
require(
!upgradeExecutor.hasRole(EXECUTOR_ROLE, address(prevEmergencySecurityCouncil)),
!IAccessControl(address(upgradeExecutor)).hasRole(EXECUTOR_ROLE, address(prevEmergencySecurityCouncil)),
"NonGovernanceChainSCMgmtActivationAction: prev emergency security council still set"
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ contract L1SCMgmtActivationAction {
IGnosisSafe public immutable newEmergencySecurityCouncil;
IGnosisSafe public immutable prevEmergencySecurityCouncil;
uint256 public immutable emergencySecurityCouncilThreshold;
UpgradeExecutor public immutable l1UpgradeExecutor;
IUpgradeExecutor public immutable l1UpgradeExecutor;
ICoreTimelock public immutable l1Timelock;

constructor(
IGnosisSafe _newEmergencySecurityCouncil,
IGnosisSafe _prevEmergencySecurityCouncil,
uint256 _emergencySecurityCouncilThreshold,
UpgradeExecutor _l1UpgradeExecutor,
IUpgradeExecutor _l1UpgradeExecutor,
ICoreTimelock _l1Timelock
) {
newEmergencySecurityCouncil = _newEmergencySecurityCouncil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ contract NonGovernanceChainSCMgmtActivationAction {
IGnosisSafe public immutable newEmergencySecurityCouncil;
IGnosisSafe public immutable prevEmergencySecurityCouncil;
uint256 public immutable emergencySecurityCouncilThreshold;
UpgradeExecutor public immutable upgradeExecutor;
IUpgradeExecutor public immutable upgradeExecutor;

constructor(
IGnosisSafe _newEmergencySecurityCouncil,
IGnosisSafe _prevEmergencySecurityCouncil,
uint256 _emergencySecurityCouncilThreshold,
UpgradeExecutor _upgradeExecutor
IUpgradeExecutor _upgradeExecutor
) {
newEmergencySecurityCouncil = _newEmergencySecurityCouncil;
prevEmergencySecurityCouncil = _prevEmergencySecurityCouncil;
Expand All @@ -34,11 +34,11 @@ contract NonGovernanceChainSCMgmtActivationAction {
// confirm updates
bytes32 EXECUTOR_ROLE = upgradeExecutor.EXECUTOR_ROLE();
require(
upgradeExecutor.hasRole(EXECUTOR_ROLE, address(newEmergencySecurityCouncil)),
IAccessControl(address(upgradeExecutor)).hasRole(EXECUTOR_ROLE, address(newEmergencySecurityCouncil)),
"NonGovernanceChainSCMgmtActivationAction: new emergency security council not set"
);
require(
!upgradeExecutor.hasRole(EXECUTOR_ROLE, address(prevEmergencySecurityCouncil)),
!IAccessControl(address(upgradeExecutor)).hasRole(EXECUTOR_ROLE, address(prevEmergencySecurityCouncil)),
"NonGovernanceChainSCMgmtActivationAction: prev emergency security council still set"
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@
pragma solidity 0.8.16;

import "../../../security-council-mgmt/interfaces/IGnosisSafe.sol";
import "@offchainlabs/upgrade-executor/src/UpgradeExecutor.sol";
import "@offchainlabs/upgrade-executor/src/IUpgradeExecutor.sol";
import "@openzeppelin/contracts/access/IAccessControl.sol";

library SecurityCouncilMgmtUpgradeLib {
function replaceEmergencySecurityCouncil(
IGnosisSafe _prevSecurityCouncil,
IGnosisSafe _newSecurityCouncil,
uint256 _threshold,
UpgradeExecutor _upgradeExecutor
IUpgradeExecutor _upgradeExecutor
) internal {
requireSafesEquivalent(_prevSecurityCouncil, _newSecurityCouncil, _threshold);
bytes32 EXECUTOR_ROLE = _upgradeExecutor.EXECUTOR_ROLE();
require(
_upgradeExecutor.hasRole(EXECUTOR_ROLE, address(_prevSecurityCouncil)),
IAccessControl(address(_upgradeExecutor)).hasRole(EXECUTOR_ROLE, address(_prevSecurityCouncil)),
"SecurityCouncilMgmtUpgradeLib: prev council not executor"
);
require(
!_upgradeExecutor.hasRole(EXECUTOR_ROLE, address(_newSecurityCouncil)),
!IAccessControl(address(_upgradeExecutor)).hasRole(EXECUTOR_ROLE, address(_newSecurityCouncil)),
"SecurityCouncilMgmtUpgradeLib: new council already executor"
);

_upgradeExecutor.revokeRole(EXECUTOR_ROLE, address(_prevSecurityCouncil));
_upgradeExecutor.grantRole(EXECUTOR_ROLE, address(_newSecurityCouncil));
IAccessControl(address(_upgradeExecutor)).revokeRole(EXECUTOR_ROLE, address(_prevSecurityCouncil));
IAccessControl(address(_upgradeExecutor)).grantRole(EXECUTOR_ROLE, address(_newSecurityCouncil));
}

function requireSafesEquivalent(
Expand Down
2 changes: 1 addition & 1 deletion test/security-council-mgmt/E2E.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ contract E2E is Test, DeployGnosisWithModule {
IGnosisSafe(address(vars.moduleL1Safe)),
IGnosisSafe(l1EmergencyCouncil),
secCouncilThreshold,
UpgradeExecutor(address(vars.l1Executor)),
IUpgradeExecutor(address(vars.l1Executor)),
ICoreTimelock(address(vars.l1Timelock))
);

Expand Down

0 comments on commit cbc5c7d

Please sign in to comment.