Skip to content

Commit

Permalink
add pause all / unpause all actions
Browse files Browse the repository at this point in the history
  • Loading branch information
DZGoldman committed Oct 24, 2023
1 parent 742585f commit 4583fef
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 4 deletions.
26 changes: 26 additions & 0 deletions src/gov-action-contracts/pause-all/PauseAllAction.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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;
address[] sequencersToRemove;

constructor(IL1AddressRegistry _addressRegistry, address[] memory _sequencersToRemove) {
addressRegistry = _addressRegistry;
sequencersToRemove = _sequencersToRemove;
}

function perform() external {
addressRegistry.inbox().pause();
addressRegistry.rollup().pause();
OutboxActionLib.bridgeRemoveAllOutboxes(addressRegistry);
for (uint256 i = 0; i < sequencersToRemove.length; i++) {
SequencerActionLib.removeSequencer(addressRegistry, sequencersToRemove[i]);
}
}
}
32 changes: 32 additions & 0 deletions src/gov-action-contracts/pause-all/UnpauseAllAction.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// 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;
address[] sequencersToAdd;
address[] outboxesToAdd;

constructor(
IL1AddressRegistry _addressRegistry,
address[] memory _sequencersToAdd,
address[] memory outboxesToAdd
) {
addressRegistry = _addressRegistry;
sequencersToAdd = _sequencersToAdd;
outboxesToAdd = outboxesToAdd;
}

function perform() external {
addressRegistry.inbox().unpause();
addressRegistry.rollup().resume();
OutboxActionLib.bridgeAddOutboxes(addressRegistry, outboxesToAdd);
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

0 comments on commit 4583fef

Please sign in to comment.