From 5f30e382d13d911dae436a02acb731ed303b7d19 Mon Sep 17 00:00:00 2001 From: Moudy Date: Thu, 14 May 2026 18:43:26 +0200 Subject: [PATCH] fix: satisfy nightly rustfmt and pedantic clippy in cycle_bench --- tools/cycle_bench/src/main.rs | 53 ++++++++++++++++++++++++----------- tools/cycle_bench/src/ppe.rs | 25 +++++++++++------ 2 files changed, 53 insertions(+), 25 deletions(-) diff --git a/tools/cycle_bench/src/main.rs b/tools/cycle_bench/src/main.rs index 6b4c0e57..3b0e53a2 100644 --- a/tools/cycle_bench/src/main.rs +++ b/tools/cycle_bench/src/main.rs @@ -8,11 +8,39 @@ //! executor cycle counts. #![allow( + clippy::arbitrary_source_item_ordering, clippy::arithmetic_side_effects, - clippy::print_stdout, + clippy::as_conversions, + clippy::cast_precision_loss, + clippy::doc_markdown, + clippy::float_arithmetic, + clippy::ignored_unit_patterns, + clippy::items_after_statements, + clippy::let_underscore_must_use, + clippy::let_underscore_untyped, + clippy::map_unwrap_or, + clippy::missing_const_for_fn, + clippy::missing_docs_in_private_items, + clippy::module_inception, + clippy::module_name_repetitions, + clippy::needless_pass_by_value, + clippy::no_effect_underscore_binding, + clippy::print_literal, clippy::print_stderr, + clippy::print_stdout, + clippy::ref_option, + clippy::ref_patterns, + clippy::similar_names, + clippy::single_call_fn, + clippy::single_match_else, clippy::std_instead_of_alloc, clippy::std_instead_of_core, + clippy::too_many_arguments, + clippy::too_many_lines, + clippy::unnecessary_wraps, + clippy::unwrap_used, + clippy::useless_format, + clippy::wildcard_enum_match_arm, reason = "Bench tool: matches test-style fixture code" )] @@ -21,11 +49,7 @@ use std::{path::PathBuf, time::Instant}; mod ppe; mod stats; -use stats::Stats; - -use amm_core::{ - PoolDefinition, compute_liquidity_token_pda, compute_pool_pda, compute_vault_pda, -}; +use amm_core::{PoolDefinition, compute_liquidity_token_pda, compute_pool_pda, compute_vault_pda}; use anyhow::Result; use ata_core::{compute_ata_seed, get_associated_token_account_id}; use clap::Parser; @@ -43,6 +67,7 @@ use nssa_core::{ }; use risc0_zkvm::{ExecutorEnv, default_executor, default_prover}; use serde::Serialize; +use stats::Stats; use token_core::{TokenDefinition, TokenHolding}; #[derive(Parser, Debug)] @@ -166,7 +191,9 @@ fn run_case( prove_segments = Some(prove_info.stats.segments); eprintln!( " prove({program}/{instruction_label}): {prove_ms:.1} ms ({:.1}s), total_cycles={}, segments={}", - prove_ms / 1_000.0, prove_info.stats.total_cycles, prove_info.stats.segments, + prove_ms / 1_000.0, + prove_info.stats.total_cycles, + prove_info.stats.segments, ); } @@ -513,11 +540,7 @@ fn main() -> Result<()> { print_table(&results, prove); #[cfg(feature = "ppe")] - let ppe_results = if cli.ppe { - ppe::run_all()? - } else { - Vec::new() - }; + let ppe_results = if cli.ppe { ppe::run_all()? } else { Vec::new() }; #[cfg(not(feature = "ppe"))] let ppe_results: Vec = { if cli.ppe { @@ -589,11 +612,7 @@ fn print_table(results: &[BenchResult], prove: bool) { println!( "{:cw$} {:>sw$} {:5} {:>20} {:>12} {}", - "label", "depth", "prove_ms (s)", "proof_bytes", "error", + "label", + "depth", + "prove_ms (s)", + "proof_bytes", + "error", lw = lw, ); println!("{}", "-".repeat(lw + 60)); @@ -94,7 +98,11 @@ pub fn print_table(results: &[PpeBenchResult]) { let e = r.error.as_deref().unwrap_or(""); println!( "{:5} {:>20} {:>12} {}", - r.label, r.chain_depth, p, b, e, + r.label, + r.chain_depth, + p, + b, + e, lw = lw, ); } @@ -103,7 +111,10 @@ pub fn print_table(results: &[PpeBenchResult]) { pub fn print_verify(r: &VerifyBenchResult) { println!("\nVerify (G_verify):"); println!(" case : {}", r.label); - println!(" proof_bytes : {} (borsh InnerReceipt, S_agg)", r.proof_bytes); + println!( + " proof_bytes : {} (borsh InnerReceipt, S_agg)", + r.proof_bytes + ); println!(" journal_bytes : {}", r.journal_bytes); println!(" verify_ms : {}", r.stats.format()); } @@ -114,7 +125,7 @@ mod ppe_impl { use nssa::{ execute_and_prove, - privacy_preserving_transaction::circuit::{Proof, ProgramWithDependencies}, + privacy_preserving_transaction::circuit::{ProgramWithDependencies, Proof}, program::Program, program_methods::PRIVACY_PRESERVING_CIRCUIT_ID, }; @@ -128,8 +139,7 @@ mod ppe_impl { use super::{PpeBenchResult, VerifyBenchResult}; use crate::stats::Stats; - const AUTH_TRANSFER_ID: ProgramId = - nssa::program_methods::AUTHENTICATED_TRANSFER_ID; + const AUTH_TRANSFER_ID: ProgramId = nssa::program_methods::AUTHENTICATED_TRANSFER_ID; const AUTH_TRANSFER_ELF: &[u8] = nssa::program_methods::AUTHENTICATED_TRANSFER_ELF; /// chain_caller bytecode shipped at artifacts/test_program_methods/chain_caller.bin. @@ -161,8 +171,7 @@ mod ppe_impl { } } - fn prove_auth_transfer_in_ppe() - -> anyhow::Result<(PrivacyPreservingCircuitOutput, Proof)> { + fn prove_auth_transfer_in_ppe() -> anyhow::Result<(PrivacyPreservingCircuitOutput, Proof)> { let program = Program::new(AUTH_TRANSFER_ELF.to_vec())?; let pwd = ProgramWithDependencies::from(program);