Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 55 additions & 9 deletions crates/task-sender/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Task Sender

This CLI is made to stress-test the network.

It has the following commands:
Expand All @@ -8,21 +9,25 @@ 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 <NUMBER_OF_PROOFS> --proof-type groth16 \
--dir-to-save-proofs $(PWD)/scripts/test_files/task_sender/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 <RPC_URL> \
Expand All @@ -35,17 +40,20 @@ cargo run --release -- generate-and-fund-wallets \
```

### In Testnet

```bash
NUM_WALLETS=<N> 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=<N> make task_sender_generate_and_fund_wallets_devnet
```
Expand All @@ -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_SIZE> --burst-time-secs <BURST_TIME_SECS> \
--eth-rpc-url <RPC_URL> \
--network <network> \
--proofs-dirpath $(PWD)/scripts/test_files/task_sender/proofs \
--private-keys-filepath <PATH_TO_PRIVATE_KEYS_FILE>
--private-keys-filepath <PATH_TO_PRIVATE_KEYS_FILE> \
--random-address \
--burst-size <BURST_SIZE> \
--burst-time-secs <BURST_TIME_SECS> \
--network <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 <PATH_TO_PRIVATE_KEYS_FILE> \
--random-address \
--burst-size <BURST_SIZE> \
--burst-time-secs <BURST_TIME_SECS> \
--network <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 <PATH_TO_PRIVATE_KEYS_FILE> \
--burst-size <BURST_SIZE> \
--burst-time-secs <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=<N> BURST_TIME_SECS=<N> make task_sender_send_infinite_proofs_devnet
```

```bash
BURST_SIZE=<N> BURST_TIME_SECS=<N> make task_sender_send_infinite_proofs_holesky_stage
```
Expand All @@ -79,15 +122,18 @@ BURST_SIZE=<N> BURST_TIME_SECS=<N> 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 <NUM_SENDERS>
```

We also have the following related make targets:

```bash
NUM_SENDERS=<N> make task_sender_test_connections_devnet
```

```bash
NUM_SENDERS=<N> make task_sender_test_connections_holesky_stage
```
90 changes: 67 additions & 23 deletions crates/task-sender/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
};

Expand Down Expand Up @@ -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<String>,
) -> Result<Vec<VerificationData>, 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<String>,
) -> Result<Vec<VerificationData>, 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(),
}])
}
12 changes: 12 additions & 0 deletions crates/task-sender/src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ pub enum InfiniteProofType {
)]
pub_path: Option<String>,
},
#[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<String>,
},
}

#[derive(Debug, Clone, Copy)]
Expand Down
Loading