Skip to content

Forbid changing aggregation job parameters#758

Merged
mendess merged 3 commits intomainfrom
mendess/agg-job-counting
Jan 13, 2025
Merged

Forbid changing aggregation job parameters#758
mendess merged 3 commits intomainfrom
mendess/agg-job-counting

Conversation

@mendess
Copy link
Collaborator

@mendess mendess commented Jan 9, 2025

This is important for implementing the async draft later

Copy link
Contributor

@cjpatton cjpatton left a 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?

@mendess mendess force-pushed the mendess/agg-job-counting branch 2 times, most recently from cd3effe to 895900a Compare January 9, 2025 18:05
@mendess mendess force-pushed the mendess/agg-job-counting branch from 895900a to 0447fd6 Compare January 9, 2025 18:10
Copy link
Contributor

@cjpatton cjpatton left a 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.

Comment on lines +63 to +72
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))
}
}
Copy link
Contributor

@cjpatton cjpatton Jan 9, 2025

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.

@mendess mendess force-pushed the mendess/agg-job-counting branch from d65f840 to 6e576ff Compare January 10, 2025 15:00
@mendess mendess merged commit 974dd0c into main Jan 13, 2025
4 checks passed
@mendess mendess deleted the mendess/agg-job-counting branch January 13, 2025 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants