Skip to content

Commit 2fdeab8

Browse files
authored
Add Fault Proof upgrade template directory (#269)
* set up fault proof upgrade scripts * update readme * fix comments and nits * add upgrade fault proof contracts template * rename setup-hardfork -> setup-upgrade-fault-proofs
1 parent df1f376 commit 2fdeab8

File tree

9 files changed

+603
-0
lines changed

9 files changed

+603
-0
lines changed

Makefile

+6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ PROJECT_DIR = $(network)/$(shell date +'%Y-%m-%d')-$(task)
22
DEPLOY_DIR = $(network)/$(shell date +'%Y-%m-%d')-deploy
33
INCIDENT_DIR = $(network)/$(shell date +'%Y-%m-%d')-$(incident)
44
GAS_INCREASE_DIR = $(network)/$(shell date +'%Y-%m-%d')-increase-gas-limit
5+
FAULT_PROOF_UPGRADE_DIR = $(network)/$(shell date +'%Y-%m-%d')-upgrade-fault-proofs
56
TEMPLATE_GENERIC = setup-templates/template-generic
67
TEMPLATE_DEPLOY = setup-templates/template-deploy
78
TEMPLATE_INCIDENT = setup-templates/template-incident
89
TEMPLATE_GAS_INCREASE = setup-templates/template-gas-increase
10+
TEMPLATE_UPGRADE_FAULT_PROOFS = setup-templates/template-upgrade-fault-proofs
911

1012
ifndef $(GOPATH)
1113
GOPATH=$(shell go env GOPATH)
@@ -40,6 +42,10 @@ setup-gas-increase:
4042
rm -rf $(TEMPLATE_GAS_INCREASE)/cache $(TEMPLATE_GAS_INCREASE)/lib $(TEMPLATE_GAS_INCREASE)/out
4143
cp -r $(TEMPLATE_GAS_INCREASE) $(GAS_INCREASE_DIR)
4244

45+
# Run `make setup-upgrade-fault-proofs network=<network>`
46+
setup-upgrade-fault-proofs:
47+
cp -r $(TEMPLATE_UPGRADE_FAULT_PROOFS) $(FAULT_PROOF_UPGRADE_DIR)
48+
4349
##
4450
# Solidity Setup
4551
##

README.md

+19
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ To execute a new task, run one of the following commands (depending on the type
3838
- For incident response commands: `make setup-incident network=<network> incident=<incident-name>`
3939
- For gas increase commands: `make setup-gas-increase network=<network>`
4040
- For full new deployment (of L1 contracts related to Base): `make setup-deploy network=<network>`
41+
- For fault proof upgrade: `make setup-upgrade-fault-proofs network=<network>`
4142
- For contract calls, upgrades, or one-off contract deployments: `make setup-task network=<network> task=<task-name>`
4243

4344
Next, `cd` into the directory that was created for you and follow the steps listed below for the relevant template.
@@ -92,6 +93,24 @@ This template is increasing the throughput on Base Chain.
9293
1. Check in the task when it's ready to sign and collect signatures from signers
9394
1. Once executed, check in the records files and mark the task `DONE` in the README.
9495

96+
## Using the fault proof upgrade template
97+
98+
This template is used to upgrade the fault proof contracts. This is commonly done in conjunction with a hardfork.
99+
100+
1. Ensure you have followed the instructions above in `setup`
101+
1. Go to the folder that was created using the `make setup-upgrade-fault-proofs network=<network>` step
102+
1. Specify the commit of [Optimism code](https://github.com/ethereum-optimism/optimism) and [Base contracts code](https://github.com/base-org/contracts) you intend to use in the `.env` file
103+
1. Run `make deps`
104+
1. Add the new absolute prestate to the `.env` file. This can be found in the op-program prestates [releases.json](https://github.com/ethereum-optimism/optimism/blob/develop/op-program/prestates/releases.json) file.
105+
1. NOTE: If this task is for mainnet, the directory should work as-is. If this task is for testnet, you will need to follow the following steps:
106+
1. Update the `UpgradeDGF` script to inherit `MultisigBuilder` instead of `NestedMultisigBuilder`
107+
1. Comment out the mainnet environment variables and uncomment the testnet vars in `.env`
108+
1. Comment out the nested multisig builder commands in the Makefile and uncomment the multisig builder commands
109+
1. Build the contracts with `forge build`
110+
1. Remove the unneeded validations from `VALIDATION.md` and update the relevant validations accordingly
111+
1. Check in the task when it's ready to sign and collect signatures from signers
112+
1. Once executed, check in the records files and mark the task `DONE` in the README.
113+
95114
## Using the generic template
96115

97116
This template can be used to do contract calls, upgrades, or one-off deployments.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
OP_COMMIT=
2+
BASE_CONTRACTS_COMMIT=
3+
4+
ABSOLUTE_PRESTATE=
5+
6+
# Sepolia Config
7+
# SYSTEM_CONFIG=0xf272670eb55e895584501d564AfEB048bEd26194
8+
# OWNER_SAFE=0x0fe884546476dDd290eC46318785046ef68a0BA9
9+
# LEDGER_ACCOUNT=1
10+
11+
# Mainnet Config
12+
SYSTEM_CONFIG=0x73a79Fab69143498Ed3712e519A88a918e1f4072
13+
OWNER_SAFE=0x7bB41C3008B3f03FE483B28b8DB90e19Cf07595c
14+
CB_SIGNER_SAFE_ADDR=0x9855054731540A48b28990B63DcF4f33d8AE46A1
15+
OP_SIGNER_SAFE_ADDR=0x9BA6e03D8B90dE867373Db8cF1A58d2F7F006b3A
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
include ../../Makefile
2+
include ../.env
3+
include .env
4+
5+
ifndef LEDGER_ACCOUNT
6+
override LEDGER_ACCOUNT = 0
7+
endif
8+
9+
.PHONY: deploy
10+
deploy:
11+
forge script --rpc-url $(L1_RPC_URL) DeployDisputeGames \
12+
--ledger --hd-paths "m/44'/60'/$(LEDGER_ACCOUNT)'/0/0" --broadcast -vvvv
13+
14+
##
15+
# MultisigBuilder commands
16+
# The following commands can be used for tasks that utilize the MultisigBuilder.
17+
# Note that --ledger --hd-paths <PATH> can be replaced with --private-key $(PRIVATE_KEY)
18+
# in any command when using a local key.
19+
##
20+
21+
# .PHONY: sign
22+
# sign:
23+
# $(GOPATH)/bin/eip712sign --ledger --hd-paths "m/44'/60'/$(LEDGER_ACCOUNT)'/0/0" -- \
24+
# forge script --rpc-url $(L1_RPC_URL) UpgradeDGF --sig "sign()"
25+
26+
# .PHONY: execute
27+
# execute:
28+
# forge script --rpc-url $(L1_RPC_URL) UpgradeDGF \
29+
# --sig "run(bytes)" $(SIGNATURES) \
30+
# --ledger --hd-paths "m/44'/60'/$(LEDGER_ACCOUNT)'/0/0" --broadcast -vvvv
31+
32+
##
33+
# NestedMultisigBuilder commands
34+
# The following commands can be used for tasks that utilize the NestedMultisigBuilder.
35+
# Note that --ledger --hd-paths <PATH> can be replaced with --private-key $(PRIVATE_KEY)
36+
# in any command when using a local key.
37+
# See more documentation on the various steps in NestedMultisigBuilder.sol.
38+
##
39+
40+
# This step is run by signers on the "children" safes
41+
.PHONY: sign-cb
42+
sign-cb:
43+
$(GOPATH)/bin/eip712sign --ledger --hd-paths "m/44'/60'/$(LEDGER_ACCOUNT)'/0/0" -- \
44+
forge script --rpc-url $(L1_RPC_URL) UpgradeDGF \
45+
--sig "sign(address)" $(CB_SIGNER_SAFE_ADDR)
46+
47+
.PHONY: sign-op
48+
sign-op:
49+
$(GOPATH)/bin/eip712sign --ledger --hd-paths "m/44'/60'/$(LEDGER_ACCOUNT)'/0/0" -- \
50+
forge script --rpc-url $(L1_RPC_URL) UpgradeDGF \
51+
--sig "sign(address)" $(OP_SIGNER_SAFE_ADDR)
52+
53+
# This step is run once per "child" safe, and can be run by anyone (doesn't have to be a signer)
54+
.PHONY: approve-cb
55+
approve-cb:
56+
forge script --rpc-url $(L1_RPC_URL) UpgradeDGF \
57+
--sig "approve(address,bytes)" $(CB_SIGNER_SAFE_ADDR) $(SIGNATURES) \
58+
--ledger --hd-paths "m/44'/60'/$(LEDGER_ACCOUNT)'/0/0" --broadcast
59+
60+
.PHONY: approve-op
61+
approve-op:
62+
forge script --rpc-url $(L1_RPC_URL) UpgradeDGF \
63+
--sig "approve(address,bytes)" $(OP_SIGNER_SAFE_ADDR) $(SIGNATURES) \
64+
--ledger --hd-paths "m/44'/60'/$(LEDGER_ACCOUNT)'/0/0" --broadcast
65+
66+
# This step is run once after all children safes have approved and can be run by anyone (doesn't have to be a signer)
67+
.PHONY: execute
68+
execute:
69+
forge script --rpc-url $(L1_RPC_URL) UpgradeDGF \
70+
--sig "run()" --ledger --hd-paths "m/44'/60'/$(LEDGER_ACCOUNT)'/0/0" --broadcast
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# Upgrade Fault Proofs
2+
3+
Status: PENDING
4+
5+
## Description
6+
7+
This task contains two scripts. One for deploying new versions of the `FaultDisputeGame` and `PermissionedDisputeGame` contracts, and one for updating the `DisputeGameFactory` contract to reference the new dispute game contracts.
8+
9+
## Procedure
10+
11+
### 1. Update repo:
12+
13+
```bash
14+
cd contract-deployments
15+
git pull
16+
cd <network>/<date>-upgrade-fault-proofs
17+
make deps
18+
```
19+
20+
### 2. Setup Ledger
21+
22+
Your Ledger needs to be connected and unlocked. The Ethereum
23+
application needs to be opened on Ledger with the message "Application
24+
is ready".
25+
26+
### 3. Run relevant script(s)
27+
28+
#### 3.1 Deploy new Dispute Game Implementations
29+
30+
```bash
31+
make deploy
32+
```
33+
34+
This will output the new addresses of the `FaultDisputeGame` and `PermissionedDisputeGame` contracts to an `addresses.json` file. You will need to commit this file to the repo before signers can sign.
35+
36+
#### 3.2 Sign the transaction
37+
38+
**If on testnet**:
39+
40+
```bash
41+
make sign
42+
```
43+
44+
**If on mainnet**:
45+
46+
Coinbase signer:
47+
48+
```bash
49+
make sign-cb
50+
```
51+
52+
Op signer:
53+
54+
```bash
55+
make sign-op
56+
```
57+
58+
You will see a "Simulation link" from the output.
59+
60+
Paste this URL in your browser. A prompt may ask you to choose a
61+
project, any project will do. You can create one if necessary.
62+
63+
Click "Simulate Transaction".
64+
65+
We will be performing 3 validations and extract the domain hash and message hash to approve on your Ledger:
66+
67+
1. Validate integrity of the simulation.
68+
2. Validate correctness of the state diff.
69+
3. Validate and extract domain hash and message hash to approve.
70+
71+
##### 3.2.1 Validate integrity of the simulation.
72+
73+
Make sure you are on the "Overview" tab of the tenderly simulation, to
74+
validate integrity of the simulation, we need to check the following:
75+
76+
1. "Network": Check the network is Sepolia or Mainnet.
77+
2. "Timestamp": Check the simulation is performed on a block with a
78+
recent timestamp (i.e. close to when you run the script).
79+
3. "Sender": Check the address shown is your signer account. If not see the derivation path Note above.
80+
81+
##### 3.2.2. Validate correctness of the state diff.
82+
83+
Now click on the "State" tab, and refer to the [State Validations](./VALIDATION.md) instructions for the transaction you are signing.
84+
Once complete return to this document to complete the signing.
85+
86+
##### 3.2.3. Extract the domain hash and the message hash to approve.
87+
88+
Now that we have verified the transaction performs the right
89+
operation, we need to extract the domain hash and the message hash to
90+
approve.
91+
92+
Go back to the "Overview" tab, and find the
93+
`GnosisSafe.checkSignatures` call. This call's `data` parameter
94+
contains both the domain hash and the message hash that will show up
95+
in your Ledger.
96+
97+
It will be a concatenation of `0x1901`, the domain hash, and the
98+
message hash: `0x1901[domain hash][message hash]`.
99+
100+
Note down this value. You will need to compare it with the ones
101+
displayed on the Ledger screen at signing.
102+
103+
Once the validations are done, it's time to actually sign the
104+
transaction.
105+
106+
> [!WARNING]
107+
> This is the most security critical part of the playbook: make sure the
108+
> domain hash and message hash in the following two places match:
109+
>
110+
> 1. On your Ledger screen.
111+
> 2. In the Tenderly simulation. You should use the same Tenderly
112+
> simulation as the one you used to verify the state diffs, instead
113+
> of opening the new one printed in the console.
114+
>
115+
> There is no need to verify anything printed in the console. There is
116+
> no need to open the new Tenderly simulation link either.
117+
118+
After verification, sign the transaction. You will see the `Data`,
119+
`Signer` and `Signature` printed in the console. Format should be
120+
something like this:
121+
122+
```shell
123+
Data: <DATA>
124+
Signer: <ADDRESS>
125+
Signature: <SIGNATURE>
126+
```
127+
128+
Double check the signer address is the right one.
129+
130+
##### 3.2.4 Send the output to Facilitator(s)
131+
132+
Nothing has occurred onchain - these are offchain signatures which
133+
will be collected by Facilitators for execution. Execution can occur
134+
by anyone once a threshold of signatures are collected, so a
135+
Facilitator will do the final execution for convenience.
136+
137+
Share the `Data`, `Signer` and `Signature` with the Facilitator, and
138+
congrats, you are done!
139+
140+
### [For Facilitator ONLY] How to execute
141+
142+
#### Execute the transaction
143+
144+
1. IMPORTANT: Ensure op-challenger has been updated before executing.
145+
1. Collect outputs from all participating signers.
146+
1. Concatenate all signatures and export it as the `SIGNATURES`
147+
environment variable, i.e. `export
148+
SIGNATURES="[SIGNATURE1][SIGNATURE2]..."`.
149+
1. Run the `make execute` or `make approve` command as described below to execute the transaction.
150+
151+
For example, if the quorum is 2 and you get the following outputs:
152+
153+
```shell
154+
Data: 0xDEADBEEF
155+
Signer: 0xC0FFEE01
156+
Signature: AAAA
157+
```
158+
159+
```shell
160+
Data: 0xDEADBEEF
161+
Signer: 0xC0FFEE02
162+
Signature: BBBB
163+
```
164+
165+
If on testnet, then you should run:
166+
167+
Coinbase facilitator:
168+
169+
```bash
170+
SIGNATURES=AAAABBBB make execute
171+
```
172+
173+
If on mainnet, then you should run:
174+
175+
Coinbase facilitator:
176+
177+
```bash
178+
SIGNATURES=AAAABBBB make approve-cb
179+
```
180+
181+
Optimism facilitator:
182+
183+
```bash
184+
SIGNATURES=AAAABBBB make approve-op
185+
```
186+
187+
#### If on mainnet, execute the transaction
188+
189+
Once the signatures have been submitted approving the transaction for all nested Safes run:
190+
191+
```bash
192+
make execute
193+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Validation
2+
3+
This document can be used to validate the state diff resulting from the execution of the upgrade transactions.
4+
5+
For each contract listed in the state diff, please verify that no contracts or state changes shown in the Tenderly diff are missing from this document. Additionally, please verify that for each contract:
6+
7+
- The following state changes (and none others) are made to that contract. This validates that no unexpected state changes occur.
8+
- All addresses (in section headers and storage values) match the provided name, using the Etherscan and Superchain Registry links provided. This validates the bytecode deployed at the addresses contains the correct logic.
9+
- All key values match the semantic meaning provided, which can be validated using the storage layout links provided.
10+
11+
## Mainnet State Changes
12+
13+
### `0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e` (`DisputeGameFactory`)
14+
15+
- **Key**: `0x4d5a9bd2e41301728d41c8e705190becb4e74abe869f75bdb405b63716a35f9e` <br/>
16+
**Before**: `0x00000000000000000000000068f600e592799c16d1b096616edbf1681fb9c0de` <br/>
17+
**After**: Newly deployed `PermissionedDisputeGame` address converted to bytes32 <br/>
18+
**Meaning**: Updates the `PermissionedDisputeGame` implementation address from `0x68f600e592799c16D1b096616eDbf1681FB9c0De` to the newly deployed contract address.
19+
**Verify**: You can verify the key derivation by running `cast index uint32 1 101` in your terminal.
20+
- **Key**: `0xffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b` <br/>
21+
**Before**: `0x000000000000000000000000b7fb44a61fde2b9db28a84366e168b14d1a1b103` <br/>
22+
**After**: Newly deployed `FaultDisputeGame` address converted to bytes32 <br/>
23+
**Meaning**: Updates the `FaultDisputeGame` implementation address from `0xB7fB44a61fdE2b9DB28a84366e168b14D1a1b103` to the newly deployed contract address.
24+
**Verify**: You can verify the key derivation by running `cast index uint32 0 101` in your terminal.
25+
26+
## Sepolia State Changes
27+
28+
### `0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1` (`DisputeGameFactory`)
29+
30+
- **Key**: `0x4d5a9bd2e41301728d41c8e705190becb4e74abe869f75bdb405b63716a35f9e` <br/>
31+
**Before**: `0x00000000000000000000000068f600e592799c16d1b096616edbf1681fb9c0de` <br/>
32+
**After**: Newly deployed `PermissionedDisputeGame` address converted to bytes32 <br/>
33+
**Meaning**: Updates the `PermissionedDisputeGame` implementation address from `0x68f600e592799c16D1b096616eDbf1681FB9c0De` to the newly deployed contract address.
34+
**Verify**: You can verify the key derivation by running `cast index uint32 1 101` in your terminal.
35+
- **Key**: `0xffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b` <br/>
36+
**Before**: `0x000000000000000000000000b7fb44a61fde2b9db28a84366e168b14d1a1b103` <br/>
37+
**After**: Newly deployed `FaultDisputeGame` address converted to bytes32 <br/>
38+
**Meaning**: Updates the `FaultDisputeGame` implementation address from `0xB7fB44a61fdE2b9DB28a84366e168b14D1a1b103` to the newly deployed contract address.
39+
**Verify**: You can verify the key derivation by running `cast index uint32 0 101` in your terminal.
40+
41+
You should also see nonce updates for the `ProxyAdminOwner` (`0x0fe884546476dDd290eC46318785046ef68a0BA9`) and the address you're signing with.

0 commit comments

Comments
 (0)