@@ -68,8 +68,8 @@ use janus_messages::{
68
68
taskprov:: TaskConfig ,
69
69
AggregateShare , AggregateShareAad , AggregateShareReq , AggregationJobContinueReq ,
70
70
AggregationJobId , AggregationJobInitializeReq , AggregationJobResp , AggregationJobStep ,
71
- BatchSelector , Collection , CollectionJobId , CollectionReq , Duration , ExtensionType , HpkeConfig ,
72
- HpkeConfigList , InputShareAad , Interval , PartialBatchSelector , PlaintextInputShare ,
71
+ BatchSelector , CollectionJobId , CollectionJobReq , CollectionJobResp , Duration , ExtensionType ,
72
+ HpkeConfig , HpkeConfigList , InputShareAad , Interval , PartialBatchSelector , PlaintextInputShare ,
73
73
PrepareResp , PrepareStepResult , Report , ReportError , ReportIdChecksum , ReportShare , Role ,
74
74
TaskId ,
75
75
} ;
@@ -529,14 +529,14 @@ impl<C: Clock> Aggregator<C> {
529
529
}
530
530
531
531
/// Handle a collection job creation request. Only supported by the leader. `req_bytes` is an
532
- /// encoded [`CollectionReq`] .
532
+ /// encoded [`CollectionJobReq`]. Returns an encoded [`CollectionJobResp`] on success .
533
533
async fn handle_create_collection_job (
534
534
& self ,
535
535
task_id : & TaskId ,
536
536
collection_job_id : & CollectionJobId ,
537
537
req_bytes : & [ u8 ] ,
538
538
auth_token : Option < AuthenticationToken > ,
539
- ) -> Result < ( ) , Error > {
539
+ ) -> Result < Vec < u8 > , Error > {
540
540
let task_aggregator = self
541
541
. task_aggregators
542
542
. get ( task_id)
@@ -566,7 +566,7 @@ impl<C: Clock> Aggregator<C> {
566
566
task_id : & TaskId ,
567
567
collection_job_id : & CollectionJobId ,
568
568
auth_token : Option < AuthenticationToken > ,
569
- ) -> Result < Option < Vec < u8 > > , Error > {
569
+ ) -> Result < Vec < u8 > , Error > {
570
570
let task_aggregator = self
571
571
. task_aggregators
572
572
. get ( task_id)
@@ -1034,7 +1034,7 @@ impl<C: Clock> TaskAggregator<C> {
1034
1034
datastore : & Datastore < C > ,
1035
1035
collection_job_id : & CollectionJobId ,
1036
1036
req_bytes : & [ u8 ] ,
1037
- ) -> Result < ( ) , Error > {
1037
+ ) -> Result < Vec < u8 > , Error > {
1038
1038
self . vdaf_ops
1039
1039
. handle_create_collection_job (
1040
1040
datastore,
@@ -1049,7 +1049,7 @@ impl<C: Clock> TaskAggregator<C> {
1049
1049
& self ,
1050
1050
datastore : & Datastore < C > ,
1051
1051
collection_job_id : & CollectionJobId ,
1052
- ) -> Result < Option < Vec < u8 > > , Error > {
1052
+ ) -> Result < Vec < u8 > , Error > {
1053
1053
self . vdaf_ops
1054
1054
. handle_get_collection_job ( datastore, Arc :: clone ( & self . task ) , collection_job_id)
1055
1055
. await
@@ -1834,19 +1834,20 @@ impl VdafOps {
1834
1834
}
1835
1835
1836
1836
// This is a repeated request. Send the same response we computed last time.
1837
- return Ok ( Some ( AggregationJobResp :: new (
1838
- tx. get_report_aggregations_for_aggregation_job (
1839
- vdaf,
1840
- & Role :: Helper ,
1841
- task_id,
1842
- aggregation_job_id,
1843
- )
1844
- . await ?
1845
- . iter ( )
1846
- . filter_map ( ReportAggregation :: last_prep_resp)
1847
- . cloned ( )
1848
- . collect ( ) ,
1849
- ) ) ) ;
1837
+ return Ok ( Some ( AggregationJobResp :: Finished {
1838
+ prepare_resps : tx
1839
+ . get_report_aggregations_for_aggregation_job (
1840
+ vdaf,
1841
+ & Role :: Helper ,
1842
+ task_id,
1843
+ aggregation_job_id,
1844
+ )
1845
+ . await ?
1846
+ . iter ( )
1847
+ . filter_map ( ReportAggregation :: last_prep_resp)
1848
+ . cloned ( )
1849
+ . collect ( ) ,
1850
+ } ) ) ;
1850
1851
}
1851
1852
1852
1853
Ok ( None )
@@ -2358,11 +2359,11 @@ impl VdafOps {
2358
2359
let ( mut prep_resps_by_agg_job, counters) =
2359
2360
aggregation_job_writer. write ( tx, vdaf) . await ?;
2360
2361
Ok ( (
2361
- AggregationJobResp :: new (
2362
- prep_resps_by_agg_job
2362
+ AggregationJobResp :: Finished {
2363
+ prepare_resps : prep_resps_by_agg_job
2363
2364
. remove ( aggregation_job. id ( ) )
2364
2365
. unwrap_or_default ( ) ,
2365
- ) ,
2366
+ } ,
2366
2367
counters,
2367
2368
) )
2368
2369
} )
@@ -2473,13 +2474,13 @@ impl VdafOps {
2473
2474
}
2474
2475
}
2475
2476
return Ok ( (
2476
- AggregationJobResp :: new (
2477
- report_aggregations
2477
+ AggregationJobResp :: Finished {
2478
+ prepare_resps : report_aggregations
2478
2479
. iter ( )
2479
2480
. filter_map ( ReportAggregation :: last_prep_resp)
2480
2481
. cloned ( )
2481
2482
. collect ( ) ,
2482
- ) ,
2483
+ } ,
2483
2484
TaskAggregationCounter :: default ( ) ,
2484
2485
) ) ;
2485
2486
} else if aggregation_job. step ( ) . increment ( ) != req. step ( ) {
@@ -2574,7 +2575,7 @@ impl VdafOps {
2574
2575
task : Arc < AggregatorTask > ,
2575
2576
collection_job_id : & CollectionJobId ,
2576
2577
collection_req_bytes : & [ u8 ] ,
2577
- ) -> Result < ( ) , Error > {
2578
+ ) -> Result < Vec < u8 > , Error > {
2578
2579
match task. batch_mode ( ) {
2579
2580
task:: BatchMode :: TimeInterval => {
2580
2581
vdaf_ops_dispatch ! ( self , ( vdaf, _, VdafType , VERIFY_KEY_LENGTH ) => {
@@ -2612,19 +2613,19 @@ impl VdafOps {
2612
2613
vdaf : Arc < A > ,
2613
2614
collection_job_id : & CollectionJobId ,
2614
2615
req_bytes : & [ u8 ] ,
2615
- ) -> Result < ( ) , Error >
2616
+ ) -> Result < Vec < u8 > , Error >
2616
2617
where
2617
2618
A :: AggregationParam : ' static + Send + Sync + PartialEq + Eq + Hash ,
2618
2619
A :: AggregateShare : Send + Sync ,
2619
2620
{
2620
2621
let req =
2621
- Arc :: new ( CollectionReq :: < B > :: get_decoded ( req_bytes) . map_err ( Error :: MessageDecode ) ?) ;
2622
+ Arc :: new ( CollectionJobReq :: < B > :: get_decoded ( req_bytes) . map_err ( Error :: MessageDecode ) ?) ;
2622
2623
let aggregation_param = Arc :: new (
2623
2624
A :: AggregationParam :: get_decoded ( req. aggregation_parameter ( ) )
2624
2625
. map_err ( Error :: MessageDecode ) ?,
2625
2626
) ;
2626
2627
2627
- Ok ( datastore
2628
+ datastore
2628
2629
. run_tx ( "collect" , move |tx| {
2629
2630
let ( task, vdaf, collection_job_id, req, aggregation_param) = (
2630
2631
Arc :: clone ( & task) ,
@@ -2715,7 +2716,11 @@ impl VdafOps {
2715
2716
Ok ( ( ) )
2716
2717
} )
2717
2718
} )
2718
- . await ?)
2719
+ . await ?;
2720
+
2721
+ CollectionJobResp :: < B > :: Processing
2722
+ . get_encoded ( )
2723
+ . map_err ( Error :: MessageEncode )
2719
2724
}
2720
2725
2721
2726
/// Handle GET requests to the leader's `tasks/{task-id}/collection_jobs/{collection-job-id}`
@@ -2727,7 +2732,7 @@ impl VdafOps {
2727
2732
datastore : & Datastore < C > ,
2728
2733
task : Arc < AggregatorTask > ,
2729
2734
collection_job_id : & CollectionJobId ,
2730
- ) -> Result < Option < Vec < u8 > > , Error > {
2735
+ ) -> Result < Vec < u8 > , Error > {
2731
2736
match task. batch_mode ( ) {
2732
2737
task:: BatchMode :: TimeInterval => {
2733
2738
vdaf_ops_dispatch ! ( self , ( vdaf, _, VdafType , VERIFY_KEY_LENGTH ) => {
@@ -2765,7 +2770,7 @@ impl VdafOps {
2765
2770
task : Arc < AggregatorTask > ,
2766
2771
vdaf : Arc < A > ,
2767
2772
collection_job_id : & CollectionJobId ,
2768
- ) -> Result < Option < Vec < u8 > > , Error >
2773
+ ) -> Result < Vec < u8 > , Error >
2769
2774
where
2770
2775
A :: AggregationParam : Send + Sync ,
2771
2776
A :: AggregateShare : Send + Sync ,
@@ -2790,7 +2795,7 @@ impl VdafOps {
2790
2795
match collection_job. state ( ) {
2791
2796
CollectionJobState :: Start => {
2792
2797
debug ! ( %collection_job_id, task_id = %task. id( ) , "collection job has not run yet" ) ;
2793
- Ok ( None )
2798
+ Ok ( CollectionJobResp :: < B > :: Processing )
2794
2799
}
2795
2800
2796
2801
CollectionJobState :: Finished {
@@ -2839,19 +2844,15 @@ impl VdafOps {
2839
2844
. map_err ( Error :: MessageEncode ) ?,
2840
2845
) ?;
2841
2846
2842
- Ok ( Some (
2843
- Collection :: < B > :: new (
2844
- PartialBatchSelector :: new (
2845
- B :: partial_batch_identifier ( collection_job. batch_identifier ( ) ) . clone ( ) ,
2846
- ) ,
2847
- * report_count,
2848
- * client_timestamp_interval,
2849
- encrypted_leader_aggregate_share,
2850
- encrypted_helper_aggregate_share. clone ( ) ,
2851
- )
2852
- . get_encoded ( )
2853
- . map_err ( Error :: MessageEncode ) ?,
2854
- ) )
2847
+ Ok ( CollectionJobResp :: < B > :: Finished {
2848
+ partial_batch_selector : PartialBatchSelector :: new (
2849
+ B :: partial_batch_identifier ( collection_job. batch_identifier ( ) ) . clone ( ) ,
2850
+ ) ,
2851
+ report_count : * report_count,
2852
+ interval : * client_timestamp_interval,
2853
+ leader_encrypted_agg_share : encrypted_leader_aggregate_share,
2854
+ helper_encrypted_agg_share : encrypted_helper_aggregate_share. clone ( ) ,
2855
+ } )
2855
2856
}
2856
2857
2857
2858
CollectionJobState :: Abandoned => Err ( Error :: AbandonedCollectionJob (
@@ -2863,6 +2864,11 @@ impl VdafOps {
2863
2864
Err ( Error :: DeletedCollectionJob ( * task. id ( ) , * collection_job_id) )
2864
2865
}
2865
2866
}
2867
+ . and_then ( |collection_job_resp| {
2868
+ collection_job_resp
2869
+ . get_encoded ( )
2870
+ . map_err ( Error :: MessageEncode )
2871
+ } )
2866
2872
}
2867
2873
2868
2874
#[ tracing:: instrument( skip( self , datastore, task) , fields( task_id = ?task. id( ) ) , err( level = Level :: DEBUG ) ) ]
0 commit comments