Skip to content

Commit

Permalink
Add extra info to CommitteeLengthMismatch error
Browse files Browse the repository at this point in the history
  • Loading branch information
Tumas committed May 14, 2024
1 parent 431fbe3 commit 24f6beb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions helper_functions/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ pub(crate) enum Error {
AttestingIndicesNotSortedAndUnique,
#[error("commitee index is out of bounds")]
CommitteeIndexOutOfBounds,
#[error("aggregation bitlist length does not match committee length")]
CommitteeLengthMismatch,
#[error("aggregation bitlist length {aggregation_bitlist_length} does not match committee length {committee_length}")]
CommitteeLengthMismatch {
aggregation_bitlist_length: usize,
committee_length: usize,
},
#[error("epoch is after next one relative to state")]
EpochAfterNext,
#[error("epoch is before previous one relative to state")]
Expand Down
5 changes: 4 additions & 1 deletion helper_functions/src/phase0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ pub fn get_attesting_indices<'all, P: Preset>(

ensure!(
committee.len() == aggregation_bits.len(),
Error::CommitteeLengthMismatch,
Error::CommitteeLengthMismatch {
aggregation_bitlist_length: aggregation_bits.len(),
committee_length: committee.len(),
},
);

// `Itertools::zip_eq` is slower than `Iterator::zip` when iterating over packed indices.
Expand Down

0 comments on commit 24f6beb

Please sign in to comment.