Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node: add missing_iterations logs #1154

Merged
merged 2 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions node-data/src/bls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,14 @@ impl PublicKey {
&self.inner
}

/// Converts inner data in a truncated base58 string.
/// Truncated base58 representation of inner data
pub fn to_bs58(&self) -> String {
let mut bs = bs58::encode(&self.as_bytes.inner()).into_string();
bs.truncate(16);
bs
self.as_bytes.to_bs58()
}

/// Full base58 representation of inner data
pub fn to_base58(&self) -> String {
self.as_bytes.to_base58()
}
}

Expand All @@ -81,7 +84,7 @@ impl Ord for PublicKey {

impl std::fmt::Debug for PublicKey {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let bs = bs58::encode(&self.as_bytes.inner()).into_string();
let bs = self.to_base58();
f.debug_struct("PublicKey").field("bs58", &bs).finish()
}
}
Expand All @@ -99,6 +102,18 @@ impl PublicKeyBytes {
pub fn inner(&self) -> &[u8; 96] {
&self.0
}

/// Full base58 representation of inner data
pub fn to_base58(&self) -> String {
bs58::encode(&self.0).into_string()
}

/// Truncated base58 representation of inner data
pub fn to_bs58(&self) -> String {
let mut bs = self.to_base58();
bs.truncate(16);
bs
}
}

/// Loads consensus keys from an encrypted file.
Expand Down
50 changes: 49 additions & 1 deletion node/src/chain/acceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use dusk_consensus::contract_state::{
};
use dusk_consensus::user::committee::CommitteeSet;
use dusk_consensus::user::provisioners::Provisioners;
use dusk_consensus::user::sortition;
use hex::ToHex;
use node_data::ledger::{
self, to_str, Block, Hash, Header, Seed, Signature, SpentTransaction,
Expand All @@ -33,7 +34,7 @@ use tokio::sync::{oneshot, Mutex, RwLock};
use tokio::task::JoinHandle;
use tracing::{error, info, warn};

use dusk_consensus::config;
use dusk_consensus::config::{self, SELECTION_COMMITTEE_SIZE};
use std::any;
use std::collections::HashMap;

Expand Down Expand Up @@ -177,6 +178,45 @@ impl<DB: database::DB, VM: vm::VMExecution, N: Network> Acceptor<N, DB, VM> {
Ok(())
}

fn log_missing_iterations(
&self,
provisioners_list: &Provisioners,
iteration: u8,
seed: Seed,
round: u64,
) {
if iteration == 0 {
return;
}
let mut prov = provisioners_list.clone();
prov.update_eligibility_flag(round);
for iter in 0..iteration {
let committee_keys = prov.create_committee(&sortition::Config {
committee_size: SELECTION_COMMITTEE_SIZE,
round,
seed,
step: iter * 3,
});
if committee_keys.len() != 1 {
let len = committee_keys.len();
error!(
"Unable to generate voting committee for missed block: {len}",
)
} else {
let generator = committee_keys
.first()
.expect("committee to have 1 entry")
.to_bs58();
warn!(
event = "missed iteration",
height = round,
iter,
generator,
);
}
}
}

pub(crate) async fn try_accept_block(
&self,
blk: &Block,
Expand Down Expand Up @@ -228,6 +268,13 @@ impl<DB: database::DB, VM: vm::VMExecution, N: Network> Acceptor<N, DB, VM> {
Ok(txs)
})?;

self.log_missing_iterations(
&provisioners_list,
blk.header().iteration,
mrb.header().seed,
blk.header().height,
);

// Update provisioners list
let updated_provisioners = {
Self::needs_update(blk, &txs).then(|| vm.get_provisioners())
Expand Down Expand Up @@ -270,6 +317,7 @@ impl<DB: database::DB, VM: vm::VMExecution, N: Network> Acceptor<N, DB, VM> {
fsv_bitset,
ssv_bitset,
block_time,
generator = blk.header().generator_bls_pubkey.to_bs58(),
dur_ms = duration.as_millis(),
);

Expand Down