Skip to content

Commit 8a844f8

Browse files
Copilot0xrinegade
andcommitted
Fix trailing whitespace in audit_modular.rs
Co-authored-by: 0xrinegade <[email protected]>
1 parent 90d4306 commit 8a844f8

File tree

11 files changed

+745
-381
lines changed

11 files changed

+745
-381
lines changed

benches/deployment_benchmarks.rs

Lines changed: 47 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
use criterion::{criterion_group, criterion_main, Criterion, BenchmarkId};
2-
use osvm::utils::ebpf_deploy::{
3-
load_program, load_program_id, DeployConfig, RpcClientCache,
4-
};
1+
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
2+
use osvm::utils::ebpf_deploy::{load_program, load_program_id, DeployConfig, RpcClientCache};
53
use std::fs::File;
64
use std::io::Write;
75
use std::time::{Duration, Instant};
@@ -10,65 +8,61 @@ use tempfile::tempdir;
108
/// Benchmark program loading performance
119
fn benchmark_load_program(c: &mut Criterion) {
1210
let dir = tempdir().unwrap();
13-
11+
1412
// Create test programs of different sizes
1513
let sizes = vec![
16-
("small", 10_000), // 10KB
17-
("medium", 100_000), // 100KB
18-
("large", 1_000_000), // 1MB
14+
("small", 10_000), // 10KB
15+
("medium", 100_000), // 100KB
16+
("large", 1_000_000), // 1MB
1917
("xlarge", 2_000_000), // 2MB
2018
];
21-
19+
2220
let mut group = c.benchmark_group("load_program");
23-
21+
2422
for (name, size) in sizes {
2523
let program_path = dir.path().join(format!("program_{}.so", name));
2624
let program_data = vec![0u8; size];
2725
let mut file = File::create(&program_path).unwrap();
2826
file.write_all(&program_data).unwrap();
29-
27+
3028
group.benchmark_with_input(
3129
BenchmarkId::new("load_program", name),
3230
&program_path.to_string_lossy().to_string(),
3331
|b, path| {
34-
b.iter(|| {
35-
load_program(path).unwrap()
36-
});
32+
b.iter(|| load_program(path).unwrap());
3733
},
3834
);
3935
}
40-
36+
4137
group.finish();
4238
}
4339

4440
/// Benchmark program ID loading performance
4541
fn benchmark_load_program_id(c: &mut Criterion) {
4642
let dir = tempdir().unwrap();
4743
let program_id_file = dir.path().join("program_id.json");
48-
44+
4945
// Create test program ID file
5046
let program_id_content = r#"{"programId": "HN4tEEGheziD9dqcWg4xZd29htcerjXKGoGiQXM5hxiS"}"#;
5147
let mut file = File::create(&program_id_file).unwrap();
5248
file.write_all(program_id_content.as_bytes()).unwrap();
53-
49+
5450
c.bench_function("load_program_id", |b| {
55-
b.iter(|| {
56-
load_program_id(program_id_file.to_str().unwrap()).unwrap()
57-
});
51+
b.iter(|| load_program_id(program_id_file.to_str().unwrap()).unwrap());
5852
});
5953
}
6054

6155
/// Benchmark RPC client cache performance
6256
fn benchmark_rpc_client_cache(c: &mut Criterion) {
6357
let mut group = c.benchmark_group("rpc_client_cache");
64-
58+
6559
// Test cache performance with multiple URLs
6660
let urls = vec![
6761
"https://api.devnet.solana.com",
68-
"https://api.testnet.solana.com",
62+
"https://api.testnet.solana.com",
6963
"https://api.mainnet-beta.solana.com",
7064
];
71-
65+
7266
group.bench_function("cache_miss", |b| {
7367
b.iter(|| {
7468
let mut cache = RpcClientCache::new();
@@ -77,40 +71,38 @@ fn benchmark_rpc_client_cache(c: &mut Criterion) {
7771
}
7872
});
7973
});
80-
74+
8175
group.bench_function("cache_hit", |b| {
8276
let mut cache = RpcClientCache::new();
8377
// Pre-populate cache
8478
for url in &urls {
8579
cache.get_client(url);
8680
}
87-
81+
8882
b.iter(|| {
8983
for url in &urls {
9084
cache.get_client(url);
9185
}
9286
});
9387
});
94-
88+
9589
group.finish();
9690
}
9791

9892
/// Benchmark deployment configuration creation
9993
fn benchmark_deploy_config_creation(c: &mut Criterion) {
10094
c.bench_function("deploy_config_creation", |b| {
101-
b.iter(|| {
102-
DeployConfig {
103-
binary_path: "program.so".to_string(),
104-
program_id_path: "program_id.json".to_string(),
105-
owner_path: "owner.json".to_string(),
106-
fee_payer_path: "fee_payer.json".to_string(),
107-
publish_idl: true,
108-
idl_file_path: Some("idl.json".to_string()),
109-
network_selection: "all".to_string(),
110-
json_output: false,
111-
retry_attempts: 3,
112-
confirm_large_binaries: false,
113-
}
95+
b.iter(|| DeployConfig {
96+
binary_path: "program.so".to_string(),
97+
program_id_path: "program_id.json".to_string(),
98+
owner_path: "owner.json".to_string(),
99+
fee_payer_path: "fee_payer.json".to_string(),
100+
publish_idl: true,
101+
idl_file_path: Some("idl.json".to_string()),
102+
network_selection: "all".to_string(),
103+
json_output: false,
104+
retry_attempts: 3,
105+
confirm_large_binaries: false,
114106
});
115107
});
116108
}
@@ -119,7 +111,7 @@ fn benchmark_deploy_config_creation(c: &mut Criterion) {
119111
fn benchmark_json_operations(c: &mut Criterion) {
120112
use osvm::utils::ebpf_deploy::DeploymentResult;
121113
use solana_sdk::pubkey::Pubkey;
122-
114+
123115
let result = DeploymentResult {
124116
network: "devnet".to_string(),
125117
program_id: Pubkey::new_unique(),
@@ -129,65 +121,61 @@ fn benchmark_json_operations(c: &mut Criterion) {
129121
retries_attempted: 3,
130122
duration_ms: 5000,
131123
};
132-
124+
133125
let mut group = c.benchmark_group("json_operations");
134-
126+
135127
group.bench_function("serialize", |b| {
136-
b.iter(|| {
137-
serde_json::to_string(&result).unwrap()
138-
});
128+
b.iter(|| serde_json::to_string(&result).unwrap());
139129
});
140-
130+
141131
let json_str = serde_json::to_string(&result).unwrap();
142132
group.bench_function("deserialize", |b| {
143133
b.iter(|| {
144134
let _: DeploymentResult = serde_json::from_str(&json_str).unwrap();
145135
});
146136
});
147-
137+
148138
group.finish();
149139
}
150140

151141
/// Benchmark file operations for deployment
152142
fn benchmark_file_operations(c: &mut Criterion) {
153143
let dir = tempdir().unwrap();
154-
144+
155145
// Create test files of various sizes
156146
let file_sizes = vec![1_000, 10_000, 100_000, 1_000_000];
157147
let mut test_files = Vec::new();
158-
148+
159149
for size in file_sizes {
160150
let file_path = dir.path().join(format!("test_{}.dat", size));
161151
let data = vec![0u8; size];
162152
let mut file = File::create(&file_path).unwrap();
163153
file.write_all(&data).unwrap();
164154
test_files.push((size, file_path));
165155
}
166-
156+
167157
let mut group = c.benchmark_group("file_operations");
168-
158+
169159
for (size, file_path) in test_files {
170160
group.benchmark_with_input(
171161
BenchmarkId::new("read_file", size),
172162
&file_path,
173163
|b, path| {
174-
b.iter(|| {
175-
std::fs::read(path).unwrap()
176-
});
164+
b.iter(|| std::fs::read(path).unwrap());
177165
},
178166
);
179167
}
180-
168+
181169
group.finish();
182170
}
183171

184172
/// Benchmark memory usage and allocation patterns
185173
fn benchmark_memory_allocation(c: &mut Criterion) {
186174
let mut group = c.benchmark_group("memory_allocation");
187-
175+
188176
// Test vector allocation for different program sizes
189177
let sizes = vec![10_000, 100_000, 1_000_000, 5_000_000];
190-
178+
191179
for size in sizes {
192180
group.benchmark_with_input(
193181
BenchmarkId::new("vec_allocation", size),
@@ -199,7 +187,7 @@ fn benchmark_memory_allocation(c: &mut Criterion) {
199187
},
200188
);
201189
}
202-
190+
203191
group.finish();
204192
}
205193

@@ -214,4 +202,4 @@ criterion_group!(
214202
benchmark_memory_allocation
215203
);
216204

217-
criterion_main!(benches);
205+
criterion_main!(benches);

src/main.rs

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,39 @@ pub mod utils;
3232

3333
/// Check if a command is a known OSVM command
3434
fn is_known_command(sub_command: &str) -> bool {
35-
matches!(sub_command,
36-
"balance" | "svm" | "nodes" | "examples" | "rpc-manager" | "deploy" |
37-
"solana" | "doctor" | "audit" | "new_feature_command" | "v" | "ver" | "version"
35+
matches!(
36+
sub_command,
37+
"balance"
38+
| "svm"
39+
| "nodes"
40+
| "examples"
41+
| "rpc-manager"
42+
| "deploy"
43+
| "solana"
44+
| "doctor"
45+
| "audit"
46+
| "new_feature_command"
47+
| "v"
48+
| "ver"
49+
| "version"
3850
)
3951
}
4052

4153
/// Handle AI query command
42-
async fn handle_ai_query(sub_command: &str, sub_matches: &clap::ArgMatches) -> Result<(), Box<dyn std::error::Error>> {
54+
async fn handle_ai_query(
55+
sub_command: &str,
56+
sub_matches: &clap::ArgMatches,
57+
) -> Result<(), Box<dyn std::error::Error>> {
4358
// For external subcommands, clap provides the additional arguments differently
4459
// We need to collect them from the raw args since clap doesn't know about them
4560
let args: Vec<String> = std::env::args().collect();
46-
61+
4762
// Find where our subcommand starts and collect everything after osvm
4863
let mut query_parts = Vec::new();
4964
let mut found_osvm = false;
50-
51-
for arg in args.iter().skip(1) { // Skip the binary name
65+
66+
for arg in args.iter().skip(1) {
67+
// Skip the binary name
5268
if !found_osvm {
5369
found_osvm = true;
5470
}
@@ -57,12 +73,12 @@ async fn handle_ai_query(sub_command: &str, sub_matches: &clap::ArgMatches) -> R
5773
query_parts.push(arg.clone());
5874
}
5975
}
60-
76+
6177
let query = query_parts.join(" ");
62-
78+
6379
// Make AI request
6480
println!("🔍 Interpreting as AI query: \"{}\"", query);
65-
81+
6682
let ai_service = crate::services::ai_service::AiService::new();
6783
match ai_service.query(&query).await {
6884
Ok(response) => {
@@ -74,7 +90,7 @@ async fn handle_ai_query(sub_command: &str, sub_matches: &clap::ArgMatches) -> R
7490
eprintln!("💡 Use 'osvm --help' to see available commands");
7591
}
7692
}
77-
93+
7894
Ok(())
7995
}
8096

@@ -178,14 +194,14 @@ async fn handle_audit_command(
178194

179195
let no_commit = matches.get_flag("no-commit");
180196
let default_output_dir = matches.get_one::<String>("output").unwrap().to_string();
181-
197+
182198
// If --no-commit is used and output directory is the default, use current directory
183199
let output_dir = if no_commit && default_output_dir == "audit_reports" {
184200
".".to_string()
185201
} else {
186202
default_output_dir
187203
};
188-
204+
189205
let format = matches.get_one::<String>("format").unwrap().to_string();
190206
let verbose = matches.get_count("verbose");
191207
let test_mode = matches.get_flag("test");

0 commit comments

Comments
 (0)