Skip to content

Commit a29ad1e

Browse files
committed
Fix clippy fmt
1 parent 82c5c13 commit a29ad1e

File tree

3 files changed

+155
-28
lines changed

3 files changed

+155
-28
lines changed

crates/CLAUDE.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Build Commands
6+
7+
### Rust Workspace
8+
- **Build all crates**: `cargo build` (from `/crates` directory)
9+
- **Build specific crate**: `cargo build --manifest-path ./crates/[crate-name]/Cargo.toml`
10+
- **Build with release optimization**: `cargo build --release`
11+
12+
### Batcher
13+
- **Build**: `cargo build --manifest-path ./crates/batcher/Cargo.toml --release`
14+
- **Run**: `cargo run --manifest-path ./crates/batcher/Cargo.toml --release -- --config ./config-files/config-batcher.yaml --env-file ./crates/batcher/.env`
15+
- **Start locally**: `make batcher_start_local`
16+
17+
### CLI
18+
- **Build**: `cd crates/cli && cargo build --release`
19+
- **Install**: `cargo install --path crates/cli`
20+
- **Install script**: `./crates/cli/install_aligned.sh`
21+
22+
### SDK
23+
- **Build**: `cargo build --manifest-path ./crates/sdk/Cargo.toml`
24+
- **Test**: `cargo test --manifest-path ./crates/sdk/Cargo.toml`
25+
26+
## Testing Commands
27+
28+
### Rust Tests
29+
- **Run all tests**: `cargo test` (from `/crates` directory)
30+
- **Run specific crate tests**: `cargo test --manifest-path ./crates/[crate-name]/Cargo.toml`
31+
- **Run with release mode**: `cargo test --release`
32+
33+
### Go Tests
34+
- **Run all Go tests**: `go test ./... -timeout 15m`
35+
- **Run retry tests**: `cd core/ && go test -v -timeout 15m`
36+
37+
### FFI Tests
38+
- **SP1 Rust FFI**: `cd operator/sp1/lib && RUST_MIN_STACK=83886080 cargo test --release`
39+
- **RISC Zero Rust FFI**: `cd operator/risc_zero/lib && cargo test --release`
40+
- **Merkle Tree FFI**: `cd operator/merkle_tree/lib && RUST_MIN_STACK=83886080 cargo test --release`
41+
42+
## Linting Commands
43+
44+
### Solidity Contracts
45+
- **Lint contracts**: `cd contracts && npm run lint:sol`
46+
47+
### Rust (via Makefile targets)
48+
- Check individual crate formatting: `cargo fmt --check --manifest-path ./crates/[crate-name]/Cargo.toml`
49+
- Check individual crate linting: `cargo clippy --manifest-path ./crates/[crate-name]/Cargo.toml`
50+
51+
## Common Development Commands
52+
53+
### Dependencies
54+
- **Install all dependencies**: `make deps`
55+
- **Install Go dependencies**: `make go_deps`
56+
- **Initialize submodules**: `make submodules`
57+
58+
### Development Environment
59+
- **Start Anvil**: `make anvil_start`
60+
- **Start full local environment**: `make setup_local_aligned_all`
61+
- **Build all FFIs**: `make build_all_ffi`
62+
63+
### Proof Submission
64+
- **Send SP1 proof**: `make batcher_send_sp1_task RPC_URL=http://localhost:8545 NETWORK=devnet`
65+
- **Send RISC0 proof**: `make batcher_send_risc0_task RPC_URL=http://localhost:8545 NETWORK=devnet`
66+
- **Send Gnark proofs**: `make batcher_send_gnark_plonk_bn254_task RPC_URL=http://localhost:8545 NETWORK=devnet`
67+
68+
## Architecture Overview
69+
70+
### Core Components
71+
72+
**Aligned Layer** is a verification layer for zero-knowledge proofs built on EigenLayer. The system consists of several key components:
73+
74+
1. **Batcher** (`crates/batcher/`): Aggregates multiple proofs into batches for efficient verification
75+
- Listens for WebSocket connections from clients
76+
- Collects verification data and batches them based on time/size thresholds
77+
- Submits batches to the verification layer
78+
79+
2. **SDK** (`crates/sdk/`): Provides client libraries for interacting with Aligned Layer
80+
- **Verification Layer**: Core verification functionality
81+
- **Aggregation Layer**: Handles proof aggregation modes
82+
- **Communication**: Protocol implementations for client-server communication
83+
- **Ethereum Integration**: Smart contract interfaces and utilities
84+
85+
3. **CLI** (`crates/cli/`): Command-line interface for submitting proofs and interacting with the system
86+
- Proof submission with various proving systems (SP1, RISC0, Gnark, Circom)
87+
- Balance queries and verification status checks
88+
- Batch verification data handling
89+
90+
4. **Task Sender** (`crates/task-sender/`): Utility for load testing and automated proof submission
91+
- Wallet generation and funding
92+
- Infinite proof submission with configurable parameters
93+
- Connection testing utilities
94+
95+
### Supported Proving Systems
96+
97+
The system supports multiple zero-knowledge proving systems:
98+
- **SP1**: Succinct's zkVM proving system
99+
- **RISC Zero**: General-purpose zkVM
100+
- **Gnark**: Groth16 and PLONK protocols (BN254, BLS12-381)
101+
- **Circom**: Circuit compiler with Groth16 backend
102+
103+
### Key Architectural Patterns
104+
105+
1. **Modular Design**: Each component (batcher, SDK, CLI) is a separate crate with clear boundaries
106+
2. **Async/Await**: Heavy use of Tokio for asynchronous operations
107+
3. **FFI Integration**: Foreign function interfaces for integrating with Go-based verifiers
108+
4. **EigenLayer Integration**: Built as an AVS (Actively Validated Service) on EigenLayer
109+
5. **Multi-Network Support**: Configurable for different networks (devnet, testnet, mainnet)
110+
111+
### Development Workflow
112+
113+
1. **Local Development**: Use `make anvil_start` to start local blockchain
114+
2. **Component Testing**: Each crate can be built and tested independently
115+
3. **Integration Testing**: Full system testing using Docker compose or Makefile targets
116+
4. **Proof Generation**: Scripts in `scripts/test_files/` for generating test proofs
117+
118+
### Configuration Management
119+
120+
- **YAML Configuration**: Primary configuration files in `config-files/`
121+
- **Environment Variables**: `.env` files for sensitive configuration
122+
- **Network-Specific Config**: Separate configurations for different networks
123+
- **Makefile Parameters**: Extensive use of Make variables for configuration

crates/task-sender/src/commands.rs

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use tokio::join;
1919
use tokio_tungstenite::connect_async;
2020

2121
use crate::structs::{
22-
GenerateAndFundWalletsArgs, GenerateProofsArgs, InfiniteProofType, ProofType, SendInfiniteProofsArgs,
23-
TestConnectionsArgs,
22+
GenerateAndFundWalletsArgs, GenerateProofsArgs, InfiniteProofType, ProofType,
23+
SendInfiniteProofsArgs, TestConnectionsArgs,
2424
};
2525

2626
const GROTH_16_PROOF_GENERATOR_FILE_PATH: &str =
@@ -271,8 +271,8 @@ async fn load_senders_from_file(
271271
let mut senders = vec![];
272272

273273
for line in reader.lines() {
274-
let private_key_str = line
275-
.map_err(|err| format!("Could not read line from private keys file: {}", err))?;
274+
let private_key_str =
275+
line.map_err(|err| format!("Could not read line from private keys file: {}", err))?;
276276
let wallet = Wallet::from_str(private_key_str.trim())
277277
.map_err(|_| "Invalid private key".to_string())?
278278
.with_chain_id(chain_id.as_u64());
@@ -297,7 +297,7 @@ async fn run_infinite_proof_sender(
297297
random_address: bool,
298298
) {
299299
let mut handles = vec![];
300-
300+
301301
for (i, sender) in senders.iter().enumerate() {
302302
let wallet = sender.wallet.clone();
303303
let verification_data = verification_data.clone();
@@ -382,7 +382,8 @@ pub async fn send_infinite_proofs(args: SendInfiniteProofsArgs) {
382382

383383
// Load wallets using shared function
384384
info!("Loading wallets");
385-
let senders = match load_senders_from_file(&args.eth_rpc_url, &args.private_keys_filepath).await {
385+
let senders = match load_senders_from_file(&args.eth_rpc_url, &args.private_keys_filepath).await
386+
{
386387
Ok(senders) => senders,
387388
Err(err) => {
388389
error!("{}", err);
@@ -396,16 +397,20 @@ pub async fn send_infinite_proofs(args: SendInfiniteProofsArgs) {
396397
InfiniteProofType::GnarkGroth16 { proofs_dir } => {
397398
info!("Loading Groth16 proofs from directory structure");
398399
let data = get_verification_data_from_proofs_folder(
399-
proofs_dir.clone(),
400-
senders[0].wallet.address()
400+
proofs_dir.clone(),
401+
senders[0].wallet.address(),
401402
);
402403
if data.is_empty() {
403404
error!("Verification data empty, not continuing");
404405
return;
405406
}
406407
data
407408
}
408-
InfiniteProofType::Risc0 { proof_path, bin_path, pub_path } => {
409+
InfiniteProofType::Risc0 {
410+
proof_path,
411+
bin_path,
412+
pub_path,
413+
} => {
409414
info!("Loading RISC Zero proof files");
410415
let Ok(proof) = std::fs::read(proof_path) else {
411416
error!("Could not read proof file: {}", proof_path);
@@ -432,12 +437,12 @@ pub async fn send_infinite_proofs(args: SendInfiniteProofsArgs) {
432437
}]
433438
}
434439
};
435-
440+
436441
info!("Proofs loaded!");
437442

438443
let max_fee = U256::from_dec_str(&args.max_fee).expect("Invalid max fee");
439444
let network: Network = args.network.into();
440-
445+
441446
info!("Starting senders!");
442447
run_infinite_proof_sender(
443448
senders,
@@ -447,10 +452,14 @@ pub async fn send_infinite_proofs(args: SendInfiniteProofsArgs) {
447452
args.burst_time_secs,
448453
max_fee,
449454
args.random_address,
450-
).await;
455+
)
456+
.await;
451457
}
452458

453-
fn load_groth16_proof_files(dir_path: &std::path::Path, base_name: &str) -> Option<VerificationData> {
459+
fn load_groth16_proof_files(
460+
dir_path: &std::path::Path,
461+
base_name: &str,
462+
) -> Option<VerificationData> {
454463
let proof_path = dir_path.join(format!("{}.proof", base_name));
455464
let public_input_path = dir_path.join(format!("{}.pub", base_name));
456465
let vk_path = dir_path.join(format!("{}.vk", base_name));
@@ -482,7 +491,9 @@ fn load_from_subdirectories(dir_path: &str) -> Vec<VerificationData> {
482491
.and_then(|dir| dir.flatten().map(|e| e.path()).find(|path| path.is_file()))
483492
{
484493
if let Some(base_name) = first_file.file_stem().and_then(|s| s.to_str()) {
485-
if let Some(verification_data) = load_groth16_proof_files(&proof_folder_dir, base_name) {
494+
if let Some(verification_data) =
495+
load_groth16_proof_files(&proof_folder_dir, base_name)
496+
{
486497
verifications_data.push(verification_data);
487498
}
488499
}
@@ -496,7 +507,7 @@ fn load_from_subdirectories(dir_path: &str) -> Vec<VerificationData> {
496507
fn load_from_flat_directory(dir_path: &str) -> Vec<VerificationData> {
497508
let mut verifications_data = vec![];
498509
let mut base_names = std::collections::HashSet::new();
499-
510+
500511
// Collect all unique base names from .proof files
501512
if let Ok(dir) = std::fs::read_dir(dir_path) {
502513
for entry in dir.flatten() {
@@ -530,8 +541,9 @@ fn get_verification_data_from_proofs_folder(
530541
// Check if we have subdirectories with groth16 in the name
531542
let has_groth16_subdirs = std::fs::read_dir(&dir_path)
532543
.map(|dir| {
533-
dir.flatten()
534-
.any(|entry| entry.path().is_dir() && entry.path().to_str().unwrap().contains("groth16"))
544+
dir.flatten().any(|entry| {
545+
entry.path().is_dir() && entry.path().to_str().unwrap().contains("groth16")
546+
})
535547
})
536548
.unwrap_or(false);
537549

@@ -548,4 +560,3 @@ fn get_verification_data_from_proofs_folder(
548560

549561
verifications_data
550562
}
551-

crates/task-sender/src/structs.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,23 +140,17 @@ pub enum InfiniteProofType {
140140
#[clap(about = "Send infinite Gnark Groth16 proofs from directory")]
141141
GnarkGroth16 {
142142
#[arg(
143-
name = "The generated proofs directory",
143+
name = "The generated proofs directory",
144144
long = "proofs-dir",
145145
default_value = "scripts/test_files/task_sender/proofs"
146146
)]
147147
proofs_dir: String,
148148
},
149149
#[clap(about = "Send infinite RISC Zero proofs from file paths")]
150150
Risc0 {
151-
#[arg(
152-
name = "Path to RISC Zero proof file (.proof)",
153-
long = "proof-path"
154-
)]
151+
#[arg(name = "Path to RISC Zero proof file (.proof)", long = "proof-path")]
155152
proof_path: String,
156-
#[arg(
157-
name = "Path to RISC Zero binary file (.bin)",
158-
long = "bin-path"
159-
)]
153+
#[arg(name = "Path to RISC Zero binary file (.bin)", long = "bin-path")]
160154
bin_path: String,
161155
#[arg(
162156
name = "Path to RISC Zero public input file (.pub) - optional",
@@ -166,7 +160,6 @@ pub enum InfiniteProofType {
166160
},
167161
}
168162

169-
170163
#[derive(Debug, Clone, Copy)]
171164
enum NetworkNameArg {
172165
Devnet,

0 commit comments

Comments
 (0)