mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Move where we trigger KeyGen to avoid a race condition
We only expect processor messages when we have the relevant Tributary. We queued Tributary creation, yet then kicked off processor messages. We need to wait until the Tributary is actually created to kick off processor messages.
This commit is contained in:
@@ -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<D: Db, Pro: Processors, P: P2p>(
|
||||
break;
|
||||
}
|
||||
}
|
||||
spec.unwrap()
|
||||
spec.expect("received message from processor we don't have a tributary for")
|
||||
};
|
||||
|
||||
let genesis = spec.genesis();
|
||||
|
||||
Reference in New Issue
Block a user