diff --git a/coordinator/src/main.rs b/coordinator/src/main.rs index 183c010f..1c49d650 100644 --- a/coordinator/src/main.rs +++ b/coordinator/src/main.rs @@ -179,6 +179,27 @@ pub async fn scan_tributaries< ) .await; + // Trigger a DKG for the newly added Tributary + let set = spec.set(); + processors + .send( + set.network, + processor_messages::CoordinatorMessage::KeyGen( + processor_messages::key_gen::CoordinatorMessage::GenerateKey { + id: processor_messages::key_gen::KeyGenId { set, attempt: 0 }, + params: frost::ThresholdParams::new( + spec.t(), + spec.n(), + spec + .i(Ristretto::generator() * key.deref()) + .expect("adding a tribuary for a set we aren't in set for"), + ) + .unwrap(), + }, + ), + ) + .await; + tributary_readers.push((spec, reader)); } } @@ -438,7 +459,7 @@ pub async fn handle_processors( break; } } - spec.unwrap() + spec.expect("received message from processor we don't have a tributary for") }; let genesis = spec.genesis(); diff --git a/coordinator/src/substrate/mod.rs b/coordinator/src/substrate/mod.rs index 19d76ff9..b6bb3608 100644 --- a/coordinator/src/substrate/mod.rs +++ b/coordinator/src/substrate/mod.rs @@ -4,7 +4,6 @@ use std::collections::{HashSet, HashMap}; use zeroize::Zeroizing; use ciphersuite::{group::GroupEncoding, Ciphersuite, Ristretto}; -use frost::ThresholdParams; use serai_client::{ SeraiError, Block, Serai, @@ -19,7 +18,7 @@ use serai_client::{ use serai_db::DbTxn; -use processor_messages::{SubstrateContext, key_gen::KeyGenId, CoordinatorMessage}; +use processor_messages::{SubstrateContext, CoordinatorMessage}; use tokio::time::sleep; @@ -86,28 +85,6 @@ async fn handle_new_set< let spec = TributarySpec::new(block.hash(), time, set, set_data); create_new_tributary(db, spec.clone()).await; - - // Trigger a DKG - // TODO: Check how the processor handles this being fired multiple times - // We already have a unique event ID based on block, event index (where event index is - // the one generated in this handle_block function) - // We could use that on this end and the processor end? - processors - .send( - set.network, - CoordinatorMessage::KeyGen(processor_messages::key_gen::CoordinatorMessage::GenerateKey { - id: KeyGenId { set, attempt: 0 }, - params: ThresholdParams::new( - spec.t(), - spec.n(), - spec - .i(Ristretto::generator() * key.deref()) - .expect("In set for a set we aren't in set for"), - ) - .unwrap(), - }), - ) - .await; } else { log::info!("not present in set {:?}", set); }