From 8f6beb5d3afc667edec5fc68af6ea2d280c052ae Mon Sep 17 00:00:00 2001 From: nadir-akhtar-coinbase <64859114+nadir-akhtar-coinbase@users.noreply.github.com> Date: Wed, 6 Mar 2024 10:39:08 -0800 Subject: [PATCH] [sepolia] Incident practice - pause and unpause Sepolia (#126) * Add auto-generated contracts and set up .env file * Remove unneeded files and info * Remove unneeded Makefile commands * Refactor for EOA * Remove constant type due to compiler issues * Add require statements and slightly refactor * Update Makefile for EOA signing and broadcasting * Use addr for broadcasting --- sepolia/2024-02-28-pause-unpause-portal/.env | 6 ++++ .../2024-02-28-pause-unpause-portal/Makefile | 29 +++++++++++++++++++ .../foundry.toml | 19 ++++++++++++ .../script/PausePortal.s.sol | 19 ++++++++++++ .../script/UnpausePortal.s.sol | 19 ++++++++++++ 5 files changed, 92 insertions(+) create mode 100644 sepolia/2024-02-28-pause-unpause-portal/.env create mode 100644 sepolia/2024-02-28-pause-unpause-portal/Makefile create mode 100644 sepolia/2024-02-28-pause-unpause-portal/foundry.toml create mode 100644 sepolia/2024-02-28-pause-unpause-portal/script/PausePortal.s.sol create mode 100644 sepolia/2024-02-28-pause-unpause-portal/script/UnpausePortal.s.sol diff --git a/sepolia/2024-02-28-pause-unpause-portal/.env b/sepolia/2024-02-28-pause-unpause-portal/.env new file mode 100644 index 00000000..5399c66e --- /dev/null +++ b/sepolia/2024-02-28-pause-unpause-portal/.env @@ -0,0 +1,6 @@ +OP_COMMIT=10b06fb49861053999a89533d846ee5c2ccb33e1 +BASE_CONTRACTS_COMMIT=fe492be3478134b2305c207a12b153eca04148c0 + +GUARDIAN=0xA9FF930151130fd19DA1F03E5077AFB7C78F8503 +OPTIMISM_PORTAL_PROXY=0x49f53e41452C74589E85cA1677426Ba426459e85 +GUARDIAN_PRIVATE_KEY= # TODO: Fill in when running script diff --git a/sepolia/2024-02-28-pause-unpause-portal/Makefile b/sepolia/2024-02-28-pause-unpause-portal/Makefile new file mode 100644 index 00000000..7fa84939 --- /dev/null +++ b/sepolia/2024-02-28-pause-unpause-portal/Makefile @@ -0,0 +1,29 @@ +include ../../Makefile +include ../.env +include .env + +ifndef LEDGER_ACCOUNT +override LEDGER_ACCOUNT = 0 +endif + +## +# Incident response commands +# Note that --ledger --hd-paths can be replaced with --private-key $(PRIVATE_KEY) +# in any command when using a local key. +## + +# Pause OptimismPortal Commands + +.PHONY: pause-portal +pause-portal: deps + forge script --rpc-url $(L1_RPC_URL) \ + PausePortal --private-key $(GUARDIAN_PRIVATE_KEY) \ + --broadcast + +# Unpause OptimismPortal Commands + +.PHONY: unpause-portal +unpause-portal: deps + forge script --rpc-url $(L1_RPC_URL) \ + UnpausePortal --private-key $(GUARDIAN_PRIVATE_KEY) \ + --broadcast diff --git a/sepolia/2024-02-28-pause-unpause-portal/foundry.toml b/sepolia/2024-02-28-pause-unpause-portal/foundry.toml new file mode 100644 index 00000000..f9d2c247 --- /dev/null +++ b/sepolia/2024-02-28-pause-unpause-portal/foundry.toml @@ -0,0 +1,19 @@ +[profile.default] +src = 'src' +out = 'out' +libs = ['lib'] +broadcast = 'records' +fs_permissions = [ {access = "read-write", path = "./"} ] +optimizer = true +optimizer_runs = 999999 +solc_version = "0.8.15" +via-ir = true +remappings = [ + '@eth-optimism-bedrock/=lib/optimism/packages/contracts-bedrock/', + '@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts', + '@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts', + '@rari-capital/solmate/=lib/solmate/', + '@base-contracts/=lib/base-contracts' +] + +# See more config options https://github.com/foundry-rs/foundry/tree/master/config diff --git a/sepolia/2024-02-28-pause-unpause-portal/script/PausePortal.s.sol b/sepolia/2024-02-28-pause-unpause-portal/script/PausePortal.s.sol new file mode 100644 index 00000000..77094058 --- /dev/null +++ b/sepolia/2024-02-28-pause-unpause-portal/script/PausePortal.s.sol @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.15; + +import "forge-std/Script.sol"; +import "@eth-optimism-bedrock/src/L1/OptimismPortal.sol"; + +contract PausePortal is Script { + address internal OPTIMISM_PORTAL_PROXY = vm.envAddress("OPTIMISM_PORTAL_PROXY"); + address internal GUARDIAN = vm.envAddress("GUARDIAN"); + + function run() external { + OptimismPortal optimismPortal = OptimismPortal(payable(OPTIMISM_PORTAL_PROXY)); + + vm.broadcast(GUARDIAN); + optimismPortal.pause(); + + require(optimismPortal.paused() == true, "PausePortal: failed to pause"); + } +} diff --git a/sepolia/2024-02-28-pause-unpause-portal/script/UnpausePortal.s.sol b/sepolia/2024-02-28-pause-unpause-portal/script/UnpausePortal.s.sol new file mode 100644 index 00000000..8f6217ee --- /dev/null +++ b/sepolia/2024-02-28-pause-unpause-portal/script/UnpausePortal.s.sol @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.15; + +import "forge-std/Script.sol"; +import "@eth-optimism-bedrock/src/L1/OptimismPortal.sol"; + +contract UnpausePortal is Script { + address internal OPTIMISM_PORTAL_PROXY = vm.envAddress("OPTIMISM_PORTAL_PROXY"); + address internal GUARDIAN = vm.envAddress("GUARDIAN"); + + function run() external { + OptimismPortal optimismPortal = OptimismPortal(payable(OPTIMISM_PORTAL_PROXY)); + + vm.broadcast(GUARDIAN); + optimismPortal.unpause(); + + require(optimismPortal.paused() == false, "PausePortal: failed to unpause"); + } +}