Skip to content

Commit

Permalink
edits
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Aug 27, 2024
1 parent 90a866f commit 656b9be
Show file tree
Hide file tree
Showing 18 changed files with 222 additions and 190 deletions.
299 changes: 160 additions & 139 deletions Cargo.lock

Large diffs are not rendered by default.

53 changes: 18 additions & 35 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,18 @@ repository = ""
[workspace.dependencies]

# kona
# kona-common = { git = "https://github.com/ethereum-optimism/kona", branch = "main" }
# kona-common-proc = { git = "https://github.com/ethereum-optimism/kona", branch = "main" }
# kona-preimage = { git = "https://github.com/ethereum-optimism/kona", branch = "main", features = [
# "rkyv",
# ] }
# kona-primitives = { git = "https://github.com/ethereum-optimism/kona", branch = "main" }
# kona-mpt = { git = "https://github.com/ethereum-optimism/kona", branch = "main" }
# kona-derive = { git = "https://github.com/ethereum-optimism/kona", branch = "main", default-features = false }
# kona-executor = { git = "https://github.com/ethereum-optimism/kona", branch = "main" }
# kona-client = { git = "https://github.com/ethereum-optimism/kona", branch = "main" }
# kona-host = { git = "https://github.com/ethereum-optimism/kona", branch = "main" }
# Note: CachingOracle needs to be exposed publicly in Kona. Make a PR to re-expose it again.
kona-common = { git = "https://github.com/ethereum-optimism/kona", rev = "e4a032c1325687221d01674f0de0fd757e516e65" }
kona-common-proc = { git = "https://github.com/ethereum-optimism/kona", rev = "e4a032c1325687221d01674f0de0fd757e516e65" }
kona-preimage = { git = "https://github.com/ethereum-optimism/kona", rev = "e4a032c1325687221d01674f0de0fd757e516e65", features = [
# TODO: Change to stable tag when released.
kona-common = { git = "https://github.com/ethereum-optimism/kona", branch = "main" }
kona-common-proc = { git = "https://github.com/ethereum-optimism/kona", branch = "main" }
kona-preimage = { git = "https://github.com/ethereum-optimism/kona", branch = "main", features = [
"rkyv",
] }
kona-primitives = { git = "https://github.com/ethereum-optimism/kona", rev = "e4a032c1325687221d01674f0de0fd757e516e65" }
kona-mpt = { git = "https://github.com/ethereum-optimism/kona", rev = "e4a032c1325687221d01674f0de0fd757e516e65" }
kona-derive = { git = "https://github.com/ethereum-optimism/kona", rev = "e4a032c1325687221d01674f0de0fd757e516e65", default-features = false }
kona-executor = { git = "https://github.com/ethereum-optimism/kona", rev = "e4a032c1325687221d01674f0de0fd757e516e65" }
kona-client = { git = "https://github.com/ethereum-optimism/kona", rev = "e4a032c1325687221d01674f0de0fd757e516e65" }
kona-host = { git = "https://github.com/ethereum-optimism/kona", rev = "e4a032c1325687221d01674f0de0fd757e516e65" }
kona-primitives = { git = "https://github.com/ethereum-optimism/kona", branch = "main" }
kona-mpt = { git = "https://github.com/ethereum-optimism/kona", branch = "main" }
kona-derive = { git = "https://github.com/ethereum-optimism/kona", branch = "main", default-features = false }
kona-executor = { git = "https://github.com/ethereum-optimism/kona", branch = "main" }
kona-client = { git = "https://github.com/ethereum-optimism/kona", branch = "main" }
kona-host = { git = "https://github.com/ethereum-optimism/kona", branch = "main" }

# general
anyhow = { version = "1.0.86", default-features = false }
Expand Down Expand Up @@ -79,7 +68,7 @@ alloy = { version = "0.2", default-features = false, features = ["full"] }
alloy-primitives = { version = "0.7.6", default-features = false }
alloy-rlp = { version = "0.3.5", default-features = false }
alloy-eips = { version = "0.2", default-features = false }
revm = { git = "https://github.com/bluealloy/revm", version = "13.0", default-features = false }
revm = { version = "13.0", default-features = false }
bincode = "1.3.3"
base64 = "0.22.1"
tower-http = { version = "0.5.2", features = ["limit"] }
Expand All @@ -88,14 +77,11 @@ alloy-sol-types = { version = "0.7.6" }
op-alloy-consensus = { version = "0.1.4", default-features = false }

# sp1
sp1-lib = { git = "https://github.com/succinctlabs/sp1.git", branch = "john/faster-runtime", features = [
"verify",
] }
sp1-zkvm = { git = "https://github.com/succinctlabs/sp1.git", branch = "john/faster-runtime", features = [
"verify",
] }
sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git", branch = "john/faster-runtime" }
sp1-build = { git = "https://github.com/succinctlabs/sp1.git", branch = "john/faster-runtime" }
# TODO: Change to stable tag.
sp1-lib = { version = "1.2.0-rc1", features = ["verify"] }
sp1-zkvm = { version = "1.2.0-rc1", features = ["verify"] }
sp1-sdk = { version = "1.2.0-rc1" }
sp1-build = { version = "1.2.0-rc1" }

# kzg
kzg-rs = { git = "https://github.com/succinctlabs/kzg-rs" }
Expand All @@ -110,11 +96,8 @@ lto = "fat"
[patch.crates-io]
tiny-keccak = { git = "https://github.com/sp1-patches/tiny-keccak", branch = "patch-v2.0.2" }
sha2 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-sha2-v0.10.8" }
sha3 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha3", branch = "patch-sha3-v0.10.8" }
ecdsa-core = { git = "https://github.com/sp1-patches/signatures", package = "ecdsa", branch = "patch-ecdsa-v0.16.9" }
substrate-bn = { git = "https://github.com/sp1-patches/bn", branch = "patch-v0.6.0" }
# Note: This alloy-primitives patch uses sha3 instead of tiny-keccak.
# Note: Patch alloy-primitives to use sha3 instead of tiny-keccak. Reduces cycle count for Keccak by 50%.
sha3 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha3", branch = "patch-sha3-v0.10.8" }
alloy-primitives = { git = "https://github.com/sp1-patches/alloy-core", branch = "patch-v0.7.7" }
# alloy-primitives = { path = "../alloy-core/crates/primitives" }
# alloy-sol-macro-expander = { git = "https://github.com/sp1-patches/alloy-core", branch = "patch-v0.7.7" }
# secp256k1 = { git = "https://github.com/sp1-patches/rust-secp256k1", branch = "patch-secp256k1-v0.29.0" }
3 changes: 2 additions & 1 deletion client-programs/fault-proof/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ cfg_if! {
use alloc::vec::Vec;
} else {
use kona_client::CachingOracle;
use client_utils::pipes::{ORACLE_READER, HINT_WRITER};
}
}

Expand Down Expand Up @@ -58,7 +59,7 @@ fn main() {
// If we are compiling for online mode, create a caching oracle that speaks to the
// fetcher via hints, and gather boot info from this oracle.
} else {
let oracle = Arc::new(CachingOracle::new(1024));
let oracle = Arc::new(CachingOracle::new(1024, ORACLE_READER, HINT_WRITER));
let boot = Arc::new(BootInfo::load(oracle.as_ref()).await.unwrap());
let precompile_overrides = NoPrecompileOverride;
}
Expand Down
7 changes: 4 additions & 3 deletions client-programs/range/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ cfg_if! {
use alloc::vec::Vec;
} else {
use kona_client::CachingOracle;
use client_utils::pipes::{ORACLE_READER, HINT_WRITER};
}
}

Expand Down Expand Up @@ -72,7 +73,7 @@ fn main() {
// If we are compiling for online mode, create a caching oracle that speaks to the
// fetcher via hints, and gather boot info from this oracle.
} else {
let oracle = Arc::new(CachingOracle::new(1024));
let oracle = Arc::new(CachingOracle::new(1024, ORACLE_READER, HINT_WRITER));
let boot = Arc::new(BootInfo::load(oracle.as_ref()).await.unwrap());

// let precompile_overrides = NoPrecompileOverride;
Expand All @@ -83,7 +84,7 @@ fn main() {
let precompile_overrides = NoPrecompileOverride;

let l1_provider = OracleL1ChainProvider::new(boot.clone(), oracle.clone());
let mut l2_provider = MultiblockOracleL2ChainProvider::new(boot.clone(), oracle.clone());
let mut l2_provider = MultiblockOracleL2ChainProvider::new(boot.clone(), oracle.clone());
let beacon = OracleBlobProvider::new(oracle.clone());

////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -113,7 +114,7 @@ fn main() {
.with_fetcher(l2_provider.clone())
.with_hinter(l2_provider.clone())
.with_precompile_overrides(precompile_overrides)
.build()
.build()
.unwrap();
println!("cycle-tracker-end: execution-instantiation");

Expand Down
1 change: 1 addition & 0 deletions crates/client-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ kona-client.workspace = true
kona-preimage.workspace = true
kona-mpt.workspace = true
kona-derive.workspace = true
kona-common.workspace = true

# general
serde.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions crates/client-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pub mod precompiles;

pub mod types;

pub mod pipes;

extern crate alloc;

pub mod driver;
Expand Down
18 changes: 18 additions & 0 deletions crates/client-utils/src/pipes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//! Contains FPVM-specific constructs for the `kona-client` program.
use kona_common::FileDescriptor;
use kona_preimage::{HintWriter, OracleReader, PipeHandle};

/// The global preimage oracle reader pipe.
static ORACLE_READER_PIPE: PipeHandle =
PipeHandle::new(FileDescriptor::PreimageRead, FileDescriptor::PreimageWrite);

/// The global hint writer pipe.
static HINT_WRITER_PIPE: PipeHandle =
PipeHandle::new(FileDescriptor::HintRead, FileDescriptor::HintWrite);

/// The global preimage oracle reader.
pub static ORACLE_READER: OracleReader = OracleReader::new(ORACLE_READER_PIPE);

/// The global hint writer.
pub static HINT_WRITER: HintWriter = HintWriter::new(HINT_WRITER_PIPE);
4 changes: 3 additions & 1 deletion crates/client-utils/src/precompiles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
use alloc::sync::Arc;
use kona_executor::PrecompileOverride;
use kona_mpt::{TrieDB, TrieDBFetcher, TrieDBHinter};
use revm::db::states::state::State;
use revm::handler::Handler;
use revm::{
handler::register::EvmHandler,
precompile::{
bn128, secp256k1, Precompile, PrecompileResult, PrecompileSpecId, PrecompileWithAddress,
},
primitives::Bytes,
ContextPrecompiles, State,
ContextPrecompiles,
};

pub const PRECOMPILE_HOOK_FD: u32 = 115;
Expand Down
1 change: 1 addition & 0 deletions crates/host-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ tokio.workspace = true
futures.workspace = true
num-format.workspace = true
serde.workspace = true
sp1-build.workspace = true
2 changes: 1 addition & 1 deletion crates/host-utils/src/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ impl SP1KonaDataFetcher {
data_dir: Some(data_directory.into()),
exec: Some(exec_directory),
server: false,
// rollup_config_path: None,
rollup_config_path: None,
v: 0,
})
}
Expand Down
Binary file modified elf/aggregation-elf
Binary file not shown.
Binary file modified elf/range-elf
Binary file not shown.
6 changes: 4 additions & 2 deletions op-succinct-proposer/bin/cost_estimator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ struct SpanBatchRange {
end: u64,
}

/// Get the boundaries of the span batches from the Go server from the optimism monorepo. This endpoint
/// downloads the data posted to the Optimism L1 Batch Inbox contract.
async fn get_span_batch_ranges_from_server(
data_fetcher: &SP1KonaDataFetcher,
start: u64,
Expand All @@ -86,9 +88,9 @@ async fn get_span_batch_ranges_from_server(
batchSender: batch_sender.to_string(),
};

// Get the span batch server URL from the environment.
let span_batch_server_url =
env::var("SPAN_BATCH_SERVER_URL").unwrap_or("http://localhost:8080".to_string());

let query_url = format!("{}/span-batch-ranges", span_batch_server_url);

let response: SpanBatchResponse = client
Expand All @@ -99,6 +101,7 @@ async fn get_span_batch_ranges_from_server(
.json()
.await?;

// Return the ranges.
Ok(response.ranges)
}

Expand Down Expand Up @@ -136,7 +139,6 @@ async fn main() -> Result<()> {
let rollup_config = RollupConfig::from_l2_chain_id(l2_chain_id).unwrap();

// Fetch the span batch ranges according to args.start and args.end
// TODO: If the ranges are greater than 20 blocks, we will have to split them in a custom way.
let span_batch_ranges: Vec<SpanBatchRange> = get_span_batch_ranges_from_server(
&data_fetcher,
args.start,
Expand Down
3 changes: 2 additions & 1 deletion op-succinct-proposer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ pub async fn run_native_host(
let target_dir = metadata.target_directory.join("release");
let args = convert_host_cli_to_args(host_cli);

// Run the native host runner.
let child = tokio::process::Command::new(target_dir.join("native_host_runner"))
.args(&args)
.env("RUST_LOG", "info")
.spawn()?;

let child = Arc::new(Mutex::new(child));
let child_clone = Arc::clone(&child);

// Time out the native host runner after the given timeout.
let result = tokio::select! {
status = wait_for_child(child_clone) => status,
_ = tokio::time::sleep(timeout) => {
Expand Down
5 changes: 4 additions & 1 deletion zkvm-host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@ kona-host = { workspace = true }

# local
host-utils.workspace = true
client-utils.workspace = true

# sp1
sp1-sdk = { workspace = true }
anyhow.workspace = true
dotenv.workspace = true
num-format.workspace = true
client-utils.workspace = true
revm.workspace = true
log.workspace = true
csv.workspace = true


[build-dependencies]
sp1-build = { workspace = true }
host-utils = { workspace = true }
3 changes: 2 additions & 1 deletion zkvm-host/bin/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async fn main() -> Result<()> {
l2_chain_id, args.start, args.end
);

// Make the directory if it doesn't exist.
// Create the report directory if it doesn't exist.
let report_dir = format!("execution-reports/multi/{}", l2_chain_id);
if !std::path::Path::new(&report_dir).exists() {
fs::create_dir_all(&report_dir).unwrap();
Expand All @@ -120,6 +120,7 @@ async fn main() -> Result<()> {
)
.await;
println!("Execution Stats: \n{:?}", stats);

// Write to CSV.
let mut csv_writer = csv::Writer::from_path(report_path)?;
csv_writer.serialize(&stats)?;
Expand Down
4 changes: 0 additions & 4 deletions zkvm-host/bin/single.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ async fn main() -> Result<()> {

// By default, re-run the native execution unless the user passes `--use-cache`.
if !args.use_cache {
println!(
"Overwriting existing data directory. {}",
data_dir.display()
);
// Overwrite existing data directory.
fs::create_dir_all(&data_dir).unwrap();

Expand Down
1 change: 0 additions & 1 deletion zkvm-host/src/lib.rs

This file was deleted.

0 comments on commit 656b9be

Please sign in to comment.