-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forbid changing aggregation job parameters #758
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good, just one blocking comment: Is it feasible to hash the AggregationJobInitReq before decoding?
crates/daphne-service-utils/src/durable_requests/bindings/aggregation_job_store.rs
Outdated
Show resolved
Hide resolved
crates/daphne-service-utils/src/durable_requests/bindings/aggregation_job_store.rs
Show resolved
Hide resolved
crates/daphne-service-utils/src/durable_requests/bindings/aggregation_job_store.rs
Outdated
Show resolved
Hide resolved
cd3effe
to
895900a
Compare
895900a
to
0447fd6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the decode-then-hash issue, I think this is good to go. I have one more suggestion there.
crates/daphne-service-utils/src/durable_requests/bindings/aggregation_job_store.rs
Outdated
Show resolved
Hide resolved
impl DecodeFromDapHttpBody for HashedAggregationJobReq { | ||
fn decode_from_http_body(bytes: Bytes, meta: &DapRequestMeta) -> Result<Self, DapAbort> { | ||
let mut cursor = Cursor::new(bytes.as_ref()); | ||
// Check that media type matches. | ||
meta.get_checked_media_type(DapMediaType::AggregationJobInitReq)?; | ||
// Decode the body | ||
HashedAggregationJobReq::decode_with_param(&meta.version, &mut cursor) | ||
.map_err(|e| DapAbort::from_codec_error(e, meta.task_id)) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hashing with HashedAggregationJobReq::decode_with_param()
is a little awkward because you have to keep track of the start and end of the message in the cursor. Also, and this is very nit picky: HashedAggregationJobReq
is not a DAP protocol message, so arguably doesn't belong in the messages
module.
I think I would have done this differently:
impl DecodeFromDapHttpBody for HashedAggregationJobReq {
fn decode_from_http_body(bytes: Bytes, meta: &DapRequestMeta) -> Result<Self, DapAbort> {
// Check that media type matches.
meta.get_checked_media_type(DapMediaType::AggregationJobInitReq)?;
// Decode the body
let agg_job_req = AggregationJobReq::get_decoded_with_param(&meta.version, bytes.as_ref())
.map_err(|e| DapAbort::from_codec_error(e, meta.task_id))?;
Ok(Self{
agg_job_req:
hash: sha256(bytes.as_ref()),
})
}
}
Note that this also enforces that there is nothing left to read in bytes
.
This is important for implementing the async draft later