@@ -251,21 +251,6 @@ impl<'a> Scheduler<'a> {
251251 }
252252}
253253
254- fn decompress_transaction_inputs (
255- inputs : & mut HashMap < Handle , Option < DFGTxInput > > ,
256- gpu_idx : usize ,
257- ) -> Result < usize > {
258- let mut count = 0 ;
259- for txinput in inputs. values_mut ( ) {
260- if let Some ( DFGTxInput :: Compressed ( ( ( t, c) , allowed) ) ) = txinput {
261- let decomp = SupportedFheCiphertexts :: decompress ( * t, c, gpu_idx) ?;
262- * txinput = Some ( DFGTxInput :: Value ( ( decomp, * allowed) ) ) ;
263- count += 1 ;
264- }
265- }
266- Ok ( count)
267- }
268-
269254fn re_randomise_operation_inputs (
270255 cts : & mut [ SupportedFheCiphertexts ] ,
271256 opcode : i32 ,
@@ -327,41 +312,10 @@ fn execute_partition(
327312 }
328313 continue ' tx;
329314 } ;
330- * i = Some ( DFGTxInput :: Value ( ( ct. ct . clone ( ) , ct. is_allowed ) ) ) ;
331- }
332- }
333-
334- // Decompress ciphertexts
335- {
336- let _guard = tracing:: info_span!(
337- "decompress_ciphertexts" ,
338- txn_id = %txn_id_short,
339- count = tracing:: field:: Empty ,
340- )
341- . entered ( ) ;
342-
343- match decompress_transaction_inputs ( tx_inputs, gpu_idx) {
344- Ok ( count) => {
345- tracing:: Span :: current ( ) . record ( "count" , count as i64 ) ;
346- }
347- Err ( e) => {
348- error ! ( target: "scheduler" , { transaction_id = ?hex:: encode( & tid) , error = ?e } ,
349- "Error while decompressing inputs" ) ;
350- telemetry:: set_current_span_error ( & e) ;
351- for nidx in dfg. graph . node_identifiers ( ) {
352- let Some ( node) = dfg. graph . node_weight_mut ( nidx) else {
353- error ! ( target: "scheduler" , { index = ?nidx. index( ) } , "Wrong dataflow graph index" ) ;
354- continue ;
355- } ;
356- if node. is_allowed {
357- res. insert (
358- node. result_handle . clone ( ) ,
359- Err ( SchedulerError :: DecompressionError . into ( ) ) ,
360- ) ;
361- }
362- }
363- continue ' tx;
364- }
315+ * i = Some ( DFGTxInput :: Compressed ( (
316+ ct. compressed_ct . clone ( ) ,
317+ ct. is_allowed ,
318+ ) ) ) ;
365319 }
366320 }
367321
@@ -410,7 +364,7 @@ fn execute_partition(
410364 // Update input of consumers
411365 if let Ok ( ref res) = result. 1 {
412366 child_node. inputs [ * edge. weight ( ) as usize ] =
413- DFGTaskInput :: Value ( res. 0 . clone ( ) ) ;
367+ DFGTaskInput :: Compressed ( res. clone ( ) ) ;
414368 }
415369 }
416370 }
@@ -422,8 +376,7 @@ fn execute_partition(
422376 res. insert (
423377 node. result_handle . clone ( ) ,
424378 result. 1 . map ( |v| TaskResult {
425- ct : v. 0 ,
426- compressed_ct : if node. is_allowed { v. 1 } else { None } ,
379+ compressed_ct : v,
427380 is_allowed : node. is_allowed ,
428381 transaction_id : tid. clone ( ) ,
429382 } ) ,
@@ -460,12 +413,35 @@ fn try_execute_node(
460413 }
461414 let mut cts = Vec :: with_capacity ( node. inputs . len ( ) ) ;
462415 for i in std:: mem:: take ( & mut node. inputs ) {
463- if let DFGTaskInput :: Value ( i) = i {
464- cts. push ( i) ;
465- } else {
466- // That should not be possible as we called the checker.
467- error ! ( target: "scheduler" , { handle = ?hex:: encode( & node. result_handle) } , "Computation missing inputs" ) ;
468- return Err ( SchedulerError :: MissingInputs . into ( ) ) ;
416+ match i {
417+ DFGTaskInput :: Value ( v) => {
418+ if !matches ! ( v, SupportedFheCiphertexts :: Scalar ( _) ) {
419+ error ! ( target: "scheduler" , { handle = ?hex:: encode( & node. result_handle) } ,
420+ "Consensus risk: non-scalar uncompressed ciphertext" ) ;
421+ }
422+ cts. push ( v) ;
423+ }
424+ DFGTaskInput :: Compressed ( cct) => {
425+ let decompressed = SupportedFheCiphertexts :: decompress (
426+ cct. ct_type ,
427+ & cct. ct_bytes ,
428+ gpu_idx,
429+ )
430+ . map_err ( |e| {
431+ error ! (
432+ target: "scheduler" ,
433+ { handle = ?hex:: encode( & node. result_handle) , ct_type = cct. ct_type, error = ?e } ,
434+ "Error while decompressing op input"
435+ ) ;
436+ telemetry:: set_current_span_error ( & e) ;
437+ SchedulerError :: DecompressionError
438+ } ) ?;
439+ cts. push ( decompressed) ;
440+ }
441+ DFGTaskInput :: Dependence ( _) => {
442+ error ! ( target: "scheduler" , { handle = ?hex:: encode( & node. result_handle) } , "Computation missing inputs" ) ;
443+ return Err ( SchedulerError :: MissingInputs . into ( ) ) ;
444+ }
469445 }
470446 }
471447 // Re-randomize inputs for this operation
@@ -482,24 +458,20 @@ fn try_execute_node(
482458 RERAND_LATENCY_BATCH_HISTOGRAM . observe ( elapsed. as_secs_f64 ( ) ) ;
483459 }
484460 let opcode = node. opcode ;
485- let is_allowed = node. is_allowed ;
486461 Ok ( run_computation (
487462 opcode,
488463 cts,
489464 node_index,
490- is_allowed,
491465 gpu_idx,
492466 transaction_id,
493467 ) )
494468}
495469
496- type OpResult = Result < ( SupportedFheCiphertexts , Option < ( i16 , Vec < u8 > ) > ) > ;
497-
470+ type OpResult = Result < CompressedCiphertext > ;
498471fn run_computation (
499472 operation : i32 ,
500473 inputs : Vec < SupportedFheCiphertexts > ,
501474 graph_node_index : usize ,
502- is_allowed : bool ,
503475 gpu_idx : usize ,
504476 transaction_id : & Handle ,
505477) -> ( usize , OpResult ) {
@@ -524,7 +496,7 @@ fn run_computation(
524496 tracing:: Span :: current ( ) . record ( "compressed_size" , ct_bytes. len ( ) as i64 ) ;
525497 (
526498 graph_node_index,
527- Ok ( ( inputs [ 0 ] . clone ( ) , Some ( ( ct_type, ct_bytes) ) ) ) ,
499+ Ok ( CompressedCiphertext { ct_type, ct_bytes } ) ,
528500 )
529501 }
530502 Err ( error) => {
@@ -553,31 +525,30 @@ fn run_computation(
553525
554526 match result {
555527 Ok ( result) => {
556- if is_allowed {
557- // Compression span
558- let _guard = tracing:: info_span!(
559- "compress_ciphertext" ,
560- txn_id = %txn_id_short,
561- ct_type = result. type_name( ) ,
562- operation = op_name,
563- compressed_size = tracing:: field:: Empty ,
564- )
565- . entered ( ) ;
566- let ct_type = result. type_num ( ) ;
567- let compressed = result. compress ( ) ;
568- match compressed {
569- Ok ( ct_bytes) => {
570- tracing:: Span :: current ( )
571- . record ( "compressed_size" , ct_bytes. len ( ) as i64 ) ;
572- ( graph_node_index, Ok ( ( result, Some ( ( ct_type, ct_bytes) ) ) ) )
573- }
574- Err ( error) => {
575- telemetry:: set_current_span_error ( & error) ;
576- ( graph_node_index, Err ( error. into ( ) ) )
577- }
528+ // Compression span
529+ let _guard = tracing:: info_span!(
530+ "compress_ciphertext" ,
531+ txn_id = %txn_id_short,
532+ ct_type = result. type_name( ) ,
533+ operation = op_name,
534+ compressed_size = tracing:: field:: Empty ,
535+ )
536+ . entered ( ) ;
537+ let ct_type = result. type_num ( ) ;
538+ let compressed = result. compress ( ) ;
539+ match compressed {
540+ Ok ( ct_bytes) => {
541+ tracing:: Span :: current ( )
542+ . record ( "compressed_size" , ct_bytes. len ( ) as i64 ) ;
543+ (
544+ graph_node_index,
545+ Ok ( CompressedCiphertext { ct_type, ct_bytes } ) ,
546+ )
547+ }
548+ Err ( error) => {
549+ telemetry:: set_current_span_error ( & error) ;
550+ ( graph_node_index, Err ( error. into ( ) ) )
578551 }
579- } else {
580- ( graph_node_index, Ok ( ( result, None ) ) )
581552 }
582553 }
583554 Err ( e) => {
0 commit comments