Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sep/026: Add task to fix sepolia fp upgrade #421

Merged
merged 5 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,13 @@ jobs:
yq --version
forge --version

simulate_sep_026:
docker:
- image: << pipeline.parameters.ci_builder_image >>
steps:
- simulate_nested:
task: "sep/026-fp-holocene-upgrade-fix"

workflows:
main:
jobs:
Expand Down Expand Up @@ -295,3 +302,6 @@ workflows:
- just_simulate_sc_rehearsal_2
- just_simulate_sc_rehearsal_4
- just_simulate_permissionless_fp_upgrade

# sepolia
- simulate_sep_026
13 changes: 13 additions & 0 deletions script/verification/Verification.s.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import {console2 as console} from "forge-std/console2.sol";
import {LibString} from "solady/utils/LibString.sol";
import {Types} from "@eth-optimism-bedrock/scripts/Types.sol";
import {CommonBase} from "forge-std/Base.sol";
Expand Down Expand Up @@ -75,6 +76,7 @@ contract SuperchainRegistry is CommonBase {
opContractsReleaseQ = string.concat("\"op-contracts/", _opContractsRelease, "\"");
_readSuperchainConfig();
_readStandardVersions();
_applyOverrides();
}

/// @notice Reads the contract addresses from the superchain registry.
Expand Down Expand Up @@ -162,4 +164,15 @@ contract SuperchainRegistry is CommonBase {
{
sv_.version = stdToml.readString(data, string.concat("$.RELEASE.", key, ".version"));
}

function _applyOverrides() internal {
try vm.envAddress("SCR_OVERRIDE_MIPS_ADDRESS") returns (address mips) {
console.log("SuperchainRegistry: overriding MIPS address to %s", mips);
standardVersions.MIPS.Address = mips;
} catch { /* Ignore, no override */ }
try vm.envString("SCR_OVERRIDE_MIPS_VERSION") returns (string memory ver) {
console.log("SuperchainRegistry: overriding MIPS version to %s", ver);
standardVersions.MIPS.version = ver;
} catch { /* Ignore, no override */ }
}
}
14 changes: 14 additions & 0 deletions tasks/sep/026-fp-holocene-upgrade-fix/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ETH_RPC_URL="https://ethereum-sepolia.publicnode.com"
OWNER_SAFE=0x1Eb2fFc903729a0F03966B917003800b145F56E2
COUNCIL_SAFE=0xf64bc17485f0B4Ea5F06A96514182FC4cB561977
FOUNDATION_SAFE=0xDEe57160aAfCF04c34C887B5962D0a69676d3C8B

SAFE_NONCE_0X1EB2FFC903729A0F03966B917003800B145F56E2=15 # noop
SAFE_NONCE_0XF64BC17485F0B4EA5F06A96514182FC4CB561977=21 # noop
SAFE_NONCE_0XDEE57160AAFCF04C34C887B5962D0A69676D3C8B=29 # noop

# override since we use MIPS64, which is not in the SCR yet
SCR_OVERRIDE_MIPS_ADDRESS=0xa1e470b6bd25e8eea9ffcda6a1518be5eb8ee7bb
SCR_OVERRIDE_MIPS_VERSION=1.0.0-beta.7
# we change the WETH in this task, which is non-standard
DISPUTE_GAME_CHANGE_WETH=true
57 changes: 57 additions & 0 deletions tasks/sep/026-fp-holocene-upgrade-fix/NestedSignFromJson.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import {console2 as console} from "forge-std/console2.sol";
import {Vm} from "forge-std/Vm.sol";
import {stdJson} from "forge-std/StdJson.sol";
import {Simulation} from "@base-contracts/script/universal/Simulation.sol";
import {NestedSignFromJson as OriginalNestedSignFromJson} from "script/NestedSignFromJson.s.sol";
import {DisputeGameUpgrade} from "script/verification/DisputeGameUpgrade.s.sol";
import {CouncilFoundationNestedSign} from "script/verification/CouncilFoundationNestedSign.s.sol";
import {SuperchainRegistry} from "script/verification/Verification.s.sol";

contract NestedSignFromJson is OriginalNestedSignFromJson, CouncilFoundationNestedSign, DisputeGameUpgrade {
constructor()
SuperchainRegistry("sepolia", "op", "v1.8.0-rc.4")
DisputeGameUpgrade(
0x03b7eaa4e3cbce90381921a4b48008f4769871d64f93d113fcadca08ecee503b, // absolutePrestate
sebastianst marked this conversation as resolved.
Show resolved Hide resolved
0x833a817eF459f4eCdB83Fc5A4Bf04d09A4e83f3F, // faultDisputeGame
0xbBD576128f71186A0f9ae2F2AAb4afb4aF2dae17 // permissionedDisputeGame
)
{}

function setUp() public view {
checkInput();
}

function checkInput() public view {
string memory inputJson;
string memory path = "/tasks/sep/026-fp-holocene-upgrade-fix/input.json";
try vm.readFile(string.concat(vm.projectRoot(), path)) returns (string memory data) {
inputJson = data;
} catch {
revert(string.concat("Failed to read ", path));
}

address inputPermissionedDisputeGame =
stdJson.readAddress(inputJson, "$.transactions[0].contractInputsValues._impl");
address inputFaultDisputeGame = stdJson.readAddress(inputJson, "$.transactions[1].contractInputsValues._impl");
require(expPermissionedDisputeGame == inputPermissionedDisputeGame, "input-pdg");
require(expFaultDisputeGame == inputFaultDisputeGame, "input-fdg");
}

function _postCheck(Vm.AccountAccess[] memory accesses, Simulation.Payload memory) internal view override {
console.log("Running post-deploy assertions");
checkStateDiff(accesses);
checkDisputeGameUpgrade();
console.log("All assertions passed!");
}

function getAllowedStorageAccess() internal view override returns (address[] memory) {
return allowedStorageAccess;
}

function getCodeExceptions() internal view override returns (address[] memory) {
return codeExceptions;
}
}
37 changes: 37 additions & 0 deletions tasks/sep/026-fp-holocene-upgrade-fix/OVERVIEW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Holocene Hardfork - Proof Contract Upgrades
Upgrades the `MIPS.sol`, `FaultDisputeGame.sol`, and `PermissionedDisputeGame.sol` contracts for Holocene.

The batch will be executed on chain ID `11155111`, and contains `2` transactions.

## Tx #1: Upgrade `PERMISSIONED_CANNON` game type in `DisputeGameFactory`
Upgrades the `PERMISSIONED_CANNON` game type to the new Holocene deployment, with an updated version of `op-program` as the absolute prestate hash.

**Function Signature:** `setImplementation(uint32,address)`

**To:** `0x05F9613aDB30026FFd634f38e5C4dFd30a197Fa1`

**Value:** `0 WEI`

**Raw Input Data:** `0x14f6b1a30000000000000000000000000000000000000000000000000000000000000001000000000000000000000000bbd576128f71186a0f9ae2f2aab4afb4af2dae17`

### Inputs
**_gameType:** `1`

**_impl:** `0xbBD576128f71186A0f9ae2F2AAb4afb4aF2dae17`


## Tx #2: Upgrade `CANNON` game type in `DisputeGameFactory`
sebastianst marked this conversation as resolved.
Show resolved Hide resolved
Upgrades the `CANNON` game type to the new Holocene deployment, with an updated version of `op-program` as the absolute prestate hash.

**Function Signature:** `setImplementation(uint32,address)`

**To:** `0x05F9613aDB30026FFd634f38e5C4dFd30a197Fa1`

**Value:** `0 WEI`

**Raw Input Data:** `0x14f6b1a30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000833a817ef459f4ecdb83fc5a4bf04d09a4e83f3f`

### Inputs
**_gameType:** `0`

**_impl:** `0x833a817eF459f4eCdB83Fc5A4Bf04d09A4e83f3F`
41 changes: 41 additions & 0 deletions tasks/sep/026-fp-holocene-upgrade-fix/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Holocene Hardfork Upgrade

Status: READY TO SIGN

## Objective

Upgrades the Fault Proof contracts of **OP Sepolia** for Holocene, fixing an upgrade with wrongly
newly deployed `DelayedWETH` from #374, and then subsequent faulty upgrade to MIPS64-MT in #410,
which again used the wrong `DelayedWETH`.

Using a MIPS64 absolute prestate hash of `0x03b7eaa4e3cbce90381921a4b48008f4769871d64f93d113fcadca08ecee503b`.

Governance post of the upgrade can be found at https://gov.optimism.io/t/upgrade-proposal-11-holocene-network-upgrade/9313.

This upgrades the Fault Proof contracts in the
[op-contracts/v1.8.0-rc.4](https://github.com/ethereum-optimism/optimism/tree/op-contracts/v1.8.0-rc.4) release.

## Pre-deployments

- `MIPS64` - `0xa1e470b6bd25e8eea9ffcda6a1518be5eb8ee7bb`
- `FaultDisputeGame` - `0x833a817eF459f4eCdB83Fc5A4Bf04d09A4e83f3F`
- `PermissionedDisputeGame` - `0xbBD576128f71186A0f9ae2F2AAb4afb4aF2dae17`

## Simulation

Please see the "Simulating and Verifying the Transaction" instructions in [NESTED.md](../../../NESTED.md).
When simulating, ensure the logs say `Using script /your/path/to/superchain-ops/tasks/sep/025-fp-holocene-upgrade-fix/NestedSignFromJson.s.sol`.
This ensures all safety checks are run. If the default `NestedSignFromJson.s.sol` script is shown (without the full path), something is wrong and the safety checks will not run.

## State Validation

Please see the instructions for [validation](./VALIDATION.md).

## Execution

This upgrade
* Changes dispute game implementation of the `CANNON` and `PERMISSIONED_CANNON` game types to contain a `op-program` release for the Holocene hardfork, which contains
the Holocene fork implementation as well as a `ChainConfig` and `RollupConfig` for the L2 chain being upgraded.
* Upgrades `MIPS.sol` to support the `F_GETFD` syscall, required by the golang 1.22+ runtime.

See the [overview](./OVERVIEW.md) and `input.json` bundle for more details.
49 changes: 49 additions & 0 deletions tasks/sep/026-fp-holocene-upgrade-fix/VALIDATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Validation

This document can be used to validate the state overrides and diffs resulting from the execution of the FP upgrade transaction.

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:

- The following state changes (and none others) are made to that contract. This validates that no unexpected state changes occur.
- 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.
- All key values match the semantic meaning provided, which can be validated using the storage layout links provided.

## Nested Safe State Overrides and Changes

This task is executed by the nested 2/2 `ProxyAdminOwner` Safe. Refer to the
[generic nested Safe execution validation document](../../../NESTED-VALIDATION.md)
for the expected state overrides and changes.

The `approvedHashes` mapping **key** of the `ProxyAdminOwner` that should change during the simulation is
- Council simulation: `0x27f38a0f9fb806fdf71a205880cdcbd83a0bfb9ae1769b6a4aa6545c53fa4527`
- Foundation simulation: `0xf50bc38a52b16adccfd799639dd5bfabf655cb35d68c44864186a208b29b37fb`

calculated as explained in the nested validation doc:
```sh
SAFE_HASH=0x63962452498b3b28f8813e99890a00437a292fea8dca8db1fbb97c417e082879 # "Nested hash:"
SAFE_ROLE=0xf64bc17485f0B4Ea5F06A96514182FC4cB561977 # Council
cast index bytes32 $SAFE_HASH $(cast index address $SAFE_ROLE 8)
# 0x27f38a0f9fb806fdf71a205880cdcbd83a0bfb9ae1769b6a4aa6545c53fa4527

SAFE_ROLE=0xDEe57160aAfCF04c34C887B5962D0a69676d3C8B # Foundation
cast index bytes32 $SAFE_HASH $(cast index address $SAFE_ROLE 8)
# 0xf50bc38a52b16adccfd799639dd5bfabf655cb35d68c44864186a208b29b37fb
```

## State Changes

This section describes the specific state changes of this upgrade, not related to the nested Safe state changes.

### `0x05F9613aDB30026FFd634f38e5C4dFd30a197Fa1` (`DisputeGameFactoryProxy`)

- **Key**: `0xffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b` <br/>
**Before**: `0x000000000000000000000000924d3d3b3b16e74bab577e50d23b2a38990dd52c` <br/>
**After**: `0x000000000000000000000000833a817ef459f4ecdb83fc5a4bf04d09a4e83f3f` <br/>
**Meaning**: Updates the CANNON game type implementation. You can verify which implementation is set using `cast call 0x05F9613aDB30026FFd634f38e5C4dFd30a197Fa1 "gameImpls(uint32)(address)" 0`, where `0` is the [`CANNON` game type](https://github.com/ethereum-optimism/optimism/blob/op-contracts/v1.4.0/packages/contracts-bedrock/src/dispute/lib/Types.sol#L28).
sebastianst marked this conversation as resolved.
Show resolved Hide resolved
Before this task has been executed, you will see that the returned address is `0x924D3d3B3b16E74bAb577e50d23b2a38990dD52C`, matching the "Before" value of this slot, demonstrating this slot is storing the address of the CANNON implementation.

- **Key**: `0x4d5a9bd2e41301728d41c8e705190becb4e74abe869f75bdb405b63716a35f9e` <br/>
**Before**: `0x000000000000000000000000879e899523ba9a4ab212a2d70cf1af73b906cbe5` <br/>
**After**: `0x000000000000000000000000bbd576128f71186a0f9ae2f2aab4afb4af2dae17` <br/>
**Meaning**: Updates the PERMISSIONED_CANNON game type implementation. You can verify which implementation is set using `cast call 0x05F9613aDB30026FFd634f38e5C4dFd30a197Fa1 "gameImpls(uint32)(address)" 1`, where `1` is the [`PERMISSIONED_CANNON` game type](https://github.com/ethereum-optimism/optimism/blob/op-contracts/v1.4.0/packages/contracts-bedrock/src/dispute/lib/Types.sol#L31).
Before this task has been executed, you will see that the returned address is `0x879e899523bA9a4Ab212a2d70cF1af73B906CbE5`, matching the "Before" value of this slot, demonstrating this slot is storing the address of the PERMISSIONED_CANNON implementation.
67 changes: 67 additions & 0 deletions tasks/sep/026-fp-holocene-upgrade-fix/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"chainId": 11155111,
"metadata": {
"name": "Holocene Hardfork - Proof Contract Upgrades",
"description": "Upgrades the `MIPS.sol`, `FaultDisputeGame.sol`, and `PermissionedDisputeGame.sol` contracts for Holocene."
sebastianst marked this conversation as resolved.
Show resolved Hide resolved
},
"transactions": [
{
"metadata": {
"name": "Upgrade `PERMISSIONED_CANNON` game type in `DisputeGameFactory`",
"description": "Upgrades the `PERMISSIONED_CANNON` game type to the new Holocene deployment, with an updated version of `op-program` as the absolute prestate hash."
},
"to": "0x05F9613aDB30026FFd634f38e5C4dFd30a197Fa1",
"value": "0x0",
"data": "0x14f6b1a30000000000000000000000000000000000000000000000000000000000000001000000000000000000000000bbd576128f71186a0f9ae2f2aab4afb4af2dae17",
"contractMethod": {
"type": "function",
"name": "setImplementation",
"inputs": [
{
"name": "_gameType",
"type": "uint32"
},
{
"name": "_impl",
"type": "address"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
"contractInputsValues": {
"_gameType": "1",
"_impl": "0xbBD576128f71186A0f9ae2F2AAb4afb4aF2dae17"
}
},
{
"metadata": {
"name": "Upgrade `CANNON` game type in `DisputeGameFactory`",
"description": "Upgrades the `CANNON` game type to the new Holocene deployment, with an updated version of `op-program` as the absolute prestate hash."
},
"to": "0x05F9613aDB30026FFd634f38e5C4dFd30a197Fa1",
"value": "0x0",
"data": "0x14f6b1a30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000833a817ef459f4ecdb83fc5a4bf04d09a4e83f3f",
"contractMethod": {
"type": "function",
"name": "setImplementation",
"inputs": [
{
"name": "_gameType",
"type": "uint32"
},
{
"name": "_impl",
"type": "address"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
"contractInputsValues": {
"_gameType": "0",
"_impl": "0x833a817eF459f4eCdB83Fc5A4Bf04d09A4e83f3F"
}
}
]
}