Skip to content

Commit

Permalink
fix(consensus): update naming and remove default base time
Browse files Browse the repository at this point in the history
  • Loading branch information
therealdannzor committed Jul 29, 2024
1 parent eb794f5 commit e703536
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
}
}
}
2 changes: 1 addition & 1 deletion applications/tari_validator_node/src/consensus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion dan_layer/consensus/src/hotstuff/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
11 changes: 2 additions & 9 deletions dan_layer/consensus/src/hotstuff/pacemaker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -32,20 +31,14 @@ 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();
let on_force_beat = OnForceBeat::new();
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(
Expand All @@ -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),
}
}

Expand Down
2 changes: 1 addition & 1 deletion dan_layer/consensus/src/hotstuff/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<TConsensusSpec: ConsensusSpec> HotstuffWorker<TConsensusSpec> {
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(),
Expand Down

0 comments on commit e703536

Please sign in to comment.