Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cherry-pick] PR 7256 #7259

Merged
merged 1 commit into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions config/src/config/consensus_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub(crate) const MAX_SENDING_BLOCK_TXNS_QUORUM_STORE_OVERRIDE: u64 = 10000;
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(default, deny_unknown_fields)]
pub struct ConsensusConfig {
// Use getters to read the correct value with/without quorum store.
pub max_sending_block_txns: u64,
pub max_sending_block_txns_quorum_store_override: u64,
pub max_sending_block_bytes: u64,
Expand Down Expand Up @@ -138,12 +139,36 @@ impl ConsensusConfig {
self.safety_rules.set_data_dir(data_dir);
}

// TODO: This is ugly. Remove this and configs when quorum store is always the default.
pub fn apply_quorum_store_overrides(&mut self) {
self.max_sending_block_txns = self.max_sending_block_txns_quorum_store_override;
self.max_sending_block_bytes = self.max_sending_block_bytes_quorum_store_override;
self.max_receiving_block_txns = self.max_receiving_block_txns_quorum_store_override;
self.max_receiving_block_bytes = self.max_receiving_block_bytes_quorum_store_override;
pub fn max_sending_block_txns(&self, quorum_store_enabled: bool) -> u64 {
if quorum_store_enabled {
self.max_sending_block_txns_quorum_store_override
} else {
self.max_sending_block_txns
}
}

pub fn max_sending_block_bytes(&self, quorum_store_enabled: bool) -> u64 {
if quorum_store_enabled {
self.max_sending_block_bytes_quorum_store_override
} else {
self.max_sending_block_bytes
}
}

pub fn max_receiving_block_txns(&self, quorum_store_enabled: bool) -> u64 {
if quorum_store_enabled {
self.max_receiving_block_txns_quorum_store_override
} else {
self.max_receiving_block_txns
}
}

pub fn max_receiving_block_bytes(&self, quorum_store_enabled: bool) -> u64 {
if quorum_store_enabled {
self.max_receiving_block_bytes_quorum_store_override
} else {
self.max_receiving_block_bytes
}
}
}

Expand Down
9 changes: 4 additions & 5 deletions consensus/src/epoch_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,10 @@ impl EpochManager {
block_store.clone(),
Arc::new(payload_client),
self.time_service.clone(),
self.config.max_sending_block_txns,
self.config.max_sending_block_bytes,
self.config
.max_sending_block_txns(self.quorum_store_enabled),
self.config
.max_sending_block_bytes(self.quorum_store_enabled),
onchain_consensus_config.max_failed_authors_to_store(),
chain_health_backoff_config,
self.quorum_store_enabled,
Expand Down Expand Up @@ -810,9 +812,6 @@ impl EpochManager {
let consensus_config = onchain_consensus_config.unwrap_or_default();
let execution_config = onchain_execution_config.unwrap_or_default();
self.quorum_store_enabled = consensus_config.quorum_store_enabled();
if self.quorum_store_enabled {
self.config.apply_quorum_store_overrides();
}
self.start_round_manager(
initial_data,
epoch_state,
Expand Down
16 changes: 12 additions & 4 deletions consensus/src/round_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,17 +643,25 @@ impl RoundManager {
let payload_len = proposal.payload().map_or(0, |payload| payload.len());
let payload_size = proposal.payload().map_or(0, |payload| payload.size());
ensure!(
payload_len as u64 <= self.local_config.max_receiving_block_txns,
payload_len as u64
<= self
.local_config
.max_receiving_block_txns(self.onchain_config.quorum_store_enabled()),
"Payload len {} exceeds the limit {}",
payload_len,
self.local_config.max_receiving_block_txns,
self.local_config
.max_receiving_block_txns(self.onchain_config.quorum_store_enabled()),
);

ensure!(
payload_size as u64 <= self.local_config.max_receiving_block_bytes,
payload_size as u64
<= self
.local_config
.max_receiving_block_bytes(self.onchain_config.quorum_store_enabled()),
"Payload size {} exceeds the limit {}",
payload_size,
self.local_config.max_receiving_block_bytes,
self.local_config
.max_receiving_block_bytes(self.onchain_config.quorum_store_enabled()),
);

ensure!(
Expand Down