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

feat: port op-proposer from Optimism fork #78

Merged
merged 41 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1ded9e4
move over op proposer
ratankaliani Aug 28, 2024
c77e399
wip
ratankaliani Aug 28, 2024
f06555a
wip
ratankaliani Aug 28, 2024
51e1937
forge install: forge-std
ratankaliani Aug 28, 2024
18ea1f3
forge install: openzeppelin-contracts
ratankaliani Aug 28, 2024
212b03f
forge install: optimism
ratankaliani Aug 28, 2024
652ab03
forge install: sp1-contracts
ratankaliani Aug 28, 2024
eba61b9
wip
ratankaliani Aug 28, 2024
dd12e93
forge install: sp1-contracts
ratankaliani Aug 28, 2024
a3a52f8
wip
ratankaliani Aug 28, 2024
00e4243
forge install: sp1-contracts
ratankaliani Aug 28, 2024
00b4d5d
add
ratankaliani Aug 28, 2024
5a17a39
forge install: sp1-contracts
ratankaliani Aug 28, 2024
b336c77
wip
ratankaliani Aug 28, 2024
84dc9d3
add
ratankaliani Aug 28, 2024
7c2a6c6
forge install: openzeppelin-contracts
ratankaliani Aug 28, 2024
4f22816
add
ratankaliani Aug 28, 2024
82dae4a
forge install: openzeppelin-contracts
ratankaliani Aug 28, 2024
f1b399d
create bindings
ratankaliani Aug 28, 2024
d5c2580
add
ratankaliani Aug 28, 2024
d75aec5
Merge remote-tracking branch 'origin/main' into ratan/move-over-op-pr…
ratankaliani Aug 28, 2024
359c7c4
add op-proposer-go
ratankaliani Aug 28, 2024
309b173
fix
Aug 29, 2024
4bd3c84
fix
Aug 29, 2024
5ab3b20
fix
Aug 29, 2024
5186041
add
Aug 29, 2024
c747055
add
ratankaliani Aug 29, 2024
86b8ad8
fix
ratankaliani Aug 29, 2024
ae10ca9
fix
ratankaliani Aug 29, 2024
045b0bd
remove run docker compose
ratankaliani Aug 29, 2024
99cca1e
clean up
ratankaliani Aug 29, 2024
2632e67
fix: forge fmt
ratankaliani Aug 29, 2024
4bb94f2
update ci
ratankaliani Aug 29, 2024
1a9ec51
refactor: simplify `op-proposer` logic (#79)
ratankaliani Aug 30, 2024
0a1e265
modify
Aug 30, 2024
16dc0df
merge
Aug 30, 2024
7664529
fix
Aug 30, 2024
a195777
fix
Aug 30, 2024
ca1bba4
add
Aug 30, 2024
55ec32d
fix
Aug 30, 2024
dc85c0a
add build
Aug 30, 2024
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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/target
/data
/execution-reports
18 changes: 11 additions & 7 deletions .env.server.example
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
# Configuration for running the OP Proposer + SP1 Server
L1_RPC=
L1_BEACON_RPC=
L2_RPC=
L2_NODE_RPC=

# Note: These are used because of how the OP Proposer loads the txMgr config in the Optimism monorepo.
L1_ETH_RPC=
BEACON_RPC=
ROLLUP_RPC=


# op-proposer configuration
POLL_INTERVAL=
ROLLUP_RPC=
L2OO_ADDRESS=
PRIVATE_KEY=
L1_ETH_RPC=
BEACON_RPC=
L2_CHAIN_ID=
MAX_CONCURRENT_PROOF_REQUESTS=
MAX_BLOCK_RANGE_PER_SPAN_PROOF=30
KONA_SERVER_URL=http://op-succinct-server:3000
OP_SUCCINCT_SERVER_URL=http://op-succinct-server:3000

# SP1 Configuration for the Server
L1_RPC=
L1_BEACON_RPC=
L2_RPC=
PROVER_NETWORK_RPC=
SP1_PRIVATE_KEY=
SP1_PROVER=network
Expand Down
20 changes: 19 additions & 1 deletion .github/workflows/op_proposer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ on:

jobs:
test_op_proposer_go:
runs-on: ubuntu-latest
runs-on:
- runs-on
- runner=16cpu-linux-x64
- run-id=${{ github.run_id }}
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -25,3 +28,18 @@ jobs:
L2_NODE_RPC: ${{ secrets.L2_NODE_RPC }}
L1_RPC: ${{ secrets.L1_RPC }}
L1_BEACON_RPC: ${{ secrets.L1_BEACON_RPC }}
docker-compose-test:
name: Docker Compose Test
runs-on:
- runs-on
- runner=64cpu-linux-x64
- run-id=${{ github.run_id }}
steps:
- uses: actions/checkout@v4

- name: Set up Docker Compose
uses: docker/setup-buildx-action@v1

- name: Build Docker Compose setup
run: |
docker compose build
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: CI

on:
push:
pull_request:
branches:
- main
workflow_dispatch:

env:
Expand All @@ -26,20 +27,26 @@ jobs:
version: nightly

- name: Show Forge version
working-directory: contracts/
run: |
forge --version

- name: Run Forge fmt
working-directory: contracts/
run: |
forge fmt --check
forge fmt --check src/ test/ script/
id: fmt

- name: Run Forge build
working-directory: contracts/
run: |
forge build --sizes
id: build

- name: Run Forge tests
working-directory: contracts/
run: |
forge test -vvv
id: test
env:
L2_NODE_RPC: ${{ secrets.L2_NODE_RPC }}
13 changes: 10 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ data
# zip
**.zip

# vscode
.vscode

# .env
.env
.env.server
Expand All @@ -18,11 +21,15 @@ data
**.txt
!LICENSE.txt

# DB data
db/

# Reports
execution-reports/

# Rollup Config
**/rollup-config.json

# DB
db/proofs.db

**/bin/op-proposer

artifact_*
12 changes: 12 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[submodule "contracts/lib/forge-std"]
path = contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "contracts/lib/optimism"]
path = contracts/lib/optimism
url = https://github.com/ethereum-optimism/optimism
[submodule "contracts/lib/sp1-contracts"]
path = contracts/lib/sp1-contracts
url = https://github.com/zobront/sp1-contracts
[submodule "contracts/lib/openzeppelin-contracts"]
path = contracts/lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
21 changes: 0 additions & 21 deletions .vscode/settings.json

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Standalone repo to use Kona & SP1 to verify OP Stack blocks.
- `client-utils`: A suite of utilities for the client program.
- `host-utils`: A suite of utilities for constructing the host which runs the OP Succinct program.

**`sp1-kona`**
**`op-succinct`**
- `native-host`: The host program which runs the `op-succinct` program natively using `kona`.
- `zkvm-host`: The host program which runs the `op-succinct` program in the SP1 zkVM.
- `client-programs`: The programs proven in SP1.
Expand Down
2 changes: 1 addition & 1 deletion client-programs/aggregation/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::collections::HashMap;
/// should verify the proof matches the arbitrary vkey digest stored in the contract. This means
/// that the aggregate program would no longer need to update this value.
const MULTI_BLOCK_PROGRAM_VKEY_DIGEST: [u32; 8] =
[227309663, 1637133225, 136526498, 1878261023, 2013043842, 450616441, 575447582, 1643259779];
[1172625895, 1280247262, 651076015, 321432881, 243715685, 1565992912, 1444792760, 1908047081];

/// Verify that the L1 heads in the boot infos are in the header chain.
fn verify_l1_heads(agg_inputs: &AggregationInputs, headers: &[Header]) {
Expand Down
12 changes: 5 additions & 7 deletions client-programs/range/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ fn main() {
let boot = Arc::new(BootInfo::load(oracle.as_ref()).await.unwrap());
}
}
// Note: On some blocks, key not found in cache errors occur due to the precompiles. For
// recent blocks this isn't an issue, but we should look into this more in the future.
let precompile_overrides = ZKVMPrecompileOverride::default();

let l1_provider = OracleL1ChainProvider::new(boot.clone(), oracle.clone());
Expand Down Expand Up @@ -122,6 +120,11 @@ fn main() {
let new_block_number = new_block_header.number;
assert_eq!(new_block_number, payload.parent.block_info.number + 1);

// Increment last_block_num and check if we have reached the claim block.
if new_block_number == boot.l2_claim_block {
break 'step;
}

// Generate the Payload Envelope, which can be used to derive cached data.
let l2_payload_envelope: L2ExecutionPayloadEnvelope = OpBlock {
header: new_block_header.clone(),
Expand All @@ -144,11 +147,6 @@ fn main() {
.update_cache(new_block_header, l2_payload_envelope, &boot.rollup_config)
.unwrap();

// Increment last_block_num and check if we have reached the claim block.
if new_block_number == boot.l2_claim_block {
break 'step;
}

// Update data for the next iteration.
driver.update_safe_head(
l2_block_info,
Expand Down
2 changes: 2 additions & 0 deletions contracts/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Rollup RPC URL
L2_NODE_RPC=
2 changes: 1 addition & 1 deletion contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cache/
out/

# Ignores development broadcast logs
!/broadcast
/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/

Expand Down
14 changes: 12 additions & 2 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,19 @@ The `contracts/` directory consists of two things:

2) The `ZKUpgrader.s.sol` script, which deploys the `ZKL2OutputOracle.sol` implementation contract, upgrades an existing `L2OutputOracleProxy` to point to it, and initializes the new contract with values from `zkconfig.json`.

## Deploy
3) The `ZKDeployer.s.sol` script, which deploys the `ZKL2OutputOracle.sol` implementation contract, upgrades an existing `L2OutputOracleProxy` to point to it, and initializes the new contract with values from `zkconfig.json`.

To deploy and upgrade the contract, run the following command (where `ADMIN_PK` is the private key of the admin address for the L1 proxy contracts):
## Deploy Fresh Proxy

For OP Sepolia, you can deploy a fresh proxy with the following command:

```shell
forge script script/ZKDeployer.s.sol:ZKDeployer --rpc-url <L1_RPC> --private-key <ADMIN_PK> --verify --verifier etherscan --etherscan-api-key <ETHERSCAN_API_KEY> --broadcast --slow -vvvv --ffi
```

## Upgrade Existing Proxy

To deploy and upgrade the contract for existing chains, run the following command (where `ADMIN_PK` is the private key of the admin address for the L1 proxy contracts):

```shell
forge script script/ZKUpgrader.s.sol:ZKUpgrader --rpc-url <L1_RPC> --private-key <ADMIN_PK> --verify --verifier etherscan --etherscan-api-key <ETHERSCAN_API_KEY> --broadcast --slow --vvvv
Expand Down
22 changes: 18 additions & 4 deletions contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,23 @@
src = "src"
out = "out"
libs = ["lib"]
ffi = true
fs_permissions = [
{ access = "read", path = "zkconfig.json" }
remappings = [
# Use openzeppelin-contracts v4.7.3 as the some contracts are not compatible with 0.8.15
"@openzeppelin/=lib/openzeppelin-contracts/",
"@optimism/=lib/optimism/packages/contracts-bedrock/",
"@forge-std/=lib/forge-std/src/",
# Note: Use zobront/sp1-contracts as the current version for SP1 contracts is not compatible with the hard
# version for 0.8.15 on some Optimism contracts.
"@sp1-contracts/=lib/sp1-contracts/contracts/",
"@rari-capital/=lib/optimism/packages/contracts-bedrock/lib/",
# Optimism repo uses absolute imports, so we need to have remappings for the paths we use.
"src/libraries/=lib/optimism/packages/contracts-bedrock/src/libraries/",
"src/L1/=lib/optimism/packages/contracts-bedrock/src/L1/",
"src/L2/=lib/optimism/packages/contracts-bedrock/src/L2/",
]

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
# Enable read-write access to zkconfig.json
fs_permissions = [{ access = "read-write", path = "./zkconfig.json" }]

dotenv = ".env"
# See more config options https://github.com/foundry-rs/foundry/tree/master/config
13 changes: 6 additions & 7 deletions contracts/script/ZKDeployer.s.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { Script } from "forge-std/Script.sol";
import { ZKL2OutputOracle } from "src/ZKL2OutputOracle.sol";
import { Utils } from "test/helpers/Utils.sol";
import { Proxy } from "@optimism/src/universal/Proxy.sol";
pragma solidity ^0.8.15;

import {Script} from "forge-std/Script.sol";
import {ZKL2OutputOracle} from "../src/ZKL2OutputOracle.sol";
import {Utils} from "../test/helpers/Utils.sol";
import {Proxy} from "@optimism/src/universal/Proxy.sol";

contract ZKDeployer is Script, Utils {
function run() public {
vm.startBroadcast();

Config memory config = readJson("zkconfig.json");
Config memory config = readJsonWithRPCFromEnv("zkconfig.json");
config.l2OutputOracleProxy = address(new Proxy(msg.sender));

address zkL2OutputOracleImpl = address(new ZKL2OutputOracle());
Expand Down
9 changes: 4 additions & 5 deletions contracts/script/ZKUpgrader.s.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { Script } from "forge-std/Script.sol";
import { ZKL2OutputOracle } from "src/ZKL2OutputOracle.sol";
import { Utils } from "test/helpers/Utils.sol";
pragma solidity ^0.8.15;

import {Script} from "forge-std/Script.sol";
import {ZKL2OutputOracle} from "../src/ZKL2OutputOracle.sol";
import {Utils} from "../test/helpers/Utils.sol";

contract ZKUpgrader is Script, Utils {
function run() public {
Expand Down
Loading
Loading