Skip to content

Commit

Permalink
Check committee_index during single attestation conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Tumas committed Jan 6, 2025
1 parent db2c98f commit 275ca45
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion p2p/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
time::Instant,
};

use anyhow::{bail, Error as AnyhowError, Result};
use anyhow::{bail, ensure, Error as AnyhowError, Result};
use dedicated_executor::DedicatedExecutor;
use enum_iterator::Sequence as _;
use eth1_api::RealController;
Expand Down Expand Up @@ -41,6 +41,7 @@ use ssz::{BitList, BitVector};
use std_ext::ArcExt as _;
use thiserror::Error;
use tokio_stream::wrappers::IntervalStream;
use typenum::Unsigned as _;
use types::{
altair::containers::{SignedContributionAndProof, SyncCommitteeMessage},
capella::containers::SignedBlsToExecutionChange,
Expand Down Expand Up @@ -2133,6 +2134,11 @@ fn try_convert_to_attestation<P: Preset>(
signature,
} = single_attestation;

ensure!(
committee_index < P::MaxCommitteesPerSlot::U64,
AnyhowError::msg("invalid committee_index: {committee_index}")
);

let mut committee_bits = BitVector::default();
let index = committee_index.try_into()?;
committee_bits.set(index, true);
Expand Down

0 comments on commit 275ca45

Please sign in to comment.