mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-25 13:07:18 +00:00
spec v0.6: check custody bitfield length
This commit is contained in:
parent
a3a941efdf
commit
10884359af
@ -1,10 +1,10 @@
|
|||||||
use super::get_attesting_indices;
|
use super::{get_attesting_indices, get_attesting_indices_unsorted};
|
||||||
use itertools::{Either, Itertools};
|
use itertools::{Either, Itertools};
|
||||||
use types::*;
|
use types::*;
|
||||||
|
|
||||||
/// Convert `attestation` to (almost) indexed-verifiable form.
|
/// Convert `attestation` to (almost) indexed-verifiable form.
|
||||||
///
|
///
|
||||||
/// Spec v0.6.1
|
/// Spec v0.6.3
|
||||||
pub fn convert_to_indexed<T: EthSpec>(
|
pub fn convert_to_indexed<T: EthSpec>(
|
||||||
state: &BeaconState<T>,
|
state: &BeaconState<T>,
|
||||||
attestation: &Attestation,
|
attestation: &Attestation,
|
||||||
@ -12,6 +12,10 @@ pub fn convert_to_indexed<T: EthSpec>(
|
|||||||
let attesting_indices =
|
let attesting_indices =
|
||||||
get_attesting_indices(state, &attestation.data, &attestation.aggregation_bitfield)?;
|
get_attesting_indices(state, &attestation.data, &attestation.aggregation_bitfield)?;
|
||||||
|
|
||||||
|
// We verify the custody bitfield by calling `get_attesting_indices_unsorted` and throwing
|
||||||
|
// away the result. This avoids double-sorting - the partition below takes care of the ordering.
|
||||||
|
get_attesting_indices_unsorted(state, &attestation.data, &attestation.custody_bitfield)?;
|
||||||
|
|
||||||
let (custody_bit_0_indices, custody_bit_1_indices) =
|
let (custody_bit_0_indices, custody_bit_1_indices) =
|
||||||
attesting_indices.into_iter().enumerate().partition_map(
|
attesting_indices.into_iter().enumerate().partition_map(
|
||||||
|(committee_idx, validator_idx)| match attestation.custody_bitfield.get(committee_idx) {
|
|(committee_idx, validator_idx)| match attestation.custody_bitfield.get(committee_idx) {
|
||||||
|
Loading…
Reference in New Issue
Block a user