Skip to content

Commit

Permalink
update result contract to the latest agreement (#248)
Browse files Browse the repository at this point in the history
* update result contract to the latest agreement

* make serial_id and matched_serial_ids optional

* do not change the deployed version to not block others

* send None matches for a non-match
  • Loading branch information
eaypek-tfh authored Aug 19, 2024
1 parent c758d7d commit 606753b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 17 deletions.
22 changes: 15 additions & 7 deletions iris-mpc-common/src/helpers/sqs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,27 @@ impl SMPCRequest {

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ResultEvent {
pub node_id: usize,
pub db_index: u32,
pub is_match: bool,
pub request_id: String,
pub node_id: usize,
pub serial_id: Option<u32>,
pub is_match: bool,
pub signup_id: String,
pub matched_serial_ids: Option<Vec<u32>>,
}

impl ResultEvent {
pub fn new(node_id: usize, db_index: u32, is_match: bool, request_id: String) -> Self {
pub fn new(
node_id: usize,
serial_id: Option<u32>,
is_match: bool,
signup_id: String,
matched_serial_ids: Option<Vec<u32>>,
) -> Self {
Self {
node_id,
db_index,
serial_id,
is_match,
request_id,
signup_id,
matched_serial_ids,
}
}
}
9 changes: 7 additions & 2 deletions iris-mpc-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,13 @@ mod tests {
};
let codes_and_masks = vec![iris; count];

let result_event =
serde_json::to_string(&ResultEvent::new(0, 1_000_000_000, false, "A".repeat(64)))?;
let result_event = serde_json::to_string(&ResultEvent::new(
0,
Some(1_000_000_000),
false,
"A".repeat(64),
None,
))?;
let result_events = vec![result_event; count];

let mut tx = store.tx().await?;
Expand Down
15 changes: 9 additions & 6 deletions iris-mpc/src/bin/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ async fn main() -> eyre::Result<()> {
println!("Received result: {:?}", result);

let tmp = thread_expected_results.lock().await;
let expected_result = tmp.get(&result.request_id);
let expected_result = tmp.get(&result.signup_id);
if expected_result.is_none() {
eprintln!(
"No expected result found for request_id: {}, the SQS message is likely \
stale, clear the queue",
result.request_id
result.signup_id
);
continue;
}
Expand All @@ -123,18 +123,21 @@ async fn main() -> eyre::Result<()> {
let request = thread_requests
.lock()
.await
.get(&result.request_id)
.get(&result.signup_id)
.unwrap()
.clone();
thread_responses
.lock()
.await
.insert(result.db_index, request);
.insert(result.serial_id.unwrap(), request);
} else {
// Existing entry
println!("Expected: {:?} Got: {:?}", expected_result, result.db_index);
println!(
"Expected: {:?} Got: {:?}",
expected_result, result.serial_id
);
assert!(result.is_match);
assert_eq!(result.db_index, expected_result.unwrap());
assert_eq!(result.serial_id.unwrap(), expected_result.unwrap());
}

sqs_client
Expand Down
12 changes: 10 additions & 2 deletions iris-mpc/src/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,16 @@ async fn server_main(config: Config) -> eyre::Result<()> {
.iter()
.enumerate()
.map(|(i, &idx_result)| {
let result_event =
ResultEvent::new(party_id, idx_result, matches[i], request_ids[i].clone());
// TODO: return the actual serial ids. Skipped for now in order not to create
// big conflicts with in progress PRs.
let dummy_matched_serial_ids = Some(vec![]);
let result_event = ResultEvent::new(
party_id,
Option::from(idx_result),
matches[i],
request_ids[i].clone(),
dummy_matched_serial_ids,
);

serde_json::to_string(&result_event).wrap_err("failed to serialize result")
})
Expand Down

0 comments on commit 606753b

Please sign in to comment.