Skip to content

Commit 27d67ac

Browse files
committed
fix: add checks if min met
1 parent 2496bb9 commit 27d67ac

File tree

2 files changed

+46
-6
lines changed

2 files changed

+46
-6
lines changed

beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,13 @@ impl<E: EthSpec> PendingComponents<E> {
367367
}
368368

369369
// Log when minimum proofs requirement is met
370-
let proof_ids: Vec<_> = self.verified_execution_proofs
370+
let proof_ids: Vec<_> = self
371+
.verified_execution_proofs
371372
.iter()
372373
.map(|p| p.proof_id.as_u8().to_string())
373374
.collect();
374375

375-
let slot = self.verified_execution_proofs
376-
.first()
377-
.map(|p| p.slot);
376+
let slot = self.verified_execution_proofs.first().map(|p| p.slot);
378377

379378
self.span.in_scope(|| {
380379
if let Some(slot) = slot {
@@ -420,9 +419,15 @@ impl<E: EthSpec> PendingComponents<E> {
420419
if proof_count > 0 {
421420
let slot = self.block.as_ref().map(|b| b.as_block().slot());
422421
if let Some(slot) = slot {
423-
info!("[Ethproofs] Block ready for validation with {} execution proofs slot={}", proof_count, slot);
422+
info!(
423+
"[Ethproofs] Block ready for validation with {} execution proofs slot={}",
424+
proof_count, slot
425+
);
424426
} else {
425-
info!("[Ethproofs] Block ready for validation with {} execution proofs", proof_count);
427+
info!(
428+
"[Ethproofs] Block ready for validation with {} execution proofs",
429+
proof_count
430+
);
426431
}
427432
}
428433
debug!("Block and all data components are available");
@@ -706,6 +711,18 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> {
706711
return Ok(Availability::MissingComponents(block_root));
707712
}
708713

714+
// TODO(ethproofs): Added for demo.
715+
// Check if we already have the minimum required proofs
716+
// If so, don't add more to avoid unnecessary processing
717+
if let Some(min_proofs) = self.spec.zkvm_min_proofs_required() {
718+
if let Some(pending) = self.critical.read().peek(&block_root) {
719+
if pending.execution_proof_subnet_count() >= min_proofs {
720+
// Already have minimum required proofs, skip adding more
721+
return Ok(Availability::MissingComponents(block_root));
722+
}
723+
}
724+
}
725+
709726
// Try to get epoch from existing pending components (if block already arrived)
710727
// Otherwise use Epoch::new(0) as placeholder (will be corrected when block arrives)
711728
// Also the component cannot be marked as available, if the block is missing

beacon_node/network/src/network_beacon_processor/gossip_methods.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,29 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
792792
"Received execution proof via gossip"
793793
);
794794

795+
// TODO(ethproofs): Added for demo.
796+
// Check if we already have the minimum required proofs for this block
797+
// If so, skip verification to avoid unnecessary processing
798+
if let Some(min_proofs) = self.chain.min_execution_proofs_required() {
799+
if let Some(cached_proof_ids) = self
800+
.chain
801+
.data_availability_checker
802+
.cached_execution_proof_subnet_ids(&block_root)
803+
{
804+
if cached_proof_ids.len() >= min_proofs {
805+
// Already have minimum required proofs, ignore this one
806+
debug!(
807+
%block_root,
808+
%proof_id,
809+
cached_count = cached_proof_ids.len(),
810+
min_required = min_proofs,
811+
"Ignoring execution proof, minimum proofs already cached"
812+
);
813+
return;
814+
}
815+
}
816+
}
817+
795818
// Verify the execution proof for gossip
796819
match self
797820
.chain

0 commit comments

Comments
 (0)