Merge branch 'electra-engine-api' of https://github.com/sigp/lighthouse into beacon-api-electra

This commit is contained in:
realbigsean
2024-05-09 13:47:12 -04:00
5 changed files with 49 additions and 30 deletions

View File

@@ -1309,10 +1309,11 @@ pub fn obtain_indexed_attestation_and_committees_per_slot<T: BeaconChainTypes>(
attesting_indices_electra::get_indexed_attestation(&committees, att)
.map(|attestation| (attestation, committees_per_slot))
.map_err(|e| {
if e == BlockOperationError::BeaconStateError(NoCommitteeFound) {
let index = att.committee_index();
if e == BlockOperationError::BeaconStateError(NoCommitteeFound(index)) {
Error::NoCommitteeForSlotAndIndex {
slot: att.data.slot,
index: att.committee_index(),
index,
}
} else {
Error::Invalid(e)

View File

@@ -113,11 +113,15 @@ pub mod attesting_indices_electra {
.map(|committee| (committee.index, committee))
.collect();
let committee_count_per_slot = committees.len() as u64;
let mut participant_count = 0;
for index in committee_indices {
if let Some(&beacon_committee) = committees_map.get(&index) {
if aggregation_bits.len() != beacon_committee.committee.len() {
return Err(BeaconStateError::InvalidBitfield);
// This check is new to the spec's `process_attestation` in Electra.
if index >= committee_count_per_slot {
return Err(BeaconStateError::InvalidCommitteeIndex(index));
}
participant_count.safe_add_assign(beacon_committee.committee.len() as u64)?;
let committee_attesters = beacon_committee
.committee
.iter()
@@ -136,10 +140,13 @@ pub mod attesting_indices_electra {
committee_offset.safe_add(beacon_committee.committee.len())?;
} else {
return Err(Error::NoCommitteeFound);
return Err(Error::NoCommitteeFound(index));
}
}
// TODO(electra) what should we do when theres no committee found for a given index?
// This check is new to the spec's `process_attestation` in Electra.
if participant_count as usize != aggregation_bits.len() {
return Err(BeaconStateError::InvalidBitfield);
}
let mut indices = output.into_iter().collect_vec();

View File

@@ -161,7 +161,8 @@ pub enum Error {
MerkleTreeError(merkle_proof::MerkleTreeError),
PartialWithdrawalCountInvalid(usize),
NonExecutionAddresWithdrawalCredential,
NoCommitteeFound,
NoCommitteeFound(CommitteeIndex),
InvalidCommitteeIndex(CommitteeIndex),
}
/// Control whether an epoch-indexed field can be indexed at the next epoch or not.

View File

@@ -111,11 +111,8 @@ type_name_generic!(LightClientUpdateDeneb, "LightClientUpdate");
type_name_generic!(PendingAttestation);
type_name!(ProposerSlashing);
type_name_generic!(SignedAggregateAndProof);
type_name_generic!(SignedAggregateAndProofBase, "SignedAggregateAndProofBase");
type_name_generic!(
SignedAggregateAndProofElectra,
"SignedAggregateAndProofElectra"
);
type_name_generic!(SignedAggregateAndProofBase, "SignedAggregateAndProof");
type_name_generic!(SignedAggregateAndProofElectra, "SignedAggregateAndProof");
type_name_generic!(SignedBeaconBlock);
type_name!(SignedBeaconBlockHeader);
type_name_generic!(SignedContributionAndProof);

View File

@@ -219,7 +219,6 @@ mod ssz_static {
use types::historical_summary::HistoricalSummary;
use types::{AttesterSlashingBase, AttesterSlashingElectra, LightClientBootstrapAltair, *};
ssz_static_test!(aggregate_and_proof, AggregateAndProof<_>);
ssz_static_test!(attestation, Attestation<_>);
ssz_static_test!(attestation_data, AttestationData);
ssz_static_test!(beacon_block, SszStaticWithSpecHandler, BeaconBlock<_>);
@@ -249,7 +248,7 @@ mod ssz_static {
ssz_static_test!(voluntary_exit, VoluntaryExit);
#[test]
fn signed_aggregate_and_proof() {
fn attester_slashing() {
SszStaticHandler::<AttesterSlashingBase<MinimalEthSpec>, MinimalEthSpec>::pre_electra()
.run();
SszStaticHandler::<AttesterSlashingBase<MainnetEthSpec>, MainnetEthSpec>::pre_electra()
@@ -260,6 +259,36 @@ mod ssz_static {
.run();
}
#[test]
fn signed_aggregate_and_proof() {
SszStaticHandler::<SignedAggregateAndProofBase<MinimalEthSpec>, MinimalEthSpec>::pre_electra(
)
.run();
SszStaticHandler::<SignedAggregateAndProofBase<MainnetEthSpec>, MainnetEthSpec>::pre_electra(
)
.run();
SszStaticHandler::<SignedAggregateAndProofElectra<MinimalEthSpec>, MinimalEthSpec>::electra_only(
)
.run();
SszStaticHandler::<SignedAggregateAndProofElectra<MainnetEthSpec>, MainnetEthSpec>::electra_only(
)
.run();
}
#[test]
fn aggregate_and_proof() {
SszStaticHandler::<AggregateAndProofBase<MinimalEthSpec>, MinimalEthSpec>::pre_electra()
.run();
SszStaticHandler::<AggregateAndProofBase<MainnetEthSpec>, MainnetEthSpec>::pre_electra()
.run();
SszStaticHandler::<AggregateAndProofElectra<MinimalEthSpec>, MinimalEthSpec>::electra_only(
)
.run();
SszStaticHandler::<AggregateAndProofElectra<MainnetEthSpec>, MainnetEthSpec>::electra_only(
)
.run();
}
// BeaconBlockBody has no internal indicator of which fork it is for, so we test it separately.
#[test]
fn beacon_block_body() {
@@ -283,22 +312,6 @@ mod ssz_static {
.run();
}
#[test]
fn signed_aggregate_and_proof() {
SszStaticHandler::<SignedAggregateAndProofBase<MinimalEthSpec>, MinimalEthSpec>::pre_electra(
)
.run();
SszStaticHandler::<SignedAggregateAndProofBase<MainnetEthSpec>, MainnetEthSpec>::pre_electra(
)
.run();
SszStaticHandler::<SignedAggregateAndProofElectra<MinimalEthSpec>, MinimalEthSpec>::electra_only(
)
.run();
SszStaticHandler::<SignedAggregateAndProofElectra<MainnetEthSpec>, MainnetEthSpec>::electra_only(
)
.run();
}
// Altair and later
#[test]
fn contribution_and_proof() {