Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Sep 15, 2024
1 parent cedc089 commit 6aff41b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
Binary file modified elf/fault-proof-elf
Binary file not shown.
Binary file modified elf/range-elf
Binary file not shown.
12 changes: 8 additions & 4 deletions scripts/prove/bin/cost_estimator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use log::info;
use op_succinct_host_utils::{
fetcher::{CacheMode, OPSuccinctDataFetcher, RPCMode},
get_proof_stdin,
rollup_config::read_rollup_config,
stats::{get_execution_stats, ExecutionStats},
witnessgen::WitnessGenExecutor,
ProgramType,
Expand All @@ -16,7 +17,8 @@ use serde::{Deserialize, Serialize};
use sp1_sdk::{utils, ProverClient};
use std::{
cmp::{max, min},
env, fs,
env,
fs::{self},
future::Future,
net::TcpListener,
path::PathBuf,
Expand Down Expand Up @@ -114,7 +116,7 @@ struct BatchHostCli {
}

fn get_max_span_batch_range_size(chain_id: u64) -> u64 {
const DEFAULT_SIZE: u64 = 20;
const DEFAULT_SIZE: u64 = 50;
match chain_id {
8453 => 5, // Base
11155111 => 20, // OP Sepolia
Expand Down Expand Up @@ -167,7 +169,7 @@ async fn run_native_data_generation(
data_fetcher: &OPSuccinctDataFetcher,
split_ranges: &[SpanBatchRange],
) -> Vec<BatchHostCli> {
const CONCURRENT_NATIVE_HOST_RUNNERS: usize = 5;
const CONCURRENT_NATIVE_HOST_RUNNERS: usize = 1;

// Split the entire range into chunks of size CONCURRENT_NATIVE_HOST_RUNNERS and process chunks
// serially. Generate witnesses within each chunk in parallel. This prevents the RPC from
Expand Down Expand Up @@ -391,7 +393,9 @@ async fn main() -> Result<()> {
let data_fetcher = OPSuccinctDataFetcher::new().await;

let l2_chain_id = data_fetcher.get_chain_id(RPCMode::L2).await?;
let rollup_config = RollupConfig::from_l2_chain_id(l2_chain_id).unwrap();

// Read the rollup config.
let rollup_config: RollupConfig = read_rollup_config(l2_chain_id).unwrap();

// Start the Docker container if it doesn't exist.
manage_span_batch_server_container()?;
Expand Down
4 changes: 4 additions & 0 deletions utils/client/src/oracle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ impl InMemoryOracle {
/// Creates a new [InMemoryOracle] from the raw bytes passed into the zkVM.
/// These values are deserialized using rkyv for zero copy deserialization.
pub fn from_raw_bytes(input: Vec<u8>) -> Self {
println!("cycle-tracker-start: in-memory-oracle-from-raw-bytes-archive");
let archived = unsafe { rkyv::archived_root::<Self>(&input) };
println!("cycle-tracker-end: in-memory-oracle-from-raw-bytes-archive");
println!("cycle-tracker-start: in-memory-oracle-from-raw-bytes-deserialize");
let deserialized: Self = archived.deserialize(&mut Infallible).unwrap();
println!("cycle-tracker-end: in-memory-oracle-from-raw-bytes-deserialize");

deserialized
}
Expand Down
10 changes: 10 additions & 0 deletions utils/host/src/rollup_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,13 @@ pub fn save_rollup_config(rollup_config: &RollupConfig) -> Result<()> {
fs::write(rollup_config_path, rollup_config_str)?;
Ok(())
}

/// Read rollup config from rollup-configs/{l2_chain_id}.json in the workspace root.
pub fn read_rollup_config(l2_chain_id: u64) -> Result<RollupConfig> {
let workspace_root = cargo_metadata::MetadataCommand::new().exec()?.workspace_root;
let rollup_config_path =
workspace_root.join(format!("rollup-configs/{}.json", l2_chain_id));
let rollup_config_str = fs::read_to_string(rollup_config_path)?;
let rollup_config: RollupConfig = serde_json::from_str(&rollup_config_str)?;
Ok(rollup_config)
}

0 comments on commit 6aff41b

Please sign in to comment.