Skip to content
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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2e11554
Implement PeerDAS Fulu fork activation.
jimmygchen Jan 13, 2025
cd77b2c
Update spec tests.
jimmygchen Jan 13, 2025
b029342
Fix compilation and update Kurtosis test config for PeerDAS.
jimmygchen Jan 13, 2025
64e44e1
Fix failing tests now `fulu` fork is included.
jimmygchen Jan 14, 2025
0c9d64b
Merge remote-tracking branch 'origin/unstable' into jimmy/lh-2271-act…
jimmygchen Jan 15, 2025
4e25302
Address review comments and fix lint.
jimmygchen Jan 15, 2025
8cdf82e
Use engine v4 methods for Fulu (v5 methods do not exist yet). Update …
jimmygchen Jan 15, 2025
4d407fe
Merge remote-tracking branch 'origin/unstable' into jimmy/lh-2271-act…
jimmygchen Jan 15, 2025
8980832
Update Fulu spec tests. Revert back to testing Fulu as "feature", bec…
jimmygchen Jan 17, 2025
6d5b5ed
Merge remote-tracking branch 'origin/unstable' into jimmy/lh-2271-act…
jimmygchen Jan 17, 2025
b7da075
More test fixes for Fulu.
jimmygchen Jan 20, 2025
b63a6c4
Merge remote-tracking branch 'origin/unstable' into jimmy/lh-2271-act…
jimmygchen Jan 20, 2025
eff9a5b
More test fixes for Fulu.
jimmygchen Jan 20, 2025
614f984
Fix range sync to select custody peers from its syncing chain instead…
jimmygchen Jan 21, 2025
0e8f671
Merge branch 'unstable' into jimmy/lh-2271-activate-peerdas-at-fulu-f…
jimmygchen Jan 21, 2025
e813532
Skip blob pruning tests for Fulu.
jimmygchen Jan 21, 2025
b3da74b
Merge remote-tracking branch 'origin/unstable' into jimmy/lh-2271-act…
jimmygchen Jan 23, 2025
492c1c6
Use pre-computed data columns for testing and fix tests.
jimmygchen Jan 24, 2025
e21b31e
More beacon chain test fixes.
jimmygchen Jan 24, 2025
d8cba4b
Revert change: select peers from chain for custody by range requests
dapplion Jan 28, 2025
38c7f05
Improve request identification in range sync test
dapplion Jan 28, 2025
8cb49c7
Merge branch 'unstable' into jimmy/lh-2271-activate-peerdas-at-fulu-f…
jimmygchen Jan 30, 2025
ce8090d
Address review comments.
jimmygchen Jan 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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 reconstruction_possible = columns.len() >= num_required_columns as usize;
if reconstruction_possible {
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
Expand Down Expand Up @@ -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>(
jimmygchen marked this conversation as resolved.
Show resolved Hide resolved
kzg,
expected_kzg_commitments,
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/data_column_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ mod test {

#[tokio::test]
async fn empty_data_column_sidecars_fails_validation() {
let spec = ForkName::latest().make_genesis_spec(E::default_spec());
let spec = ForkName::Fulu.make_genesis_spec(E::default_spec());
let harness = BeaconChainHarness::builder(E::default())
.spec(spec.into())
.deterministic_keypairs(64)
Expand Down
4 changes: 4 additions & 0 deletions beacon_node/beacon_chain/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ pub enum BeaconChainError {
EmptyRpcCustodyColumns,
AttestationError(AttestationError),
AttestationCommitteeIndexNotSet,
InsufficientColumnsToReconstructBlobs {
columns_found: usize,
},
FailedToReconstructBlobs(String),
}

easy_from_to!(SlotProcessingError, BeaconChainError);
Expand Down
11 changes: 6 additions & 5 deletions beacon_node/beacon_chain/src/fulu_readiness.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Provides tools for checking if a node is ready for the Fulu upgrade.

use crate::{BeaconChain, BeaconChainTypes};
use execution_layer::http::{ENGINE_GET_PAYLOAD_V5, ENGINE_NEW_PAYLOAD_V5};
use execution_layer::http::{ENGINE_GET_PAYLOAD_V4, ENGINE_NEW_PAYLOAD_V4};
use serde::{Deserialize, Serialize};
use std::fmt;
use std::time::Duration;
Expand Down Expand Up @@ -87,14 +87,15 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
Ok(capabilities) => {
let mut missing_methods = String::from("Required Methods Unsupported:");
let mut all_good = true;
if !capabilities.get_payload_v5 {
// TODO(fulu) switch to v5 when the EL is ready
if !capabilities.get_payload_v4 {
missing_methods.push(' ');
missing_methods.push_str(ENGINE_GET_PAYLOAD_V5);
missing_methods.push_str(ENGINE_GET_PAYLOAD_V4);
all_good = false;
}
if !capabilities.new_payload_v5 {
if !capabilities.new_payload_v4 {
missing_methods.push(' ');
missing_methods.push_str(ENGINE_NEW_PAYLOAD_V5);
missing_methods.push_str(ENGINE_NEW_PAYLOAD_V4);
all_good = false;
}

Expand Down
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/kzg_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub fn blobs_to_data_column_sidecars<E: EthSpec>(
.map_err(DataColumnSidecarError::BuildSidecarFailed)
}

fn build_data_column_sidecars<E: EthSpec>(
pub(crate) fn build_data_column_sidecars<E: EthSpec>(
kzg_commitments: KzgCommitments<E>,
kzg_commitments_inclusion_proof: FixedVector<Hash256, E::KzgCommitmentsInclusionProofDepth>,
signed_block_header: SignedBeaconBlockHeader,
Expand Down
Loading