diff --git a/crates/task-sender/README.md b/crates/task-sender/README.md index d0161a5996..7f0fae8bed 100644 --- a/crates/task-sender/README.md +++ b/crates/task-sender/README.md @@ -1,4 +1,5 @@ # Task Sender + This CLI is made to stress-test the network. It has the following commands: @@ -8,6 +9,7 @@ It has the following commands: This command is to generate N Groth16 proofs. To run it, you can: + ```bash cargo run --release -- generate-proofs \ --number-of-proofs --proof-type groth16 \ @@ -15,14 +17,17 @@ cargo run --release -- generate-proofs \ ``` We also have a make target: + ```bash NUMBER_OF_PROOFS=15 make task_sender_generate_groth16_proofs ``` + ## GenerateAndFundWallets This command is to generate N wallets, and fund them in the BatcherPaymentService. To run it, you can: + ```bash cargo run --release -- generate-and-fund-wallets \ --eth-rpc-url \ @@ -35,17 +40,20 @@ cargo run --release -- generate-and-fund-wallets \ ``` ### In Testnet + ```bash NUM_WALLETS= make task_sender_generate_and_fund_wallets_holesky_stage ``` ### In Devnet: Run anvil with more prefunded accounts, using the following make target: + ```bash make anvil_start_with_more_prefunded_accounts ``` Then run the following make target, with `NUM_WALLETS` being the amount of wallets you want to deposit funds to aligned payment service, up to 1000. + ```bash NUM_WALLETS= make task_sender_generate_and_fund_wallets_devnet ``` @@ -56,20 +64,55 @@ This command sends `BURST_SIZE` proofs from each private key in `PATH_TO_PRIVATE To vary the amount of senders, it is recommended to have a backup with all private keys, and add/remove keys from the file being used. -To run it, you can: +Note: The `--random-address` flag is optional and will use the address a salt to avoid the repetitions of batches. + +### RISC Zero Proofs + ```bash cargo run --release -- send-infinite-proofs \ - --burst-size --burst-time-secs \ - --eth-rpc-url \ - --network \ - --proofs-dirpath $(PWD)/scripts/test_files/task_sender/proofs \ - --private-keys-filepath + --private-keys-filepath \ + --random-address \ + --burst-size \ + --burst-time-secs \ + --network \ + risc0 \ + --proof-path ./scripts/test_files/risc_zero/fibonacci_proof_generator/risc_zero_fibonacci_2_2_0.proof \ + --bin-path ./scripts/test_files/risc_zero/fibonacci_proof_generator/fibonacci_id_2_2_0.bin \ + --pub-path ./scripts/test_files/risc_zero/fibonacci_proof_generator/risc_zero_fibonacci_2_2_0.pub +``` + +### Gnark Groth16 Proofs + +```bash +cargo run --release -- send-infinite-proofs \ + --private-keys-filepath \ + --random-address \ + --burst-size \ + --burst-time-secs \ + --network \ + gnark-groth16 --proofs-dir ./scripts/test_files/gnark_groth16_bn254_script +``` + +### SP1 Proofs + +```bash +cargo run --release --manifest-path ./crates/task-sender/Cargo.toml -- send-infinite-proofs \ + --private-keys-filepath \ + --burst-size \ + --burst-time-secs \ + --random-address \ + sp1 \ + --proof-path ./scripts/test_files/sp1/sp1_fibonacci_5_0_0.proof \ + --elf-path ./scripts/test_files/sp1/sp1_fibonacci_5_0_0.elf \ + --pub-path ./scripts/test_files/sp1/sp1_fibonacci_5_0_0.pub ``` -We also have the following related make targets +We also have the following related make targets: + ```bash BURST_SIZE= BURST_TIME_SECS= make task_sender_send_infinite_proofs_devnet ``` + ```bash BURST_SIZE= BURST_TIME_SECS= make task_sender_send_infinite_proofs_holesky_stage ``` @@ -79,15 +122,18 @@ BURST_SIZE= BURST_TIME_SECS= make task_sender_send_infinite_proofs_holesky This command enables and hangs N connections with the Batcher. To run it, you can: -``` -cargo run --release -- test-connections \ + +```bash +cargo run --release --manifest-path ./crates/task-sender/Cargo.toml -- test-connections \ --num-senders ``` We also have the following related make targets: + ```bash NUM_SENDERS= make task_sender_test_connections_devnet ``` + ```bash NUM_SENDERS= make task_sender_test_connections_holesky_stage ``` diff --git a/crates/task-sender/src/commands.rs b/crates/task-sender/src/commands.rs index 6a2dc820aa..d03b9aa02a 100644 --- a/crates/task-sender/src/commands.rs +++ b/crates/task-sender/src/commands.rs @@ -412,29 +412,27 @@ pub async fn send_infinite_proofs(args: SendInfiniteProofsArgs) { pub_path, } => { info!("Loading RISC Zero proof files"); - let Ok(proof) = std::fs::read(proof_path) else { - error!("Could not read proof file: {}", proof_path); - return; - }; - let Ok(vm_program) = std::fs::read(bin_path) else { - error!("Could not read bin file: {}", bin_path); - return; - }; - let pub_input = if let Some(pub_path) = pub_path { - std::fs::read(pub_path).ok() - } else { - None - }; - - // Create template verification data (without proof_generator_addr) - vec![VerificationData { - proving_system: ProvingSystemId::Risc0, - proof, - pub_input, - verification_key: None, - vm_program_code: Some(vm_program), - proof_generator_addr: Address::zero(), // Will be set randomly in the loop - }] + match load_risc0_verification_data(proof_path, bin_path, pub_path) { + Ok(data) => data, + Err(err) => { + error!("Failed to load RISC Zero files: {}", err); + return; + } + } + } + InfiniteProofType::SP1 { + proof_path, + elf_path, + pub_path, + } => { + info!("Loading SP1 proof files"); + match load_sp1_verification_data(proof_path, elf_path, pub_path) { + Ok(data) => data, + Err(err) => { + error!("Failed to load SP1 files: {}", err); + return; + } + } } }; @@ -560,3 +558,49 @@ fn get_verification_data_from_proofs_folder( verifications_data } + +fn load_risc0_verification_data( + proof_path: &str, + bin_path: &str, + pub_path: &Option, +) -> Result, std::io::Error> { + let proof = std::fs::read(proof_path)?; + let vm_program = std::fs::read(bin_path)?; + let pub_input = if let Some(pub_path) = pub_path { + std::fs::read(pub_path).ok() + } else { + None + }; + + Ok(vec![VerificationData { + proving_system: ProvingSystemId::Risc0, + proof, + pub_input, + verification_key: None, + vm_program_code: Some(vm_program), + proof_generator_addr: Address::zero(), + }]) +} + +fn load_sp1_verification_data( + proof_path: &str, + elf_path: &str, + pub_path: &Option, +) -> Result, std::io::Error> { + let proof = std::fs::read(proof_path)?; + let vm_program = std::fs::read(elf_path)?; + let pub_input = if let Some(pub_path) = pub_path { + std::fs::read(pub_path).ok() + } else { + None + }; + + Ok(vec![VerificationData { + proving_system: ProvingSystemId::SP1, + proof, + pub_input, + verification_key: None, + vm_program_code: Some(vm_program), + proof_generator_addr: Address::zero(), + }]) +} diff --git a/crates/task-sender/src/structs.rs b/crates/task-sender/src/structs.rs index e6a0cd4418..8cb1e17d20 100644 --- a/crates/task-sender/src/structs.rs +++ b/crates/task-sender/src/structs.rs @@ -158,6 +158,18 @@ pub enum InfiniteProofType { )] pub_path: Option, }, + #[clap(about = "Send infinite SP1 proofs from file paths")] + SP1 { + #[arg(name = "Path to SP1 proof file (.proof)", long = "proof-path")] + proof_path: String, + #[arg(name = "Path to SP1 ELF file (.elf)", long = "elf-path")] + elf_path: String, + #[arg( + name = "Path to SP1 public input file (.pub) - optional", + long = "pub-path" + )] + pub_path: Option, + }, } #[derive(Debug, Clone, Copy)]