Skip to content

Commit

Permalink
fix: Witness generation issue in kona (#134)
Browse files Browse the repository at this point in the history
* feat: witnessgen hang

* updated elfs

* docs

* del rustfmt

* fmt

* rm test

* fix
  • Loading branch information
ratankaliani authored Sep 25, 2024
1 parent a2b3ff0 commit 9eebf51
Show file tree
Hide file tree
Showing 32 changed files with 543 additions and 238 deletions.
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spin = { version = "0.9.8", features = ["mutex"] }
lru = "0.12.3"
async-trait = "0.1.80"
sha2 = "0.10.8"
tokio = { version = "1.37.0", features = ["full"] }
tokio = { version = "1.40.0", features = ["full"] }
clap = "4.5.9"
cargo_metadata = "0.18.1"
dotenv = "0.15.0"
Expand All @@ -37,18 +37,18 @@ tower-http = { version = "0.5.2", features = ["limit"] }
kzg-rs = { version = "0.2.2" }

# kona
# Note: This version of kona is from 9/24. Pin to this release until the new version of kona is released.
kona-common = { git = "https://github.com/anton-rs/kona", rev = "5d0e211ca1c271377fe184729761bcb217f1f60a" }
kona-common-proc = { git = "https://github.com/anton-rs/kona", rev = "5d0e211ca1c271377fe184729761bcb217f1f60a" }
kona-preimage = { git = "https://github.com/anton-rs/kona", rev = "5d0e211ca1c271377fe184729761bcb217f1f60a", features = [
# Note: Switch to latest version of kona once the std::process::Command issue is resolved.
kona-common = { git = "https://github.com/moongate-forks/kona", branch = "ratan/native-client-command-bugged" }
kona-common-proc = { git = "https://github.com/moongate-forks/kona", branch = "ratan/native-client-command-bugged" }
kona-preimage = { git = "https://github.com/moongate-forks/kona", branch = "ratan/native-client-command-bugged", features = [
"rkyv",
] }
kona-primitives = { git = "https://github.com/anton-rs/kona", rev = "5d0e211ca1c271377fe184729761bcb217f1f60a" }
kona-mpt = { git = "https://github.com/anton-rs/kona", rev = "5d0e211ca1c271377fe184729761bcb217f1f60a" }
kona-derive = { git = "https://github.com/anton-rs/kona", rev = "5d0e211ca1c271377fe184729761bcb217f1f60a", default-features = false }
kona-executor = { git = "https://github.com/anton-rs/kona", rev = "5d0e211ca1c271377fe184729761bcb217f1f60a" }
kona-client = { git = "https://github.com/anton-rs/kona", rev = "5d0e211ca1c271377fe184729761bcb217f1f60a" }
kona-host = { git = "https://github.com/anton-rs/kona", rev = "5d0e211ca1c271377fe184729761bcb217f1f60a" }
kona-primitives = { git = "https://github.com/moongate-forks/kona", branch = "ratan/native-client-command-bugged" }
kona-mpt = { git = "https://github.com/moongate-forks/kona", branch = "ratan/native-client-command-bugged" }
kona-derive = { git = "https://github.com/moongate-forks/kona", branch = "ratan/native-client-command-bugged", default-features = false }
kona-executor = { git = "https://github.com/moongate-forks/kona", branch = "ratan/native-client-command-bugged" }
kona-client = { git = "https://github.com/moongate-forks/kona", branch = "ratan/native-client-command-bugged" }
kona-host = { git = "https://github.com/moongate-forks/kona", branch = "ratan/native-client-command-bugged" }

# op-succinct
op-succinct-prove = { path = "scripts/prove" }
Expand Down
2 changes: 1 addition & 1 deletion book/getting-started/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ If you are using a self-managed OP Stack chain, you will need to use your `ADMIN
To update the `L2OutputOracle` implementation, run the following command in `/contracts`:

```bash
forge script script/ZKUpgrader.s.sol:ZKUpgrader \
forge script script/OPSuccinctUpgrader.s.sol:OPSuccinctUpgrader \
--rpc-url $L1_RPC \
--private-key $PRIVATE_KEY \
--verify \
Expand Down
14 changes: 7 additions & 7 deletions contracts/opsuccinctl2ooconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"finalizationPeriod": 0,
"l2BlockTime": 2,
"owner": "0xDEd0000E32f8F40414d3ab3a830f735a3553E18e",
"proposer": "0x0000000000000000000000000000000000000000",
"rollupConfigHash": "0x0fdeac66da1ca6fb6078d16af1e8e2c306d3d26bf59efec54af4de3a39a52ba3",
"startingBlockNumber": 17675163,
"startingOutputRoot": "0x620034a9cc30f288305bc99d8c0e1cb3770065f34b05491a6d144aa9c4d186af",
"startingTimestamp": 1727152866,
"proposer": "0xDEd0000E32f8F40414d3ab3a830f735a3553E18e",
"rollupConfigHash": "0x8db2d5ac8409f1f427755d76905c72938229e8d013ebcfe894e0db67f98ea45b",
"startingBlockNumber": 17716036,
"startingOutputRoot": "0x94bd4dad79b967eca2c6a5dc3d06f41fa2d592e47245cd38caee5b0af2f5a763",
"startingTimestamp": 1727234612,
"submissionInterval": 20,
"verifierGateway": "0x3B6041173B80E77f038f3F2C0f9744f04837185e",
"aggregationVkey": "0x002fff475261fad7d14e48354686fb33a2a8263f2f603846eca4f0a44eca67f4",
"rangeVkeyCommitment": "0x3dfb83525f0a3a9118cb9c5547729551043fa7c626d4081805307b336db899ed"
"aggregationVkey": "0x004c04e3eab8ea57cd1f9076cf1b3b87e1e7155776a64ae101e0a39d9098c676",
"rangeVkeyCommitment": "0x75580008047522f72c420286476498af1ec8266960fb4f6549c3bff50109442e"
}
6 changes: 0 additions & 6 deletions contracts/test/Upgrade.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ import {Proxy} from "@optimism/src/universal/Proxy.sol";
import {Utils} from "./helpers/Utils.sol";

contract UpgradeTest is Test, Utils {
function testReadJsonSucceeds() public {
Config memory config = readJson("opsuccinctl2ooconfig.json");
assertEq(config.l2BlockTime, 2);
assertEq(config.proposer, address(0));
}

function testFreshDeployment() public {
bytes32 exampleOutputRoot = keccak256("output root");
vm.warp(12345678);
Expand Down
Binary file modified elf/aggregation-elf
Binary file not shown.
Binary file modified elf/fault-proof-elf
Binary file not shown.
Binary file modified elf/range-elf
Binary file not shown.
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ upgrade-l2oo l1_rpc admin_pk etherscan_api_key="":
L1_RPC="{{l1_rpc}}"
ADMIN_PK="{{admin_pk}}"

cd contracts && forge script script/ZKUpgrader.s.sol:ZKUpgrader --rpc-url $L1_RPC --private-key $ADMIN_PK $VERIFY --broadcast --slow
cd contracts && forge script script/OPSuccinctUpgrader.s.sol:OPSuccinctUpgrader --rpc-url $L1_RPC --private-key $ADMIN_PK $VERIFY --broadcast --slow
13 changes: 10 additions & 3 deletions programs/aggregation/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ pub fn main() {
});

// Create a map of each l1 head in the [`BootInfoStruct`]'s to booleans
let mut l1_heads_map: HashMap<B256, bool> =
agg_inputs.boot_infos.iter().map(|boot_info| (boot_info.l1Head, false)).collect();
let mut l1_heads_map: HashMap<B256, bool> = agg_inputs
.boot_infos
.iter()
.map(|boot_info| (boot_info.l1Head, false))
.collect();

// Iterate through the headers in reverse order. The headers should be sequentially linked and
// include the l1 head of each boot info.
Expand All @@ -73,7 +76,11 @@ pub fn main() {

// Check if all l1 heads were found in the chain.
for (l1_head, found) in l1_heads_map.iter() {
assert!(*found, "l1 head {:?} not found in the provided header chain", l1_head);
assert!(
*found,
"l1 head {:?} not found in the provided header chain",
l1_head
);
}

let first_boot_info = &agg_inputs.boot_infos[0];
Expand Down
9 changes: 7 additions & 2 deletions programs/range/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,14 @@ fn main() {
let mut new_block_header;
'step: loop {
// Execute the payload to generate a new block header.
info!("Executing Payload for L2 Block: {}", payload.parent.block_info.number + 1);
info!(
"Executing Payload for L2 Block: {}",
payload.parent.block_info.number + 1
);
println!("cycle-tracker-report-start: block-execution");
new_block_header = executor.execute_payload(payload.attributes.clone()).unwrap();
new_block_header = executor
.execute_payload(payload.attributes.clone())
.unwrap();
println!("cycle-tracker-report-end: block-execution");
let new_block_number = new_block_header.number;
assert_eq!(new_block_number, payload.parent.block_info.number + 1);
Expand Down
61 changes: 44 additions & 17 deletions proposer/succinct/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ async fn request_span_proof(
let data_fetcher = OPSuccinctDataFetcher::new().await;

let host_cli = data_fetcher
.get_host_cli_args(payload.start, payload.end, ProgramType::Multi, CacheMode::DeleteCache)
.get_host_cli_args(
payload.start,
payload.end,
ProgramType::Multi,
CacheMode::DeleteCache,
)
.await?;

// Start the server and native client with a timeout.
Expand All @@ -94,7 +99,9 @@ async fn request_span_proof(
let sp1_stdin = get_proof_stdin(&host_cli)?;

let prover = NetworkProver::new();
let res = prover.request_proof(MULTI_BLOCK_ELF, sp1_stdin, ProofMode::Compressed).await;
let res = prover
.request_proof(MULTI_BLOCK_ELF, sp1_stdin, ProofMode::Compressed)
.await;

// Check if error, otherwise get proof ID.
let proof_id = match res {
Expand All @@ -113,21 +120,34 @@ async fn request_agg_proof(
Json(payload): Json<AggProofRequest>,
) -> Result<(StatusCode, Json<ProofResponse>), AppError> {
info!("Received agg proof request");
let mut proofs_with_pv: Vec<SP1ProofWithPublicValues> =
payload.subproofs.iter().map(|sp| bincode::deserialize(sp).unwrap()).collect();

let boot_infos: Vec<BootInfoStruct> =
proofs_with_pv.iter_mut().map(|proof| proof.public_values.read()).collect();

let proofs: Vec<SP1Proof> =
proofs_with_pv.iter_mut().map(|proof| proof.proof.clone()).collect();

let l1_head_bytes =
hex::decode(payload.head.strip_prefix("0x").expect("Invalid L1 head, no 0x prefix."))?;
let mut proofs_with_pv: Vec<SP1ProofWithPublicValues> = payload
.subproofs
.iter()
.map(|sp| bincode::deserialize(sp).unwrap())
.collect();

let boot_infos: Vec<BootInfoStruct> = proofs_with_pv
.iter_mut()
.map(|proof| proof.public_values.read())
.collect();

let proofs: Vec<SP1Proof> = proofs_with_pv
.iter_mut()
.map(|proof| proof.proof.clone())
.collect();

let l1_head_bytes = hex::decode(
payload
.head
.strip_prefix("0x")
.expect("Invalid L1 head, no 0x prefix."),
)?;
let l1_head: [u8; 32] = l1_head_bytes.try_into().unwrap();

let fetcher = OPSuccinctDataFetcher::new().await;
let headers = fetcher.get_header_preimages(&boot_infos, l1_head.into()).await?;
let headers = fetcher
.get_header_preimages(&boot_infos, l1_head.into())
.await?;

let prover = NetworkProver::new();
let (_, vkey) = prover.setup(MULTI_BLOCK_ELF);
Expand All @@ -136,7 +156,9 @@ async fn request_agg_proof(

// Set simulation to true on aggregation proofs as they're relatively small.
env::set_var("SKIP_SIMULATION", "false");
let proof_id = prover.request_proof(AGG_ELF, stdin, ProofMode::Groth16).await?;
let proof_id = prover
.request_proof(AGG_ELF, stdin, ProofMode::Groth16)
.await?;
env::set_var("SKIP_SIMULATION", "true");

Ok((StatusCode::OK, Json(ProofResponse { proof_id })))
Expand Down Expand Up @@ -204,7 +226,10 @@ async fn get_proof_status(
}
Ok((
StatusCode::OK,
Json(ProofStatus { status: status.as_str_name().to_string(), proof: vec![] }),
Json(ProofStatus {
status: status.as_str_name().to_string(),
proof: vec![],
}),
))
}

Expand Down Expand Up @@ -234,7 +259,9 @@ where
let s: Vec<String> = Deserialize::deserialize(deserializer)?;
s.into_iter()
.map(|base64_str| {
general_purpose::STANDARD.decode(base64_str).map_err(serde::de::Error::custom)
general_purpose::STANDARD
.decode(base64_str)
.map_err(serde::de::Error::custom)
})
.collect()
}
19 changes: 15 additions & 4 deletions proposer/succinct/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,32 @@ use sp1_build::{build_program_with_args, BuildArgs};
/// Build a native program.
fn build_native_program(program: &str) {
let status = Command::new("cargo")
.args(["build", "--workspace", "--bin", program, "--profile", "release-client-lto"])
.args([
"build",
"--workspace",
"--bin",
program,
"--profile",
"release-client-lto",
])
.status()
.expect("Failed to execute cargo build command");

if !status.success() {
panic!("Failed to build {}", program);
}

println!("cargo:warning={} built with release-client-lto profile", program);
println!(
"cargo:warning={} built with release-client-lto profile",
program
);
}

/// Build the native host runner to a separate target directory to avoid build lockups.
fn build_native_host_runner() {
let metadata =
cargo_metadata::MetadataCommand::new().exec().expect("Failed to get cargo metadata");
let metadata = cargo_metadata::MetadataCommand::new()
.exec()
.expect("Failed to get cargo metadata");
let target_dir = metadata.target_directory.join("native_host_runner");

let status = Command::new("cargo")
Expand Down
8 changes: 4 additions & 4 deletions rollup-configs/11155420.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"genesis": {
"l1": {
"hash": "0x48f520cf4ddaf34c8336e6e490632ea3cf1e5e93b0b2bc6e917557e31845371b",
"number": "0x3e1ff0"
"number": 4071408,
"hash": "0x48f520cf4ddaf34c8336e6e490632ea3cf1e5e93b0b2bc6e917557e31845371b"
},
"l2": {
"hash": "0x102de6ffb001480cc9b8b548fd05c34cd4f46ae4aa91759393db90ea0409887d",
"number": "0x0"
"number": 0,
"hash": "0x102de6ffb001480cc9b8b548fd05c34cd4f46ae4aa91759393db90ea0409887d"
},
"l2_time": 1691802540,
"system_config": {
Expand Down
11 changes: 0 additions & 11 deletions rustfmt.toml

This file was deleted.

Loading

0 comments on commit 9eebf51

Please sign in to comment.