Skip to content

Commit

Permalink
Add check for number of last_election_certificate_ids
Browse files Browse the repository at this point in the history
  • Loading branch information
raychu86 committed Dec 18, 2023
1 parent 1e90511 commit 4a3cf3c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ledger/narwhal/batch-header/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ impl<N: Network> BatchHeader<N> {
ensure!(transmission_ids.len() <= Self::MAX_TRANSMISSIONS, "Invalid number of transmission ids");
// Ensure that the number of previous certificate IDs is within bounds.
ensure!(previous_certificate_ids.len() <= Self::MAX_CERTIFICATES, "Invalid number of previous certificate IDs");
// Ensure the number of last election certificate IDs is within bounds.
ensure!(
last_election_certificate_ids.len() <= Self::MAX_CERTIFICATES,
"Invalid number of last election certificate IDs"
);

// Retrieve the address.
let author = Address::try_from(private_key)?;
Expand Down Expand Up @@ -150,6 +155,11 @@ impl<N: Network> BatchHeader<N> {
ensure!(transmission_ids.len() <= Self::MAX_TRANSMISSIONS, "Invalid number of transmission ids");
// Ensure that the number of previous certificate IDs is within bounds.
ensure!(previous_certificate_ids.len() <= Self::MAX_CERTIFICATES, "Invalid number of previous certificate IDs");
// Ensure the number of last election certificate IDs is within bounds.
ensure!(
last_election_certificate_ids.len() <= Self::MAX_CERTIFICATES,
"Invalid number of last election certificate IDs"
);

// Compute the batch ID.
let batch_id = Self::compute_batch_id(
Expand Down

0 comments on commit 4a3cf3c

Please sign in to comment.