From 9c25c4ef12395b0558acb65bb5f1d263d3a0acdc Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Wed, 31 Jan 2024 16:37:18 -0500 Subject: [PATCH] removed mmap dependency, removed unused imports --- Cargo.lock | 11 ----------- Cargo.toml | 5 ++--- bin/mpc_coordinator.rs | 3 +-- bin/mpc_participant.rs | 2 +- src/coordinator.rs | 6 +++--- src/distance.rs | 6 +++--- src/encoded_bits.rs | 2 +- 7 files changed, 11 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8fbbd69..0c612cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1620,16 +1620,6 @@ version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" -[[package]] -name = "memmap" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "metrics" version = "0.21.1" @@ -1712,7 +1702,6 @@ dependencies = [ "futures", "hex", "itertools 0.12.0", - "memmap", "metrics", "ordered-float 4.2.0", "proptest", diff --git a/Cargo.toml b/Cargo.toml index 33f0a09..d2a4650 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,13 +10,14 @@ bytemuck = { version = "1.14.1", features = ["derive"] } clap = { version = "4.4.18", features = ["derive", "env"] } config = "0.13.4" criterion = "0.5.1" +docker-db = { git = "https://github.com/Dzejkop/docker-db", rev = "ef9a4dfccd9cb9b4babeebfea0ba815e36afbafe" } dotenv = "0.15.0" eyre = "0.6.11" futures = "0.3.30" hex = { version = "0.4.3", features = ["serde"] } itertools = "0.12.0" -memmap = "0.7.0" metrics = "0.21.1" +ordered-float = "4.2.0" rand = "0.8.5" rayon = "1.8.1" serde = { version = "1.0.195", features = ["derive"] } @@ -27,12 +28,10 @@ sqlx = { version = "0.7.3", features = [ "postgres", "chrono", ] } -docker-db = { git = "https://github.com/Dzejkop/docker-db", rev = "ef9a4dfccd9cb9b4babeebfea0ba815e36afbafe" } telemetry-batteries = { git = "https://github.com/worldcoin/telemetry-batteries.git", rev = "c6816624415ae194da5203a5161621a9e10ad3b0" } tokio = { version = "1.35.1", features = ["macros"] } tracing = "0.1.40" tracing-subscriber = "0.3.18" -ordered-float = "4.2.0" [dev-dependencies] float_eq = "1.0.1" diff --git a/bin/mpc_coordinator.rs b/bin/mpc_coordinator.rs index 89b5974..41a81c2 100644 --- a/bin/mpc_coordinator.rs +++ b/bin/mpc_coordinator.rs @@ -1,7 +1,6 @@ use std::env; use std::path::PathBuf; -use aws_config::BehaviorVersion; use clap::Parser; use mpc::config::CoordinatorConfig; use mpc::coordinator::Coordinator; @@ -61,7 +60,7 @@ async fn main() -> eyre::Result<()> { .add_source(config::Environment::with_prefix("MPC").separator("__")) .build()?; - let config = settings.try_deserialize::()?; + let _config = settings.try_deserialize::()?; //TODO: update to use config instead of env vars let query_queue_url = env::var("AWS_QUERY_QUEUE")?; diff --git a/bin/mpc_participant.rs b/bin/mpc_participant.rs index 5e8e50f..b383f4d 100644 --- a/bin/mpc_participant.rs +++ b/bin/mpc_participant.rs @@ -55,7 +55,7 @@ async fn main() -> eyre::Result<()> { settings = settings.add_source(config::File::from(path).required(true)); } - let settings = settings + let _settings = settings .add_source(config::Environment::with_prefix("MPC").separator("__")) .build()?; diff --git a/src/coordinator.rs b/src/coordinator.rs index a4fe830..7a49b4b 100644 --- a/src/coordinator.rs +++ b/src/coordinator.rs @@ -1,11 +1,11 @@ use std::collections::BinaryHeap; -use std::fs::{File, OpenOptions}; + use std::net::SocketAddr; use std::sync::Arc; use std::time::Duration; use futures::future; -use memmap::Mmap; + use rayon::iter::{IntoParallelIterator, ParallelIterator}; use tokio::io::{AsyncReadExt, AsyncWriteExt, BufReader}; use tokio::net::TcpStream; @@ -157,7 +157,7 @@ impl Coordinator { // Collect futures of denominator and share batches let streams_future = future::try_join_all( participants.iter_mut().enumerate().map( - |(i, stream)| async move { + |(_i, stream)| async move { let mut batch = vec![[0_u16; 31]; BATCH_SIZE]; let mut buffer: &mut [u8] = bytemuck::cast_slice_mut(batch.as_mut_slice()); diff --git a/src/distance.rs b/src/distance.rs index 801b334..0b5ccb3 100644 --- a/src/distance.rs +++ b/src/distance.rs @@ -1,4 +1,4 @@ -use bytemuck::{Pod, Zeroable}; + use rayon::prelude::*; use serde::{Deserialize, Serialize}; @@ -211,7 +211,7 @@ mod tests { let query = &data[d.left]; let entry = &data[d.right]; - let encrypted = encode(&entry); + let encrypted = encode(entry); for (i, v) in encrypted.0.iter().enumerate() { match *v { u16::MAX => assert!(entry.mask[i] && entry.pattern[i]), @@ -222,7 +222,7 @@ mod tests { } // Encode entry - let preprocessed = encode(&query); + let preprocessed = encode(query); let distances = distances(&preprocessed, &[encrypted]).next().unwrap(); let denominators = diff --git a/src/encoded_bits.rs b/src/encoded_bits.rs index 293aada..e9bd530 100644 --- a/src/encoded_bits.rs +++ b/src/encoded_bits.rs @@ -6,7 +6,7 @@ use bytemuck::{cast_slice_mut, Pod, Zeroable}; use rand::distributions::{Distribution, Standard}; use rand::{thread_rng, Rng}; use serde::de::{SeqAccess, Visitor}; -use serde::{de, Deserialize, Deserializer, Serialize}; +use serde::{de, Deserialize, Deserializer}; use crate::bits::{Bits, BITS, COLS};