-
Notifications
You must be signed in to change notification settings - Fork 72
Lr/split validation #3495
Lr/split validation #3495
Changes from 8 commits
8bf609a
1383d7a
bdd911e
0df5de2
20e9397
63b5aff
63c5e28
9957263
3161e3a
419bcfc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,6 +84,11 @@ pub enum HotShotEvent<TYPES: NodeType> { | |
| /// 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: | ||
| /// 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 | ||
| /// 4. The proposal passes either liveness or safety check. | ||
| QuorumProposalValidated(QuorumProposal<TYPES>, Leaf<TYPES>), | ||
| /// A quorum proposal is missing for a view that we meed | ||
| QuorumProposalRequest(ProposalMissing<TYPES>), | ||
|
|
@@ -191,6 +196,13 @@ pub enum HotShotEvent<TYPES: NodeType> { | |
|
|
||
| /// A new high_qc has been updated in `Consensus`. | ||
| HighQcUpdated(QuorumCertificate<TYPES>), | ||
|
|
||
| /// A quorum proposal has been preliminarily validated. | ||
| /// The preliminary checks include: | ||
| /// 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>>), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| } | ||
|
|
||
| impl<TYPES: NodeType> Display for HotShotEvent<TYPES> { | ||
|
|
@@ -428,6 +440,13 @@ impl<TYPES: NodeType> Display for HotShotEvent<TYPES> { | |
| HotShotEvent::HighQcUpdated(cert) => { | ||
| write!(f, "HighQcUpdated(view_number={:?})", cert.view_number()) | ||
| } | ||
| HotShotEvent::QuorumProposalPreliminarilyValidated(proposal) => { | ||
| write!( | ||
| f, | ||
| "QuorumProposalPreliminarilyValidated(view_number={:?}", | ||
| proposal.data.view_number() | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,6 @@ use hotshot_types::{ | |
| block_contents::BlockHeader, | ||
| election::Membership, | ||
| node_implementation::{ConsensusTime, NodeType}, | ||
| signature_key::SignatureKey, | ||
| BlockPayload, ValidatedState, | ||
| }, | ||
| utils::{Terminator, View, ViewInner}, | ||
|
|
@@ -353,7 +352,6 @@ pub async fn validate_proposal_safety_and_liveness<TYPES: NodeType>( | |
| consensus: OuterConsensus<TYPES>, | ||
| decided_upgrade_certificate: Arc<RwLock<Option<UpgradeCertificate<TYPES>>>>, | ||
| quorum_membership: Arc<TYPES::Membership>, | ||
| view_leader_key: TYPES::SignatureKey, | ||
| event_stream: Sender<Arc<HotShotEvent<TYPES>>>, | ||
| sender: TYPES::SignatureKey, | ||
| event_sender: Sender<Event<TYPES>>, | ||
|
|
@@ -397,18 +395,6 @@ pub async fn validate_proposal_safety_and_liveness<TYPES: NodeType>( | |
| ) | ||
| .await; | ||
|
|
||
| // 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: | ||
| // | ||
| // proposal.validate_signature(&quorum_membership)?; | ||
| // | ||
| // in a future PR. | ||
| ensure!( | ||
| view_leader_key.validate(&proposal.signature, proposed_leaf.commit().as_ref()), | ||
| "Could not verify proposal." | ||
| ); | ||
|
|
||
| UpgradeCertificate::validate(&proposal.data.upgrade_certificate, &quorum_membership)?; | ||
|
|
||
| // Validate that the upgrade certificate is re-attached, if we saw one on the parent | ||
|
|
@@ -487,7 +473,6 @@ pub async fn validate_proposal_safety_and_liveness<TYPES: NodeType>( | |
| /// If any validation or view number check fails. | ||
| pub fn validate_proposal_view_and_certs<TYPES: NodeType>( | ||
| proposal: &Proposal<TYPES, QuorumProposal<TYPES>>, | ||
| sender: &TYPES::SignatureKey, | ||
| cur_view: TYPES::Time, | ||
| quorum_membership: &Arc<TYPES::Membership>, | ||
| timeout_membership: &Arc<TYPES::Membership>, | ||
|
|
@@ -499,11 +484,14 @@ pub fn validate_proposal_view_and_certs<TYPES: NodeType>( | |
| proposal.data.clone() | ||
| ); | ||
|
|
||
| let view_leader_key = quorum_membership.leader(view); | ||
| ensure!( | ||
| view_leader_key == *sender, | ||
| "Leader key does not match key in proposal" | ||
| ); | ||
| // 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: | ||
|
||
| // | ||
| // proposal.validate_signature(&quorum_membership)?; | ||
| // | ||
| // in a future PR. | ||
| proposal.validate_signature(quorum_membership)?; | ||
|
|
||
| // Verify a timeout certificate OR a view sync certificate exists and is valid. | ||
| if proposal.data.justify_qc.view_number() != view - 1 { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this!