forked from sigp/lighthouse
-
Notifications
You must be signed in to change notification settings - Fork 2
Fix: pass min_required_proofs as a parameter #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -272,6 +272,7 @@ impl<E: EthSpec> PendingComponents<E> { | |
| &self, | ||
| spec: &Arc<ChainSpec>, | ||
| num_expected_columns_opt: Option<usize>, | ||
| min_proofs_required_opt: Option<usize>, | ||
| recover: R, | ||
| ) -> Result<Option<AvailableExecutedBlock<E>>, AvailabilityCheckError> | ||
| where | ||
|
|
@@ -349,11 +350,8 @@ impl<E: EthSpec> PendingComponents<E> { | |
| return Ok(None); | ||
| }; | ||
|
|
||
| // Check if this node needs execution proofs to validate blocks. | ||
| let needs_execution_proofs = spec.zkvm_min_proofs_required().is_some(); | ||
|
|
||
| if needs_execution_proofs { | ||
| let min_proofs = spec.zkvm_min_proofs_required().unwrap(); | ||
| // Check if this block needs execution proofs. | ||
| if let Some(min_proofs) = min_proofs_required_opt { | ||
| let num_proofs = self.execution_proof_subnet_count(); | ||
| if num_proofs < min_proofs { | ||
| // Not enough execution proofs yet | ||
|
|
@@ -605,7 +603,13 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> { | |
| ); | ||
| }); | ||
|
|
||
| self.check_availability_and_cache_components(block_root, pending_components, None) | ||
| let min_proofs_required_opt = self.get_min_proofs_required(epoch); | ||
| self.check_availability_and_cache_components( | ||
| block_root, | ||
| pending_components, | ||
| None, | ||
| min_proofs_required_opt, | ||
| ) | ||
| } | ||
|
|
||
| #[allow(clippy::type_complexity)] | ||
|
|
@@ -645,10 +649,12 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> { | |
| ); | ||
| }); | ||
|
|
||
| let min_proofs_required_opt = self.get_min_proofs_required(epoch); | ||
| self.check_availability_and_cache_components( | ||
| block_root, | ||
| pending_components, | ||
| Some(num_expected_columns), | ||
| min_proofs_required_opt, | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -682,6 +688,7 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> { | |
| })?; | ||
|
|
||
| let num_expected_columns_opt = self.get_num_expected_columns(epoch); | ||
| let min_proofs_required_opt = self.get_min_proofs_required(epoch); | ||
|
|
||
| pending_components.span.in_scope(|| { | ||
| debug!( | ||
|
|
@@ -696,6 +703,7 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> { | |
| block_root, | ||
| pending_components, | ||
| num_expected_columns_opt, | ||
| min_proofs_required_opt, | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -704,10 +712,12 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> { | |
| block_root: Hash256, | ||
| pending_components: MappedRwLockReadGuard<'_, PendingComponents<T::EthSpec>>, | ||
| num_expected_columns_opt: Option<usize>, | ||
| min_proofs_required_opt: Option<usize>, | ||
| ) -> Result<Availability<T::EthSpec>, AvailabilityCheckError> { | ||
| if let Some(available_block) = pending_components.make_available( | ||
| &self.spec, | ||
| num_expected_columns_opt, | ||
| min_proofs_required_opt, | ||
| |block, span| self.state_cache.recover_pending_executed_block(block, span), | ||
| )? { | ||
| // Explicitly drop read lock before acquiring write lock | ||
|
|
@@ -876,6 +886,7 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> { | |
| })?; | ||
|
|
||
| let num_expected_columns_opt = self.get_num_expected_columns(epoch); | ||
| let min_proofs_required_opt = self.get_min_proofs_required(epoch); | ||
|
|
||
| pending_components.span.in_scope(|| { | ||
| debug!( | ||
|
|
@@ -889,6 +900,7 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> { | |
| block_root, | ||
| pending_components, | ||
| num_expected_columns_opt, | ||
| min_proofs_required_opt, | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -903,6 +915,16 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> { | |
| } | ||
| } | ||
|
|
||
| /// Returns the minimum number of execution proofs required for a block at the given epoch. | ||
| /// Returns `None` if proofs are not required (zkVM not enabled for this epoch). | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does not check proof boundary epoch/retention window since that will be done on the sync layer |
||
| fn get_min_proofs_required(&self, epoch: Epoch) -> Option<usize> { | ||
| if self.spec.is_zkvm_enabled_for_epoch(epoch) { | ||
| self.spec.zkvm_min_proofs_required() | ||
| } else { | ||
| None | ||
| } | ||
| } | ||
|
|
||
| /// maintain the cache | ||
| pub fn do_maintenance(&self, cutoff_epoch: Epoch) -> Result<(), AvailabilityCheckError> { | ||
| // clean up any lingering states in the state cache | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means we could have execution proofs, pre-peerDAS -- we can make this stricter/remove this later on if we feel it doesn't help with testing