From a24915b321be1274104e5cb771d6883f4e04ec2e Mon Sep 17 00:00:00 2001 From: Arun Koshy Date: Tue, 26 Sep 2023 11:16:09 -0700 Subject: [PATCH] Add a genesis state for genesis certs --- narwhal/types/src/primary.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/narwhal/types/src/primary.rs b/narwhal/types/src/primary.rs index 688d2f33e98309..2d0fbe038e6e99 100644 --- a/narwhal/types/src/primary.rs +++ b/narwhal/types/src/primary.rs @@ -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 { @@ -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, } } @@ -1322,6 +1326,9 @@ impl CertificateV2 { epoch: committee.epoch(), ..Default::default() }), + aggregate_signature_verification_state: AggregateSignatureVerificationState::Genesis( + AggregateSignatureBytes::default(), + ), ..Self::default() }) .collect() @@ -1488,7 +1495,8 @@ impl CertificateV2 { fn verify_signature(&mut self, pks: Vec) -> 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);