diff --git a/node-data/src/bls.rs b/node-data/src/bls.rs index 43c0b9c665..4e33422fe2 100644 --- a/node-data/src/bls.rs +++ b/node-data/src/bls.rs @@ -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() } } @@ -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() } } @@ -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. diff --git a/node/src/chain/acceptor.rs b/node/src/chain/acceptor.rs index eebce2ef80..b74fbde32d 100644 --- a/node/src/chain/acceptor.rs +++ b/node/src/chain/acceptor.rs @@ -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, @@ -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; @@ -177,6 +178,45 @@ impl Acceptor { 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, @@ -228,6 +268,13 @@ impl Acceptor { 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()) @@ -270,6 +317,7 @@ impl Acceptor { fsv_bitset, ssv_bitset, block_time, + generator = blk.header().generator_bls_pubkey.to_bs58(), dur_ms = duration.as_millis(), );