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: implement threshold strategy #287

Merged
merged 20 commits into from
Sep 24, 2024
Merged

Conversation

gregorydemay
Copy link
Member

@gregorydemay gregorydemay commented Sep 23, 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.

@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 12:33
src/rpc_client/mod.rs Show resolved Hide resolved
src/rpc_client/mod.rs Show resolved Hide resolved
src/rpc_client/providers.rs Outdated Show resolved Hide resolved
src/rpc_client/requests.rs Outdated Show resolved Hide resolved
src/rpc_client/responses.rs Outdated Show resolved Hide resolved
src/rpc_client/tests.rs Show resolved Hide resolved
@THLO
Copy link
Contributor

THLO commented Sep 23, 2024

if it appeared more that the specified threshold number of times.

Shouldn't it be "at least the specified threshold number of times"?

src/rpc_client/mod.rs Outdated Show resolved Hide resolved
gregorydemay added a commit that referenced this pull request Sep 24, 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 (#287).

---------

Co-authored-by: Thomas Locher <[email protected]>
Base automatically changed from gdemay/284-consensus to main September 24, 2024 07:54
# Conflicts:
#	Cargo.toml
#	evm_rpc_types/src/rpc_client/mod.rs
#	src/rpc_client/mod.rs
@gregorydemay gregorydemay merged commit 691f840 into main Sep 24, 2024
3 checks passed
@gregorydemay gregorydemay deleted the gdemay/284-consensus-threshold branch September 24, 2024 09:37
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