Skip to content

Commit

Permalink
Merge pull request fedimint#4189 from joschisan/rm_full_participation
Browse files Browse the repository at this point in the history
fix: remove non-fault tolerant query strategy
  • Loading branch information
justinmoon authored Feb 1, 2024
2 parents 718bf5e + 09fe6aa commit 7fe0a20
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 21 deletions.
7 changes: 1 addition & 6 deletions fedimint-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use fedimint_core::config::{ClientConfig, FederationId};
use fedimint_core::core::OperationId;
use fedimint_core::db::{Database, DatabaseValue};
use fedimint_core::module::{ApiAuth, ApiRequestErased};
use fedimint_core::query::ThresholdConsensus;
use fedimint_core::util::SafeUrl;
use fedimint_core::{task, PeerId, TieredMulti};
use fedimint_ln_client::LightningClientInit;
Expand Down Expand Up @@ -720,11 +719,7 @@ impl FedimintCli {
.await
.map_err_cli_general()?,
None => ws_api
.request_with_strategy(
ThresholdConsensus::full_participation(ws_api.peers().len()),
method,
params,
)
.request_current_consensus(method, params)
.await
.map_err_cli_general()?,
};
Expand Down
2 changes: 1 addition & 1 deletion fedimint-core/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ pub trait FederationApiExt: IRawFederationApi {
Ret: serde::de::DeserializeOwned + Eq + Debug + Clone + MaybeSend,
{
self.request_with_strategy(
ThresholdConsensus::overcome_evil(self.all_peers().total()),
ThresholdConsensus::new(self.all_peers().total()),
method,
params,
)
Expand Down
16 changes: 2 additions & 14 deletions fedimint-core/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl<R: Eq + Clone + Debug, T> QueryStrategy<R, BTreeMap<PeerId, T>> for FilterM
}
}

/// Returns when a threshold of responses are equal
/// Returns when we obtain a threshold of identical responses
pub struct ThresholdConsensus<R> {
error_strategy: ErrorStrategy,
responses: BTreeMap<PeerId, R>,
Expand All @@ -226,9 +226,7 @@ pub struct ThresholdConsensus<R> {
}

impl<R> ThresholdConsensus<R> {
// Require that enough participants return the same message to ensure that we
// overcome the threshold for malicious nodes
pub fn overcome_evil(total_peers: usize) -> Self {
pub fn new(total_peers: usize) -> Self {
let max_evil = (total_peers - 1) / 3;
let threshold = total_peers - max_evil;

Expand All @@ -239,16 +237,6 @@ impl<R> ThresholdConsensus<R> {
threshold,
}
}

// Require that all participants return the same message
pub fn full_participation(total_peers: usize) -> Self {
Self {
error_strategy: ErrorStrategy::new(1),
responses: BTreeMap::new(),
retry: BTreeSet::new(),
threshold: total_peers,
}
}
}

impl<R: Eq> ThresholdConsensus<R> {
Expand Down

0 comments on commit 7fe0a20

Please sign in to comment.