-
Notifications
You must be signed in to change notification settings - Fork 794
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
Implement PeerDAS Fulu fork activation #6795
base: unstable
Are you sure you want to change the base?
Changes from all commits
2e11554
cd77b2c
b029342
64e44e1
0c9d64b
4e25302
8cdf82e
4d407fe
8980832
6d5b5ed
b7da075
b63a6c4
eff9a5b
614f984
0e8f671
e813532
b3da74b
492c1c6
e21b31e
d8cba4b
38c7f05
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ use crate::execution_payload::{get_execution_payload, NotifyExecutionLayer, Prep | |
use crate::fork_choice_signal::{ForkChoiceSignalRx, ForkChoiceSignalTx, ForkChoiceWaitResult}; | ||
use crate::graffiti_calculator::GraffitiCalculator; | ||
use crate::head_tracker::{HeadTracker, HeadTrackerReader, SszHeadTracker}; | ||
use crate::kzg_utils::reconstruct_blobs; | ||
use crate::light_client_finality_update_verification::{ | ||
Error as LightClientFinalityUpdateError, VerifiedLightClientFinalityUpdate, | ||
}; | ||
|
@@ -1249,6 +1250,55 @@ impl<T: BeaconChainTypes> BeaconChain<T> { | |
self.store.get_blobs(block_root).map_err(Error::from) | ||
} | ||
|
||
/// Returns the data columns at the given root, if any. | ||
/// | ||
/// ## Errors | ||
/// May return a database error. | ||
pub fn get_data_columns( | ||
&self, | ||
block_root: &Hash256, | ||
) -> Result<Option<DataColumnSidecarList<T::EthSpec>>, Error> { | ||
self.store.get_data_columns(block_root).map_err(Error::from) | ||
} | ||
|
||
/// Returns the blobs at the given root, if any. | ||
/// | ||
/// Uses the `block.epoch()` to determine whether to retrieve blobs or columns from the store. | ||
/// | ||
/// If at least 50% of columns are retrieved, blobs will be reconstructed and returned, | ||
/// otherwise an error `InsufficientColumnsToReconstructBlobs` is returned. | ||
/// | ||
/// ## Errors | ||
/// May return a database error. | ||
pub fn get_or_reconstruct_blobs( | ||
&self, | ||
block_root: &Hash256, | ||
) -> Result<Option<BlobSidecarList<T::EthSpec>>, Error> { | ||
let Some(block) = self.store.get_blinded_block(block_root)? else { | ||
return Ok(None); | ||
}; | ||
|
||
if self.spec.is_peer_das_enabled_for_epoch(block.epoch()) { | ||
if let Some(columns) = self.store.get_data_columns(block_root)? { | ||
let num_required_columns = self.spec.number_of_columns / 2; | ||
let blobs_available = columns.len() >= num_required_columns as usize; | ||
if blobs_available { | ||
reconstruct_blobs(&self.kzg, &columns, None, &block, &self.spec) | ||
.map(Some) | ||
.map_err(Error::FailedToReconstructBlobs) | ||
} else { | ||
Err(Error::InsufficientColumnsToReconstructBlobs { | ||
columns_found: columns.len(), | ||
}) | ||
} | ||
} else { | ||
Ok(None) | ||
} | ||
} else { | ||
self.get_blobs(block_root).map(|b| b.blobs()) | ||
} | ||
} | ||
|
||
/// Returns the data columns at the given root, if any. | ||
/// | ||
/// ## Errors | ||
|
@@ -5850,6 +5900,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> { | |
|
||
let kzg = self.kzg.as_ref(); | ||
|
||
// TODO(fulu): we no longer need blob proofs from PeerDAS and could avoid computing. | ||
kzg_utils::validate_blobs::<T::EthSpec>( | ||
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. Why are we validating blobs in the first place if we have compute the proofs? And what do you mean we don't need the KZG proofs anymore? 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. Good question - the blob KZG proofs come from the EL (from the tx sender and EL validates them, not sure if this has changed), so we should verify them, but I could be wrong. We also verify them again before we publish them. Blob KZG proofs are no longer used from PeerDAS - we don't send BlobSidecars to peers anymore, and we only use the cell KZG proofs, so validating these blob proofs may not be useful. |
||
kzg, | ||
expected_kzg_commitments, | ||
|
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.
nit but a better name would be "reconstruction_possible", or just inline the
columns.len() >= num_required_columns
in the if, I think it's easy enough to understand