Skip to content

Commit

Permalink
Add a genesis state for genesis certs
Browse files Browse the repository at this point in the history
  • Loading branch information
arun-koshy committed Sep 26, 2023
1 parent 36404cf commit a24915b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions narwhal/types/src/primary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,9 @@ pub enum AggregateSignatureVerificationState {
// This state occurs when the certificate has not yet received a quorum of
// signatures.
Unsigned(AggregateSignatureBytes),
// This state occurs only for genesis certificates which always has valid
// signatures bytes but the bytes are garbage so we don't mark them as verified.
Genesis(AggregateSignatureBytes),
}

impl Default for AggregateSignatureVerificationState {
Expand Down Expand Up @@ -1279,7 +1282,8 @@ impl CertificateAPI for CertificateV2 {
AggregateSignatureVerificationState::VerifiedIndirectly(bytes)
| AggregateSignatureVerificationState::VerifiedDirectly(bytes)
| AggregateSignatureVerificationState::Unverified(bytes)
| AggregateSignatureVerificationState::Unsigned(bytes) => bytes,
| AggregateSignatureVerificationState::Unsigned(bytes)
| AggregateSignatureVerificationState::Genesis(bytes) => bytes,
}
}

Expand Down Expand Up @@ -1322,6 +1326,9 @@ impl CertificateV2 {
epoch: committee.epoch(),
..Default::default()
}),
aggregate_signature_verification_state: AggregateSignatureVerificationState::Genesis(
AggregateSignatureBytes::default(),
),
..Self::default()
})
.collect()
Expand Down Expand Up @@ -1488,7 +1495,8 @@ impl CertificateV2 {
fn verify_signature(&mut self, pks: Vec<PublicKey>) -> DagResult<()> {
let aggregrate_signature_bytes = match self.aggregate_signature_verification_state {
AggregateSignatureVerificationState::VerifiedIndirectly(ref bytes) => bytes,
AggregateSignatureVerificationState::VerifiedDirectly(_) => return Ok(()),
AggregateSignatureVerificationState::VerifiedDirectly(_)
| AggregateSignatureVerificationState::Genesis(_) => return Ok(()),
AggregateSignatureVerificationState::Unverified(ref bytes) => bytes,
AggregateSignatureVerificationState::Unsigned(_) => {
bail!(DagError::CertificateRequiresQuorum);
Expand Down

0 comments on commit a24915b

Please sign in to comment.