Skip to content

Commit f0367d6

Browse files
committed
Fix PLATFORM_URL and cache volume for challenges
- PLATFORM_URL now uses VALIDATOR_NAME (platform-server or platform-validator) - Cache volume uses stable name based on challenge name only - Fixes dataset re-download on every restart
1 parent 1fead0e commit f0367d6

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

crates/challenge-orchestrator/src/docker.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,12 @@ impl DockerClient {
473473
debug!("Volume creation result for {}: {:?}", volume_name, e);
474474
}
475475

476-
// Create cache volume for downloaded datasets
477-
let cache_volume_name = format!("{}-cache", volume_name);
476+
// Create cache volume for downloaded datasets (shared across restarts)
477+
// Use challenge name only (not suffix) so cache persists even if container name changes
478+
let cache_volume_name = format!(
479+
"challenge-{}-cache",
480+
config.name.to_lowercase().replace(' ', "-")
481+
);
478482
let cache_volume_opts = bollard::volume::CreateVolumeOptions {
479483
name: cache_volume_name.as_str(),
480484
driver: "local",
@@ -498,7 +502,7 @@ impl DockerClient {
498502
"/tmp/platform-tasks:/app/data/tasks:rw".to_string(), // Override internal tasks
499503
"/tmp/platform-tasks:/tmp/platform-tasks:rw".to_string(), // For DinD path mapping
500504
format!("{}:/data:rw", volume_name), // Named volume for persistent state
501-
format!("{}-cache:/root/.cache:rw", volume_name), // Cache for downloaded datasets
505+
format!("{}:/root/.cache:rw", cache_volume_name), // Cache for downloaded datasets
502506
]),
503507
..Default::default()
504508
};
@@ -541,17 +545,21 @@ impl DockerClient {
541545
env.push(format!("OWNER_HOTKEY={}", owner_hotkey));
542546
}
543547
// Pass Platform URL for metagraph verification
544-
// Use container hostname or env var since we're on the same Docker network
545-
let validator_host = std::env::var("VALIDATOR_CONTAINER_NAME")
546-
.unwrap_or_else(|_| "platform-validator".to_string());
547-
env.push(format!("PLATFORM_URL=http://{}:8080", validator_host));
548+
// Use VALIDATOR_NAME to determine if we're server or validator
549+
let platform_host = std::env::var("VALIDATOR_NAME")
550+
.map(|name| format!("platform-{}", name))
551+
.unwrap_or_else(|_| {
552+
std::env::var("VALIDATOR_CONTAINER_NAME")
553+
.unwrap_or_else(|_| "platform-server".to_string())
554+
});
555+
env.push(format!("PLATFORM_URL=http://{}:8080", platform_host));
548556

549557
// Pass Container Broker WebSocket URL for secure container spawning
550558
// Challenges connect to this broker instead of using Docker socket directly
551559
let broker_port = std::env::var("BROKER_WS_PORT").unwrap_or_else(|_| "8090".to_string());
552560
env.push(format!(
553561
"CONTAINER_BROKER_WS_URL=ws://{}:{}",
554-
validator_host, broker_port
562+
platform_host, broker_port
555563
));
556564

557565
// Pass JWT token for broker authentication (if set)

0 commit comments

Comments
 (0)