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

Ink Sepolia Holocene and L1 Pectra support tasks #560

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions tasks/sep/ink-001-fp-holocene-pectra-upgrade/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ETH_RPC_URL="https://ethereum-sepolia.publicnode.com"
COUNCIL_SAFE=0xf64bc17485f0B4Ea5F06A96514182FC4cB561977
FOUNDATION_SAFE=0xDEe57160aAfCF04c34C887B5962D0a69676d3C8B
OWNER_SAFE=0x1Eb2fFc903729a0F03966B917003800b145F56E2
SAFE_NONCE=""
SIMULATE_WITHOUT_LEDGER=0 # set to 1 during development
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import {NestedSignFromJson as OriginalNestedSignFromJson} from "script/NestedSignFromJson.s.sol";
import {Simulation} from "@base-contracts/script/universal/Simulation.sol";
import {Types} from "@eth-optimism-bedrock/scripts/libraries/Types.sol";
import {console2 as console} from "forge-std/console2.sol";
import {stdJson} from "forge-std/StdJson.sol";
import {LibString} from "solady/utils/LibString.sol";
import {GnosisSafe} from "safe-contracts/GnosisSafe.sol";
import {Vm, VmSafe} from "forge-std/Vm.sol";
import "@eth-optimism-bedrock/src/dispute/lib/Types.sol";
import {DisputeGameFactory} from "@eth-optimism-bedrock/src/dispute/DisputeGameFactory.sol";
import {FaultDisputeGame} from "@eth-optimism-bedrock/src/dispute/FaultDisputeGame.sol";
import {PermissionedDisputeGame} from "@eth-optimism-bedrock/src/dispute/PermissionedDisputeGame.sol";
import {MIPS} from "@eth-optimism-bedrock/src/cannon/MIPS.sol";
import {ISemver} from "@eth-optimism-bedrock/interfaces/universal/ISemver.sol";

contract NestedSignFromJson is OriginalNestedSignFromJson {
using LibString for string;

DisputeGameFactory constant dgfProxy = DisputeGameFactory(0x860e626c700AF381133D9f4aF31412A2d1DB3D5d);
address constant livenessGuard = 0xc26977310bC89DAee5823C2e2a73195E85382cC7;
bytes32 constant absolutePrestate = 0x03dfa3b3ac66e8fae9f338824237ebacff616df928cf7dada0e14be2531bc1f4;
address constant newMips = 0x69470D6970Cd2A006b84B1d4d70179c892cFCE01;
address constant oracle = 0x92240135b46fc1142dA181f550aE8f595B858854;
string constant gameVersion = "1.3.1";
uint256 constant chainId = 763373;

// Safe contract for this task.
GnosisSafe securityCouncilSafe = GnosisSafe(payable(vm.envAddress("COUNCIL_SAFE")));
GnosisSafe fndSafe = GnosisSafe(payable(vm.envAddress("FOUNDATION_SAFE")));
GnosisSafe ownerSafe = GnosisSafe(payable(vm.envAddress("OWNER_SAFE")));

FaultDisputeGame faultDisputeGame;
PermissionedDisputeGame permissionedDisputeGame;

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

permissionedDisputeGame = PermissionedDisputeGame(stdJson.readAddress(inputJson, "$.transactions[0].contractInputsValues._impl"));
faultDisputeGame = FaultDisputeGame(stdJson.readAddress(inputJson, "$.transactions[1].contractInputsValues._impl"));
}

function getCodeExceptions() internal view override returns (address[] memory) {
// Safe owners will appear in storage in the LivenessGuard when added, and they are allowed
// to have code AND to have no code.
address[] memory securityCouncilSafeOwners = securityCouncilSafe.getOwners();

// To make sure we probably handle all signers whether or not they have code, first we count
// the number of signers that have no code.
uint256 numberOfSafeSignersWithNoCode;
for (uint256 i = 0; i < securityCouncilSafeOwners.length; i++) {
if (securityCouncilSafeOwners[i].code.length == 0) {
numberOfSafeSignersWithNoCode++;
}
}

// Then we extract those EOA addresses into a dedicated array.
uint256 trackedSignersWithNoCode;
address[] memory safeSignersWithNoCode = new address[](numberOfSafeSignersWithNoCode);
for (uint256 i = 0; i < securityCouncilSafeOwners.length; i++) {
if (securityCouncilSafeOwners[i].code.length == 0) {
safeSignersWithNoCode[trackedSignersWithNoCode] = securityCouncilSafeOwners[i];
trackedSignersWithNoCode++;
}
}

// Here we add the standard (non Safe signer) exceptions.
address[] memory shouldHaveCodeExceptions = new address[](0 + numberOfSafeSignersWithNoCode);


// And finally, we append the Safe signer exceptions.
for (uint256 i = 0; i < safeSignersWithNoCode.length; i++) {
shouldHaveCodeExceptions[0 + i] = safeSignersWithNoCode[i];
}

return shouldHaveCodeExceptions;
}

function getAllowedStorageAccess() internal view override returns (address[] memory allowed) {
allowed = new address[](5);
allowed[0] = address(dgfProxy);
allowed[1] = address(ownerSafe);
allowed[2] = address(securityCouncilSafe);
allowed[3] = address(fndSafe);
allowed[4] = livenessGuard;
}

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

function checkDGFProxyAndGames() internal view {
console.log("check dispute game implementations");
require(address(faultDisputeGame) == address(dgfProxy.gameImpls(GameTypes.CANNON)), "dgf-100");
require(address(permissionedDisputeGame) == address(dgfProxy.gameImpls(GameTypes.PERMISSIONED_CANNON)), "dgf-200");

require(faultDisputeGame.version().eq(gameVersion), "game-100");
require(permissionedDisputeGame.version().eq(gameVersion), "game-200");

require(faultDisputeGame.absolutePrestate().raw() == absolutePrestate, "game-300");
require(permissionedDisputeGame.absolutePrestate().raw() == absolutePrestate, "game-400");

require(address(faultDisputeGame.vm()) == newMips, "game-500");
require(address(permissionedDisputeGame.vm()) == newMips, "game-600");

require(faultDisputeGame.l2ChainId() == chainId, "game-700");
require(permissionedDisputeGame.l2ChainId() == chainId, "game-800");
}

function checkMips() internal view{
console.log("check MIPS");

require(newMips.code.length != 0, "MIPS-100");
vm.assertEq(ISemver(newMips).version(), "1.2.1");
require(address(MIPS(newMips).oracle()) == oracle, "MIPS-200");
}

}
38 changes: 38 additions & 0 deletions tasks/sep/ink-001-fp-holocene-pectra-upgrade/OVERVIEW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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:** `0x860e626c700AF381133D9f4aF31412A2d1DB3D5d`

**Value:** `0 WEI`

**Raw Input Data:** `0x14f6b1a300000000000000000000000000000000000000000000000000000000000000010000000000000000000000004a0973e21274c4d939c84ac8b98d4308b7c9e249`

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

**_impl:** `0x4A0973E21274c4d939c84ac8B98D4308b7c9E249`


## Tx #2: Upgrade `CANNON` game type in `DisputeGameFactory`
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:** `0x860e626c700AF381133D9f4aF31412A2d1DB3D5d`

**Value:** `0 WEI`

**Raw Input Data:** `0x14f6b1a30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e562e81d08cd5e212661ef961b4069456e426c56`

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

**_impl:** `0xe562e81d08cD5e212661EF961B4069456e426C56`

44 changes: 44 additions & 0 deletions tasks/sep/ink-001-fp-holocene-pectra-upgrade/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Ink Sepolia Holocene Hardfork + L1 Pectra Support Upgrade

Status: DRAFT, NOT READY TO SIGN

## Objective

Upgrades the Fault Proof contracts for the Holocene hardfork and utilizes the absolute prestate that enables L1 pectra support.

The proposal was:

- [X] [Posted](https://gov.optimism.io/t/upgrade-proposal-11-holocene-network-upgrade/9313) on the governance forum.
- [X] [Approved](https://vote.optimism.io/proposals/20127877429053636874064552098716749508236019236440427814457915785398876262515) by Token House voting.
- [X] Not vetoed by the Citizens' house.
- [X] Executed on OP Mainnet.

The governance proposal should be treated as the source of truth and used to verify the correctness of the onchain operations.

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

- `MIPS` - `0x69470D6970Cd2A006b84B1d4d70179c892cFCE01`
- `FaultDisputeGame` - `0xe562e81d08cD5e212661EF961B4069456e426C56`
- `PermissionedDisputeGame` - `0x4A0973E21274c4d939c84ac8B98D4308b7c9E249`

## 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/<path>/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.
26 changes: 26 additions & 0 deletions tasks/sep/ink-001-fp-holocene-pectra-upgrade/VALIDATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Validation

This document can be used to validate the state diff resulting from the execution of the 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.

## State Changes

### `0x860e626c700AF381133D9f4aF31412A2d1DB3D5d` (`DisputeGameFactoryProxy`)

- **Key**: `0xffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b` <br/>
**Before**: `0x0000000000000000000000000000000000000000000000000000000000000000` <br/>
**After**: `0x000000000000000000000000e562e81d08cd5e212661ef961b4069456e426c56` <br/>
**Meaning**: Updates the CANNON game type implementation. You can verify which implementation is set using `cast call 0x860e626c700AF381133D9f4aF31412A2d1DB3D5d "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).
Before this task has been executed, you will see that the returned address is `0x0000000000000000000000000000000000000000000000000000000000000000`, matching the "Before" value of this slot, demonstrating this slot is storing the address of the CANNON implementation.

- **Key**: `0x4d5a9bd2e41301728d41c8e705190becb4e74abe869f75bdb405b63716a35f9e` <br/>
**Before**: `0x000000000000000000000000a8808360f7bc16da81938e5c29400d18bea651c4` <br/>
**After**: `0x0000000000000000000000004a0973e21274c4d939c84ac8b98d4308b7c9e249` <br/>
**Meaning**: Updates the PERMISSIONED_CANNON game type implementation. You can verify which implementation is set using `cast call 0x860e626c700AF381133D9f4aF31412A2d1DB3D5d "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 `0x000000000000000000000000a8808360f7bc16da81938e5c29400d18bea651c4`, 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/ink-001-fp-holocene-pectra-upgrade/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."
},
"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": "0x860e626c700AF381133D9f4aF31412A2d1DB3D5d",
"value": "0x0",
"data": "0x14f6b1a300000000000000000000000000000000000000000000000000000000000000010000000000000000000000004a0973e21274c4d939c84ac8b98d4308b7c9e249",
"contractMethod": {
"type": "function",
"name": "setImplementation",
"inputs": [
{
"name": "_gameType",
"type": "uint32"
},
{
"name": "_impl",
"type": "address"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
"contractInputsValues": {
"_gameType": "1",
"_impl": "0x4A0973E21274c4d939c84ac8B98D4308b7c9E249"
}
},
{
"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": "0x860e626c700AF381133D9f4aF31412A2d1DB3D5d",
"value": "0x0",
"data": "0x14f6b1a30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e562e81d08cd5e212661ef961b4069456e426c56",
"contractMethod": {
"type": "function",
"name": "setImplementation",
"inputs": [
{
"name": "_gameType",
"type": "uint32"
},
{
"name": "_impl",
"type": "address"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
"contractInputsValues": {
"_gameType": "0",
"_impl": "0xe562e81d08cD5e212661EF961B4069456e426C56"
}
}
]
}
4 changes: 4 additions & 0 deletions tasks/sep/ink-002-holocene-system-config-upgrade/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ETH_RPC_URL="https://ethereum-sepolia.publicnode.com"
COUNCIL_SAFE=0xf64bc17485f0B4Ea5F06A96514182FC4cB561977
FOUNDATION_SAFE=0xDEe57160aAfCF04c34C887B5962D0a69676d3C8B
OWNER_SAFE=0x1Eb2fFc903729a0F03966B917003800b145F56E2
Loading