From 14cefed23b83cda2f729a6ba1cc62bc642be11c5 Mon Sep 17 00:00:00 2001 From: Collin Jackson Date: Fri, 8 Nov 2024 13:31:29 -0800 Subject: [PATCH] format --- .github/workflows/ci.yml | 9 +++++-- clients/cli/src/prover.rs | 56 +++++++++++++++++++++++++-------------- 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f592205..1e1bf48 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,12 +32,17 @@ jobs: with: workspaces: ./clients/cli - - name: Build CLI + - name: Format + working-directory: clients/cli + run: | + rustfmt src/**/*.rs --check --edition 2021 + + - name: Build working-directory: clients/cli run: | cargo build --profile=ci-build - - name: Run cargo clippy on CLI + - name: Run cargo clippy working-directory: clients/cli run: | cargo clippy --profile=ci-build --no-deps --all-targets --workspace -- -D warnings diff --git a/clients/cli/src/prover.rs b/clients/cli/src/prover.rs index a9efff7..6342149 100644 --- a/clients/cli/src/prover.rs +++ b/clients/cli/src/prover.rs @@ -32,8 +32,8 @@ use nexus_core::{ init_circuit_trace, key::CanonicalSerialize, pp::gen_vm_pp, prove_seq_step, types::*, }, }; +use rand::RngCore; use zstd::stream::Encoder; -use rand::{ RngCore }; #[derive(Parser, Debug)] struct Args { @@ -128,8 +128,16 @@ async fn main() { let max_retries = 5; loop { - if let Err(e) = client.send(Message::Binary(registration.encode_to_vec())).await { - eprintln!("Failed to send message: {:?}, attempt {}/{}", e, retries + 1, max_retries); + if let Err(e) = client + .send(Message::Binary(registration.encode_to_vec())) + .await + { + eprintln!( + "Failed to send message: {:?}, attempt {}/{}", + e, + retries + 1, + max_retries + ); retries += 1; if retries >= max_retries { @@ -255,7 +263,10 @@ async fn main() { let proof_cycles_hertz = k as f64 * 1000.0 / progress_duration.as_millis() as f64; track( "progress".into(), - format!("Proved step {} at {:.2} proof cycles/sec.", step, proof_cycles_hertz), + format!( + "Proved step {} at {:.2} proof cycles/sec.", + step, proof_cycles_hertz + ), &ws_addr_string, json!({ "completed_fraction": completed_fraction, @@ -273,21 +284,22 @@ async fn main() { let mut retries = 0; let max_retries = 5; - loop { - if let Err(e) = client.send(Message::Binary(progress.encode_to_vec())).await { - eprintln!("Failed to send message: {:?}, attempt {}/{}", e, retries + 1, max_retries); - - retries += 1; - if retries >= max_retries { - eprintln!("Max retries reached, exiting..."); - break; - } - - // Add a delay before retrying - tokio::time::sleep(tokio::time::Duration::from_secs(u64::pow(2, retries))).await; - } else { + while let Err(e) = client.send(Message::Binary(progress.encode_to_vec())).await { + eprintln!( + "Failed to send message: {:?}, attempt {}/{}", + e, + retries + 1, + max_retries + ); + + retries += 1; + if retries >= max_retries { + eprintln!("Max retries reached, exiting..."); break; } + + // Add a delay before retrying + tokio::time::sleep(tokio::time::Duration::from_secs(u64::pow(2, retries))).await; } if step == end - 1 { @@ -305,14 +317,18 @@ async fn main() { })), }; let duration = SystemTime::now().duration_since(start_time).unwrap(); - let proof_cycles_hertz = cycles_proven as f64 * 1000.0 / duration.as_millis() as f64; + let proof_cycles_hertz = + cycles_proven as f64 * 1000.0 / duration.as_millis() as f64; client .send(Message::Binary(response.encode_to_vec())) .await - .unwrap(); + .unwrap(); track( "proof".into(), - format!("Proof sent! Overall speed was {:.2} proof cycles/sec.", proof_cycles_hertz), + format!( + "Proof sent! Overall speed was {:.2} proof cycles/sec.", + proof_cycles_hertz + ), &ws_addr_string, json!({ "proof_duration_sec": duration.as_secs(),