-
Notifications
You must be signed in to change notification settings - Fork 23
Forbid changing aggregation job parameters #758
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,23 @@ | ||
| // Copyright (c) 2024 Cloudflare, Inc. All rights reserved. | ||
| // Copyright (c) 2025 Cloudflare, Inc. All rights reserved. | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| use axum::async_trait; | ||
| use daphne::roles::DapHelper; | ||
| use daphne::{ | ||
| messages::{request::AggregationJobRequestHash, AggregationJobId, TaskId}, | ||
| roles::DapHelper, | ||
| DapError, DapVersion, | ||
| }; | ||
|
|
||
| #[async_trait] | ||
| impl DapHelper for crate::App {} | ||
| impl DapHelper for crate::App { | ||
| async fn assert_agg_job_is_immutable( | ||
| &self, | ||
| _id: AggregationJobId, | ||
| _version: DapVersion, | ||
| _task_id: &TaskId, | ||
| _req: &AggregationJobRequestHash, | ||
| ) -> Result<(), DapError> { | ||
| // the server implementation can't check for this | ||
| Ok(()) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,12 @@ | ||
| // Copyright (c) 2024 Cloudflare, Inc. All rights reserved. | ||
| // Copyright (c) 2025 Cloudflare, Inc. All rights reserved. | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| fn main() { | ||
| #[cfg(feature = "durable_requests")] | ||
| ::capnpc::CompilerCommand::new() | ||
| .file("./src/capnproto/base.capnp") | ||
| .file("./src/durable_requests/durable_request.capnp") | ||
| .file("./src/durable_requests/bindings/aggregation_job_store.capnp") | ||
| .run() | ||
| .expect("compiling schema"); | ||
| } |
11 changes: 11 additions & 0 deletions
11
crates/daphne-service-utils/src/durable_requests/bindings/aggregation_job_store.capnp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Copyright (c) 2025 Cloudflare, Inc. All rights reserved. | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| @0xa11edd1197dbcf0b; | ||
|
|
||
| using Base = import "../../capnproto/base.capnp"; | ||
|
|
||
| struct NewJobRequest { | ||
| id @0 :Base.AggregationJobId; | ||
| aggJobHash @1 :Data; | ||
| } |
63 changes: 63 additions & 0 deletions
63
crates/daphne-service-utils/src/durable_requests/bindings/aggregation_job_store.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // Copyright (c) 2025 Cloudflare, Inc. All rights reserved. | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| use crate::{ | ||
| aggregation_job_store_capnp::new_job_request, | ||
| capnproto::{CapnprotoPayloadDecode, CapnprotoPayloadEncode}, | ||
| durable_requests::ObjectIdFrom, | ||
| }; | ||
| use daphne::{ | ||
| messages::{AggregationJobId, TaskId}, | ||
| DapVersion, | ||
| }; | ||
| use serde::{Deserialize, Serialize}; | ||
| use std::borrow::Cow; | ||
|
|
||
| super::define_do_binding! { | ||
| const BINDING = "AGGREGATION_JOB_STORE"; | ||
|
|
||
| enum Command { | ||
| NewJob = "/new-job", | ||
| ListJobIds = "/job-ids", | ||
| } | ||
|
|
||
| fn name((version, task_id): (DapVersion, &'n TaskId)) -> ObjectIdFrom { | ||
| ObjectIdFrom::Name(format!("{version}/task/{task_id}")) | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug)] | ||
| pub struct NewJobRequest<'h> { | ||
| pub id: AggregationJobId, | ||
| pub agg_job_hash: Cow<'h, [u8]>, | ||
| } | ||
|
|
||
| impl CapnprotoPayloadEncode for NewJobRequest<'_> { | ||
| type Builder<'a> = new_job_request::Builder<'a>; | ||
|
|
||
| fn encode_to_builder(&self, mut builder: Self::Builder<'_>) { | ||
| self.id.encode_to_builder(builder.reborrow().init_id()); | ||
| builder.set_agg_job_hash(&self.agg_job_hash); | ||
| } | ||
| } | ||
|
|
||
| impl CapnprotoPayloadDecode for NewJobRequest<'static> { | ||
| type Reader<'a> = new_job_request::Reader<'a>; | ||
|
|
||
| fn decode_from_reader(reader: Self::Reader<'_>) -> capnp::Result<Self> | ||
| where | ||
| Self: Sized, | ||
| { | ||
| Ok(Self { | ||
| id: <_>::decode_from_reader(reader.get_id()?)?, | ||
| agg_job_hash: reader.get_agg_job_hash()?.to_vec().into(), | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Serialize, Deserialize)] | ||
| pub enum NewJobResponse { | ||
| Ok, | ||
| /// Request would change an existing aggregation job's parameters. | ||
| IllegalJobParameters, | ||
mendess marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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:HashedAggregationJobReqis not a DAP protocol message, so arguably doesn't belong in themessagesmodule.I think I would have done this differently:
Note that this also enforces that there is nothing left to read in
bytes.