diff --git a/coordinator/src/main.rs b/coordinator/src/main.rs index 1e055f5a..a1f3a6f6 100644 --- a/coordinator/src/main.rs +++ b/coordinator/src/main.rs @@ -259,7 +259,11 @@ async fn handle_processor_message( TributaryDb::::set_plan_ids(&mut txn, tributary.spec.genesis(), *block, &plans); let tx = Transaction::SubstrateBlock(*block); - log::trace!("processor message effected transaction {}", hex::encode(tx.hash())); + log::trace!( + "processor message effected transaction {} {:?}", + hex::encode(tx.hash()), + &tx + ); log::trace!("providing transaction {}", hex::encode(tx.hash())); let res = tributary.tributary.provide_transaction(tx).await; if !(res.is_ok() || (res == Err(ProvidedError::AlreadyProvided))) { @@ -700,7 +704,7 @@ async fn handle_processor_message( // If this created transactions, publish them for mut tx in txs { - log::trace!("processor message effected transaction {}", hex::encode(tx.hash())); + log::trace!("processor message effected transaction {} {:?}", hex::encode(tx.hash()), &tx); match tx.kind() { TransactionKind::Provided(_) => { @@ -919,6 +923,7 @@ async fn handle_cosigns_and_batch_publication( // Safe since this will drop the txn updating the most recently queued batch continue 'outer; }; + log::debug!("providing Batch transaction {:?}", &tx); let res = tributary.provide_transaction(tx.clone()).await; if !(res.is_ok() || (res == Err(ProvidedError::AlreadyProvided))) { if res == Err(ProvidedError::LocalMismatchesOnChain) { diff --git a/coordinator/src/p2p.rs b/coordinator/src/p2p.rs index a484b42e..cb57ee3d 100644 --- a/coordinator/src/p2p.rs +++ b/coordinator/src/p2p.rs @@ -131,6 +131,7 @@ pub trait P2p: Send + Sync + Clone + fmt::Debug + TributaryP2p { async fn broadcast(&self, kind: P2pMessageKind, msg: Vec) { let mut actual_msg = kind.serialize(); actual_msg.extend(msg); + /* log::trace!( "broadcasting p2p message (kind {})", match kind { @@ -141,6 +142,7 @@ pub trait P2p: Send + Sync + Clone + fmt::Debug + TributaryP2p { P2pMessageKind::CosignedBlock => "CosignedBlock".to_string(), } ); + */ self.broadcast_raw(actual_msg).await; } async fn receive(&self) -> Message { @@ -158,6 +160,7 @@ pub trait P2p: Send + Sync + Clone + fmt::Debug + TributaryP2p { }; break (sender, kind, msg_ref.to_vec()); }; + /* log::trace!( "received p2p message (kind {})", match kind { @@ -168,6 +171,7 @@ pub trait P2p: Send + Sync + Clone + fmt::Debug + TributaryP2p { P2pMessageKind::CosignedBlock => "CosignedBlock".to_string(), } ); + */ Message { sender, kind, msg } } } diff --git a/coordinator/src/tributary/mod.rs b/coordinator/src/tributary/mod.rs index 20a2405a..b16305d4 100644 --- a/coordinator/src/tributary/mod.rs +++ b/coordinator/src/tributary/mod.rs @@ -170,7 +170,7 @@ impl TributarySpec { } } -#[derive(Clone, PartialEq, Eq, Debug)] +#[derive(Clone, PartialEq, Eq)] pub struct SignData { pub plan: Id, pub attempt: u32, @@ -180,6 +180,17 @@ pub struct SignData { pub signed: Signed, } +impl Debug for SignData { + fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> { + fmt + .debug_struct("SignData") + .field("id", &hex::encode(self.plan.encode())) + .field("attempt", &self.attempt) + .field("signer", &hex::encode(self.signed.signer.to_bytes())) + .finish_non_exhaustive() + } +} + impl ReadWrite for SignData { fn read(reader: &mut R) -> io::Result { let plan = Id::decode(&mut scale::IoReader(&mut *reader)) @@ -235,7 +246,7 @@ impl ReadWrite for SignDat } } -#[derive(Clone, PartialEq, Eq, Debug)] +#[derive(Clone, PartialEq, Eq)] pub enum Transaction { RemoveParticipant(Participant), @@ -289,6 +300,67 @@ pub enum Transaction { }, } +impl Debug for Transaction { + fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> { + match self { + Transaction::RemoveParticipant(participant) => fmt + .debug_struct("Transaction::RemoveParticipant") + .field("participant", participant) + .finish(), + Transaction::DkgCommitments(attempt, _, signed) => fmt + .debug_struct("Transaction::DkgCommitments") + .field("attempt", attempt) + .field("signer", &hex::encode(signed.signer.to_bytes())) + .finish_non_exhaustive(), + Transaction::DkgShares { attempt, signed, .. } => fmt + .debug_struct("Transaction::DkgShares") + .field("attempt", attempt) + .field("signer", &hex::encode(signed.signer.to_bytes())) + .finish_non_exhaustive(), + Transaction::InvalidDkgShare { attempt, accuser, faulty, .. } => fmt + .debug_struct("Transaction::InvalidDkgShare") + .field("attempt", attempt) + .field("accuser", accuser) + .field("faulty", faulty) + .finish_non_exhaustive(), + Transaction::DkgConfirmed(attempt, _, signed) => fmt + .debug_struct("Transaction::DkgConfirmed") + .field("attempt", attempt) + .field("signer", &hex::encode(signed.signer.to_bytes())) + .finish_non_exhaustive(), + Transaction::CosignSubstrateBlock(block) => fmt + .debug_struct("Transaction::CosignSubstrateBlock") + .field("block", &hex::encode(block)) + .finish(), + Transaction::Batch(block, batch) => fmt + .debug_struct("Transaction::Batch") + .field("block", &hex::encode(block)) + .field("batch", &hex::encode(batch)) + .finish(), + Transaction::SubstrateBlock(block) => { + fmt.debug_struct("Transaction::SubstrateBlock").field("block", block).finish() + } + Transaction::SubstratePreprocess(sign_data) => { + fmt.debug_struct("Transaction::SubstratePreprocess").field("sign_data", sign_data).finish() + } + Transaction::SubstrateShare(sign_data) => { + fmt.debug_struct("Transaction::SubstrateShare").field("sign_data", sign_data).finish() + } + Transaction::SignPreprocess(sign_data) => { + fmt.debug_struct("Transaction::SignPreprocess").field("sign_data", sign_data).finish() + } + Transaction::SignShare(sign_data) => { + fmt.debug_struct("Transaction::SignShare").field("sign_data", sign_data).finish() + } + Transaction::SignCompleted { plan, tx_hash, .. } => fmt + .debug_struct("Transaction::SignCompleted") + .field("plan", &hex::encode(plan)) + .field("tx_hash", &hex::encode(tx_hash)) + .finish_non_exhaustive(), + } + } +} + impl ReadWrite for Transaction { fn read(reader: &mut R) -> io::Result { let mut kind = [0];