Skip to content

Commit

Permalink
use V2
Browse files Browse the repository at this point in the history
  • Loading branch information
bchocho committed Nov 1, 2022
1 parent 365ec0e commit 602b919
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
5 changes: 0 additions & 5 deletions aptos-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,11 +838,6 @@ pub fn setup_environment(
);
debug!("Mempool started in {} ms", instant.elapsed().as_millis());

assert!(
!node_config.consensus.use_quorum_store,
"QuorumStore is not yet implemented"
);

// StateSync should be instantiated and started before Consensus to avoid a cyclic dependency:
// network provider -> consensus -> state synchronizer -> network provider. This has resulted
// in a deadlock as observed in GitHub issue #749.
Expand Down
3 changes: 0 additions & 3 deletions config/src/config/consensus_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ pub struct ConsensusConfig {
// validators coordinate on the latest version to apply a manual transaction.
pub sync_only: bool,
pub channel_size: usize,
// When false, use the Direct Mempool Quorum Store
pub use_quorum_store: bool,
pub quorum_store_pull_timeout_ms: u64,
// Decides how long the leader waits before proposing empty block if there's no txns in mempool
// the period = (poll_count - 1) * 30ms
Expand Down Expand Up @@ -54,7 +52,6 @@ impl Default for ConsensusConfig {
safety_rules: SafetyRulesConfig::default(),
sync_only: false,
channel_size: 30, // hard-coded
use_quorum_store: false,

quorum_store_pull_timeout_ms: 1000,
quorum_store_poll_count: 10,
Expand Down
50 changes: 46 additions & 4 deletions types/src/on_chain_config/consensus_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
pub enum OnChainConsensusConfig {
V1(ConsensusConfigV1),
V2(ConsensusConfigV2),
}

/// The public interface that exposes all values with safe fallback.
Expand All @@ -20,13 +21,15 @@ impl OnChainConsensusConfig {
pub fn leader_reputation_exclude_round(&self) -> u64 {
match &self {
OnChainConsensusConfig::V1(config) => config.exclude_round,
OnChainConsensusConfig::V2(config) => config.exclude_round,
}
}

/// Decouple execution from consensus or not.
pub fn decoupled_execution(&self) -> bool {
match &self {
OnChainConsensusConfig::V1(config) => config.decoupled_execution,
OnChainConsensusConfig::V2(config) => config.decoupled_execution,
}
}

Expand All @@ -39,6 +42,7 @@ impl OnChainConsensusConfig {
}
match &self {
OnChainConsensusConfig::V1(config) => config.back_pressure_limit,
OnChainConsensusConfig::V2(config) => config.back_pressure_limit,
}
}

Expand All @@ -47,27 +51,30 @@ impl OnChainConsensusConfig {
pub fn max_failed_authors_to_store(&self) -> usize {
match &self {
OnChainConsensusConfig::V1(config) => config.max_failed_authors_to_store,
OnChainConsensusConfig::V2(config) => config.max_failed_authors_to_store,
}
}

// Type and configuration used for proposer election.
pub fn proposer_election_type(&self) -> &ProposerElectionType {
match &self {
OnChainConsensusConfig::V1(config) => &config.proposer_election_type,
OnChainConsensusConfig::V2(config) => &config.proposer_election_type,
}
}

pub fn enable_quorum_store(&self) -> bool {
match &self {
OnChainConsensusConfig::V1(config) => config.enable_quorum_store,
OnChainConsensusConfig::V1(_config) => false,
OnChainConsensusConfig::V2(config) => config.enable_quorum_store,
}
}
}

/// This is used when on-chain config is not initialized.
impl Default for OnChainConsensusConfig {
fn default() -> Self {
OnChainConsensusConfig::V1(ConsensusConfigV1::default())
OnChainConsensusConfig::V2(ConsensusConfigV2::default())
}
}

Expand Down Expand Up @@ -96,11 +103,46 @@ pub struct ConsensusConfigV1 {
pub exclude_round: u64,
pub proposer_election_type: ProposerElectionType,
pub max_failed_authors_to_store: usize,
// TODO: probably need a V2 for backwards compatibility?
pub enable_quorum_store: bool,
}

impl Default for ConsensusConfigV1 {
fn default() -> Self {
Self {
decoupled_execution: true,
back_pressure_limit: 10,
exclude_round: 20,
max_failed_authors_to_store: 10,
proposer_election_type: ProposerElectionType::LeaderReputation(
LeaderReputationType::ProposerAndVoter(ProposerAndVoterConfig {
active_weight: 1000,
inactive_weight: 10,
failed_weight: 1,
failure_threshold_percent: 10, // = 10%
// In each round we get stastics for the single proposer
// and large number of validators. So the window for
// the proposers needs to be significantly larger
// to have enough useful statistics.
proposer_window_num_validators_multiplier: 10,
voter_window_num_validators_multiplier: 1,
weight_by_voting_power: true,
use_history_from_previous_epoch_max_count: 5,
}),
),
}
}
}

#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
pub struct ConsensusConfigV2 {
pub decoupled_execution: bool,
pub back_pressure_limit: u64,
pub exclude_round: u64,
pub proposer_election_type: ProposerElectionType,
pub max_failed_authors_to_store: usize,
pub enable_quorum_store: bool,
}

impl Default for ConsensusConfigV2 {
fn default() -> Self {
Self {
decoupled_execution: true,
Expand Down

0 comments on commit 602b919

Please sign in to comment.