From e703536c3a452c254dee27b36da3792d85377509 Mon Sep 17 00:00:00 2001 From: dkf Date: Mon, 29 Jul 2024 11:05:05 +0100 Subject: [PATCH] fix(consensus): update naming and remove default base time --- .../tari_dan_app_utilities/src/consensus_constants.rs | 4 ++-- applications/tari_validator_node/src/consensus/mod.rs | 2 +- dan_layer/consensus/src/hotstuff/config.rs | 2 +- dan_layer/consensus/src/hotstuff/pacemaker.rs | 11 ++--------- dan_layer/consensus/src/hotstuff/worker.rs | 2 +- 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/applications/tari_dan_app_utilities/src/consensus_constants.rs b/applications/tari_dan_app_utilities/src/consensus_constants.rs index b10dd0be1..981dfc17e 100644 --- a/applications/tari_dan_app_utilities/src/consensus_constants.rs +++ b/applications/tari_dan_app_utilities/src/consensus_constants.rs @@ -26,7 +26,7 @@ pub struct ConsensusConstants { pub committee_size: u32, pub max_base_layer_blocks_ahead: u64, pub max_base_layer_blocks_behind: u64, - pub max_block_time_threshold: u64, // GST in seconds for consensus + pub pacemaker_max_base_time: u64, // GST in seconds for consensus } impl ConsensusConstants { @@ -36,7 +36,7 @@ impl ConsensusConstants { committee_size: 7, max_base_layer_blocks_ahead: 5, max_base_layer_blocks_behind: 5, - max_block_time_threshold: 10, + pacemaker_max_base_time: 10, } } } diff --git a/applications/tari_validator_node/src/consensus/mod.rs b/applications/tari_validator_node/src/consensus/mod.rs index b97f06290..22f7076d9 100644 --- a/applications/tari_validator_node/src/consensus/mod.rs +++ b/applications/tari_validator_node/src/consensus/mod.rs @@ -99,7 +99,7 @@ pub async fn spawn( HotstuffConfig { max_base_layer_blocks_behind: consensus_constants.max_base_layer_blocks_behind, max_base_layer_blocks_ahead: consensus_constants.max_base_layer_blocks_ahead, - max_block_time_threshold: consensus_constants.max_block_time_threshold, + pacemaker_max_base_time: consensus_constants.pacemaker_max_base_time, }, ); let current_view = hotstuff_worker.pacemaker().current_view().clone(); diff --git a/dan_layer/consensus/src/hotstuff/config.rs b/dan_layer/consensus/src/hotstuff/config.rs index f4f23307b..25b6987fd 100644 --- a/dan_layer/consensus/src/hotstuff/config.rs +++ b/dan_layer/consensus/src/hotstuff/config.rs @@ -5,5 +5,5 @@ pub struct HotstuffConfig { pub max_base_layer_blocks_ahead: u64, pub max_base_layer_blocks_behind: u64, - pub max_block_time_threshold: u64, + pub pacemaker_max_base_time: u64, } diff --git a/dan_layer/consensus/src/hotstuff/pacemaker.rs b/dan_layer/consensus/src/hotstuff/pacemaker.rs index 31e14ce81..ad7841b4b 100644 --- a/dan_layer/consensus/src/hotstuff/pacemaker.rs +++ b/dan_layer/consensus/src/hotstuff/pacemaker.rs @@ -21,7 +21,6 @@ use crate::hotstuff::{ const LOG_TARGET: &str = "tari::dan::consensus::hotstuff::pacemaker"; const MAX_DELTA: Duration = Duration::from_secs(300); -const DEFAULT_BLOCK_TIME: Duration = Duration::from_secs(10); pub struct PaceMaker { pace_maker_handle: PaceMakerHandle, @@ -32,7 +31,7 @@ pub struct PaceMaker { } impl PaceMaker { - pub fn new(max_block_time_threshold: u64) -> Self { + pub fn new(max_base_time: u64) -> Self { let (sender, receiver) = mpsc::channel(100); let on_beat = OnBeat::new(); @@ -40,12 +39,6 @@ impl PaceMaker { let on_leader_timeout = OnLeaderTimeout::new(); let current_height = CurrentView::new(); - let block_time = if max_block_time_threshold == 0 { - DEFAULT_BLOCK_TIME - } else { - Duration::from_secs(max_block_time_threshold) - }; - Self { handle_receiver: receiver, pace_maker_handle: PaceMakerHandle::new( @@ -57,7 +50,7 @@ impl PaceMaker { ), current_view: current_height, current_high_qc_height: NodeHeight(0), - block_time, + block_time: Duration::from_secs(max_base_time), } } diff --git a/dan_layer/consensus/src/hotstuff/worker.rs b/dan_layer/consensus/src/hotstuff/worker.rs index 478980e01..1d23f9df8 100644 --- a/dan_layer/consensus/src/hotstuff/worker.rs +++ b/dan_layer/consensus/src/hotstuff/worker.rs @@ -97,7 +97,7 @@ impl HotstuffWorker { config: HotstuffConfig, ) -> Self { let (tx_missing_transactions, rx_missing_transactions) = mpsc::unbounded_channel(); - let pacemaker = PaceMaker::new(config.max_block_time_threshold); + let pacemaker = PaceMaker::new(config.pacemaker_max_base_time); let vote_receiver = VoteReceiver::new( network, state_store.clone(),