diff --git a/tig-benchmarker/Cargo.toml b/tig-benchmarker/Cargo.toml index 4ccf0b3b..01b5bdf3 100644 --- a/tig-benchmarker/Cargo.toml +++ b/tig-benchmarker/Cargo.toml @@ -6,7 +6,6 @@ repository.workspace = true edition.workspace = true [dependencies] -anyhow = "1.0.81" futures = { version = "0.3.30" } gloo-timers = { version = "0.3.0", optional = true, features = ["futures"] } js-sys = { version = "0.3.68", optional = true } @@ -16,7 +15,6 @@ rand_distr = { version = "0.4.3", default-features = false, features = [ "alloc", ] } serde = { version = "1.0", features = ["derive"] } -serde_json = { version = "1.0.113", features = ["preserve_order"] } serde-wasm-bindgen = { version = "0.6.5", optional = true } tig-api = { path = "../tig-api" } tig-structs = { path = "../tig-structs" } diff --git a/tig-benchmarker/src/benchmarker/mod.rs b/tig-benchmarker/src/benchmarker/mod.rs index 47719e15..7d579af5 100644 --- a/tig-benchmarker/src/benchmarker/mod.rs +++ b/tig-benchmarker/src/benchmarker/mod.rs @@ -237,7 +237,6 @@ async fn run_once(num_workers: u32, ms_per_benchmark: u32) -> Result<()> { .await; { let mut state = state().lock().await; - let now = time(); (*state).time_left = Some(Timer::new(ms_per_benchmark as u64)); } loop { @@ -267,6 +266,8 @@ async fn run_once(num_workers: u32, ms_per_benchmark: u32) -> Result<()> { { // workers exit when iter returns None (*(*nonce_iter).lock().await).empty(); + let mut state = state().lock().await; + (*state).time_left = None; }; // transfers solutions computed by workers to benchmark state diff --git a/tig-benchmarker/src/benchmarker/setup_job.rs b/tig-benchmarker/src/benchmarker/setup_job.rs index 93c6bc4b..0c546dd8 100644 --- a/tig-benchmarker/src/benchmarker/setup_job.rs +++ b/tig-benchmarker/src/benchmarker/setup_job.rs @@ -7,7 +7,7 @@ use rand::{ }; use rand_distr::Distribution; use std::collections::HashMap; -use tig_structs::{config::WasmVMConfig, core::*}; +use tig_structs::core::*; use tig_utils::{FrontierOps, PointOps}; pub async fn execute() -> Result<()> { @@ -53,6 +53,7 @@ pub async fn execute() -> Result<()> { async fn find_settings_to_recompute() -> Result> { let QueryData { + latest_block, benchmarks, proofs, frauds, @@ -76,10 +77,7 @@ async fn find_settings_to_recompute() -> Result> { settings: benchmark.settings.clone(), solution_signature_threshold: u32::MAX, // is fine unless the player has committed fraud sampled_nonces: Some(sampled_nonces), - wasm_vm_config: WasmVMConfig { - max_memory: u64::MAX, - max_fuel: u64::MAX, - }, + wasm_vm_config: latest_block.config().wasm_vm.clone(), })); } } @@ -93,6 +91,7 @@ async fn pick_settings_to_benchmark() -> Result { .. } = &(*state().lock().await); let QueryData { + latest_block, player_data, challenges, download_urls, @@ -107,14 +106,14 @@ async fn pick_settings_to_benchmark() -> Result { download_url: get_download_url(&selected_algorithm_id, download_urls)?, settings: BenchmarkSettings { player_id: player_id().clone(), - block_id: query_data.latest_block.id.clone(), + block_id: latest_block.id.clone(), challenge_id: challenge.id.clone(), algorithm_id: selected_algorithm_id, difficulty, }, solution_signature_threshold: *challenge.block_data().solution_signature_threshold(), sampled_nonces: None, - wasm_vm_config: query_data.latest_block.config().wasm_vm.clone(), + wasm_vm_config: latest_block.config().wasm_vm.clone(), }) } @@ -124,12 +123,12 @@ fn pick_challenge<'a>( challenges: &'a Vec, selected_algorithms: &HashMap, ) -> Result<&'a Challenge> { - let num_qualifiers_by_challenge = match &player_data { - Some(data) => data - .num_qualifiers_by_challenge - .clone() - .ok_or_else(|| format!("Expecting num_qualifiers_by_challenge"))?, - None => HashMap::new(), + let num_qualifiers_by_challenge = match player_data + .as_ref() + .map(|x| x.num_qualifiers_by_challenge.as_ref()) + { + Some(Some(num_qualifiers_by_challenge)) => num_qualifiers_by_challenge.clone(), + _ => HashMap::new(), }; let percent_qualifiers_by_challenge: HashMap = challenges .iter() diff --git a/tig-benchmarker/src/lib.rs b/tig-benchmarker/src/lib.rs index 81ca54b5..2c40f13e 100644 --- a/tig-benchmarker/src/lib.rs +++ b/tig-benchmarker/src/lib.rs @@ -9,8 +9,7 @@ mod exports { #[wasm_bindgen] pub async fn state() -> JsValue { let state = benchmarker::state().lock().await.clone(); - let value = serde_json::to_value(&state).unwrap(); - serde_wasm_bindgen::to_value(&value).unwrap() + serde_wasm_bindgen::to_value(&state).unwrap() } #[wasm_bindgen]