Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Dispute Coordinator: Batch queries #3459

Merged
merged 4 commits into from
Jul 13, 2021

Conversation

Lldenaurois
Copy link
Contributor

This PR modifies the communication protocol between the provisioner and the dispute-coordinator. In the past, the dispute-coordinator kept track of a FuturesOrdered of oneshot-receivers and constructed a view of the recent disputes in this fashion.

Instead, it is more efficient to allow batch queries and only iterator over the recent disputes once. We leverage a single oneshot channel to reply to the batch Vec<(SessionIndex, CandidateHash)> request with the Vec<(SessionIndex, Candidatehash, CandidateVotes)> batch response.

Closes #3439

This commit moves to batch queries when responding to QueryCandidateVotes
messages. This simplifies the code in the provisioner and dispute-coordinator
by no longer requiring to make use of a FuturesOrdered when awaiting multiple
quries. Instead, the provisioner need only request the batch itself.
@Lldenaurois Lldenaurois added A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders. I8-refactor Code needs refactoring. B0-silent Changes should not be mentioned in any release notes labels Jul 12, 2021
@Lldenaurois Lldenaurois force-pushed the batch_queries branch 2 times, most recently from dc932bc to 39ab51b Compare July 12, 2021 17:37
Copy link
Contributor Author

@Lldenaurois Lldenaurois left a comment

Choose a reason for hiding this comment

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

Migrated comments from the other PR over.

#3447 was closed when another PR was merged. I just noticed today.

)? {
query_output.push(v.into());
} else {
return Err(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rphmeier Here is the modification that ensures we only respond if every (session_index, candidate_hash) exists in the db or we return an error.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is returning an io Error from the entire subsystem. We should probably just log something and continue. There's no need to break the message processing loop.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's important to make a distinction between errors the subsystem encounters while processing requests and requests the subsystem can't fulfill, but is fine with being able to skip those. As written, any request referencing missing data could interrupt the subsystem and potentially take it down.

Err(oneshot::Canceled) => {
tracing::debug!(
target: LOG_TARGET,
"Unable to query candidate votes - subsystem disconnected?",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rphmeier Added the added debug! log

@rphmeier
Copy link
Contributor

Is this still missing guide changes?

@Lldenaurois
Copy link
Contributor Author

Added guide changes and moved away from the all-or-nothing model. Instead, the session_index and candidate_hash are being sent in the response. This removes the need for a clone and seems to handle the overall behavior in a cleaner fashion.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. I8-refactor Code needs refactoring.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DisputeCoordinator QueryCandidateVotes should be able to answer multiple queries at once
2 participants