Route KeyPair so Tributary can construct SignId as needed

This commit is contained in:
Luke Parker
2023-08-25 18:37:22 -04:00
parent 3745f8b6af
commit f249e20028
3 changed files with 43 additions and 5 deletions

View File

@@ -23,7 +23,11 @@ use processor_messages::{SubstrateContext, key_gen::KeyGenId, CoordinatorMessage
use tokio::time::sleep;
use crate::{Db, processors::Processors, tributary::TributarySpec};
use crate::{
Db,
processors::Processors,
tributary::{TributarySpec, TributaryDb},
};
mod db;
pub use db::*;
@@ -298,6 +302,12 @@ async fn handle_block<
if !SubstrateDb::<D>::handled_event(&db.0, hash, event_id) {
log::info!("found fresh key gen event {:?}", key_gen);
if let ValidatorSetsEvent::KeyGen { set, key_pair } = key_gen {
// Immediately ensure this key pair is accessible to the tributary, before we fire any
// events off of it
let mut txn = db.0.txn();
TributaryDb::<D>::set_key_pair(&mut txn, set, &key_pair);
txn.commit();
handle_key_gen(key, processors, serai, &block, set, key_pair).await?;
} else {
panic!("KeyGen event wasn't KeyGen: {key_gen:?}");