Cleanup DB handling a bit in key-gen/attempt-manager

This commit is contained in:
Luke Parker
2024-08-19 00:41:18 -04:00
parent 1e8a9ec5bd
commit 2f3bd7a02a
6 changed files with 77 additions and 27 deletions

View File

@@ -182,7 +182,7 @@ impl<P: KeyGenParams, D: Db> KeyGen<P, D> {
match msg {
CoordinatorMessage::GenerateKey { session, threshold, evrf_public_keys } => {
log::info!("Generating new key. Session: {session:?}");
log::info!("generating new key, session: {session:?}");
// Unzip the vector of eVRF keys
let substrate_evrf_public_keys =
@@ -258,7 +258,7 @@ impl<P: KeyGenParams, D: Db> KeyGen<P, D> {
}
CoordinatorMessage::Participation { session, participant, participation } => {
log::info!("received participation from {:?} for {:?}", participant, session);
log::debug!("received participation from {:?} for {:?}", participant, session);
let Params { t: threshold, n, substrate_evrf_public_keys, network_evrf_public_keys } =
KeyGenDb::<P>::params(txn, session).unwrap();
@@ -293,7 +293,7 @@ impl<P: KeyGenParams, D: Db> KeyGen<P, D> {
// participations and continue. We solely have to verify them, as to identify malicious
// participants and prevent DoSs, before returning
if self.key_shares(session).is_some() {
log::info!("already finished generating a key for {:?}", session);
log::debug!("already finished generating a key for {:?}", session);
match EvrfDkg::<Ristretto>::verify(
&mut OsRng,
@@ -511,6 +511,8 @@ impl<P: KeyGenParams, D: Db> KeyGen<P, D> {
}
KeyGenDb::<P>::set_key_shares(txn, session, &substrate_keys, &network_keys);
log::info!("generated key, session: {session:?}");
// Since no one we verified was invalid, and we had the threshold, yield the new keys
vec![ProcessorMessage::GeneratedKeyPair {
session,