From 8613e14ec2552b1997699f67c00667bb1d3318ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Ver=C5=A1i=C4=87?= Date: Fri, 17 Feb 2023 17:16:38 +0300 Subject: [PATCH] [fix] #3166: don't do view changes when system is idle, i.e. there are no incoming transactions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marin Veršić --- core/src/sumeragi/main_loop.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/core/src/sumeragi/main_loop.rs b/core/src/sumeragi/main_loop.rs index baf6ac738ff..82dd4933375 100644 --- a/core/src/sumeragi/main_loop.rs +++ b/core/src/sumeragi/main_loop.rs @@ -964,20 +964,17 @@ pub(crate) fn run( &mut view_change_time, ); - if last_view_change_time.elapsed() > view_change_time { + let node_expects_block = !state.transaction_cache.is_empty(); + if node_expects_block && last_view_change_time.elapsed() > view_change_time { let role = state.current_topology.role(&sumeragi.peer_id); if let Some(VotingBlock { block, .. }) = voting_block.as_ref() { // NOTE: Suspecting the tail node because it hasn't yet committed a block produced by leader warn!(%role, block=%block.hash(), "Block not committed in due time, requesting view change..."); - } else if !state.transaction_cache.is_empty() { + } else { // NOTE: Suspecting the leader node because it hasn't produced a block // If the current node has a transaction, the leader should have as well warn!(%role, "No block produced in due time, requesting view change..."); - } else { - // NOTE: There might be an issue with transaction gossiping mechanism - // There is no meaningful performance hit if there are no transactions - info!(%role, "No new transactions, requesting view change..."); } suggest_view_change(