Skip to content
This repository was archived by the owner on Feb 27, 2025. It is now read-only.

Conversation

@lukaszrzasik
Copy link
Contributor

@lukaszrzasik lukaszrzasik commented Jul 26, 2024

Closes #3494

This PR:

Adds a new HotShotEvent::QuorumProposalPreliminarilyValidated. This event indicates that the received quorum proposal has been preliminarily validated. This means that the quorum proposal
i. is not for an old view,
ii. has been correctly signed by the leader of the current view,
iii. includes a valid justify QC.
The HotShotEvent::QuorumProposalPreliminarilyValidated is received by the QuorumProposalTaskState instead of HotShotEvent::QuorumProposalRecv. It protects the QuorumProposalTaskState against spoofed quorum proposals.

Additionally:
i. Moves the signature check from validate_proposal_safety_and_liveness to validate_proposal_view_and_certs.
ii. Broadcasts HighQcUpdated instead of UpdateHighQc at the end of handle_quorum_proposal_recv because it is more accurate and saves us from a redundant shared consensus state update.

This PR does not:

This PR allows dependency tasks-based consensus to progress when flooded with spoofed quorum proposals but the progression is much slower than normal.

Key places to review:

crates/task-impls/src/helpers.rs
crates/task-impls/src/quorum_proposal_recv/handlers.rs
crates/task-impls/src/quorum_proposal/mod.rs

How to test this PR:

All tests should pass.
The change has been tested with demo-native and one of the nodes sending spoofed quorum proposals. The consensus progresses correctly. Only the faulty leader's views timeout.

@lukaszrzasik lukaszrzasik marked this pull request as ready for review July 29, 2024 13:32
@lukaszrzasik lukaszrzasik requested a review from bfish713 as a code owner July 29, 2024 13:32
Copy link
Contributor

@jparr721 jparr721 left a comment

Choose a reason for hiding this comment

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

Great work, just a couple things I'd like your opinion on.

ensure!(
view_leader_key == *sender,
"Leader key does not match key in proposal"
view_leader_key.validate(&proposal.signature, proposed_leaf.commit().as_ref()),
Copy link
Contributor

Choose a reason for hiding this comment

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

This validate_signature method exists now. Should we just use that?

/// 1. The proposal is not for an old view
/// 2. The proposal has been correctly signed by the leader of the current view
/// 3. The justify QC is valid
QuorumProposalPreliminarilyValidated(Proposal<TYPES, QuorumProposal<TYPES>>),
Copy link
Contributor

@jparr721 jparr721 Jul 29, 2024

Choose a reason for hiding this comment

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

Do you think it'd be helpful to elucidate how this event is different from the QuorumProposalValidated event? Unfortunately, it looks like the QuorumProposalValidated event's doc comment doesn't give much information right now, so an unfamiliar reader might not be able to trivially differentiate the two events without tracing the validation paths. We could also update the validated event as well with a more descriptive doc comment.

bfish713
bfish713 previously approved these changes Jul 29, 2024
Copy link
Contributor

@jparr721 jparr721 left a comment

Choose a reason for hiding this comment

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

Looks good, one last little thing

/// All dependencies for the quorum vote are validated.
QuorumVoteDependenciesValidated(TYPES::Time),
/// A quorum proposal with the given parent leaf is validated.
/// The full validation checks include:
Copy link
Contributor

Choose a reason for hiding this comment

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

Love this!

);
// Validate the proposal's signature. This should also catch if the leaf_commitment does not equal our calculated parent commitment
//
// There is a mistake here originating in the genesis leaf/qc commit. This should be replaced by:
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we might be able to remove this comment entirely? Looks like we can keep the above, but the "there is a mistake here" part seems to be rectified.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right!

@lukaszrzasik lukaszrzasik merged commit 18ea1cb into main Jul 31, 2024
@lukaszrzasik lukaszrzasik deleted the lr/split-validation branch July 31, 2024 07:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DEPENDENCY_REFACTOR] - Split quorum proposal validation

4 participants