Skip to content

Commit

Permalink
update kona
Browse files Browse the repository at this point in the history
  • Loading branch information
hashcashier committed Dec 13, 2024
1 parent 96538a2 commit 28ced43
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ out
optimism/
*.out
*.pb
profiling/
profiling/*
25 changes: 13 additions & 12 deletions Cargo.lock

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

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ kailua-contracts = { path = "crates/contracts" }
kailua-host = { path = "bin/host" }

# Kona git = "https://github.com/ethereum-optimism/kona", rev = "c644ac6"
kona-client = { git = "https://github.com/ethereum-optimism/kona", rev = "c644ac6" }
kona-common = { git = "https://github.com/ethereum-optimism/kona", rev = "c644ac6" }
kona-common-proc = { git = "https://github.com/ethereum-optimism/kona", rev = "c644ac6" }
kona-derive = { git = "https://github.com/ethereum-optimism/kona", rev = "c644ac6", default-features = false, features = ["serde"] }
kona-executor = { git = "https://github.com/ethereum-optimism/kona", rev = "c644ac6" }
kona-host = { git = "https://github.com/ethereum-optimism/kona", rev = "c644ac6" }
kona-mpt = { git = "https://github.com/ethereum-optimism/kona", rev = "c644ac6" }
kona-preimage = { git = "https://github.com/ethereum-optimism/kona", rev = "c644ac6", features = ["rkyv"] }
kona-client = { git = "https://github.com/hashcashier/kona" }
kona-common = { git = "https://github.com/hashcashier/kona" }
kona-common-proc = { git = "https://github.com/hashcashier/kona" }
kona-derive = { git = "https://github.com/hashcashier/kona", default-features = false, features = ["serde"] }
kona-executor = { git = "https://github.com/hashcashier/kona" }
kona-host = { git = "https://github.com/hashcashier/kona" }
kona-mpt = { git = "https://github.com/hashcashier/kona" }
kona-preimage = { git = "https://github.com/hashcashier/kona", features = ["rkyv"] }

# RISC Zero zkVM
risc0-build = { version = "1.1.2" }
Expand Down
8 changes: 7 additions & 1 deletion bin/cli/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use alloy::rpc::types::Block;
use std::cmp::Ordering;
use std::collections::BinaryHeap;
use std::fs::OpenOptions;
use std::iter::repeat;
use std::process::Command;
use tracing::{info, warn};

Expand Down Expand Up @@ -106,6 +107,11 @@ pub async fn benchmark(args: BenchArgs) -> anyhow::Result<()> {
.append(true)
.open(&output_file_name)?;
// Pipe outputs to file
let verbosity_level = if args.v > 0 {
format!("-{}", repeat('v').take(args.v as usize).collect::<String>())
} else {
String::new()
};
Command::new("just")
.env("RISC0_DEV_MODE", "1")
.args(vec![
Expand All @@ -116,7 +122,7 @@ pub async fn benchmark(args: BenchArgs) -> anyhow::Result<()> {
&args.l2_node_address,
&args.op_node_address,
&args.data_dir,
"-v",
&verbosity_level,
])
.stdout(output_file)
.status()?;
Expand Down
4 changes: 3 additions & 1 deletion bin/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use alloy_primitives::{keccak256, B256};
use anyhow::Context;
use kailua_build::{KAILUA_FPVM_ELF, KAILUA_FPVM_ID};
use kona_client::l1::OracleBlobProvider;
use kona_client::l2::OracleL2ChainProvider;
use kona_client::{BootInfo, CachingOracle};
use oracle_posix::{POSIXCallbackHandle, POSIXPreimageOracleClient};
use risc0_zkvm::{default_prover, ExecutorEnv, ProveInfo, ProverOpts};
Expand Down Expand Up @@ -48,7 +49,8 @@ pub async fn run_native_client() -> anyhow::Result<Option<B256>> {
.context("BootInfo::load")?,
);
let beacon = OracleBlobProvider::new(oracle.clone());
kailua_common::client::run_client(oracle, boot, beacon)
let l2_provider = OracleL2ChainProvider::new(boot.clone(), oracle.clone());
kailua_common::client::run_client(oracle, boot, beacon, l2_provider)
}

pub async fn prove_zkvm_client() -> anyhow::Result<ProveInfo> {
Expand Down
6 changes: 5 additions & 1 deletion bin/client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@

use kailua_client::fpvm_proof_file_name;
use kailua_common::ProofJournal;
use std::env::var;
use std::str::FromStr;
use tokio::fs::File;
use tokio::io::AsyncWriteExt;
use tracing::info;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
kona_host::init_tracing_subscriber(0)?;
if let Ok(Ok(verbosity_level)) = var("KAILUA_VERBOSITY").map(|s| u8::from_str(&s)) {
kona_host::init_tracing_subscriber(verbosity_level)?;
}
// preload all data natively
info!("Running native client.");
kailua_client::run_native_client()
Expand Down
7 changes: 6 additions & 1 deletion bin/host/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use clap::Parser;
use kailua_client::fpvm_proof_file_name;
use kailua_host::{dump_data_to_kv_store, generate_rollup_config, KailuaHostCli};
use kona_host::{init_tracing_subscriber, start_server_and_native_client};
use std::env::set_var;
use std::path::Path;
use tempfile::tempdir;
use tracing::info;
Expand All @@ -31,6 +32,7 @@ use zeth_preflight_optimism::OpRethPreflightClient;
async fn main() -> anyhow::Result<()> {
let mut cfg = KailuaHostCli::parse();
init_tracing_subscriber(cfg.kona.v)?;
set_var("KAILUA_VERBOSITY", cfg.kona.v.to_string());

// compute receipt if uncached
let file_name = fpvm_proof_file_name(
Expand All @@ -49,7 +51,10 @@ async fn main() -> anyhow::Result<()> {
// run zeth preflight to fetch the necessary preimages
if let Ok(named_chain) = NamedChain::try_from(rollup_config.l2_chain_id) {
// Limitation: Only works when disk caching is enabled under a known "NamedChain"
if !cfg.kona.is_offline() && cfg.kona.data_dir.is_some() && OpRethCoreDriver::chain_spec(&named_chain).is_some() {
if !cfg.kona.is_offline()
&& cfg.kona.data_dir.is_some()
&& OpRethCoreDriver::chain_spec(&named_chain).is_some()
{
let kona_cfg = cfg.kona.clone();
// Fetch all the initial data
let preflight_data: StatelessClientData<
Expand Down
16 changes: 8 additions & 8 deletions build/risczero/fpvm/Cargo.lock

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

4 changes: 2 additions & 2 deletions build/risczero/fpvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ alloy-primitives = { version = "0.8", default-features = false, features = ["map

kailua-common = { path = "../../../crates/common" }

kona-client = { git = "https://github.com/ethereum-optimism/kona", rev = "c644ac6" }
kona-common = { git = "https://github.com/ethereum-optimism/kona", rev = "c644ac6" }
kona-client = { git = "https://github.com/hashcashier/kona" }
kona-common = { git = "https://github.com/hashcashier/kona" }

risc0-zkvm = { version = "1.1.2", features = ["std", "heap-embedded-alloc"] }

Expand Down
13 changes: 8 additions & 5 deletions build/risczero/fpvm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,26 @@ use kailua_common::ProofJournal;
use kona_client::BootInfo;
use risc0_zkvm::guest::env;
use std::sync::Arc;
use kona_client::l2::OracleL2ChainProvider;

fn main() {
let oracle = Arc::new(kailua_common::oracle::RISCZERO_POSIX_ORACLE);
let boot = kona_common::block_on(async {
let boot = Arc::new(kona_common::block_on(async {
BootInfo::load(oracle.as_ref())
.await
.expect("Failed to load BootInfo")
});
}));
let l2_provider = OracleL2ChainProvider::new(boot.clone(), oracle.clone());
// Attempt to recompute the output hash at the target block number using kona
let real_output_hash = run_client(
oracle,
Arc::new(boot.clone()),
oracle.clone(),
boot.clone(),
kailua_common::blobs::RISCZERO_POSIX_BLOB_PROVIDER,
l2_provider,
)
.expect("Failed to compute output hash.");
// Write the proof journal
let mut proof_journal = ProofJournal::from(boot.clone());
let mut proof_journal = ProofJournal::from(boot.as_ref());
if let Some(computed_output) = real_output_hash {
// With sufficient data, the input l2_claim must be true
if computed_output != boot.claimed_l2_output_root {
Expand Down
Loading

0 comments on commit 28ced43

Please sign in to comment.