Skip to content

Commit

Permalink
fix: secp256k1 add assign
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani committed Sep 25, 2024
1 parent 9eebf51 commit 4d5124c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 10 deletions.
19 changes: 16 additions & 3 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,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" }
ecdsa = { git = "https://github.com/sp1-patches/signatures", branch = "patch-ecdsa-v0.16.8" }
# TODO: Change this back to the original patch branch once the changes to sp1-lib to fix secp256k1 addition have been merged and a stable version tag is released.
ecdsa = { git = "https://github.com/sp1-patches/signatures", branch = "ratan/secp256k1-add-fixes-v0.16.8" }
bn = { git = "https://github.com/0xWOLAND/bn.git", package = "substrate-bn" }
sha3 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha3", branch = "patch-sha3-v0.10.8" }
# This patch uses sha3 instead of tiny-keccak. Reduces cycle count for Keccak by 50%.
Expand Down
Binary file modified elf/fault-proof-elf
Binary file not shown.
Binary file modified elf/range-elf
Binary file not shown.
35 changes: 29 additions & 6 deletions scripts/utils/bin/cost_estimator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ use op_succinct_host_utils::{
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use serde::{Deserialize, Serialize};
use sp1_sdk::{utils, ProverClient};
use std::sync::{Arc, Mutex};
use std::{
cmp::{max, min},
collections::HashMap,
fs::{self},
future::Future,
path::PathBuf,
sync::Arc,
time::Instant,
};
use tokio::{sync::Mutex, task::block_in_place};
use tokio::task::block_in_place;

pub const MULTI_BLOCK_ELF: &[u8] = include_bytes!("../../../elf/range-elf");

Expand Down Expand Up @@ -164,7 +164,7 @@ async fn execute_blocks_parallel(
let data_fetcher = OPSuccinctDataFetcher::new().await;
let mut exec_stats = ExecutionStats::default();
exec_stats.add_block_data(&data_fetcher, start, end).await;
let mut execution_stats_map = execution_stats_map.lock().await;
let mut execution_stats_map = execution_stats_map.lock().unwrap();
execution_stats_map.insert((start, end), exec_stats);
});
handles.push(handle);
Expand All @@ -174,13 +174,36 @@ async fn execute_blocks_parallel(
// Run the zkVM execution process for each split range in parallel and fill in the execution stats.
host_clis.par_iter().for_each(|r| {
let sp1_stdin = get_proof_stdin(&r.host_cli).unwrap();
let prover = Mutex::new(ProverClient::new());

let start_time = Instant::now();
let (_, report) = prover.execute(MULTI_BLOCK_ELF, sp1_stdin).run().unwrap();
let (_, report) = std::panic::catch_unwind(|| {
prover
.lock()
.unwrap()
.execute(MULTI_BLOCK_ELF, sp1_stdin)
.run()
})
.map_err(|e| {
eprintln!(
"Thread panicked while executing blocks {:?}-{:?}: {:?}",
r.start, r.end, e
);
})
.and_then(|res| {
res.map_err(|e| {
eprintln!(
"Failed to execute blocks {:?}-{:?}: {:?}",
r.start, r.end, e
);
})
})
.ok()
.unwrap();
let execution_duration = start_time.elapsed();

// Get the existing execution stats and modify it in place.
let mut execution_stats_map = block_on(execution_stats_map.lock());
let mut execution_stats_map = execution_stats_map.lock().unwrap();
let exec_stats = execution_stats_map.get_mut(&(r.start, r.end)).unwrap();
exec_stats.add_report_data(&report, execution_duration);
exec_stats.add_aggregate_data();
Expand All @@ -190,7 +213,7 @@ async fn execute_blocks_parallel(

let execution_stats = execution_stats_map
.lock()
.await
.unwrap()
.clone()
.into_values()
.collect();
Expand Down

0 comments on commit 4d5124c

Please sign in to comment.