Have processor-messages use CosignIntent/SignedCosign, not the historic cosign format

Has yet to update the processor accordingly.
This commit is contained in:
Luke Parker
2025-01-12 05:52:33 -05:00
parent 158140c3a7
commit e7de5125a2
8 changed files with 115 additions and 70 deletions

1
Cargo.lock generated
View File

@@ -8998,6 +8998,7 @@ dependencies = [
"hex", "hex",
"parity-scale-codec", "parity-scale-codec",
"serai-coins-primitives", "serai-coins-primitives",
"serai-cosign",
"serai-in-instructions-primitives", "serai-in-instructions-primitives",
"serai-primitives", "serai-primitives",
"serai-validator-sets-primitives", "serai-validator-sets-primitives",

View File

@@ -88,7 +88,6 @@ impl<D: Db> ContinuallyRan for CosignIntendTask<D> {
} }
let block_hash = block.hash(); let block_hash = block.hash();
SubstrateBlockHash::set(&mut txn, block_number, &block_hash); SubstrateBlockHash::set(&mut txn, block_number, &block_hash);
SubstrateBlockNumber::set(&mut txn, block_hash, &block_number);
let global_session_for_this_block = LatestGlobalSessionIntended::get(&txn); let global_session_for_this_block = LatestGlobalSessionIntended::get(&txn);

View File

@@ -8,7 +8,7 @@ use serai_client::{
validator_sets::primitives::{Session, ValidatorSet}, validator_sets::primitives::{Session, ValidatorSet},
}; };
use serai_cosign::CosignIntent; use serai_cosign::SignedCosign;
use serai_coordinator_substrate::NewSetInformation; use serai_coordinator_substrate::NewSetInformation;
@@ -66,14 +66,24 @@ pub(crate) fn prune_tributary_db(set: ValidatorSet) {
create_db! { create_db! {
Coordinator { Coordinator {
// The currently active Tributaries
ActiveTributaries: () -> Vec<NewSetInformation>, ActiveTributaries: () -> Vec<NewSetInformation>,
// The latest Tributary to have been retired for a network
// Since Tributaries are retired sequentially, this is informative to if any Tributary has been
// retired
RetiredTributary: (network: NetworkId) -> Session, RetiredTributary: (network: NetworkId) -> Session,
// The last handled message from a Processor
LastProcessorMessage: (network: NetworkId) -> u64,
// Cosigns we produced and tried to intake yet incurred an error while doing so
ErroneousCosigns: () -> Vec<SignedCosign>,
} }
} }
db_channel! { db_channel! {
Coordinator { Coordinator {
// Tributaries to clean up upon reboot
TributaryCleanup: () -> ValidatorSet, TributaryCleanup: () -> ValidatorSet,
PendingCosigns: (set: ValidatorSet) -> CosignIntent, // Cosigns we produced
SignedCosigns: () -> SignedCosign,
} }
} }

View File

@@ -8,7 +8,7 @@ use ciphersuite::{Ciphersuite, Ristretto};
use tokio::sync::mpsc; use tokio::sync::mpsc;
use serai_db::{DbTxn, Db as DbTrait}; use serai_db::{Get, DbTxn, Db as DbTrait, create_db, db_channel};
use scale::Encode; use scale::Encode;
use serai_client::validator_sets::primitives::ValidatorSet; use serai_client::validator_sets::primitives::ValidatorSet;
@@ -19,16 +19,23 @@ use serai_task::{Task, TaskHandle, ContinuallyRan};
use message_queue::{Service, Metadata, client::MessageQueue}; use message_queue::{Service, Metadata, client::MessageQueue};
use serai_cosign::Cosigning; use serai_cosign::{Faulted, CosignIntent, Cosigning};
use serai_coordinator_substrate::{NewSetInformation, SignSlashReport}; use serai_coordinator_substrate::{NewSetInformation, SignSlashReport};
use serai_coordinator_tributary::{Transaction, ProcessorMessages, ScanTributaryTask}; use serai_coordinator_tributary::{Transaction, ProcessorMessages, CosignIntents, ScanTributaryTask};
use serai_coordinator_p2p::P2p; use serai_coordinator_p2p::P2p;
use crate::Db; use crate::Db;
db_channel! {
Coordinator {
PendingCosigns: (set: ValidatorSet) -> CosignIntent,
}
}
/// Provides Cosign/Cosigned Transactions onto the Tributary. /// Provides Cosign/Cosigned Transactions onto the Tributary.
pub(crate) struct ProvideCosignCosignedTransactionsTask<CD: DbTrait, TD: DbTrait, P: P2p> { pub(crate) struct ProvideCosignCosignedTransactionsTask<CD: DbTrait, TD: DbTrait, P: P2p> {
db: CD, db: CD,
tributary_db: TD,
set: NewSetInformation, set: NewSetInformation,
tributary: Tributary<TD, Transaction, P>, tributary: Tributary<TD, Transaction, P>,
} }
@@ -79,16 +86,27 @@ impl<CD: DbTrait, TD: DbTrait, P: P2p> ContinuallyRan
let mut txn = self.db.txn(); let mut txn = self.db.txn();
// Fetch the next cosign this tributary should handle // Fetch the next cosign this tributary should handle
let Some(cosign) = crate::PendingCosigns::try_recv(&mut txn, self.set.set) else { break }; let Some(cosign) = PendingCosigns::try_recv(&mut txn, self.set.set) else { break };
pending_notable_cosign = cosign.notable; pending_notable_cosign = cosign.notable;
// If we (Serai) haven't cosigned this block, break as this is still pending // If we (Serai) haven't cosigned this block, break as this is still pending
let Ok(latest) = Cosigning::<CD>::latest_cosigned_block_number(&txn) else { break }; let latest = match Cosigning::<CD>::latest_cosigned_block_number(&txn) {
Ok(latest) => latest,
Err(Faulted) => {
log::error!("cosigning faulted");
Err("cosigning faulted")?
}
};
if latest < cosign.block_number { if latest < cosign.block_number {
break; break;
} }
// Because we've cosigned it, provide the TX for that // Because we've cosigned it, provide the TX for that
{
let mut txn = self.tributary_db.txn();
CosignIntents::provide(&mut txn, self.set.set, &cosign);
txn.commit();
}
provide_transaction( provide_transaction(
self.set.set, self.set.set,
&self.tributary, &self.tributary,
@@ -109,7 +127,7 @@ impl<CD: DbTrait, TD: DbTrait, P: P2p> ContinuallyRan
// intended_cosigns will only yield up to and including the next notable cosign // intended_cosigns will only yield up to and including the next notable cosign
for cosign in Cosigning::<CD>::intended_cosigns(&mut txn, self.set.set) { for cosign in Cosigning::<CD>::intended_cosigns(&mut txn, self.set.set) {
// Flag this cosign as pending // Flag this cosign as pending
crate::PendingCosigns::send(&mut txn, self.set.set, &cosign); PendingCosigns::send(&mut txn, self.set.set, &cosign);
// Provide the transaction to queue it for work // Provide the transaction to queue it for work
provide_transaction( provide_transaction(
self.set.set, self.set.set,
@@ -293,6 +311,7 @@ pub(crate) async fn spawn_tributary<P: P2p>(
tokio::spawn( tokio::spawn(
(ProvideCosignCosignedTransactionsTask { (ProvideCosignCosignedTransactionsTask {
db: db.clone(), db: db.clone(),
tributary_db: tributary_db.clone(),
set: set.clone(), set: set.clone(),
tributary: tributary.clone(), tributary: tributary.clone(),
}) })
@@ -313,7 +332,7 @@ pub(crate) async fn spawn_tributary<P: P2p>(
// Spawn the scan task // Spawn the scan task
let (scan_tributary_task_def, scan_tributary_task) = Task::new(); let (scan_tributary_task_def, scan_tributary_task) = Task::new();
tokio::spawn( tokio::spawn(
ScanTributaryTask::<_, _, P>::new(db.clone(), tributary_db.clone(), &set, reader) ScanTributaryTask::<_, P>::new(tributary_db.clone(), &set, reader)
// This is the only handle for this TributaryProcessorMessagesTask, so when this task is // This is the only handle for this TributaryProcessorMessagesTask, so when this task is
// dropped, it will be too // dropped, it will be too
.continually_run(scan_tributary_task_def, vec![scan_tributary_messages_task]), .continually_run(scan_tributary_task_def, vec![scan_tributary_messages_task]),

View File

@@ -9,6 +9,8 @@ use messages::sign::{VariantSignId, SignId};
use serai_db::*; use serai_db::*;
use serai_cosign::CosignIntent;
use crate::transaction::SigningProtocolRound; use crate::transaction::SigningProtocolRound;
/// A topic within the database which the group participates in /// A topic within the database which the group participates in
@@ -187,6 +189,8 @@ create_db!(
// The slash points a validator has accrued, with u32::MAX representing a fatal slash. // The slash points a validator has accrued, with u32::MAX representing a fatal slash.
SlashPoints: (set: ValidatorSet, validator: SeraiAddress) -> u32, SlashPoints: (set: ValidatorSet, validator: SeraiAddress) -> u32,
// The cosign intent for a Substrate block
CosignIntents: (set: ValidatorSet, substrate_block_hash: [u8; 32]) -> CosignIntent,
// The latest Substrate block to cosign. // The latest Substrate block to cosign.
LatestSubstrateBlockToCosign: (set: ValidatorSet) -> [u8; 32], LatestSubstrateBlockToCosign: (set: ValidatorSet) -> [u8; 32],
// The hash of the block we're actively cosigning. // The hash of the block we're actively cosigning.

View File

@@ -24,7 +24,7 @@ use tributary_sdk::{
Transaction as TributaryTransaction, Block, TributaryReader, P2p, Transaction as TributaryTransaction, Block, TributaryReader, P2p,
}; };
use serai_cosign::Cosigning; use serai_cosign::CosignIntent;
use serai_coordinator_substrate::NewSetInformation; use serai_coordinator_substrate::NewSetInformation;
use messages::sign::VariantSignId; use messages::sign::VariantSignId;
@@ -45,17 +45,34 @@ impl ProcessorMessages {
} }
} }
struct ScanBlock<'a, CD: Db, TD: Db, TDT: DbTxn, P: P2p> { /// The cosign intents.
pub struct CosignIntents;
impl CosignIntents {
/// Provide a CosignIntent for this Tributary.
///
/// This must be done before the associated `Transaction::Cosign` is provided.
pub fn provide(txn: &mut impl DbTxn, set: ValidatorSet, intent: &CosignIntent) {
db::CosignIntents::set(txn, set, intent.block_hash, intent);
}
fn take(
txn: &mut impl DbTxn,
set: ValidatorSet,
substrate_block_hash: [u8; 32],
) -> Option<CosignIntent> {
db::CosignIntents::take(txn, set, substrate_block_hash)
}
}
struct ScanBlock<'a, TD: Db, TDT: DbTxn, P: P2p> {
_td: PhantomData<TD>, _td: PhantomData<TD>,
_p2p: PhantomData<P>, _p2p: PhantomData<P>,
cosign_db: &'a CD,
tributary_txn: &'a mut TDT, tributary_txn: &'a mut TDT,
set: ValidatorSet, set: ValidatorSet,
validators: &'a [SeraiAddress], validators: &'a [SeraiAddress],
total_weight: u64, total_weight: u64,
validator_weights: &'a HashMap<SeraiAddress, u64>, validator_weights: &'a HashMap<SeraiAddress, u64>,
} }
impl<'a, CD: Db, TD: Db, TDT: DbTxn, P: P2p> ScanBlock<'a, CD, TD, TDT, P> { impl<'a, TD: Db, TDT: DbTxn, P: P2p> ScanBlock<'a, TD, TDT, P> {
fn potentially_start_cosign(&mut self) { fn potentially_start_cosign(&mut self) {
// Don't start a new cosigning instance if we're actively running one // Don't start a new cosigning instance if we're actively running one
if TributaryDb::actively_cosigning(self.tributary_txn, self.set).is_some() { if TributaryDb::actively_cosigning(self.tributary_txn, self.set).is_some() {
@@ -74,20 +91,20 @@ impl<'a, CD: Db, TD: Db, TDT: DbTxn, P: P2p> ScanBlock<'a, CD, TD, TDT, P> {
return; return;
} }
let Some(substrate_block_number) = let intent =
Cosigning::<CD>::finalized_block_number(self.cosign_db, latest_substrate_block_to_cosign) CosignIntents::take(self.tributary_txn, self.set, latest_substrate_block_to_cosign)
else { .expect("Transaction::Cosign locally provided but CosignIntents wasn't populated");
// This is a valid panic as we shouldn't be scanning this block if we didn't provide all assert_eq!(
// Provided transactions within it, and the block to cosign is a Provided transaction intent.block_hash, latest_substrate_block_to_cosign,
panic!("cosigning a block our cosigner didn't index") "provided CosignIntent wasn't saved by its block hash"
}; );
// Mark us as actively cosigning // Mark us as actively cosigning
TributaryDb::start_cosigning( TributaryDb::start_cosigning(
self.tributary_txn, self.tributary_txn,
self.set, self.set,
latest_substrate_block_to_cosign, latest_substrate_block_to_cosign,
substrate_block_number, intent.block_number,
); );
// Send the message for the processor to start signing // Send the message for the processor to start signing
TributaryDb::send_message( TributaryDb::send_message(
@@ -95,8 +112,7 @@ impl<'a, CD: Db, TD: Db, TDT: DbTxn, P: P2p> ScanBlock<'a, CD, TD, TDT, P> {
self.set, self.set,
messages::coordinator::CoordinatorMessage::CosignSubstrateBlock { messages::coordinator::CoordinatorMessage::CosignSubstrateBlock {
session: self.set.session, session: self.set.session,
block_number: substrate_block_number, intent,
block: latest_substrate_block_to_cosign,
}, },
); );
} }
@@ -411,8 +427,7 @@ impl<'a, CD: Db, TD: Db, TDT: DbTxn, P: P2p> ScanBlock<'a, CD, TD, TDT, P> {
} }
/// The task to scan the Tributary, populating `ProcessorMessages`. /// The task to scan the Tributary, populating `ProcessorMessages`.
pub struct ScanTributaryTask<CD: Db, TD: Db, P: P2p> { pub struct ScanTributaryTask<TD: Db, P: P2p> {
cosign_db: CD,
tributary_db: TD, tributary_db: TD,
set: ValidatorSet, set: ValidatorSet,
validators: Vec<SeraiAddress>, validators: Vec<SeraiAddress>,
@@ -422,10 +437,9 @@ pub struct ScanTributaryTask<CD: Db, TD: Db, P: P2p> {
_p2p: PhantomData<P>, _p2p: PhantomData<P>,
} }
impl<CD: Db, TD: Db, P: P2p> ScanTributaryTask<CD, TD, P> { impl<TD: Db, P: P2p> ScanTributaryTask<TD, P> {
/// Create a new instance of this task. /// Create a new instance of this task.
pub fn new( pub fn new(
cosign_db: CD,
tributary_db: TD, tributary_db: TD,
new_set: &NewSetInformation, new_set: &NewSetInformation,
tributary: TributaryReader<TD, Transaction>, tributary: TributaryReader<TD, Transaction>,
@@ -442,7 +456,6 @@ impl<CD: Db, TD: Db, P: P2p> ScanTributaryTask<CD, TD, P> {
} }
ScanTributaryTask { ScanTributaryTask {
cosign_db,
tributary_db, tributary_db,
set: new_set.set, set: new_set.set,
validators, validators,
@@ -454,7 +467,7 @@ impl<CD: Db, TD: Db, P: P2p> ScanTributaryTask<CD, TD, P> {
} }
} }
impl<CD: Db, TD: Db, P: P2p> ContinuallyRan for ScanTributaryTask<CD, TD, P> { impl<TD: Db, P: P2p> ContinuallyRan for ScanTributaryTask<TD, P> {
fn run_iteration(&mut self) -> impl Send + Future<Output = Result<bool, String>> { fn run_iteration(&mut self) -> impl Send + Future<Output = Result<bool, String>> {
async move { async move {
let (mut last_block_number, mut last_block_hash) = let (mut last_block_number, mut last_block_hash) =
@@ -486,7 +499,6 @@ impl<CD: Db, TD: Db, P: P2p> ContinuallyRan for ScanTributaryTask<CD, TD, P> {
(ScanBlock { (ScanBlock {
_td: PhantomData::<TD>, _td: PhantomData::<TD>,
_p2p: PhantomData::<P>, _p2p: PhantomData::<P>,
cosign_db: &self.cosign_db,
tributary_txn: &mut tributary_txn, tributary_txn: &mut tributary_txn,
set: self.set, set: self.set,
validators: &self.validators, validators: &self.validators,

View File

@@ -29,3 +29,5 @@ serai-primitives = { path = "../../substrate/primitives", default-features = fal
in-instructions-primitives = { package = "serai-in-instructions-primitives", path = "../../substrate/in-instructions/primitives", default-features = false, features = ["std", "borsh"] } in-instructions-primitives = { package = "serai-in-instructions-primitives", path = "../../substrate/in-instructions/primitives", default-features = false, features = ["std", "borsh"] }
coins-primitives = { package = "serai-coins-primitives", path = "../../substrate/coins/primitives", default-features = false, features = ["std", "borsh"] } coins-primitives = { package = "serai-coins-primitives", path = "../../substrate/coins/primitives", default-features = false, features = ["std", "borsh"] }
validator-sets-primitives = { package = "serai-validator-sets-primitives", path = "../../substrate/validator-sets/primitives", default-features = false, features = ["std", "borsh"] } validator-sets-primitives = { package = "serai-validator-sets-primitives", path = "../../substrate/validator-sets/primitives", default-features = false, features = ["std", "borsh"] }
serai-cosign = { path = "../../coordinator/cosign", default-features = false }

View File

@@ -11,6 +11,8 @@ use validator_sets_primitives::{Session, KeyPair, Slash};
use coins_primitives::OutInstructionWithBalance; use coins_primitives::OutInstructionWithBalance;
use in_instructions_primitives::SignedBatch; use in_instructions_primitives::SignedBatch;
use serai_cosign::{CosignIntent, SignedCosign};
#[derive(Clone, Copy, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)] #[derive(Clone, Copy, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)]
pub struct SubstrateContext { pub struct SubstrateContext {
pub serai_time: u64, pub serai_time: u64,
@@ -50,7 +52,8 @@ pub mod key_gen {
} }
} }
#[derive(Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)] // This set of messages is sent entirely and solely by serai-processor-key-gen.
#[derive(Clone, BorshSerialize, BorshDeserialize)]
pub enum ProcessorMessage { pub enum ProcessorMessage {
// Participated in the specified key generation protocol. // Participated in the specified key generation protocol.
Participation { session: Session, participation: Vec<u8> }, Participation { session: Session, participation: Vec<u8> },
@@ -141,7 +144,8 @@ pub mod sign {
} }
} }
#[derive(Clone, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)] // This set of messages is sent entirely and solely by serai-processor-frost-attempt-manager.
#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
pub enum ProcessorMessage { pub enum ProcessorMessage {
// Participant sent an invalid message during the sign protocol. // Participant sent an invalid message during the sign protocol.
InvalidParticipant { session: Session, participant: Participant }, InvalidParticipant { session: Session, participant: Participant },
@@ -155,39 +159,25 @@ pub mod sign {
pub mod coordinator { pub mod coordinator {
use super::*; use super::*;
// TODO: Remove this for the one defined in serai-cosign
pub fn cosign_block_msg(block_number: u64, block: [u8; 32]) -> Vec<u8> {
const DST: &[u8] = b"Cosign";
let mut res = vec![u8::try_from(DST.len()).unwrap()];
res.extend(DST);
res.extend(block_number.to_le_bytes());
res.extend(block);
res
}
#[derive(Clone, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)] #[derive(Clone, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)]
pub enum CoordinatorMessage { pub enum CoordinatorMessage {
/// Cosign the specified Substrate block. /// Cosign the specified Substrate block.
/// ///
/// This is sent by the Coordinator's Tributary scanner. /// This is sent by the Coordinator's Tributary scanner.
CosignSubstrateBlock { session: Session, block_number: u64, block: [u8; 32] }, CosignSubstrateBlock { session: Session, intent: CosignIntent },
/// Sign the slash report for this session. /// Sign the slash report for this session.
/// ///
/// This is sent by the Coordinator's Tributary scanner. /// This is sent by the Coordinator's Tributary scanner.
SignSlashReport { session: Session, report: Vec<Slash> }, SignSlashReport { session: Session, report: Vec<Slash> },
} }
#[derive(Clone, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)] // This set of messages is sent entirely and solely by serai-processor-bin's implementation of
pub struct PlanMeta { // the signers::Coordinator trait.
pub session: Session, // TODO: Move message creation into serai-processor-signers
pub id: [u8; 32], #[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
}
#[derive(Clone, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)]
pub enum ProcessorMessage { pub enum ProcessorMessage {
CosignedBlock { block_number: u64, block: [u8; 32], signature: Vec<u8> }, CosignedBlock { cosign: SignedCosign },
SignedBatch { batch: SignedBatch }, SignedBatch { batch: SignedBatch },
SubstrateBlockAck { block: u64, plans: Vec<PlanMeta> },
SignedSlashReport { session: Session, signature: Vec<u8> }, SignedSlashReport { session: Session, signature: Vec<u8> },
} }
} }
@@ -231,17 +221,16 @@ pub mod substrate {
}, },
} }
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)]
pub enum ProcessorMessage {} pub struct PlanMeta {
impl BorshSerialize for ProcessorMessage { pub session: Session,
fn serialize<W: borsh::io::Write>(&self, _writer: &mut W) -> borsh::io::Result<()> { pub transaction: [u8; 32],
unimplemented!()
}
}
impl BorshDeserialize for ProcessorMessage {
fn deserialize_reader<R: borsh::io::Read>(_reader: &mut R) -> borsh::io::Result<Self> {
unimplemented!()
} }
#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
pub enum ProcessorMessage {
// TODO: Have the processor send this
SubstrateBlockAck { block: u64, plans: Vec<PlanMeta> },
} }
} }
@@ -268,7 +257,7 @@ impl_from!(sign, CoordinatorMessage, Sign);
impl_from!(coordinator, CoordinatorMessage, Coordinator); impl_from!(coordinator, CoordinatorMessage, Coordinator);
impl_from!(substrate, CoordinatorMessage, Substrate); impl_from!(substrate, CoordinatorMessage, Substrate);
#[derive(Clone, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)] #[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
pub enum ProcessorMessage { pub enum ProcessorMessage {
KeyGen(key_gen::ProcessorMessage), KeyGen(key_gen::ProcessorMessage),
Sign(sign::ProcessorMessage), Sign(sign::ProcessorMessage),
@@ -331,8 +320,8 @@ impl CoordinatorMessage {
CoordinatorMessage::Coordinator(msg) => { CoordinatorMessage::Coordinator(msg) => {
let (sub, id) = match msg { let (sub, id) = match msg {
// We only cosign a block once, and Reattempt is a separate message // We only cosign a block once, and Reattempt is a separate message
coordinator::CoordinatorMessage::CosignSubstrateBlock { block_number, .. } => { coordinator::CoordinatorMessage::CosignSubstrateBlock { intent, .. } => {
(0, block_number.encode()) (0, intent.block_number.encode())
} }
// We only sign one slash report, and Reattempt is a separate message // We only sign one slash report, and Reattempt is a separate message
coordinator::CoordinatorMessage::SignSlashReport { session, .. } => (1, session.encode()), coordinator::CoordinatorMessage::SignSlashReport { session, .. } => (1, session.encode()),
@@ -404,17 +393,26 @@ impl ProcessorMessage {
} }
ProcessorMessage::Coordinator(msg) => { ProcessorMessage::Coordinator(msg) => {
let (sub, id) = match msg { let (sub, id) = match msg {
coordinator::ProcessorMessage::CosignedBlock { block, .. } => (0, block.encode()), coordinator::ProcessorMessage::CosignedBlock { cosign } => {
(0, cosign.cosign.block_hash.encode())
}
coordinator::ProcessorMessage::SignedBatch { batch, .. } => (1, batch.batch.id.encode()), coordinator::ProcessorMessage::SignedBatch { batch, .. } => (1, batch.batch.id.encode()),
coordinator::ProcessorMessage::SubstrateBlockAck { block, .. } => (2, block.encode()), coordinator::ProcessorMessage::SignedSlashReport { session, .. } => (2, session.encode()),
coordinator::ProcessorMessage::SignedSlashReport { session, .. } => (3, session.encode()),
}; };
let mut res = vec![PROCESSOR_UID, TYPE_COORDINATOR_UID, sub]; let mut res = vec![PROCESSOR_UID, TYPE_COORDINATOR_UID, sub];
res.extend(&id); res.extend(&id);
res res
} }
ProcessorMessage::Substrate(_) => panic!("requesting intent for empty message type"), ProcessorMessage::Substrate(msg) => {
let (sub, id) = match msg {
substrate::ProcessorMessage::SubstrateBlockAck { block, .. } => (0, block.encode()),
};
let mut res = vec![PROCESSOR_UID, TYPE_SUBSTRATE_UID, sub];
res.extend(&id);
res
}
} }
} }
} }