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

feat: Choose a consensus strategy #286

Merged
merged 10 commits into from
Sep 24, 2024
Merged

feat: Choose a consensus strategy #286

merged 10 commits into from
Sep 24, 2024

Conversation

gregorydemay
Copy link
Member

@gregorydemay gregorydemay commented Sep 20, 2024

Introduce a new parameter in RpcConfig to let the caller choose between different consensus strategies to aggregate answers from multiple providers. Two strategies are defined, with the possibility of adding more in the future:

  1. Equality: this is the default and matches the current behaviour, where all responses are expected to be non-error cases and all responses are expected to be equal.
  2. Threshold: new strategy introduced by this PR, allowing to relax the aforementioned equality strategy to only a subset of the responses. Choosing this strategy may influence the chosen providers to match the specified threshold parameters. The implementation of responses aggregation in this case is done in a separate PR (feat: implement threshold strategy #287).

Base automatically changed from gdemay/243-move-types to main September 20, 2024 19:08
@gregorydemay gregorydemay linked an issue Sep 23, 2024 that may be closed by this pull request
@gregorydemay gregorydemay marked this pull request as ready for review September 23, 2024 06:20
src/lib.rs Show resolved Hide resolved
Copy link
Collaborator

@rvanasa rvanasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on! The refactoring changes look great. LGTM modulo the ongoing conversation about what to name num_providers and min_num_ok.

evm_rpc_types/src/rpc_client/mod.rs Show resolved Hide resolved
candid/evm_rpc.did Show resolved Hide resolved
candid/evm_rpc.did Show resolved Hide resolved
src/rpc_client/mod.rs Show resolved Hide resolved
src/rpc_client/mod.rs Show resolved Hide resolved
src/rpc_client/mod.rs Show resolved Hide resolved
src/rpc_client/mod.rs Show resolved Hide resolved
src/rpc_client/mod.rs Show resolved Hide resolved
src/rpc_client/mod.rs Show resolved Hide resolved
@gregorydemay gregorydemay merged commit 4661cef into main Sep 24, 2024
3 checks passed
@gregorydemay gregorydemay deleted the gdemay/284-consensus branch September 24, 2024 07:54
gregorydemay added a commit that referenced this pull request Sep 24, 2024
Follow-up on #286 to implement the threshold strategy to aggregate
responses from multiple providers:

- Introduce a top-level `MultiCallResults::reduce` method which takes as
parameter a `ConsensusStrategy` to aggregate the various responses. All
existing methods, including `eth_fee_history`, were refactor to use the
new `reduce` method.
- In case of `ConsensusStrategy::Threshold`, the reduction strategy
simply consists of returning the most frequent (non-error) response if
it appeared at least the specified threshold number of times.
- Refactor `MultiCallResults` to stored ok results and errors
separately.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support robust consensus strategies between providers
3 participants