Skip to content

Commit

Permalink
buckets->length
Browse files Browse the repository at this point in the history
  • Loading branch information
tgeoghegan committed Aug 14, 2023
1 parent 81fbab5 commit f8d4920
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 27 deletions.
4 changes: 2 additions & 2 deletions aggregator/src/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,8 @@ impl<C: Clock> TaskAggregator<C> {
VdafOps::Prio3SumVec(Arc::new(vdaf), verify_key)
}

VdafInstance::Prio3Histogram { buckets } => {
let vdaf = Prio3::new_histogram(2, *buckets)?;
VdafInstance::Prio3Histogram { length } => {
let vdaf = Prio3::new_histogram(2, *length)?;
let verify_key = task.primary_vdaf_verify_key()?;
VdafOps::Prio3Histogram(Arc::new(vdaf), verify_key)
}
Expand Down
8 changes: 4 additions & 4 deletions aggregator/src/aggregator/aggregation_job_creator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ impl<C: Clock + 'static> AggregationJobCreator<C> {
.await
}

(task::QueryType::TimeInterval, VdafInstance::Prio3Histogram { buckets }) => {
let vdaf = Arc::new(Prio3::new_histogram(2, *buckets)?);
(task::QueryType::TimeInterval, VdafInstance::Prio3Histogram { length }) => {
let vdaf = Arc::new(Prio3::new_histogram(2, *length)?);
self.create_aggregation_jobs_for_time_interval_task_no_param::<PRIO3_VERIFY_KEY_LENGTH, Prio3Histogram>(task, vdaf)
.await
}
Expand Down Expand Up @@ -404,9 +404,9 @@ impl<C: Clock + 'static> AggregationJobCreator<C> {
max_batch_size,
batch_time_window_size,
},
VdafInstance::Prio3Histogram { buckets },
VdafInstance::Prio3Histogram { length },
) => {
let vdaf = Arc::new(Prio3::new_histogram(2, *buckets)?);
let vdaf = Arc::new(Prio3::new_histogram(2, *length)?);
let max_batch_size = *max_batch_size;
let batch_time_window_size = *batch_time_window_size;
self.create_aggregation_jobs_for_fixed_size_task_no_param::<
Expand Down
4 changes: 2 additions & 2 deletions aggregator_core/src/datastore/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ async fn roundtrip_task(ephemeral_datastore: EphemeralDatastore) {
(VdafInstance::Prio3CountVec { length: 64 }, Role::Helper),
(VdafInstance::Prio3Sum { bits: 64 }, Role::Helper),
(VdafInstance::Prio3Sum { bits: 32 }, Role::Helper),
(VdafInstance::Prio3Histogram { buckets: 4 }, Role::Leader),
(VdafInstance::Prio3Histogram { buckets: 5 }, Role::Leader),
(VdafInstance::Prio3Histogram { length: 4 }, Role::Leader),
(VdafInstance::Prio3Histogram { length: 5 }, Role::Leader),
(VdafInstance::Poplar1 { bits: 8 }, Role::Helper),
(VdafInstance::Poplar1 { bits: 64 }, Role::Helper),
] {
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ fn json_encode_vdaf(vdaf: &VdafInstance) -> Value {
"bits": format!("{bits}"),
"length": format!("{length}"),
}),
VdafInstance::Prio3Histogram { buckets } => {
VdafInstance::Prio3Histogram { length } => {
json!({
"type": "Prio3Histogram",
"buckets": format!("{buckets}"),
"length": format!("{length}"),
})
}
_ => panic!("VDAF {vdaf:?} is not yet supported"),
Expand Down
6 changes: 4 additions & 2 deletions integration_tests/src/divviup_api_client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::anyhow;
use anyhow::{anyhow, Context};
use http::{
header::{ACCEPT, CONTENT_TYPE},
Method,
Expand Down Expand Up @@ -41,7 +41,9 @@ impl TryFrom<&VdafInstance> for ApiVdaf {
// we want.
// https://github.com/divviup/divviup-api/issues/410
Ok(ApiVdaf::Histogram {
buckets: (0..=length).collect(),
buckets: (0..=*length)
.map(|length| u64::try_from(length).context("cannot convert length to u64"))
.collect::<Result<Vec<_>, _>>()?,
})
}
_ => Err(anyhow!("unsupported VDAF: {vdaf:?}")),
Expand Down
10 changes: 5 additions & 5 deletions integration_tests/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,13 @@ pub async fn submit_measurements_and_verify_aggregate(
)
.await;
}
VdafInstance::Prio3Histogram { buckets } => {
let vdaf = Prio3::new_histogram(2, *buckets).unwrap();
VdafInstance::Prio3Histogram { length } => {
let vdaf = Prio3::new_histogram(2, *length).unwrap();

let mut aggregate_result = vec![0; *buckets];
aggregate_result.resize(*buckets, 0);
let mut aggregate_result = vec![0; *length];
aggregate_result.resize(*length, 0);
let measurements = iter::repeat_with(|| {
let choice = thread_rng().gen_range(0..*buckets);
let choice = thread_rng().gen_range(0..*length);
aggregate_result[choice] += 1;
choice
})
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/tests/divviup_ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async fn janus_divviup_ts_histogram() {

run_divviup_ts_integration_test(
&container_client(),
VdafInstance::Prio3Histogram { buckets: 4 },
VdafInstance::Prio3Histogram { length: 4 },
)
.await;
}
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/tests/in_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ async fn in_cluster_histogram() {

// Start port forwards and set up task.
let janus_pair = InClusterJanusPair::new(
VdafInstance::Prio3Histogram { buckets: 4 },
VdafInstance::Prio3Histogram { length: 4 },
QueryType::TimeInterval,
)
.await;
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/tests/janus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ async fn janus_janus_histogram_4_buckets() {
let container_client = container_client();
let janus_pair = JanusPair::new(
&container_client,
VdafInstance::Prio3Histogram { buckets: 4 },
VdafInstance::Prio3Histogram { length: 4 },
QueryType::TimeInterval,
)
.await;
Expand Down
4 changes: 2 additions & 2 deletions interop_binaries/src/bin/janus_interop_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ async fn handle_upload(
handle_upload_generic(http_client, vdaf_client, request, measurement).await?;
}

VdafInstance::Prio3Histogram { buckets } => {
VdafInstance::Prio3Histogram { length } => {
let measurement = parse_primitive_measurement::<usize>(request.measurement.clone())?;
let vdaf_client = Prio3::new_histogram(2, buckets)
let vdaf_client = Prio3::new_histogram(2, length)
.context("failed to construct Prio3Histogram VDAF")?;
handle_upload_generic(http_client, vdaf_client, request, measurement).await?;
}
Expand Down
8 changes: 4 additions & 4 deletions interop_binaries/src/bin/janus_interop_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ async fn handle_collection_start(
.await?
}

(ParsedQuery::TimeInterval(batch_interval), VdafInstance::Prio3Histogram { buckets }) => {
let vdaf = Prio3::new_histogram(2, buckets)
(ParsedQuery::TimeInterval(batch_interval), VdafInstance::Prio3Histogram { length }) => {
let vdaf = Prio3::new_histogram(2, length)
.context("failed to construct Prio3Histogram VDAF")?;
handle_collect_generic(
http_client,
Expand Down Expand Up @@ -581,8 +581,8 @@ async fn handle_collection_start(
.await?
}

(ParsedQuery::FixedSize(fixed_size_query), VdafInstance::Prio3Histogram { buckets }) => {
let vdaf = Prio3::new_histogram(2, buckets)
(ParsedQuery::FixedSize(fixed_size_query), VdafInstance::Prio3Histogram { length }) => {
let vdaf = Prio3::new_histogram(2, length)
.context("failed to construct Prio3Histogram VDAF")?;
handle_collect_generic(
http_client,
Expand Down
2 changes: 1 addition & 1 deletion interop_binaries/tests/end_to_end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ async fn e2e_prio3_histogram() {
QueryKind::TimeInterval,
json!({
"type": "Prio3Histogram",
"buckets": "6",
"length": "6",
}),
&[
json!("0"),
Expand Down

0 comments on commit f8d4920

Please sign in to comment.