@@ -282,21 +282,6 @@ async fn main() -> Result<()> {
282282 info ! ( "Platform server: {}" , args. platform_server) ;
283283 platform_client. health_with_retry ( ) . await ;
284284
285- // List challenges
286- match platform_client. list_challenges ( ) . await {
287- Ok ( c) if !c. is_empty ( ) => {
288- info ! ( "Challenges:" ) ;
289- for ch in & c {
290- info ! (
291- " - {} (mechanism={}, healthy={})" ,
292- ch. id, ch. mechanism_id, ch. is_healthy
293- ) ;
294- }
295- }
296- Ok ( _) => info ! ( "No challenges yet" ) ,
297- Err ( e) => warn ! ( "Failed to list challenges: {}" , e) ,
298- }
299-
300285 // Container broker
301286 info ! ( "Container broker on port {}..." , args. broker_port) ;
302287 let broker = Arc :: new ( ContainerBroker :: with_policy ( SecurityPolicy :: default ( ) ) . await ?) ;
@@ -314,7 +299,7 @@ async fn main() -> Result<()> {
314299 } ) ;
315300
316301 // Challenge orchestrator
317- let _orchestrator = if args. docker_challenges {
302+ let orchestrator = if args. docker_challenges {
318303 match ChallengeOrchestrator :: new ( OrchestratorConfig {
319304 network_name : "platform-network" . to_string ( ) ,
320305 health_check_interval : Duration :: from_secs ( 30 ) ,
@@ -333,6 +318,55 @@ async fn main() -> Result<()> {
333318 None
334319 } ;
335320
321+ // List challenges and start containers
322+ let challenges = platform_client. list_challenges ( ) . await ?;
323+ if challenges. is_empty ( ) {
324+ info ! ( "No challenges registered on platform-server" ) ;
325+ } else {
326+ info ! ( "Challenges from platform-server:" ) ;
327+ for ch in & challenges {
328+ info ! (
329+ " - {} (mechanism={}, healthy={})" ,
330+ ch. id, ch. mechanism_id, ch. is_healthy
331+ ) ;
332+ }
333+
334+ // Start challenge containers
335+ if let Some ( ref orch) = orchestrator {
336+ for ch in & challenges {
337+ let docker_image = format ! ( "ghcr.io/platformnetwork/{}:latest" , ch. id) ;
338+ // Generate a deterministic UUID from challenge name
339+ let challenge_uuid =
340+ uuid:: Uuid :: new_v5 ( & uuid:: Uuid :: NAMESPACE_DNS , ch. id . as_bytes ( ) ) ;
341+ let config = challenge_orchestrator:: ChallengeContainerConfig {
342+ challenge_id : platform_core:: ChallengeId ( challenge_uuid) ,
343+ name : ch. id . clone ( ) ,
344+ docker_image,
345+ mechanism_id : ch. mechanism_id as u8 ,
346+ emission_weight : ch. emission_weight ,
347+ timeout_secs : 3600 ,
348+ cpu_cores : 2.0 ,
349+ memory_mb : 4096 ,
350+ gpu_required : false ,
351+ } ;
352+
353+ info ! ( "Starting challenge container: {}" , ch. id) ;
354+ match orch. add_challenge ( config) . await {
355+ Ok ( _) => info ! ( "Challenge container started: {}" , ch. id) ,
356+ Err ( e) => error ! ( "Failed to start challenge {}: {}" , ch. id, e) ,
357+ }
358+ }
359+
360+ // Start health monitoring
361+ let orch_clone = orch. clone ( ) ;
362+ tokio:: spawn ( async move {
363+ if let Err ( e) = orch_clone. start ( ) . await {
364+ error ! ( "Orchestrator health monitor error: {}" , e) ;
365+ }
366+ } ) ;
367+ }
368+ }
369+
336370 // RPC server
337371 let addr: SocketAddr = format ! ( "{}:{}" , args. rpc_addr, args. rpc_port) . parse ( ) ?;
338372 let rpc_server = RpcServer :: new (
0 commit comments