File tree Expand file tree Collapse file tree 2 files changed +44
-1
lines changed
Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -310,6 +310,18 @@ async fn start_challenge(
310310 . await
311311 . map_err ( |e| ( StatusCode :: INTERNAL_SERVER_ERROR , e. to_string ( ) ) ) ?;
312312
313+ info ! ( "Challenge {} started at {}" , id, endpoint) ;
314+
315+ // Broadcast to all validators so they start their local containers
316+ state
317+ . broadcast_event ( models:: WsEvent :: ChallengeStarted (
318+ models:: ChallengeStartedEvent {
319+ id : id. clone ( ) ,
320+ endpoint : endpoint. clone ( ) ,
321+ } ,
322+ ) )
323+ . await ;
324+
313325 Ok ( Json ( serde_json:: json!( {
314326 "success" : true ,
315327 "endpoint" : endpoint
Original file line number Diff line number Diff line change @@ -861,7 +861,38 @@ async fn connect_to_websocket(
861861 "Received challenge_started event for: {} at {}" ,
862862 event. id, event. endpoint
863863 ) ;
864- // Could auto-start container here if needed
864+ // Start the challenge container locally
865+ if let Some ( ref orch) = orchestrator {
866+ let docker_image = format ! ( "ghcr.io/platformnetwork/{}:latest" , event. id) ;
867+ let challenge_uuid =
868+ uuid:: Uuid :: new_v5 ( & uuid:: Uuid :: NAMESPACE_DNS , event. id . as_bytes ( ) ) ;
869+ let config = challenge_orchestrator:: ChallengeContainerConfig {
870+ challenge_id : platform_core:: ChallengeId ( challenge_uuid) ,
871+ name : event. id . clone ( ) ,
872+ docker_image,
873+ mechanism_id : 0 , // Default mechanism
874+ emission_weight : 100.0 ,
875+ timeout_secs : 3600 ,
876+ cpu_cores : 2.0 ,
877+ memory_mb : 4096 ,
878+ gpu_required : false ,
879+ } ;
880+
881+ match orch. add_challenge ( config) . await {
882+ Ok ( _) => {
883+ info ! ( "Challenge container started locally: {}" , event. id) ;
884+ // Add to URL map
885+ challenge_urls
886+ . write ( )
887+ . insert ( event. id . clone ( ) , event. endpoint . clone ( ) ) ;
888+ }
889+ Err ( e) => {
890+ error ! ( "Failed to start challenge container {}: {}" , event. id, e)
891+ }
892+ }
893+ } else {
894+ warn ! ( "No orchestrator available to start challenge: {}" , event. id) ;
895+ }
865896 }
866897 Ok ( WsEvent :: Ping ) => {
867898 debug ! ( "Received ping from server" ) ;
You can’t perform that action at this time.
0 commit comments