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

add pause all / unpause all action contracts #220

Open
wants to merge 2 commits into
base: deploy-actions
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@ contract L1AddressRegistry is IL1AddressRegistry {
IL1Timelock public immutable l1Timelock;
IL1CustomGateway public immutable customGateway;
IL1GatewayRouter public immutable gatewayRouter;
address[] public outboxes;
address[] public sequencers;

constructor(
IInbox _inbox,
IL1Timelock _l1Timelock,
IL1CustomGateway _customGateway,
IL1GatewayRouter _gatewayRouter
IL1GatewayRouter _gatewayRouter,
address[] memory _outboxes,
address[] memory _sequencers
) {
inbox = _inbox;
l1Timelock = _l1Timelock;
customGateway = _customGateway;
gatewayRouter = _gatewayRouter;
outboxes = _outboxes;
sequencers = _sequencers;
}

function rollup() public view returns (IRollupCore) {
Expand All @@ -32,4 +38,12 @@ contract L1AddressRegistry is IL1AddressRegistry {
function sequencerInbox() public view returns (ISequencerInbox) {
return inbox.sequencerInbox();
}

function getOutboxes() public view returns (address[] memory) {
return outboxes;
}

function getSequencers() public view returns (address[] memory) {
return sequencers;
Copy link
Collaborator

@yahgwai yahgwai Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think sequencers can be expected to change, likewise outboxes, so we probably dont want to hardcode them here. I think it would be better to add some pause functionality to the bridge instead, but maybe that's a longer term solution for a different pr?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm yeah agreed; pausable bridge let's us more directly both pause sequencing, outbox execution, and gives means to pause force inclusion, v nice. Kinda like the idea of pushing forward with that in the short/ASAP - term. (tho in the immediate term maybe we temporarily have this? idk)

}
}
5 changes: 4 additions & 1 deletion src/gov-action-contracts/address-registries/interfaces.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,7 @@ interface IL1AddressRegistry is
IL1TimelockGetter,
IL1GatewayRouterGetter,
IL1CustomGatewayGetter
{}
{
function getSequencers() external view returns (address[] memory);
function getOutboxes() external view returns (address[] memory);
}
25 changes: 25 additions & 0 deletions src/gov-action-contracts/pause-all/PauseAllAction.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.16;

import "../address-registries/interfaces.sol";
import "../set-outbox/OutboxActionLib.sol";
import "../sequencer/SequencerActionLib.sol";

/// @notice pause inbox and rollup, remove all outboxes and sequencers
contract PauseAllAction {
IL1AddressRegistry public immutable addressRegistry;

constructor(IL1AddressRegistry _addressRegistry) {
addressRegistry = _addressRegistry;
}

function perform() external {
addressRegistry.inbox().pause();
addressRegistry.rollup().pause();
OutboxActionLib.bridgeRemoveAllOutboxes(addressRegistry);
address[] memory sequencersToRemove = addressRegistry.getSequencers();
for (uint256 i = 0; i < sequencersToRemove.length; i++) {
SequencerActionLib.removeSequencer(addressRegistry, sequencersToRemove[i]);
}
}
}
25 changes: 25 additions & 0 deletions src/gov-action-contracts/pause-all/UnpauseAllAction.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.16;

import "../address-registries/interfaces.sol";
import "../set-outbox/OutboxActionLib.sol";
import "../sequencer/SequencerActionLib.sol";

/// @notice unpause inbox and rollup, add outboxes and sequencers (i.e., undoes PauseAllAction)
contract UnPauseAllAction {
IL1AddressRegistry public immutable addressRegistry;

constructor(IL1AddressRegistry _addressRegistry) {
addressRegistry = _addressRegistry;
}

function perform() external {
addressRegistry.inbox().unpause();
addressRegistry.rollup().resume();
OutboxActionLib.bridgeAddOutboxes(addressRegistry, addressRegistry.getOutboxes());
address[] memory sequencersToAdd = addressRegistry.getSequencers();
for (uint256 i = 0; i < sequencersToAdd.length; i++) {
SequencerActionLib.addSequencer(addressRegistry, sequencersToAdd[i]);
}
}
}
6 changes: 2 additions & 4 deletions src/gov-action-contracts/set-outbox/OutboxActionLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import "@openzeppelin/contracts/utils/Address.sol";
import "@arbitrum/nitro-contracts/src/bridge/IOutbox.sol";

library OutboxActionLib {
function bridgeAddOutboxes(IBridgeGetter addressRegistry, address[] calldata outboxes)
internal
{
function bridgeAddOutboxes(IBridgeGetter addressRegistry, address[] memory outboxes) internal {
IBridge bridge = addressRegistry.bridge();
for (uint256 i = 0; i < outboxes.length; i++) {
address outbox = outboxes[i];
Expand All @@ -20,7 +18,7 @@ library OutboxActionLib {
}
}

function bridgeRemoveOutboxes(IBridgeGetter addressRegistry, address[] calldata outboxes)
function bridgeRemoveOutboxes(IBridgeGetter addressRegistry, address[] memory outboxes)
internal
{
IBridge bridge = addressRegistry.bridge();
Expand Down
4 changes: 3 additions & 1 deletion test/util/ActionTestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ abstract contract ActionTestBase {
l1Timelock.grantRole(l1Timelock.TIMELOCK_ADMIN_ROLE(), address(ue));
l1Timelock.revokeRole(l1Timelock.TIMELOCK_ADMIN_ROLE(), address(l1Timelock));
l1Timelock.revokeRole(l1Timelock.TIMELOCK_ADMIN_ROLE(), address(this));
address[] memory outboxes = new address[](0);
address[] memory sequencers = new address[](0);

addressRegistry =
new _ar.L1AddressRegistry(IInbox(address(inbox)), _ifaces.IL1Timelock(address(l1Timelock)), _ifaces.IL1CustomGateway(address(0)), _ifaces.IL1GatewayRouter(address(0)));
new _ar.L1AddressRegistry(IInbox(address(inbox)), _ifaces.IL1Timelock(address(l1Timelock)), _ifaces.IL1CustomGateway(address(0)), _ifaces.IL1GatewayRouter(address(0)), outboxes, sequencers);
bridgeGetter = _ifaces.IBridgeGetter(address(addressRegistry));
inboxGetter = _ifaces.IInboxGetter(address(addressRegistry));
sequencerInboxGetter = _ifaces.ISequencerInboxGetter(address(addressRegistry));
Expand Down
Loading