diff --git a/examples/debugger/src/main.rs b/examples/debugger/src/main.rs index 78b03dff9..f7a905dbc 100644 --- a/examples/debugger/src/main.rs +++ b/examples/debugger/src/main.rs @@ -17,8 +17,8 @@ async fn main() { } let app = Compiler::new() - .fhe_program(mad) .fhe_program(add_squares) + .fhe_program(mad) .compile() .unwrap(); diff --git a/sunscreen_runtime/src/debugger/server.rs b/sunscreen_runtime/src/debugger/server.rs index 192a07be2..c3540859d 100644 --- a/sunscreen_runtime/src/debugger/server.rs +++ b/sunscreen_runtime/src/debugger/server.rs @@ -82,6 +82,38 @@ async fn get_code(session: web::Path) -> impl Responder { } } +/** + * Gets the info of a node in the debugging graph for an FHE program. + */ +#[get("graphs/{session}/{nodeid}")] +pub async fn get_fhe_node_data( + path_info: web::Path<(String, usize)> + ) -> Result { + + let (session, nodeid) = path_info.into_inner(); + let sessions = get_sessions().lock().unwrap(); + + if sessions.contains_key(&session) { + let curr_session = sessions.get(&session).unwrap().unwrap_bfv_session(); + + let data = curr_session + .program_data + .get(nodeid) + .unwrap(); + + let data_json = serde_json::to_string(data).map_err(|e| { + actix_web::error::ErrorInternalServerError(format!( + "Failed to serialize node data to JSON: {}", + e + )) + })?; + Ok(HttpResponse::Ok().body(data_json)) + } else { + Ok(HttpResponse::NotFound().body("Node {:?} not found", nodeid)) + } +} + + /* /** * Gets node data in the compilation graph. diff --git a/sunscreen_runtime/src/debugger/sessions.rs b/sunscreen_runtime/src/debugger/sessions.rs index cca7308ca..907a171b9 100644 --- a/sunscreen_runtime/src/debugger/sessions.rs +++ b/sunscreen_runtime/src/debugger/sessions.rs @@ -60,6 +60,8 @@ pub struct BfvSession { /** * The values of operands in the compilation graph. */ + + // TODO: maybe this shouldn't be a Vec of SealData ... pub program_data: Vec>, /** * Used for decryption of ciphertexts for visualization. diff --git a/sunscreen_runtime/src/runtime.rs b/sunscreen_runtime/src/runtime.rs index 1d7dd20be..dec580150 100644 --- a/sunscreen_runtime/src/runtime.rs +++ b/sunscreen_runtime/src/runtime.rs @@ -438,6 +438,7 @@ where fhe_program.metadata.name, SESSION_NUM.fetch_add(1, std::sync::atomic::Ordering::Relaxed) ); + println!("session name: {:?}", session_name); self.run_impl( fhe_program,