Modify SubstrateBlockAck as needed

Replaces plan IDs with key + ID, letting the coordinator determine the sessions
for the plans.

Properly scopes which plan IDs are set on which tributaries, and ensures we
have the necessary tributaries at time of handling.
This commit is contained in:
Luke Parker
2023-10-14 20:37:54 -04:00
parent 62e1d63f47
commit 584943d1e9
7 changed files with 62 additions and 18 deletions

View File

@@ -24,7 +24,7 @@ use serai_client::{
in_instructions::primitives::{InInstruction, InInstructionWithBalance, Batch},
SeraiCoins,
};
use messages::{sign::SignId, SubstrateContext, CoordinatorMessage};
use messages::{coordinator::PlanMeta, sign::SignId, SubstrateContext, CoordinatorMessage};
use crate::{*, tests::*};
@@ -346,7 +346,10 @@ async fn sign_test() {
messages::coordinator::ProcessorMessage::SubstrateBlockAck {
network: NetworkId::Bitcoin,
block: last_serai_block.number(),
plans: vec![plan_id],
plans: vec![PlanMeta {
key: (Secp256k1::generator() * *network_key).to_bytes().to_vec(),
id: plan_id,
}],
},
))
.await;

View File

@@ -5,7 +5,7 @@ use std::{
use dkg::{Participant, tests::clone_without};
use messages::{sign::SignId, SubstrateContext};
use messages::{coordinator::PlanMeta, sign::SignId, SubstrateContext};
use serai_client::{
primitives::{BlockHash, crypto::RuntimePublic, PublicKey, SeraiAddress, NetworkId},
@@ -155,7 +155,7 @@ pub(crate) async fn sign_batch(
pub(crate) async fn substrate_block(
coordinator: &mut Coordinator,
block: messages::substrate::CoordinatorMessage,
) -> Vec<[u8; 32]> {
) -> Vec<PlanMeta> {
match block.clone() {
messages::substrate::CoordinatorMessage::SubstrateBlock {
context: _,

View File

@@ -236,7 +236,7 @@ fn send_test() {
let (mut id, mut preprocesses) =
recv_sign_preprocesses(&mut coordinators, key_pair.1.to_vec(), 0).await;
// TODO: Should this use the Substrate key?
assert_eq!(id, SignId { key: key_pair.1.to_vec(), id: plans[0], attempt: 0 });
assert_eq!(id, SignId { key: key_pair.1.to_vec(), id: plans[0].id, attempt: 0 });
// Trigger a random amount of re-attempts
for attempt in 1 ..= u32::try_from(OsRng.next_u64() % 4).unwrap() {