Skip to content

Commit

Permalink
Set SeraiBlockNumber in cosign.rs as it's used by the cosigning protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
kayabaNerve committed Dec 10, 2023
1 parent 7fa4c33 commit 18303c5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
5 changes: 4 additions & 1 deletion coordinator/src/substrate/cosign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use serai_client::{

use serai_db::*;

use crate::{Db, substrate::in_set};
use crate::{Db, substrate::in_set, tributary::SeraiBlockNumber};

// 5 minutes, expressed in blocks
// TODO: Pull a constant for block time
Expand Down Expand Up @@ -233,6 +233,9 @@ pub async fn advance_cosign_protocol(
.await?
.expect("couldn't get block which should've been finalized");

// Save the block number for this block, as needed by the cosigner to perform cosigning
SeraiBlockNumber::set(&mut txn, actual_block.hash(), &block);

if potentially_cosign_block(&mut txn, serai, block, skipped_block, window_end_exclusive).await?
{
to_cosign = Some((block, actual_block.hash()));
Expand Down
12 changes: 1 addition & 11 deletions coordinator/src/substrate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ use processor_messages::SubstrateContext;

use tokio::{sync::mpsc, time::sleep};

use crate::{
Db,
processors::Processors,
tributary::{TributarySpec, SeraiBlockNumber},
};
use crate::{Db, processors::Processors, tributary::TributarySpec};

mod db;
pub use db::*;
Expand Down Expand Up @@ -356,12 +352,6 @@ async fn handle_new_blocks<D: Db, Pro: Processors>(
.await?
.expect("couldn't get block before the latest finalized block");

// Save the block number for this block, as needed by the Tributary code
// TODO: Review why this is?
let mut txn = db.txn();
SeraiBlockNumber::set(&mut txn, block.hash(), &b);
txn.commit();

log::info!("handling substrate block {b}");
handle_block(db, key, new_tributary_spec, tributary_retired, processors, serai, block).await?;
*next_block += 1;
Expand Down
2 changes: 1 addition & 1 deletion coordinator/src/tests/tributary/dkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ async fn dkg_test() {
for (i, key) in keys.iter().enumerate() {
handle_new_blocks::<_, _, _, _, _, _, _, _, LocalP2p>(
&mut dbs[i],
&key,
key,
|_, _, _, _| async { panic!("provided TX caused recognized_id to be called after shares") },
&processors,
|_, _, _| async { panic!("test tried to publish a new Serai TX") },
Expand Down

0 comments on commit 18303c5

Please sign in to comment.