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: u128

Threshold 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: Instant

Absolute 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: Duration

Timeout 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: Duration

Timeout 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: Duration

Timeout 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: Duration

Timeout 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: Duration

Timeout 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: Duration

Timeout 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: Duration

Timeout 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

source

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.

source

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

source§

fn clone(&self) -> BPConConfig

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for BPConConfig

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for BPConConfig

source§

fn eq(&self, other: &BPConConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for BPConConfig

source§

impl StructuralPartialEq for BPConConfig

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V