Finish Modifications to get_attesting_indices()

This commit is contained in:
Mark Mackey
2024-09-11 16:18:35 -05:00
parent 330863d970
commit 4c9e12cfb6
14 changed files with 143 additions and 72 deletions

View File

@@ -629,6 +629,7 @@ impl<'a, T: BeaconChainTypes> IndexedAggregatedAttestation<'a, T> {
attesting_indices_electra::get_indexed_attestation(
&committees,
&signed_aggregate.message.aggregate,
&chain.spec,
)
.map_err(|e| BeaconChainError::from(e).into())
}
@@ -1364,7 +1365,7 @@ pub fn obtain_indexed_attestation_and_committees_per_slot<T: BeaconChainTypes>(
}
}
AttestationRef::Electra(att) => {
attesting_indices_electra::get_indexed_attestation(&committees, att)
attesting_indices_electra::get_indexed_attestation(&committees, att, &chain.spec)
.map(|attestation| (attestation, committees_per_slot))
.map_err(|e| {
if let BlockOperationError::BeaconStateError(NoCommitteeFound(index)) = e {

View File

@@ -226,7 +226,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
let inclusion_delay = state.slot().safe_sub(attestation.data().slot)?.as_u64();
let sqrt_total_active_balance =
SqrtTotalActiveBalance::new(processing_epoch_end.get_total_active_balance()?);
for attester in get_attesting_indices_from_state(state, attestation)? {
for attester in get_attesting_indices_from_state(state, attestation, &self.spec)? {
let validator = processing_epoch_end.get_validator(attester as usize)?;
if !validator.slashed
&& !rewarded_attesters.contains(&attester)
@@ -281,7 +281,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
&self.spec,
)?;
let attesting_indices = get_attesting_indices_from_state(state, attestation)?;
let attesting_indices =
get_attesting_indices_from_state(state, attestation, &self.spec)?;
let mut proposer_reward_numerator = 0;
for index in attesting_indices {
let index = index as usize;

View File

@@ -4202,19 +4202,20 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// Attestations.
for attestation in block.body().attestations() {
let indexed_attestation = match ctxt.get_indexed_attestation(state, attestation) {
Ok(indexed) => indexed,
Err(e) => {
debug!(
self.log,
"Failed to get indexed attestation";
"purpose" => "validator monitor",
"attestation_slot" => attestation.data().slot,
"error" => ?e,
);
continue;
}
};
let indexed_attestation =
match ctxt.get_indexed_attestation(state, attestation, &self.spec) {
Ok(indexed) => indexed,
Err(e) => {
debug!(
self.log,
"Failed to get indexed attestation";
"purpose" => "validator monitor",
"attestation_slot" => attestation.data().slot,
"error" => ?e,
);
continue;
}
};
validator_monitor.register_attestation_in_block(
indexed_attestation,
parent_block_slot,
@@ -4270,7 +4271,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
}
}
let indexed_attestation = match ctxt.get_indexed_attestation(state, a) {
let indexed_attestation = match ctxt.get_indexed_attestation(state, a, &self.spec) {
Ok(indexed) => indexed,
Err(e) => {
debug!(
@@ -4311,19 +4312,20 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
) {
if let Some(slasher) = self.slasher.as_ref() {
for attestation in block.body().attestations() {
let indexed_attestation = match ctxt.get_indexed_attestation(state, attestation) {
Ok(indexed) => indexed,
Err(e) => {
debug!(
self.log,
"Failed to get indexed attestation";
"purpose" => "slasher",
"attestation_slot" => attestation.data().slot,
"error" => ?e,
);
continue;
}
};
let indexed_attestation =
match ctxt.get_indexed_attestation(state, attestation, &self.spec) {
Ok(indexed) => indexed,
Err(e) => {
debug!(
self.log,
"Failed to get indexed attestation";
"purpose" => "slasher",
"attestation_slot" => attestation.data().slot,
"error" => ?e,
);
continue;
}
};
slasher.accept_attestation(indexed_attestation.clone_as_indexed_attestation());
}
}
@@ -5355,7 +5357,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
for attestation in self.naive_aggregation_pool.read().iter() {
let import = |attestation: &Attestation<T::EthSpec>| {
let attesting_indices =
get_attesting_indices_from_state(&state, attestation.to_ref())?;
get_attesting_indices_from_state(&state, attestation.to_ref(), &self.spec)?;
self.op_pool
.insert_attestation(attestation.clone(), attesting_indices)
};

View File

@@ -28,7 +28,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.body()
.attestations()
.map(|att| {
let attesting_indices = get_attesting_indices_from_state(state, att)?;
let attesting_indices = get_attesting_indices_from_state(state, att, &self.spec)?;
Ok(SplitAttestation::new(
att.clone_as_attestation(),
attesting_indices,

View File

@@ -1650,7 +1650,7 @@ impl<T: BeaconChainTypes> ExecutionPendingBlock<T> {
// Register each attestation in the block with fork choice.
for (i, attestation) in block.message().body().attestations().enumerate() {
let indexed_attestation = consensus_context
.get_indexed_attestation(&state, attestation)
.get_indexed_attestation(&state, attestation, &chain.spec)
.map_err(|e| BlockError::PerBlockProcessingError(e.into_with_index(i)))?;
match fork_choice.on_attestation(