diff --git a/coordinator/src/db.rs b/coordinator/src/db.rs index 0704df8f6..2be5d63b0 100644 --- a/coordinator/src/db.rs +++ b/coordinator/src/db.rs @@ -67,19 +67,24 @@ impl MainDb { res } - fn first_preprocess_key(id: [u8; 32]) -> Vec { - Self::main_key(b"first_preprocess", id) - } - pub fn save_first_preprocess(txn: &mut D::Transaction<'_>, id: [u8; 32], preprocess: Vec) { - let key = Self::first_preprocess_key(id); + fn first_preprocess_key(network: NetworkId, id: [u8; 32]) -> Vec { + Self::main_key(b"first_preprocess", (network, id).encode()) + } + pub fn save_first_preprocess( + txn: &mut D::Transaction<'_>, + network: NetworkId, + id: [u8; 32], + preprocess: Vec, + ) { + let key = Self::first_preprocess_key(network, id); if let Some(existing) = txn.get(&key) { assert_eq!(existing, preprocess, "saved a distinct first preprocess"); return; } txn.put(key, preprocess); } - pub fn first_preprocess(getter: &G, id: [u8; 32]) -> Option> { - getter.get(Self::first_preprocess_key(id)) + pub fn first_preprocess(getter: &G, network: NetworkId, id: [u8; 32]) -> Option> { + getter.get(Self::first_preprocess_key(network, id)) } fn batch_key(network: NetworkId, id: u32) -> Vec { diff --git a/coordinator/src/main.rs b/coordinator/src/main.rs index 2a79b04f9..d4ba7641f 100644 --- a/coordinator/src/main.rs +++ b/coordinator/src/main.rs @@ -1,5 +1,3 @@ -#![allow(unused_variables)] - use core::{ops::Deref, future::Future}; use std::{ sync::Arc, @@ -203,7 +201,6 @@ impl::F>, recognized_id: RID, - p2p: P, processors: Pro, serai: Arc, mut new_tributary: broadcast::Receiver>, @@ -229,7 +225,6 @@ pub(crate) async fn scan_tributaries< let raw_db = raw_db.clone(); let key = key.clone(); let recognized_id = recognized_id.clone(); - let p2p = p2p.clone(); let processors = processors.clone(); let serai = serai.clone(); async move { @@ -305,7 +300,7 @@ pub async fn heartbeat_tributaries( let mut readers = vec![]; loop { - while let Ok(ActiveTributary { spec, tributary }) = { + while let Ok(ActiveTributary { spec: _, tributary }) = { match new_tributary.try_recv() { Ok(tributary) => Ok(tributary), Err(broadcast::error::TryRecvError::Empty) => Err(()), @@ -608,7 +603,7 @@ async fn handle_processor_messages( ProcessorMessage::Sign(msg) => match msg { sign::ProcessorMessage::Preprocess { id, preprocess } => { if id.attempt == 0 { - MainDb::::save_first_preprocess(&mut txn, id.id, preprocess); + MainDb::::save_first_preprocess(&mut txn, network, id.id, preprocess); None } else { @@ -668,7 +663,7 @@ async fn handle_processor_messages( // If this is the first attempt instance, wait until we synchronize around // the batch first if id.attempt == 0 { - MainDb::::save_first_preprocess(&mut txn, id.id, preprocess); + MainDb::::save_first_preprocess(&mut txn, spec.set().network, id.id, preprocess); Some(Transaction::Batch(block.0, id.id)) } else { @@ -942,7 +937,7 @@ pub async fn run( // This waits until the necessary preprocess is available let get_preprocess = |raw_db, id| async move { loop { - let Some(preprocess) = MainDb::::first_preprocess(raw_db, id) else { + let Some(preprocess) = MainDb::::first_preprocess(raw_db, network, id) else { sleep(Duration::from_millis(100)).await; continue; }; @@ -985,7 +980,6 @@ pub async fn run( raw_db, key.clone(), recognized_id, - p2p.clone(), processors.clone(), serai.clone(), new_tributary_listener_2, diff --git a/coordinator/src/substrate/mod.rs b/coordinator/src/substrate/mod.rs index 5ed4f7ac8..9ee96e52f 100644 --- a/coordinator/src/substrate/mod.rs +++ b/coordinator/src/substrate/mod.rs @@ -43,11 +43,10 @@ async fn in_set( Ok(Some(data.participants.iter().any(|(participant, _)| participant.0 == key))) } -async fn handle_new_set( +async fn handle_new_set( db: &mut D, key: &Zeroizing<::F>, create_new_tributary: CNT, - processors: &Pro, serai: &Serai, block: &Block, set: ValidatorSet, @@ -88,7 +87,6 @@ async fn handle_new_set( - key: &Zeroizing<::F>, processors: &Pro, serai: &Serai, block: &Block, @@ -239,8 +237,7 @@ async fn handle_block::handled_event(&db.0, hash, event_id) { log::info!("found fresh new set event {:?}", new_set); - handle_new_set(&mut db.0, key, create_new_tributary.clone(), processors, serai, &block, set) - .await?; + handle_new_set(&mut db.0, key, create_new_tributary.clone(), serai, &block, set).await?; let mut txn = db.0.txn(); SubstrateDb::::handle_event(&mut txn, hash, event_id); txn.commit(); @@ -259,7 +256,7 @@ async fn handle_block::set_key_pair(&mut txn, set, &key_pair); txn.commit(); - handle_key_gen(key, processors, serai, &block, set, key_pair).await?; + handle_key_gen(processors, serai, &block, set, key_pair).await?; } else { panic!("KeyGen event wasn't KeyGen: {key_gen:?}"); } diff --git a/coordinator/src/tests/tributary/dkg.rs b/coordinator/src/tests/tributary/dkg.rs index 874a78954..aa8ea7c94 100644 --- a/coordinator/src/tests/tributary/dkg.rs +++ b/coordinator/src/tests/tributary/dkg.rs @@ -281,7 +281,7 @@ async fn dkg_test() { let key_pair = (serai_client::Public(substrate_key), network_key.try_into().unwrap()); let mut txs = vec![]; - for (k, key) in keys.iter().enumerate() { + for key in keys.iter() { let attempt = 0; // This is fine to re-use the one DB as such, due to exactly how this specific call is coded, // albeit poor diff --git a/coordinator/src/tests/tributary/mod.rs b/coordinator/src/tests/tributary/mod.rs index fd198b8ed..be4a348b9 100644 --- a/coordinator/src/tests/tributary/mod.rs +++ b/coordinator/src/tests/tributary/mod.rs @@ -66,7 +66,7 @@ fn serialize_transaction() { // Create a valid vec of shares let mut shares = vec![]; // Create up to 512 participants - for i in 0 .. (OsRng.next_u64() % 512) { + for _ in 0 .. (OsRng.next_u64() % 512) { let mut share = vec![0; share_len]; OsRng.fill_bytes(&mut share); shares.push(share); diff --git a/coordinator/src/tributary/mod.rs b/coordinator/src/tributary/mod.rs index 9ae31ce1d..8ae0e7d6e 100644 --- a/coordinator/src/tributary/mod.rs +++ b/coordinator/src/tributary/mod.rs @@ -297,7 +297,7 @@ impl ReadWrite for Transaction { let share_len = usize::from(u16::from_le_bytes(share_len)); let mut shares = vec![]; - for i in 0 .. u16::from_le_bytes(share_quantity) { + for _ in 0 .. u16::from_le_bytes(share_quantity) { let mut share = vec![0; share_len]; reader.read_exact(&mut share)?; shares.push(share); @@ -490,7 +490,7 @@ impl TransactionTrait for Transaction { } } - if let Transaction::SignCompleted { plan, tx_hash, first_signer, signature } = self { + if let Transaction::SignCompleted { first_signer, signature, .. } = self { if !signature.verify(*first_signer, self.sign_completed_challenge()) { Err(TransactionError::InvalidContent)?; }