refactor for normal mode

This commit is contained in:
Tan Chee Keong
2025-04-23 10:24:59 +08:00
parent 37a0276b53
commit 67bfd112b5

View File

@@ -651,11 +651,10 @@ pub async fn fill_in_aggregation_proofs<T: SlotClock + 'static, E: EthSpec>(
// Store all partial sync selection proofs so that it can be sent together later // Store all partial sync selection proofs so that it can be sent together later
for &subnet_id in &subnet_ids { for &subnet_id in &subnet_ids {
let duties_service = duties_service.clone(); let duties_service = duties_service.clone();
let duty = duty.clone();
futures_unordered.push(async move { futures_unordered.push(async move {
let result = make_sync_selection_proof( let result = make_sync_selection_proof(
&duties_service, &duties_service,
&duty, duty,
proof_slot, proof_slot,
subnet_id, subnet_id,
config_ref, config_ref,
@@ -748,39 +747,23 @@ pub async fn fill_in_aggregation_proofs<T: SlotClock + 'static, E: EthSpec>(
// Create futures to produce proofs. // Create futures to produce proofs.
let duties_service_ref = &duties_service; let duties_service_ref = &duties_service;
let config_ref = &config;
let futures = subnet_ids.iter().map(|subnet_id| async move { let futures = subnet_ids.iter().map(|subnet_id| async move {
// Construct proof for prior slot. // Construct proof for prior slot.
let proof_slot = slot - 1; let proof_slot = slot - 1;
let proof = match duties_service_ref let proof = make_sync_selection_proof(
.validator_store duties_service_ref,
.produce_sync_selection_proof(&duty.pubkey, proof_slot, *subnet_id) duty,
.await proof_slot,
{ *subnet_id,
Ok(proof) => proof, config_ref,
Err(ValidatorStoreError::UnknownPubkey(pubkey)) => { &duties_service_ref.beacon_nodes,
// A pubkey can be missing when a validator was recently )
// removed via the API. .await;
debug!(
?pubkey,
pubkey = ?duty.pubkey,
slot = %proof_slot,
"Missing pubkey for sync selection proof"
);
return None;
}
Err(e) => {
warn!(
error = ?e,
pubkey = ?duty.pubkey,
slot = %proof_slot,
"Unable to sign selection proof"
);
return None;
}
};
match proof.is_aggregator::<E>() { match proof {
Some(proof) => match proof.is_aggregator::<E>() {
Ok(true) => { Ok(true) => {
debug!( debug!(
validator_index = duty.validator_index, validator_index = duty.validator_index,
@@ -800,6 +783,9 @@ pub async fn fill_in_aggregation_proofs<T: SlotClock + 'static, E: EthSpec>(
); );
None None
} }
},
None => None,
} }
}); });