|
1 | 1 | //! Put Alpenglow consensus messages here so all clients can agree on the format. |
2 | 2 | use { |
3 | | - crate::vote::Vote, |
| 3 | + crate::{ |
| 4 | + fraction::Fraction, |
| 5 | + migration::GENESIS_VOTE_THRESHOLD, |
| 6 | + vote::{Vote, VoteType}, |
| 7 | + }, |
4 | 8 | serde::{Deserialize, Serialize}, |
5 | 9 | solana_bls_signatures::Signature as BLSSignature, |
6 | 10 | solana_clock::Slot, |
@@ -161,6 +165,31 @@ impl CertificateType { |
161 | 165 | _ => None, |
162 | 166 | } |
163 | 167 | } |
| 168 | + |
| 169 | + /// Returns the stake fraction required for certificate completion and the |
| 170 | + /// `VoteType`s that contribute to this certificate. |
| 171 | + /// |
| 172 | + /// Must be in sync with `Vote::to_cert_types` |
| 173 | + pub const fn limits_and_vote_types(&self) -> (Fraction, &'static [VoteType]) { |
| 174 | + match self { |
| 175 | + CertificateType::Notarize(_, _) => { |
| 176 | + (Fraction::from_percentage(60), &[VoteType::Notarize]) |
| 177 | + } |
| 178 | + CertificateType::NotarizeFallback(_, _) => ( |
| 179 | + Fraction::from_percentage(60), |
| 180 | + &[VoteType::Notarize, VoteType::NotarizeFallback], |
| 181 | + ), |
| 182 | + CertificateType::FinalizeFast(_, _) => { |
| 183 | + (Fraction::from_percentage(80), &[VoteType::Notarize]) |
| 184 | + } |
| 185 | + CertificateType::Finalize(_) => (Fraction::from_percentage(60), &[VoteType::Finalize]), |
| 186 | + CertificateType::Skip(_) => ( |
| 187 | + Fraction::from_percentage(60), |
| 188 | + &[VoteType::Skip, VoteType::SkipFallback], |
| 189 | + ), |
| 190 | + CertificateType::Genesis(_, _) => (GENESIS_VOTE_THRESHOLD, &[VoteType::Genesis]), |
| 191 | + } |
| 192 | + } |
164 | 193 | } |
165 | 194 |
|
166 | 195 | /// The actual certificate with the aggregate signature and bitmap for which validators are included in the aggregate. |
|
0 commit comments