Skip to content

Commit 2591932

Browse files
committed
fix: update Rust to 1.85 and format code
- Update Dockerfile to use Rust 1.85 for edition2024 support - Run cargo fmt on all source files
1 parent 21d8c57 commit 2591932

13 files changed

Lines changed: 72 additions & 58 deletions

File tree

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# term-executor service Dockerfile
2-
FROM rust:1.78-slim-bookworm AS builder
2+
FROM rust:1.85-slim-bookworm AS builder
33

44
# Install dependencies
55
RUN apt-get update && apt-get install -y \

src/api/http/handlers.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ use axum::{
88
use serde::{Deserialize, Serialize};
99
use tracing::{debug, info};
1010

11+
use crate::basilica::VerificationResult;
1112
use crate::crypto::verify_validator_signature;
1213
use crate::error::ExecutorError;
1314
use crate::executor::{ExecutionRequest, ExecutionResult, ExecutionStatus, TaskSpec};
1415
use crate::AppState;
15-
use crate::basilica::VerificationResult;
1616

1717
/// Health check response
1818
#[derive(Serialize)]
@@ -47,7 +47,12 @@ pub async fn verify_instance(
4747

4848
// Verify validator signature
4949
let message = format!("verify:{}:{}", instance_id, req.timestamp);
50-
verify_validator_signature(&req.validator_hotkey, &req.signature, &message, req.timestamp)?;
50+
verify_validator_signature(
51+
&req.validator_hotkey,
52+
&req.signature,
53+
&message,
54+
req.timestamp,
55+
)?;
5156

5257
// Verify the instance
5358
let result = state.engine.verify_instance(&instance_id).await?;
@@ -99,7 +104,12 @@ pub async fn execute_task(
99104
"execute:{}:{}:{}",
100105
req.instance_id, req.task.id, req.timestamp
101106
);
102-
verify_validator_signature(&req.validator_hotkey, &req.signature, &message, req.timestamp)?;
107+
verify_validator_signature(
108+
&req.validator_hotkey,
109+
&req.signature,
110+
&message,
111+
req.timestamp,
112+
)?;
103113

104114
// Create execution request
105115
let exec_request = ExecutionRequest {
@@ -174,7 +184,12 @@ pub async fn cancel_execution(
174184

175185
// Verify validator signature
176186
let message = format!("cancel:{}:{}", execution_id, req.timestamp);
177-
verify_validator_signature(&req.validator_hotkey, &req.signature, &message, req.timestamp)?;
187+
verify_validator_signature(
188+
&req.validator_hotkey,
189+
&req.signature,
190+
&message,
191+
req.timestamp,
192+
)?;
178193

179194
// Cancel
180195
state.engine.cancel(&execution_id).await?;

src/api/http/middleware.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
//! HTTP middleware
22
3-
use axum::{
4-
body::Body,
5-
extract::Request,
6-
http::StatusCode,
7-
middleware::Next,
8-
response::Response,
9-
};
3+
use axum::{body::Body, extract::Request, http::StatusCode, middleware::Next, response::Response};
104
use tracing::warn;
115

126
/// Authentication middleware (placeholder)

src/api/http/routes.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,17 @@ pub fn create_router(state: AppState) -> Router {
2424
Router::new()
2525
// Health check
2626
.route("/health", get(handlers::health_check))
27-
2827
// Instance verification
2928
.route("/v1/instances/:id/verify", post(handlers::verify_instance))
30-
3129
// Execution endpoints
3230
.route("/v1/execute", post(handlers::execute_task))
3331
.route("/v1/executions/:id", get(handlers::get_execution))
34-
.route("/v1/executions/:id/cancel", post(handlers::cancel_execution))
35-
32+
.route(
33+
"/v1/executions/:id/cancel",
34+
post(handlers::cancel_execution),
35+
)
3636
// Stats
3737
.route("/v1/stats", get(handlers::get_stats))
38-
3938
// Apply middleware
4039
.layer(cors)
4140
.layer(TraceLayer::new_for_http())

src/basilica/client.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,9 @@ impl BasilicaClient {
113113
)));
114114
}
115115

116-
let exec_response: ExecResponse = response
117-
.json()
118-
.await
119-
.map_err(|e| ExecutorError::BasilicaApi(format!("Failed to parse exec response: {}", e)))?;
116+
let exec_response: ExecResponse = response.json().await.map_err(|e| {
117+
ExecutorError::BasilicaApi(format!("Failed to parse exec response: {}", e))
118+
})?;
120119

121120
info!(
122121
"Exec completed on {}: exit_code={}, duration={}ms",
@@ -234,10 +233,7 @@ impl BasilicaClient {
234233
info!("Instance {} verified successfully", instance_id);
235234
Ok(VerificationResult::success(instance_id, &metadata))
236235
} else {
237-
warn!(
238-
"Instance {} verification failed: {:?}",
239-
instance_id, errors
240-
);
236+
warn!("Instance {} verification failed: {:?}", instance_id, errors);
241237
Ok(VerificationResult::failure(instance_id, &metadata, errors))
242238
}
243239
}
@@ -273,7 +269,8 @@ impl BasilicaClient {
273269
}
274270
}
275271

276-
Err(last_error.unwrap_or_else(|| ExecutorError::ExecutionFailed("Unknown error".to_string())))
272+
Err(last_error
273+
.unwrap_or_else(|| ExecutorError::ExecutionFailed("Unknown error".to_string())))
277274
}
278275
}
279276

src/cleanup/manager.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,8 @@ impl CleanupManager {
130130
async fn stop_on_instance(&self, instance_id: &str) -> anyhow::Result<()> {
131131
// Send a kill signal to any agent processes
132132
// This is best-effort cleanup
133-
let request = crate::basilica::ExecRequest::shell(
134-
"pkill -f '/agent/agent' 2>/dev/null || true",
135-
10,
136-
);
133+
let request =
134+
crate::basilica::ExecRequest::shell("pkill -f '/agent/agent' 2>/dev/null || true", 10);
137135

138136
match self.basilica.exec(instance_id, &request, None).await {
139137
Ok(_) => debug!("Sent cleanup signal to instance {}", instance_id),

src/cleanup/registry.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,7 @@ mod tests {
252252
.await
253253
.unwrap();
254254

255-
registry
256-
.update_state("c1", ContainerState::Completed)
257-
.await;
255+
registry.update_state("c1", ContainerState::Completed).await;
258256

259257
let container = registry.get("c1").await.unwrap();
260258
assert_eq!(container.state, ContainerState::Completed);

src/crypto/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ pub fn verify_validator_signature(
4848
));
4949
}
5050

51-
debug!("Signature verified for hotkey {}", &hotkey[..16.min(hotkey.len())]);
51+
debug!(
52+
"Signature verified for hotkey {}",
53+
&hotkey[..16.min(hotkey.len())]
54+
);
5255

5356
Ok(())
5457
}
@@ -114,7 +117,12 @@ mod tests {
114117
let timestamp = chrono::Utc::now().timestamp();
115118
let message = format!("test:{}:{}", "instance-123", timestamp);
116119

117-
let result = verify_validator_signature("invalid-hotkey", "0".repeat(128).as_str(), &message, timestamp);
120+
let result = verify_validator_signature(
121+
"invalid-hotkey",
122+
"0".repeat(128).as_str(),
123+
&message,
124+
timestamp,
125+
);
118126
assert!(matches!(result, Err(ExecutorError::InvalidHotkey(_))));
119127
}
120128
}

src/executor/engine.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,7 @@ impl ExecutionEngine {
230230
self.metrics
231231
.execution_failed(&exec.request.task.id, &e.to_string());
232232

233-
self.queue
234-
.mark_failed(execution_id, &e.to_string())
235-
.await;
233+
self.queue.mark_failed(execution_id, &e.to_string()).await;
236234
}
237235
}
238236
}

src/executor/queue.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ impl ExecutionQueue {
234234
ExecutionStatus::Pending => pending += 1,
235235
ExecutionStatus::Running => running += 1,
236236
ExecutionStatus::Completed => completed += 1,
237-
ExecutionStatus::Failed | ExecutionStatus::Cancelled | ExecutionStatus::TimedOut => {
238-
failed += 1
239-
}
237+
ExecutionStatus::Failed
238+
| ExecutionStatus::Cancelled
239+
| ExecutionStatus::TimedOut => failed += 1,
240240
}
241241
}
242242

0 commit comments

Comments
 (0)