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

Dispute Coordinator Subsystem #3150

Merged
merged 67 commits into from
Jun 13, 2021
Merged

Dispute Coordinator Subsystem #3150

merged 67 commits into from
Jun 13, 2021

Conversation

rphmeier
Copy link
Contributor

@rphmeier rphmeier commented Jun 1, 2021

Closes #3166

The dispute coordinator keeps track of all votes received on all candidates in a rolling window of sessions. It uses these to detect disputes between validators. It also provides interfaces to inform the provisioner about what to include in the chain.

More information can be found in the implementers' guide: https://w3f.github.io/parachain-implementers-guide/node/disputes/dispute-coordinator.html

This does not yet implement chain rollbacks or integrate the subsystem into the overseer. That will require a parachains-db version upgrade and will be done in a follow-on pull request.

@rphmeier rphmeier added A3-in_progress Pull request is in progress. No review needed at this stage. 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. labels Jun 1, 2021
node/core/dispute-coordinator/src/lib.rs Outdated Show resolved Hide resolved
node/subsystem/src/messages.rs Outdated Show resolved Hide resolved
node/subsystem/src/messages.rs Show resolved Hide resolved
node/core/dispute-coordinator/src/db/v1.rs Show resolved Hide resolved
@rphmeier rphmeier marked this pull request as ready for review June 11, 2021 15:03
@rphmeier rphmeier added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Jun 11, 2021
@rphmeier rphmeier added the D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed. label Jun 11, 2021
rphmeier added 2 commits June 12, 2021 15:37
as of #3222 we can do most of the work within the approval voting subsystem
@Lldenaurois Lldenaurois self-requested a review June 12, 2021 17:59

// It would be nice to draw this from the chain state, but we have no tools for it right now.
// On Polkadot this is 1 day, and on Kusama it's 6 hours.
const DISPUTE_WINDOW: SessionIndex = 6;
Copy link
Member

Choose a reason for hiding this comment

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

but we have no tools for it right now

could you elaborate why can't we use SessionInfo::dispute_period from the runtime like we did previously?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no dispute_period in struct SessionInfo. That is exactly what I mean by 'no tools for it' - we'd need to change the type definition or add a new runtime API.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I meant in HostConfiguration.

Copy link
Member

Choose a reason for hiding this comment

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

But we can probably rely on the fact that session_info will store sessions based on dispute_period?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#3227 <- We need to expose it, and that's beyond scope here IMO

Copy link
Contributor

@drahnr drahnr left a comment

Choose a reason for hiding this comment

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

A few nits, generally looks very good and seems to do what is described in the Dispute Coordinator in the guide 👍

node/core/dispute-coordinator/src/db/v1.rs Outdated Show resolved Hide resolved
node/core/dispute-coordinator/src/db/v1.rs Show resolved Hide resolved
node/core/dispute-coordinator/src/db/v1.rs Outdated Show resolved Hide resolved
node/core/dispute-coordinator/src/lib.rs Outdated Show resolved Hide resolved
node/core/dispute-coordinator/src/lib.rs Show resolved Hide resolved
node/primitives/src/lib.rs Show resolved Hide resolved
node/primitives/src/lib.rs Show resolved Hide resolved
node/core/dispute-coordinator/src/lib.rs Outdated Show resolved Hide resolved
rphmeier and others added 2 commits June 12, 2021 21:31
@rphmeier rphmeier merged commit 19c1d29 into master Jun 13, 2021
@rphmeier rphmeier deleted the rh-dispute-coordinator branch June 13, 2021 11:35
/// When inspecting a new import notification, updates the session info cache to match
/// the session of the imported block.
///
/// this only needs to be called on heads where we are directly notified about import, as sessions do
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// this only needs to be called on heads where we are directly notified about import, as sessions do
/// This only needs to be called on heads where we are directly notified about import, as sessions do

/// this only needs to be called on heads where we are directly notified about import, as sessions do
/// not change often and import notifications are expected to be typically increasing in session number.
///
/// some backwards drift in session index is acceptable.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// some backwards drift in session index is acceptable.
/// Some backwards drift in session index is acceptable.

Err(SessionsUnavailable {
kind,
info: Some(SessionsUnavailableInfo {
window_start: latest +1,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
window_start: latest +1,
window_start: fresh_start,

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIU this could also be window_start since that's what we wanted the full window to be, but we only started requesting from fresh_start and so that's the only data that we're missing.

let update = SessionWindowUpdate::Advanced {
prev_window_start: old_window_start,
prev_window_end: old_window_end,
new_window_start: window_start,
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use earliest_session from below here to account for the edge case described.

Comment on lines +253 to +254
/// The indices of validators who have already voted on this candidate.
voted_indices: Vec<ValidatorIndex>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure this will be needed.

Comment on lines +1255 to +1259
// Add variants here as needed, `{ cnt += 1; }` for those that need to be
// notified, `unreachable!()` for those that should not.
}
}
assert_eq!(cnt, EXPECTED_COUNT);
Copy link
Contributor

Choose a reason for hiding this comment

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

Formatted with spaces.

}
}


Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

Comment on lines +284 to +285

// TODO [after https://github.com/paritytech/polkadot/issues/3160]: chain rollbacks
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// TODO [after https://github.com/paritytech/polkadot/issues/3160]: chain rollbacks

I guess this won't be happening anymore as we'll go with using SelectChain instead.

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. D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Dispute Coordinator
6 participants