Struct bpcon::config::BPConConfig
source · pub struct BPConConfig {
pub party_weights: Vec<u64>,
pub threshold: u128,
pub launch_at: Instant,
pub launch1a_timeout: Duration,
pub launch1b_timeout: Duration,
pub launch2a_timeout: Duration,
pub launch2av_timeout: Duration,
pub launch2b_timeout: Duration,
pub finalize_timeout: Duration,
pub grace_period: Duration,
}Expand description
Configuration structure for BPCon.
BPConConfig holds the various timeouts and weight configurations necessary
for the BPCon consensus protocol. This configuration controls the timing
of different stages in the protocol and the distribution of party weights.
Fields§
§party_weights: Vec<u64>Parties weights: party_weights[i] corresponds to the i-th party’s weight.
These weights determine the influence each party has in the consensus process.
The sum of these weights is used to calculate the threshold for reaching a
Byzantine Fault Tolerant (BFT) quorum.
threshold: u128Threshold weight to define BFT quorum.
This value must be greater than or equal to 2/3 of the total weight of all parties combined. The quorum is the minimum weight required to make decisions in the BPCon protocol.
launch_at: InstantAbsolute time, at which party begins to work.
This timeout differs from launch1a_timeout as it applies to a distinct status
and does not involve listening to external events and messages.
launch1a_timeout: DurationTimeout before the 1a stage is launched.
The 1a stage is the first phase of the BPCon consensus process, where leader is informing other participants about the start of the ballot. This timeout controls the delay before starting this stage.
launch1b_timeout: DurationTimeout before the 1b stage is launched.
In the 1b stage, participants exchange their last voted ballot number and elected value. This timeout controls the delay before starting this stage.
launch2a_timeout: DurationTimeout before the 2a stage is launched.
The 2a stage involves leader proposing a selected value and other participants verifying it. This timeout controls the delay before starting this stage.
launch2av_timeout: DurationTimeout before the 2av stage is launched.
The 2av stage is where 2a obtained value shall gather needed weight to pass. This timeout controls the delay before starting this stage.
launch2b_timeout: DurationTimeout before the 2b stage is launched.
The 2b stage is where the final value is chosen and broadcasted. This timeout controls the delay before starting this stage.
finalize_timeout: DurationTimeout before the finalization stage is launched.
The finalization stage is not a part of protocol, but rather internal-centric mechanics to conclude ballot. This timeout controls the delay before starting this stage.
grace_period: DurationTimeout for a graceful period to accommodate parties with latency.
This grace period allows parties with slower communication or processing times to catch up, helping to ensure that all parties can participate fully in the consensus process.
Implementations§
source§impl BPConConfig
impl BPConConfig
sourcepub fn with_default_timeouts(party_weights: Vec<u64>, threshold: u128) -> Self
pub fn with_default_timeouts(party_weights: Vec<u64>, threshold: u128) -> Self
Create a new BPConConfig with default timeouts.
This method initializes a BPConConfig instance using default timeout values for each
stage of the BPCon consensus protocol. These defaults are placeholders and should be
tuned according to the specific needs and characteristics of the network.
§Parameters
party_weights: A vector of weights corresponding to each party involved in the consensus.threshold: The weight threshold required to achieve a BFT quorum.
§Returns
A new BPConConfig instance with the provided party_weights and threshold,
and default timeouts for all stages.
sourcepub fn compute_bft_threshold(party_weights: Vec<u64>) -> u128
pub fn compute_bft_threshold(party_weights: Vec<u64>) -> u128
Compute the Byzantine Fault Tolerance (BFT) threshold for the consensus protocol.
This function calculates the minimum weight required to achieve a BFT quorum. In BFT systems, consensus is typically reached when more than two-thirds of the total weight is gathered from non-faulty parties.
§Parameters
party_weights: A vector of weights corresponding to each party involved in the consensus. These weights represent the voting power or influence of each party in the protocol.
§Returns
The BFT threshold as a u128 value, which represents the minimum total weight
required to achieve consensus in a Byzantine Fault Tolerant system. This is calculated
as two-thirds of the total party weights.
§Example
use bpcon::config::BPConConfig;
let party_weights = vec![10, 20, 30, 40, 50];
let threshold = BPConConfig::compute_bft_threshold(party_weights);
assert_eq!(threshold, 100);In the example above, the total weight is 150, and the BFT threshold is calculated as 2/3 * 150 = 100.
Trait Implementations§
source§impl Clone for BPConConfig
impl Clone for BPConConfig
source§fn clone(&self) -> BPConConfig
fn clone(&self) -> BPConConfig
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for BPConConfig
impl Debug for BPConConfig
source§impl PartialEq for BPConConfig
impl PartialEq for BPConConfig
impl Eq for BPConConfig
impl StructuralPartialEq for BPConConfig
Auto Trait Implementations§
impl Freeze for BPConConfig
impl RefUnwindSafe for BPConConfig
impl Send for BPConConfig
impl Sync for BPConConfig
impl Unpin for BPConConfig
impl UnwindSafe for BPConConfig
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)