Added additional log statements for future debugging purposes

This commit is contained in:
Jędrzej Stuczyński
2022-05-12 11:28:42 +01:00
parent fb09e97eb6
commit 9f4029eb85
3 changed files with 30 additions and 2 deletions
@@ -7,6 +7,7 @@ use crate::dkg::main_loop::ContractEventsSender;
use futures::channel::mpsc;
use futures::StreamExt;
use log::error;
use log::trace;
use std::fmt::Display;
pub(crate) type DispatcherSender = mpsc::UnboundedSender<Event>;
@@ -32,9 +33,11 @@ impl Dispatcher {
fn handle_event(&self, event: Event) {
match event {
Event::NewDealing(new_dealing_request) => {
trace!("received and forwarding NewDealing Event");
self.forward_event(&self.dealing_processor, new_dealing_request)
}
Event::DkgContractChange(watcher_event) => {
trace!("received and forwarding DkgContractChange Event");
self.forward_event(&self.contract_event_sender, watcher_event)
}
}
+13 -1
View File
@@ -9,7 +9,7 @@ use crate::dkg::state::{Dealer, DkgState, Malformation, MalformedDealer};
use coconut_dkg_common::types::{Addr, BlockHeight, DealerDetails};
use futures::channel::mpsc;
use futures::StreamExt;
use log::info;
use log::{debug, info, trace};
// essentially events originating from the contract watcher could only drive our state forward
// (TODO: is it actually true? I guess we'll find out soon enough)
@@ -45,6 +45,7 @@ impl<C> ProcessingLoop<C> {
if dealer.bte_public_key.verify() {
self.dkg_state.try_add_new_dealer(dealer).await
} else {
debug!("received dealer {} failed to prove possession of its BTE key and it will be dealt with accordingly", dealer.chain_address);
let dealer_address = dealer.chain_address.clone();
// the dealer failed to provide valid proof of possession
let malformation = Malformation::InvalidBTEPublicKey;
@@ -61,6 +62,10 @@ impl<C> ProcessingLoop<C> {
dealer_details: DealerDetails,
malformation: Malformation,
) {
debug!(
"received dealer {} is malformed ({:?}) and it will be dealt with accordingly",
dealer_details.address, malformation
);
let dealer_address = dealer_details.address.clone();
self.dkg_state
.try_add_malformed_dealer(MalformedDealer::Raw(dealer_details))
@@ -70,6 +75,7 @@ impl<C> ProcessingLoop<C> {
}
async fn process_new_dealer(&self, dealer_details: DealerDetails) {
trace!("processing new dealer ({})", dealer_details.address);
match Dealer::try_parse_from_raw(&dealer_details) {
Ok(dealer) => self.deal_with_new_dealer(dealer).await,
Err(malformed_dealer) => {
@@ -80,10 +86,16 @@ impl<C> ProcessingLoop<C> {
}
async fn process_dealer_removal(&self, dealer_address: Addr) {
trace!("processing dealer removal ({})", dealer_address);
self.dkg_state.try_remove_dealer(dealer_address).await
}
async fn process_dealer_changes(&self, changes: Vec<DealerChange>, height: BlockHeight) {
debug!(
"processing dealer set change event with {} changes at height {}",
changes.len(),
height
);
for change in changes {
match change {
DealerChange::Addition { details } => self.process_new_dealer(details).await,
@@ -5,7 +5,7 @@ use crate::dkg::error::DkgError;
use crate::dkg::state::StateAccessor;
use crate::Client;
use coconut_dkg_common::types::EpochState;
use log::warn;
use log::{debug, trace, warn};
use std::collections::HashMap;
use std::time::Duration;
use tokio::time::interval;
@@ -49,6 +49,7 @@ where
.keys()
.chain(known_dealers.values().map(|dealer| &dealer.chain_address))
{
debug!("detected dealer that should get removed - {}", dealer);
if !contract_dealers.contains_key(dealer) {
changes.push(DealerChange::Removal {
address: dealer.clone(),
@@ -68,10 +69,15 @@ where
// we had absolutely no idea about this dealer existing
if !is_bad || !is_known {
debug!("detected dealer that should get added - {}", dealer);
changes.push(DealerChange::Addition { details });
}
}
trace!(
"pushing {} dealer set changes onto the event queue",
changes.len()
);
self.state_accessor
.push_contract_change_event(Event::new(
current_height,
@@ -96,6 +102,8 @@ where
}
async fn poll_contract(&self) -> Result<(), DkgError> {
trace!("polling the dkg smart contract for any changes");
// based on the current epoch state (assuming it HASN'T CHANGED since last check), the following further actions have to be performed:
// (if the epoch state changed, we have to ALSO perform actions as if it was in the previous variants):
@@ -113,6 +121,11 @@ where
let prior_epoch = self.state_accessor.current_epoch().await;
let current_epoch = self.client.get_dkg_epoch().await?;
debug!(
"contract epoch is in {:?} state, while our stored epoch is in {:?}",
current_epoch.state, prior_epoch.state
);
if prior_epoch.state != current_epoch.state {
todo!()
}