Skip to content

Commit

Permalink
config changes (aptos-labs#12556)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielxiangzl authored Mar 16, 2024
1 parent b69a7a3 commit 36cd163
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
6 changes: 6 additions & 0 deletions config/src/config/consensus_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pub struct ConsensusConfig {
pub max_blocks_per_sending_request_quorum_store_override: u64,
pub max_blocks_per_receiving_request: u64,
pub max_blocks_per_receiving_request_quorum_store_override: u64,
pub broadcast_vote: bool,
}

#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
Expand Down Expand Up @@ -283,6 +284,7 @@ impl Default for ConsensusConfig {
max_blocks_per_sending_request_quorum_store_override: 10,
max_blocks_per_receiving_request: 10,
max_blocks_per_receiving_request_quorum_store_override: 100,
broadcast_vote: true,
}
}
}
Expand All @@ -292,6 +294,10 @@ impl ConsensusConfig {
self.safety_rules.set_data_dir(data_dir);
}

pub fn enable_broadcast_vote(&mut self, enable: bool) {
self.broadcast_vote = enable;
}

pub fn max_blocks_per_sending_request(&self, quorum_store_enabled: bool) -> u64 {
if quorum_store_enabled {
self.max_blocks_per_sending_request_quorum_store_override
Expand Down
1 change: 0 additions & 1 deletion consensus/src/epoch_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,6 @@ impl<P: OnChainConfigProvider> EpochManager<P> {
self.config.clone(),
onchain_randomness_config,
onchain_jwk_consensus_config,
true,
);

round_manager.init(last_vote).await;
Expand Down
7 changes: 2 additions & 5 deletions consensus/src/round_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ pub struct RoundManager {
local_config: ConsensusConfig,
randomness_config: OnChainRandomnessConfig,
jwk_consensus_config: OnChainJWKConsensusConfig,
broadcast_vote: bool,
}

impl RoundManager {
Expand All @@ -234,7 +233,6 @@ impl RoundManager {
local_config: ConsensusConfig,
randomness_config: OnChainRandomnessConfig,
jwk_consensus_config: OnChainJWKConsensusConfig,
broadcast_vote: bool,
) -> Self {
// when decoupled execution is false,
// the counter is still static.
Expand All @@ -261,7 +259,6 @@ impl RoundManager {
local_config,
randomness_config,
jwk_consensus_config,
broadcast_vote,
}
}

Expand Down Expand Up @@ -840,7 +837,7 @@ impl RoundManager {
self.round_state.record_vote(vote.clone());
let vote_msg = VoteMsg::new(vote.clone(), self.block_store.sync_info());

if self.broadcast_vote {
if self.local_config.broadcast_vote {
info!(self.new_log(LogEvent::Vote), "{}", vote);
self.network.broadcast_vote(vote_msg).await;
} else {
Expand Down Expand Up @@ -945,7 +942,7 @@ impl RoundManager {
is_timeout = vote.is_timeout(),
);

if !self.broadcast_vote && !vote.is_timeout() {
if !self.local_config.broadcast_vote && !vote.is_timeout() {
// Unlike timeout votes regular votes are sent to the leaders of the next round only.
let next_round = round + 1;
ensure!(
Expand Down
1 change: 0 additions & 1 deletion consensus/src/round_manager_fuzzing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ fn create_node_for_fuzzing() -> RoundManager {
ConsensusConfig::default(),
OnChainRandomnessConfig::default_enabled(),
OnChainJWKConsensusConfig::default_enabled(),
true,
)
}

Expand Down
6 changes: 4 additions & 2 deletions consensus/src/round_manager_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ impl NodeSetup {

let (round_manager_tx, _) = aptos_channel::new(QueueStyle::LIFO, 1, None);

let mut local_config = local_consensus_config.clone();
local_config.enable_broadcast_vote(false);

let mut round_manager = RoundManager::new(
epoch_state,
Arc::clone(&block_store),
Expand All @@ -318,10 +321,9 @@ impl NodeSetup {
storage.clone(),
onchain_consensus_config.clone(),
round_manager_tx,
local_consensus_config.clone(),
local_config,
onchain_randomness_config.clone(),
onchain_jwk_consensus_config.clone(),
false,
);
block_on(round_manager.init(last_vote_sent));
Self {
Expand Down

0 comments on commit 36cd163

Please sign in to comment.