From 3bb141beed1b8480a59486d0e1e0345f8284bd7b Mon Sep 17 00:00:00 2001 From: FiveMovesAhead Date: Mon, 6 Oct 2025 12:40:01 +0100 Subject: [PATCH] Update to load solution from base64 string. --- tig-verifier/src/main.rs | 75 ++++++++++++---------------------------- 1 file changed, 22 insertions(+), 53 deletions(-) diff --git a/tig-verifier/src/main.rs b/tig-verifier/src/main.rs index d189dc6..f238183 100644 --- a/tig-verifier/src/main.rs +++ b/tig-verifier/src/main.rs @@ -10,62 +10,36 @@ use cudarc::{driver::CudaContext, nvrtc::Ptx, runtime::result::device::get_devic fn cli() -> Command { Command::new("tig-verifier") - .about("Verifies a solution or merkle proof") + .about("Verifies a solution") .arg_required_else_help(true) - .subcommand( - Command::new("verify_solution") - .about("Verifies a solution") - .arg( - arg!( "Settings json string or path to json file") - .value_parser(clap::value_parser!(String)), - ) - .arg( - arg!( "A string used in seed generation") - .value_parser(clap::value_parser!(String)), - ) - .arg(arg!( "Nonce value").value_parser(clap::value_parser!(u64))) - .arg( - arg!( "Solution json string, path to json file, or '-' for stdin") - .value_parser(clap::value_parser!(String)), - ) - .arg( - arg!(--ptx [PTX] "Path to a CUDA ptx file") - .value_parser(clap::value_parser!(PathBuf)), - ) - .arg( - arg!(--gpu [GPU] "Which GPU device to use") - .value_parser(clap::value_parser!(usize)), - ), + .arg( + arg!( "Settings json string or path to json file") + .value_parser(clap::value_parser!(String)), ) - .subcommand( - Command::new("verify_merkle_proof") - .about("Verifies a merkle proof") - .arg(arg!( "Merkle root").value_parser(clap::value_parser!(String))) - .arg( - arg!( "Merkle proof json string, path to json file, or '-' for stdin") - .value_parser(clap::value_parser!(String)), - ), + .arg( + arg!( "A string used in seed generation") + .value_parser(clap::value_parser!(String)), ) + .arg(arg!( "Nonce value").value_parser(clap::value_parser!(u64))) + .arg( + arg!( "Solution base64 string, path to b64 file, or '-' for stdin") + .value_parser(clap::value_parser!(String)), + ) + .arg(arg!(--ptx [PTX] "Path to a CUDA ptx file").value_parser(clap::value_parser!(PathBuf))) + .arg(arg!(--gpu [GPU] "Which GPU device to use").value_parser(clap::value_parser!(usize))) } fn main() { let matches = cli().get_matches(); - if let Err(e) = match matches.subcommand() { - Some(("verify_solution", sub_m)) => verify_solution( - sub_m.get_one::("SETTINGS").unwrap().clone(), - sub_m.get_one::("RAND_HASH").unwrap().clone(), - *sub_m.get_one::("NONCE").unwrap(), - sub_m.get_one::("SOLUTION").unwrap().clone(), - sub_m.get_one::("ptx").cloned(), - sub_m.get_one::("gpu").cloned(), - ), - Some(("verify_merkle_proof", sub_m)) => verify_merkle_proof( - sub_m.get_one::("ROOT").unwrap().clone(), - sub_m.get_one::("PROOF").unwrap().clone(), - ), - _ => Err(anyhow!("Invalid subcommand")), - } { + if let Err(e) = verify_solution( + matches.get_one::("SETTINGS").unwrap().clone(), + matches.get_one::("RAND_HASH").unwrap().clone(), + *matches.get_one::("NONCE").unwrap(), + matches.get_one::("SOLUTION").unwrap().clone(), + matches.get_one::("ptx").cloned(), + matches.get_one::("gpu").cloned(), + ) { eprintln!("Error: {}", e); std::process::exit(1); } @@ -204,11 +178,6 @@ pub fn verify_solution( Ok(()) } -pub fn verify_merkle_proof(_merkle_root: String, _merkle_proof: String) -> Result<()> { - // TODO - Err(anyhow!("Merkle proof verification is not implemented yet")) -} - fn load_settings(settings: &str) -> BenchmarkSettings { let settings = if settings.ends_with(".json") { fs::read_to_string(settings).unwrap_or_else(|_| {