Skip to content

Commit fe21b92

Browse files
authored
add scripts for sepolia FP re-deploy (#285)
1 parent 40a1ac1 commit fe21b92

File tree

7 files changed

+473
-0
lines changed

7 files changed

+473
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
OP_COMMIT=2073f4059bd806af3e8b76b820aa3fa0b42016d0
2+
BASE_CONTRACTS_COMMIT=cdedd0fe728eb1f9d63eaa4c6e59138cfb3803d3
3+
4+
ABSOLUTE_PRESTATE=0x0354eee87a1775d96afee8977ef6d5d6bd3612b256170952a01bf1051610ee01
5+
6+
SYSTEM_CONFIG=0xf272670eb55e895584501d564AfEB048bEd26194
7+
OWNER_SAFE=0x0fe884546476dDd290eC46318785046ef68a0BA9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
include ../../Makefile
2+
include ../.env
3+
include .env
4+
5+
ifndef LEDGER_ACCOUNT
6+
override LEDGER_ACCOUNT = 1
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# Upgrade Fault Proofs
2+
3+
Status: READY TO DEPLOY
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 sepolia/2025-03-12-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+
```bash
39+
make sign
40+
```
41+
42+
You will see a "Simulation link" from the output.
43+
44+
Paste this URL in your browser. A prompt may ask you to choose a
45+
project, any project will do. You can create one if necessary.
46+
47+
Click "Simulate Transaction".
48+
49+
We will be performing 3 validations and extract the domain hash and message hash to approve on your Ledger:
50+
51+
1. Validate integrity of the simulation.
52+
2. Validate correctness of the state diff.
53+
3. Validate and extract domain hash and message hash to approve.
54+
55+
##### 3.2.1 Validate integrity of the simulation.
56+
57+
Make sure you are on the "Overview" tab of the tenderly simulation, to
58+
validate integrity of the simulation, we need to check the following:
59+
60+
1. "Network": Check the network is Sepolia.
61+
2. "Timestamp": Check the simulation is performed on a block with a
62+
recent timestamp (i.e. close to when you run the script).
63+
3. "Sender": Check the address shown is your signer account. If not see the derivation path Note above.
64+
65+
##### 3.2.2. Validate correctness of the state diff.
66+
67+
Now click on the "State" tab, and refer to the [State Validations](./VALIDATION.md) instructions for the transaction you are signing.
68+
Once complete return to this document to complete the signing.
69+
70+
##### 3.2.3. Extract the domain hash and the message hash to approve.
71+
72+
Now that we have verified the transaction performs the right
73+
operation, we need to extract the domain hash and the message hash to
74+
approve.
75+
76+
Go back to the "Overview" tab, and find the
77+
`GnosisSafe.checkSignatures` call. This call's `data` parameter
78+
contains both the domain hash and the message hash that will show up
79+
in your Ledger.
80+
81+
It will be a concatenation of `0x1901`, the domain hash, and the
82+
message hash: `0x1901[domain hash][message hash]`.
83+
84+
Note down this value. You will need to compare it with the ones
85+
displayed on the Ledger screen at signing.
86+
87+
Once the validations are done, it's time to actually sign the
88+
transaction.
89+
90+
> [!WARNING]
91+
> This is the most security critical part of the playbook: make sure the
92+
> domain hash and message hash in the following two places match:
93+
>
94+
> 1. On your Ledger screen.
95+
> 2. In the Tenderly simulation. You should use the same Tenderly
96+
> simulation as the one you used to verify the state diffs, instead
97+
> of opening the new one printed in the console.
98+
>
99+
> There is no need to verify anything printed in the console. There is
100+
> no need to open the new Tenderly simulation link either.
101+
102+
After verification, sign the transaction. You will see the `Data`,
103+
`Signer` and `Signature` printed in the console. Format should be
104+
something like this:
105+
106+
```shell
107+
Data: <DATA>
108+
Signer: <ADDRESS>
109+
Signature: <SIGNATURE>
110+
```
111+
112+
Double check the signer address is the right one.
113+
114+
##### 3.2.4 Send the output to Facilitator(s)
115+
116+
Nothing has occurred onchain - these are offchain signatures which
117+
will be collected by Facilitators for execution. Execution can occur
118+
by anyone once a threshold of signatures are collected, so a
119+
Facilitator will do the final execution for convenience.
120+
121+
Share the `Data`, `Signer` and `Signature` with the Facilitator, and
122+
congrats, you are done!
123+
124+
### [For Facilitator ONLY] How to execute
125+
126+
#### Execute the transaction
127+
128+
1. IMPORTANT: Ensure op-challenger has been updated before executing.
129+
1. Collect outputs from all participating signers.
130+
1. Concatenate all signatures and export it as the `SIGNATURES`
131+
environment variable, i.e. `export
132+
SIGNATURES="[SIGNATURE1][SIGNATURE2]..."`.
133+
1. Run the `make execute` command as described below to execute the transaction.
134+
135+
For example, if the quorum is 2 and you get the following outputs:
136+
137+
```shell
138+
Data: 0xDEADBEEF
139+
Signer: 0xC0FFEE01
140+
Signature: AAAA
141+
```
142+
143+
```shell
144+
Data: 0xDEADBEEF
145+
Signer: 0xC0FFEE02
146+
Signature: BBBB
147+
```
148+
149+
Then you should run:
150+
151+
```bash
152+
SIGNATURES=AAAABBBB make execute
153+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
## Sepolia State Changes
12+
13+
### `0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1` (`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+
You should also see nonce updates for the `ProxyAdminOwner` (`0x0fe884546476dDd290eC46318785046ef68a0BA9`) and the address you're signing with.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 = 999999
9+
solc_version = "0.8.15"
10+
via-ir = false
11+
remappings = [
12+
'@eth-optimism-bedrock/=lib/optimism/packages/contracts-bedrock/',
13+
'@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts',
14+
'@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts',
15+
'@rari-capital/solmate/=lib/solmate/',
16+
'@base-contracts/=lib/base-contracts',
17+
'solady/=lib/solady/src/',
18+
'@lib-keccak/=lib/lib-keccak/contracts/lib',
19+
]
20+
21+
# See more config options https://github.com/foundry-rs/foundry/tree/master/config
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity 0.8.15;
3+
4+
import {Script} from "forge-std/Script.sol";
5+
6+
import {
7+
FaultDisputeGame,
8+
IAnchorStateRegistry,
9+
IDelayedWETH,
10+
IBigStepper
11+
} from "@eth-optimism-bedrock/src/dispute/FaultDisputeGame.sol";
12+
import {PermissionedDisputeGame} from "@eth-optimism-bedrock/src/dispute/PermissionedDisputeGame.sol";
13+
import {GameTypes, Duration, Claim} from "@eth-optimism-bedrock/src/dispute/lib/Types.sol";
14+
import {DisputeGameFactory} from "@eth-optimism-bedrock/src/dispute/DisputeGameFactory.sol";
15+
import {SystemConfig} from "@eth-optimism-bedrock/src/L1/SystemConfig.sol";
16+
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
17+
18+
/// @notice This script deploys new versions of FaultDisputeGame and PermissionedDisputeGame with all the same
19+
/// parameters as the existing implementations excluding the absolute prestate.
20+
contract DeployDisputeGames is Script {
21+
using Strings for address;
22+
23+
SystemConfig internal _SYSTEM_CONFIG = SystemConfig(vm.envAddress("SYSTEM_CONFIG"));
24+
Claim absolutePrestate = Claim.wrap(vm.envBytes32("ABSOLUTE_PRESTATE"));
25+
26+
DisputeGameFactory dgfProxy;
27+
28+
uint256 maxGameDepth;
29+
uint256 splitDepth;
30+
uint256 l2ChainId;
31+
address proposer;
32+
address challenger;
33+
Duration clockExtension;
34+
Duration maxClockDuration;
35+
IDelayedWETH faultDisputeGameWeth;
36+
IDelayedWETH permissionedDisputeGameWeth;
37+
IAnchorStateRegistry anchorStateRegistry;
38+
IBigStepper bigStepper;
39+
40+
function setUp() public {
41+
dgfProxy = DisputeGameFactory(_SYSTEM_CONFIG.disputeGameFactory());
42+
FaultDisputeGame currentFdg = FaultDisputeGame(address(dgfProxy.gameImpls(GameTypes.CANNON)));
43+
PermissionedDisputeGame currentPdg =
44+
PermissionedDisputeGame(address(dgfProxy.gameImpls(GameTypes.PERMISSIONED_CANNON)));
45+
46+
absolutePrestate = currentFdg.absolutePrestate();
47+
maxGameDepth = currentFdg.maxGameDepth();
48+
splitDepth = currentFdg.splitDepth();
49+
clockExtension = currentFdg.clockExtension();
50+
maxClockDuration = currentFdg.maxClockDuration();
51+
bigStepper = currentFdg.vm();
52+
faultDisputeGameWeth = currentFdg.weth();
53+
anchorStateRegistry = currentFdg.anchorStateRegistry();
54+
l2ChainId = currentFdg.l2ChainId();
55+
56+
permissionedDisputeGameWeth = currentPdg.weth();
57+
proposer = currentPdg.proposer();
58+
challenger = currentPdg.challenger();
59+
}
60+
61+
function run() public {
62+
(address fdg, address pdg) = _deployContracts();
63+
64+
vm.writeFile(
65+
"addresses.json",
66+
string.concat(
67+
"{",
68+
"\"faultDisputeGame\": \"",
69+
fdg.toHexString(),
70+
"\",",
71+
"\"permissionedDisputeGame\": \"",
72+
pdg.toHexString(),
73+
"\"" "}"
74+
)
75+
);
76+
}
77+
78+
function _deployContracts() private returns (address, address) {
79+
vm.startBroadcast();
80+
address fdg = address(
81+
new FaultDisputeGame(
82+
GameTypes.CANNON,
83+
absolutePrestate,
84+
maxGameDepth,
85+
splitDepth,
86+
clockExtension,
87+
maxClockDuration,
88+
bigStepper,
89+
faultDisputeGameWeth,
90+
anchorStateRegistry,
91+
l2ChainId
92+
)
93+
);
94+
95+
address pdg = address(
96+
new PermissionedDisputeGame(
97+
GameTypes.PERMISSIONED_CANNON,
98+
absolutePrestate,
99+
maxGameDepth,
100+
splitDepth,
101+
clockExtension,
102+
maxClockDuration,
103+
bigStepper,
104+
permissionedDisputeGameWeth,
105+
anchorStateRegistry,
106+
l2ChainId,
107+
proposer,
108+
challenger
109+
)
110+
);
111+
vm.stopBroadcast();
112+
113+
return (fdg, pdg);
114+
}
115+
}

0 commit comments

Comments
 (0)