Skip to content

Commit 70194df

Browse files
authored
Implement PeerDAS Fulu fork activation (#6795)
Addresses #6706 This PR activates PeerDAS at the Fulu fork epoch instead of `EIP_7594_FORK_EPOCH`. This means we no longer support testing PeerDAS with Deneb / Electrs, as it's now part of a hard fork.
1 parent 7d54a43 commit 70194df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1125
-639
lines changed

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use crate::execution_payload::{get_execution_payload, NotifyExecutionLayer, Prep
3434
use crate::fork_choice_signal::{ForkChoiceSignalRx, ForkChoiceSignalTx, ForkChoiceWaitResult};
3535
use crate::graffiti_calculator::GraffitiCalculator;
3636
use crate::head_tracker::{HeadTracker, HeadTrackerReader, SszHeadTracker};
37+
use crate::kzg_utils::reconstruct_blobs;
3738
use crate::light_client_finality_update_verification::{
3839
Error as LightClientFinalityUpdateError, VerifiedLightClientFinalityUpdate,
3940
};
@@ -1249,6 +1250,55 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
12491250
self.store.get_blobs(block_root).map_err(Error::from)
12501251
}
12511252

1253+
/// Returns the data columns at the given root, if any.
1254+
///
1255+
/// ## Errors
1256+
/// May return a database error.
1257+
pub fn get_data_columns(
1258+
&self,
1259+
block_root: &Hash256,
1260+
) -> Result<Option<DataColumnSidecarList<T::EthSpec>>, Error> {
1261+
self.store.get_data_columns(block_root).map_err(Error::from)
1262+
}
1263+
1264+
/// Returns the blobs at the given root, if any.
1265+
///
1266+
/// Uses the `block.epoch()` to determine whether to retrieve blobs or columns from the store.
1267+
///
1268+
/// If at least 50% of columns are retrieved, blobs will be reconstructed and returned,
1269+
/// otherwise an error `InsufficientColumnsToReconstructBlobs` is returned.
1270+
///
1271+
/// ## Errors
1272+
/// May return a database error.
1273+
pub fn get_or_reconstruct_blobs(
1274+
&self,
1275+
block_root: &Hash256,
1276+
) -> Result<Option<BlobSidecarList<T::EthSpec>>, Error> {
1277+
let Some(block) = self.store.get_blinded_block(block_root)? else {
1278+
return Ok(None);
1279+
};
1280+
1281+
if self.spec.is_peer_das_enabled_for_epoch(block.epoch()) {
1282+
if let Some(columns) = self.store.get_data_columns(block_root)? {
1283+
let num_required_columns = self.spec.number_of_columns / 2;
1284+
let reconstruction_possible = columns.len() >= num_required_columns as usize;
1285+
if reconstruction_possible {
1286+
reconstruct_blobs(&self.kzg, &columns, None, &block, &self.spec)
1287+
.map(Some)
1288+
.map_err(Error::FailedToReconstructBlobs)
1289+
} else {
1290+
Err(Error::InsufficientColumnsToReconstructBlobs {
1291+
columns_found: columns.len(),
1292+
})
1293+
}
1294+
} else {
1295+
Ok(None)
1296+
}
1297+
} else {
1298+
self.get_blobs(block_root).map(|b| b.blobs())
1299+
}
1300+
}
1301+
12521302
/// Returns the data columns at the given root, if any.
12531303
///
12541304
/// ## Errors
@@ -5850,6 +5900,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
58505900

58515901
let kzg = self.kzg.as_ref();
58525902

5903+
// TODO(fulu): we no longer need blob proofs from PeerDAS and could avoid computing.
58535904
kzg_utils::validate_blobs::<T::EthSpec>(
58545905
kzg,
58555906
expected_kzg_commitments,

beacon_node/beacon_chain/src/data_column_verification.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ mod test {
699699

700700
#[tokio::test]
701701
async fn empty_data_column_sidecars_fails_validation() {
702-
let spec = ForkName::latest().make_genesis_spec(E::default_spec());
702+
let spec = ForkName::Fulu.make_genesis_spec(E::default_spec());
703703
let harness = BeaconChainHarness::builder(E::default())
704704
.spec(spec.into())
705705
.deterministic_keypairs(64)

beacon_node/beacon_chain/src/errors.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ pub enum BeaconChainError {
226226
EmptyRpcCustodyColumns,
227227
AttestationError(AttestationError),
228228
AttestationCommitteeIndexNotSet,
229+
InsufficientColumnsToReconstructBlobs {
230+
columns_found: usize,
231+
},
232+
FailedToReconstructBlobs(String),
229233
}
230234

231235
easy_from_to!(SlotProcessingError, BeaconChainError);

beacon_node/beacon_chain/src/fulu_readiness.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Provides tools for checking if a node is ready for the Fulu upgrade.
22
33
use crate::{BeaconChain, BeaconChainTypes};
4-
use execution_layer::http::{ENGINE_GET_PAYLOAD_V5, ENGINE_NEW_PAYLOAD_V5};
4+
use execution_layer::http::{ENGINE_GET_PAYLOAD_V4, ENGINE_NEW_PAYLOAD_V4};
55
use serde::{Deserialize, Serialize};
66
use std::fmt;
77
use std::time::Duration;
@@ -87,14 +87,15 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
8787
Ok(capabilities) => {
8888
let mut missing_methods = String::from("Required Methods Unsupported:");
8989
let mut all_good = true;
90-
if !capabilities.get_payload_v5 {
90+
// TODO(fulu) switch to v5 when the EL is ready
91+
if !capabilities.get_payload_v4 {
9192
missing_methods.push(' ');
92-
missing_methods.push_str(ENGINE_GET_PAYLOAD_V5);
93+
missing_methods.push_str(ENGINE_GET_PAYLOAD_V4);
9394
all_good = false;
9495
}
95-
if !capabilities.new_payload_v5 {
96+
if !capabilities.new_payload_v4 {
9697
missing_methods.push(' ');
97-
missing_methods.push_str(ENGINE_NEW_PAYLOAD_V5);
98+
missing_methods.push_str(ENGINE_NEW_PAYLOAD_V4);
9899
all_good = false;
99100
}
100101

beacon_node/beacon_chain/src/kzg_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ pub fn blobs_to_data_column_sidecars<E: EthSpec>(
186186
.map_err(DataColumnSidecarError::BuildSidecarFailed)
187187
}
188188

189-
fn build_data_column_sidecars<E: EthSpec>(
189+
pub(crate) fn build_data_column_sidecars<E: EthSpec>(
190190
kzg_commitments: KzgCommitments<E>,
191191
kzg_commitments_inclusion_proof: FixedVector<Hash256, E::KzgCommitmentsInclusionProofDepth>,
192192
signed_block_header: SignedBeaconBlockHeader,

0 commit comments

Comments
 (0)