Skip to content

Commit

Permalink
get tests to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
eserilev committed Apr 14, 2024
1 parent 55ff98c commit 1110958
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 39 deletions.
1 change: 0 additions & 1 deletion beacon_node/beacon_chain/src/attestation_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,6 @@ pub fn obtain_indexed_attestation_and_committees_per_slot<T: BeaconChainTypes>(
map_attestation_committee(chain, attestation, |(committees, committees_per_slot)| {
match attestation {
Attestation::Base(att) => {
println!("BASE FAILURE");
let committee = committees
.iter()
.filter(|&committee| committee.index == att.data.index)
Expand Down
9 changes: 5 additions & 4 deletions beacon_node/http_api/tests/broadcast_validation_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ pub async fn consensus_gossip() {
assert_eq!(error_response.status(), Some(StatusCode::BAD_REQUEST));

assert!(
matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: Invalid block: StateRootMismatch { block: 0x0000000000000000000000000000000000000000000000000000000000000000, local: 0xfc675d642ff7a06458eb33c7d7b62a5813e34d1b2bb1aee3e395100b579da026 }".to_string())
matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: Invalid block: StateRootMismatch { block: 0x0000000000000000000000000000000000000000000000000000000000000000, local: 0xa134420ce0b5cbd374f732114921a0abd93b3f5bc28550852ac32dbca539ea7d }".to_string())
);
}

Expand Down Expand Up @@ -604,7 +604,7 @@ pub async fn equivocation_gossip() {
assert_eq!(error_response.status(), Some(StatusCode::BAD_REQUEST));

assert!(
matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: Invalid block: StateRootMismatch { block: 0x0000000000000000000000000000000000000000000000000000000000000000, local: 0xfc675d642ff7a06458eb33c7d7b62a5813e34d1b2bb1aee3e395100b579da026 }".to_string())
matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: Invalid block: StateRootMismatch { block: 0x0000000000000000000000000000000000000000000000000000000000000000, local: 0xa134420ce0b5cbd374f732114921a0abd93b3f5bc28550852ac32dbca539ea7d }".to_string())
);
}

Expand Down Expand Up @@ -1006,8 +1006,9 @@ pub async fn blinded_consensus_gossip() {
/* mandated by Beacon API spec */
assert_eq!(error_response.status(), Some(StatusCode::BAD_REQUEST));

// TODO(eip7549) not sure whats going on here
assert!(
matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: Invalid block: StateRootMismatch { block: 0x0000000000000000000000000000000000000000000000000000000000000000, local: 0xfc675d642ff7a06458eb33c7d7b62a5813e34d1b2bb1aee3e395100b579da026 }".to_string())
matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: Invalid block: StateRootMismatch { block: 0x0000000000000000000000000000000000000000000000000000000000000000, local: 0xa134420ce0b5cbd374f732114921a0abd93b3f5bc28550852ac32dbca539ea7d }".to_string())
);
}

Expand Down Expand Up @@ -1219,7 +1220,7 @@ pub async fn blinded_equivocation_gossip() {
assert_eq!(error_response.status(), Some(StatusCode::BAD_REQUEST));

assert!(
matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: Invalid block: StateRootMismatch { block: 0x0000000000000000000000000000000000000000000000000000000000000000, local: 0xfc675d642ff7a06458eb33c7d7b62a5813e34d1b2bb1aee3e395100b579da026 }".to_string())
matches!(error_response, eth2::Error::ServerMessage(err) if err.message == "BAD_REQUEST: Invalid block: StateRootMismatch { block: 0x0000000000000000000000000000000000000000000000000000000000000000, local: 0xa134420ce0b5cbd374f732114921a0abd93b3f5bc28550852ac32dbca539ea7d }".to_string())
);
}

Expand Down
3 changes: 1 addition & 2 deletions beacon_node/operation_pool/src/attestation_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<E: EthSpec> SplitAttestation<E> {
aggregation_bits: att.aggregation_bits,
signature: att.signature,
},

Attestation::Electra(att) => {
// TODO(eip7549) how should we handle an empty (or invalid?) committee bits
let index = att.committee_bits.highest_set_bit().unwrap_or(0);
Expand All @@ -82,7 +82,6 @@ impl<E: EthSpec> SplitAttestation<E> {
signature: att.signature,
}
}
,
};

Self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ pub mod indexed_attestation_electra {
.filter_map(|(i, &index)| {
if let Ok(aggregation_bit_index) = committee_offset.safe_add(i) {
if aggregation_bits.get(aggregation_bit_index).unwrap_or(false) {
return Some(index as u64)
}
return Some(index as u64);
}
}
None
})
Expand Down
6 changes: 5 additions & 1 deletion consensus/state_processing/src/consensus_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ impl<E: EthSpec> ConsensusContext<E> {
indexed_attestation_electra::get_indexed_attestation(
&state
.get_beacon_committees_at_slot(attestation.data.slot)
.map_err(|_| BlockOperationError::Invalid(AttestationInvalid::BadTargetEpoch))?,
.map_err(|_| {
BlockOperationError::Invalid(
AttestationInvalid::BadTargetEpoch,
)
})?,
attestation,
)?;
Ok(vacant.insert(indexed_attestation))
Expand Down
28 changes: 0 additions & 28 deletions consensus/types/src/attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,34 +106,6 @@ impl<E: EthSpec> Hash for Attestation<E> {
}

impl<E: EthSpec> Attestation<E> {
// pub fn aggregation_bits(&self) -> Vec<u8> {
// match self {
// Attestation::Base(att) => att.aggregation_bits.as_slice().to_owned(),
// Attestation::Electra(att) => att.aggregation_bits.as_slice().to_owned(),
// }
// }

// pub fn get_aggregation_bit(&self, index: usize) -> Result<bool, ssz_types::Error> {
// match self {
// Attestation::Base(att) => att.aggregation_bits.get(index),
// Attestation::Electra(att) => att.aggregation_bits.get(index),
// }
// }

// pub fn is_empty_aggregation_bits(&self) -> bool {
// match self {
// Attestation::Base(att) => att.aggregation_bits.is_zero(),
// Attestation::Electra(att) => att.aggregation_bits.is_zero(),
// }
// }

// pub fn aggregation_num_set_bits(&self) -> usize {
// match self {
// Attestation::Base(att) => att.aggregation_bits.num_set_bits(),
// Attestation::Electra(att) => att.aggregation_bits.num_set_bits(),
// }
// }

/// Aggregate another Attestation into this one.
///
/// The aggregation bitfields must be disjoint, and the data must be the same.
Expand Down
3 changes: 2 additions & 1 deletion validator_client/src/attestation_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,8 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
})
} else {
// TODO(eip7594) committee_bits should be init with correct length
let mut committee_bits = BitList::with_capacity(duty.committee_length as usize).unwrap();
let mut committee_bits =
BitList::with_capacity(duty.committee_length as usize).unwrap();
committee_bits.set(committee_index as usize, true).unwrap();
Attestation::Electra(AttestationElectra {
aggregation_bits: BitList::with_capacity(duty.committee_length as usize)
Expand Down

0 comments on commit 1110958

Please sign in to comment.