Skip to content

Commit 7d35390

Browse files
authored
feat: Add Task Template for Switching Base to a Permissioned Game and Retiring Existing Dispute Games (#434)
* init run * update only template * rename to switch to permissioned game * update script name * update readme * fix typo * add postcheck for permissioned cannon * add gametype postcheck * add filled in senders for base simulation * update readme * fix makefile * pr feedback * fix readme * fix comment * rm unused variable * make compatible with signer tool * update readmes * pr feedback * pr feedback
1 parent 9020251 commit 7d35390

File tree

7 files changed

+215
-0
lines changed

7 files changed

+215
-0
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ SAFE_MANAGEMENT_DIR = $(network)/$(shell date +'%Y-%m-%d')-safe-management
88
FUNDING_DIR = $(network)/$(shell date +'%Y-%m-%d')-funding
99
SET_BASE_BRIDGE_PARTNER_THRESHOLD_DIR = $(network)/$(shell date +'%Y-%m-%d')-pause-bridge-base
1010
PAUSE_BRIDGE_BASE_DIR = $(network)/$(shell date +'%Y-%m-%d')-pause-bridge-base
11+
SWITCH_TO_PERMISSIONED_GAME_DIR=$(network)/$(shell date +'%Y-%m-%d')-switch-to-permissioned-game
1112

1213
TEMPLATE_GENERIC = setup-templates/template-generic
1314
TEMPLATE_GAS_INCREASE = setup-templates/template-gas-increase
@@ -17,6 +18,7 @@ TEMPLATE_SAFE_MANAGEMENT = setup-templates/template-safe-management
1718
TEMPLATE_FUNDING = setup-templates/template-funding
1819
TEMPLATE_SET_BASE_BRIDGE_PARTNER_THRESHOLD = setup-templates/template-set-bridge-partner-threshold
1920
TEMPLATE_PAUSE_BRIDGE_BASE = setup-templates/template-pause-bridge-base
21+
TEMPLATE_SWITCH_TO_PERMISSIONED_GAME = setup-templates/template-switch-to-permissioned-game
2022

2123
ifndef $(GOPATH)
2224
GOPATH=$(shell go env GOPATH)
@@ -70,6 +72,10 @@ setup-bridge-pause:
7072
rm -rf $(TEMPLATE_PAUSE_BRIDGE_BASE)/cache $(TEMPLATE_PAUSE_BRIDGE_BASE)/lib $(TEMPLATE_PAUSE_BRIDGE_BASE)/out
7173
cp -r $(TEMPLATE_PAUSE_BRIDGE_BASE) $(PAUSE_BRIDGE_BASE_DIR)
7274

75+
setup-switch-to-permissioned-game:
76+
rm -rf $(TEMPLATE_SWITCH_TO_PERMISSIONED_GAME)/cache $(TEMPLATE_SWITCH_TO_PERMISSIONED_GAME)/lib $(TEMPLATE_SWITCH_TO_PERMISSIONED_GAME)/out
77+
cp -r $(TEMPLATE_SWITCH_TO_PERMISSIONED_GAME) $(SWITCH_TO_PERMISSIONED_GAME_DIR)
78+
7379
##
7480
# Solidity Setup
7581
##

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ To execute a new task, run one of the following commands (depending on the type
4444
- For funding tasks: `make setup-funding network=<network>`
4545
- For updating the partner threshold in Base Bridge: `make setup-bridge-partner-threshold network=<network>`
4646
- For pausing / un-pausing Base Bridge: `make setup-bridge-pause network=<network>`
47+
- For switching to a permissioned game and retiring dispute games: `make setup-switch-to-permissioned-game network=<network>`
4748

4849
Next, `cd` into the directory that was created for you and follow the steps listed below for the relevant template.
4950

@@ -192,3 +193,17 @@ This template is used to pause or un-pause [Base Bridge](https://github.com/base
192193
1. Generate the validation file for signers with `make gen-validation`.
193194
1. Check in the task when it's ready to sign and request the facilitators to collect signatures from signers.
194195
1. Once executed, check in the records files and mark the task `EXECUTED` in the README.
196+
197+
## Using the Switch to Permissioned Game template
198+
199+
This template is used to switch Base to a Permissioned Game.
200+
201+
1. Ensure you have followed the instructions above in `setup`.
202+
1. Run `make setup-switch-to-permissioned-game network=<network>` and go to the folder that was created by this command.
203+
1. Specify the commit of [Optimism code](https://github.com/ethereum-optimism/optimism) and [Base contracts code](https://github.com/base/contracts) you intend to use in the `.env` file.
204+
1. Run `make deps`.
205+
1. Ensure only the Sepolia or Mainnet variables are in the `.env` file depending on what network this task is for.
206+
1. Build the contracts with `forge build`.
207+
1. Generate the validation file for signers with `make gen-validation`.
208+
1. Check in the task when it's ready to sign and request the facilitators to collect signatures from signers.
209+
1. Once executed, check in the records files and mark the task `EXECUTED` in the README.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
OP_COMMIT=
2+
BASE_CONTRACTS_COMMIT=
3+
4+
RECORD_STATE_DIFF=true
5+
6+
# Mainnet Config
7+
SYSTEM_CONFIG=0x73a79Fab69143498Ed3712e519A88a918e1f4072
8+
9+
# Optimism Guardian Multisig (controls Anchor State Registry)
10+
OWNER_SAFE=0x09f7150D8c019BeF34450d6920f6B3608ceFdAf2
11+
# Owner of Optimism Guardian Multisig
12+
OP_SECURITY_COUNCIL_SAFE=0xc2819DC788505Aac350142A7A707BF9D03E3Bd03
13+
14+
SENDER=0x1822b35B09f5ce1C78ecbC06AC0A4e17885b925e # used to simulate
15+
16+
# #Sepolia Config
17+
#SYSTEM_CONFIG=0xf272670eb55e895584501d564AfEB048bEd26194
18+
19+
# #Optimism Guardian Multisig (controls Anchor State Registry)
20+
#OWNER_SAFE=0x7a50f00e8D05b95F98fE38d8BeE366a7324dCf7E
21+
# #Owner of Optimism Guardian Multisig
22+
#OP_SECURITY_COUNCIL_SAFE=0xf64bc17485f0B4Ea5F06A96514182FC4cB561977
23+
24+
# # used to simulate
25+
#SENDER=0x1084092Ac2f04c866806CF3d4a385Afa4F6A6C97
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
include ../../Makefile
2+
include ../../Multisig.mk
3+
4+
include ../.env
5+
include .env
6+
7+
ifndef LEDGER_ACCOUNT
8+
override LEDGER_ACCOUNT = 0
9+
endif
10+
11+
RPC_URL = $(L1_RPC_URL)
12+
SCRIPT_NAME = SwitchToPermissionedGame
13+
14+
.PHONY: gen-validation
15+
gen-validation: checkout-signer-tool run-script
16+
17+
.PHONY: run-script
18+
run-script:
19+
mkdir validations; \
20+
cd $(SIGNER_TOOL_PATH); \
21+
npm ci; \
22+
bun run scripts/genValidationFile.ts --rpc-url $(RPC_URL) \
23+
--workdir .. --forge-cmd 'forge script --rpc-url $(RPC_URL) \
24+
$(SCRIPT_NAME) --sig "sign(address[])" ["$(OP_SECURITY_COUNCIL_SAFE)"] --sender $(SENDER)' --out ../validations/op-signer.json;
25+
26+
.PHONY: approve-op
27+
approve-op:
28+
$(call MULTISIG_APPROVE,$(OP_SECURITY_COUNCIL_SAFE),$(SIGNATURES))
29+
30+
# Execute
31+
.PHONY: execute
32+
execute:
33+
$(call MULTISIG_EXECUTE,0x)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Switch to Permissioned Games
2+
3+
Status: READY TO SIGN
4+
5+
## Description
6+
7+
Switches Base to Permissioned Fault Dispute Games and retires existing games.
8+
9+
## Install dependencies
10+
11+
### 1. Update foundry
12+
13+
```bash
14+
foundryup
15+
```
16+
17+
### 2. Install Node.js if needed
18+
19+
First, check if you have node installed
20+
21+
```bash
22+
node --version
23+
```
24+
25+
If you see a version output from the above command, you can move on. Otherwise, install node
26+
27+
```bash
28+
brew install node
29+
```
30+
31+
## Sign Task
32+
33+
### 1. Update repo:
34+
35+
```bash
36+
cd contract-deployments
37+
git pull
38+
```
39+
40+
### 2. Run the signing tool (NOTE: do not enter the task directory. Run this command from the project's root).
41+
42+
```bash
43+
make sign-task
44+
```
45+
46+
### 3. Open the UI at [http://localhost:3000](http://localhost:3000)
47+
48+
### 4. Send signature to facilitator
49+
50+
You may now kill the Signer Tool process in your terminal window by running `Ctrl + C`.
51+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[profile.default]
2+
src = 'src'
3+
out = 'out'
4+
libs = ['lib']
5+
broadcast = 'records'
6+
fs_permissions = [{ access = "read-write", path = "./" }]
7+
optimizer = true
8+
optimizer_runs = 200
9+
via-ir = false
10+
remappings = [
11+
'@eth-optimism-bedrock/=lib/optimism/packages/contracts-bedrock/',
12+
'@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts',
13+
'@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts',
14+
'@rari-capital/solmate/=lib/solmate/',
15+
'@base-contracts/=lib/base-contracts',
16+
'solady/=lib/solady/src/',
17+
'@lib-keccak/=lib/lib-keccak/contracts/lib',
18+
]
19+
20+
# See more config options https://github.com/foundry-rs/foundry/tree/master/config
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity 0.8.15;
3+
4+
import {Vm} from "forge-std/Vm.sol";
5+
import {IMulticall3} from "forge-std/interfaces/IMulticall3.sol";
6+
import {IAnchorStateRegistry} from "@eth-optimism-bedrock/src/dispute/FaultDisputeGame.sol";
7+
import {SystemConfig} from "@eth-optimism-bedrock/src/L1/SystemConfig.sol";
8+
import {DisputeGameFactory} from "@eth-optimism-bedrock/src/dispute/DisputeGameFactory.sol";
9+
import {FaultDisputeGame} from "@eth-optimism-bedrock/src/dispute/PermissionedDisputeGame.sol";
10+
import {GameTypes, GameType} from "@eth-optimism-bedrock/src/dispute/lib/Types.sol";
11+
import {MultisigScript} from "@base-contracts/script/universal/MultisigScript.sol";
12+
import {Simulation} from "@base-contracts/script/universal/Simulation.sol";
13+
14+
/// @notice This script updates the respectedGameType and retires existing games in the AnchorStateRegistry.
15+
contract SwitchToPermissionedGame is MultisigScript {
16+
address public immutable OWNER_SAFE;
17+
18+
SystemConfig internal immutable _SYSTEM_CONFIG = SystemConfig(vm.envAddress("SYSTEM_CONFIG"));
19+
20+
IAnchorStateRegistry anchorStateRegistry;
21+
22+
constructor() {
23+
OWNER_SAFE = vm.envAddress("OWNER_SAFE");
24+
}
25+
26+
function setUp() public {
27+
DisputeGameFactory dgfProxy = DisputeGameFactory(_SYSTEM_CONFIG.disputeGameFactory());
28+
FaultDisputeGame currentFdg = FaultDisputeGame(address(dgfProxy.gameImpls(GameTypes.CANNON)));
29+
anchorStateRegistry = currentFdg.anchorStateRegistry();
30+
}
31+
32+
// Confirm the retirementTimestamp is updated to the block time and the
33+
// respectedGameType is updated to PERMISSIONED_CANNON.
34+
function _postCheck(Vm.AccountAccess[] memory, Simulation.Payload memory) internal view override {
35+
require(anchorStateRegistry.retirementTimestamp() == block.timestamp, "post-110");
36+
require(
37+
GameType.unwrap(anchorStateRegistry.respectedGameType()) == GameType.unwrap(GameTypes.PERMISSIONED_CANNON),
38+
"post-111"
39+
);
40+
}
41+
42+
function _buildCalls() internal view override returns (IMulticall3.Call3Value[] memory) {
43+
IMulticall3.Call3Value[] memory calls = new IMulticall3.Call3Value[](2);
44+
45+
calls[0] = IMulticall3.Call3Value({
46+
target: address(anchorStateRegistry),
47+
allowFailure: false,
48+
callData: abi.encodeCall(IAnchorStateRegistry.setRespectedGameType, (GameTypes.PERMISSIONED_CANNON)),
49+
value: 0
50+
});
51+
52+
calls[1] = IMulticall3.Call3Value({
53+
target: address(anchorStateRegistry),
54+
allowFailure: false,
55+
callData: abi.encodeCall(IAnchorStateRegistry.updateRetirementTimestamp, ()),
56+
value: 0
57+
});
58+
59+
return calls;
60+
}
61+
62+
function _ownerSafe() internal view override returns (address) {
63+
return OWNER_SAFE;
64+
}
65+
}

0 commit comments

Comments
 (0)