Metrics for sync aggregate fullness (#2439)

## Issue Addressed

NA

## Proposed Changes

Adds a metric to see how many set bits are in the sync aggregate for each beacon block being imported.

## Additional Info

NA
This commit is contained in:
Paul Hauner
2021-07-13 02:22:55 +00:00
parent 27aec1962c
commit 9656ffee7c
4 changed files with 35 additions and 4 deletions

View File

@@ -45,6 +45,16 @@ pub struct BeaconBlockBody<T: EthSpec> {
pub sync_aggregate: SyncAggregate<T>,
}
impl<'a, T: EthSpec> BeaconBlockBodyRef<'a, T> {
/// Access the sync aggregate from the block's body, if one exists.
pub fn sync_aggregate(self) -> Option<&'a SyncAggregate<T>> {
match self {
BeaconBlockBodyRef::Base(_) => None,
BeaconBlockBodyRef::Altair(inner) => Some(&inner.sync_aggregate),
}
}
}
#[cfg(test)]
mod tests {
mod base {

View File

@@ -33,4 +33,9 @@ impl<T: EthSpec> SyncAggregate<T> {
sync_committee_signature: AggregateSignature::empty(),
}
}
/// Returns how many bits are `true` in `self.sync_committee_bits`.
pub fn num_set_bits(&self) -> usize {
self.sync_committee_bits.num_set_bits()
}
}