Bug fixes and log statements

Also shims next nonce code with a fine-for-now piece of code which is unviable
in production, yet should survive testnet.
This commit is contained in:
Luke Parker
2023-08-13 02:21:56 -04:00
parent 049fefb5fd
commit 7e71450dc4
11 changed files with 217 additions and 72 deletions

View File

@@ -147,6 +147,13 @@ impl<D: Db, T: Transaction> Blockchain<D, T> {
pub(crate) fn add_block(&mut self, block: &Block<T>, commit: Vec<u8>) -> Result<(), BlockError> {
self.verify_block(block)?;
log::info!(
"adding block {} to tributary {} with {} TXs",
hex::encode(block.hash()),
hex::encode(self.genesis),
block.transactions.len(),
);
// None of the following assertions should be reachable since we verified the block
// Take it from the Option so Rust doesn't consider self as mutably borrowed thanks to the

View File

@@ -210,8 +210,9 @@ pub trait Network: Send + Sync {
/// Type used for ordered blocks of information.
type Block: Block;
/// Maximum block processing time in seconds. This should include both the actual processing time
/// and the time to download the block.
/// Maximum block processing time in seconds.
///
/// This should include both the time to download the block and the actual processing time.
const BLOCK_PROCESSING_TIME: u32;
/// Network latency time in seconds.
const LATENCY_TIME: u32;

View File

@@ -197,7 +197,9 @@ impl<N: Network + 'static> TendermintMachine<N> {
// Sleep until this round ends
let round_end = self.block.end_time[&end_round];
sleep(round_end.instant().saturating_duration_since(Instant::now())).await;
let time_until_round_end = round_end.instant().saturating_duration_since(Instant::now());
log::trace!("sleeping until round ends in {}ms", time_until_round_end.as_millis());
sleep(time_until_round_end).await;
// Clear our outbound message queue
self.queue = VecDeque::new();
@@ -313,6 +315,7 @@ impl<N: Network + 'static> TendermintMachine<N> {
let rounds_to_skip = Instant::now().duration_since(start_time.instant()).as_secs() /
u64::from(N::block_time());
if rounds_to_skip != 0 {
log::trace!("joining mid-block so skipping {rounds_to_skip} rounds");
machine.round(RoundNumber(rounds_to_skip.try_into().unwrap()), None);
}
machine
@@ -446,7 +449,9 @@ impl<N: Network + 'static> TendermintMachine<N> {
"TendermintMachine produced block {}",
hex::encode(block.id().as_ref()),
);
let id = block.id();
let proposal = self.network.add_block(block, commit).await;
log::trace!("added block {} (produced by machine)", hex::encode(id.as_ref()));
self.reset(msg.round, proposal).await;
}
Err(TendermintError::Malicious(validator)) => self.slash(validator).await,