Skip to content

Commit

Permalink
Merge branch 'unstable' into tracing-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
macladson committed Jan 30, 2025
2 parents d68afc9 + 70194df commit 429b8b3
Show file tree
Hide file tree
Showing 64 changed files with 1,272 additions and 754 deletions.
1 change: 0 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[env]
# Set the number of arenas to 16 when using jemalloc.
JEMALLOC_SYS_WITH_MALLOC_CONF = "abort_conf:true,narenas:16"

11 changes: 11 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@ pre-build = ["apt-get install -y cmake clang-5.0"]

[target.aarch64-unknown-linux-gnu]
pre-build = ["apt-get install -y cmake clang-5.0"]

# Allow setting page size limits for jemalloc at build time:
# For certain architectures (like aarch64), we must compile
# jemalloc with support for large page sizes, otherwise the host's
# system page size will be used, which may not work on the target systems.
# JEMALLOC_SYS_WITH_LG_PAGE=16 tells jemalloc to support up to 64-KiB
# pages. See: https://github.com/sigp/lighthouse/issues/5244
[build.env]
passthrough = [
"JEMALLOC_SYS_WITH_LG_PAGE",
]
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,18 @@ install-lcli:
build-x86_64:
cross build --bin lighthouse --target x86_64-unknown-linux-gnu --features "portable,$(CROSS_FEATURES)" --profile "$(CROSS_PROFILE)" --locked
build-aarch64:
cross build --bin lighthouse --target aarch64-unknown-linux-gnu --features "portable,$(CROSS_FEATURES)" --profile "$(CROSS_PROFILE)" --locked
# JEMALLOC_SYS_WITH_LG_PAGE=16 tells jemalloc to support up to 64-KiB
# pages, which are commonly used by aarch64 systems.
# See: https://github.com/sigp/lighthouse/issues/5244
JEMALLOC_SYS_WITH_LG_PAGE=16 cross build --bin lighthouse --target aarch64-unknown-linux-gnu --features "portable,$(CROSS_FEATURES)" --profile "$(CROSS_PROFILE)" --locked

build-lcli-x86_64:
cross build --bin lcli --target x86_64-unknown-linux-gnu --features "portable" --profile "$(CROSS_PROFILE)" --locked
build-lcli-aarch64:
cross build --bin lcli --target aarch64-unknown-linux-gnu --features "portable" --profile "$(CROSS_PROFILE)" --locked
# JEMALLOC_SYS_WITH_LG_PAGE=16 tells jemalloc to support up to 64-KiB
# pages, which are commonly used by aarch64 systems.
# See: https://github.com/sigp/lighthouse/issues/5244
JEMALLOC_SYS_WITH_LG_PAGE=16 cross build --bin lcli --target aarch64-unknown-linux-gnu --features "portable" --profile "$(CROSS_PROFILE)" --locked

# Create a `.tar.gz` containing a binary for a specific target.
define tarball_release_binary
Expand Down
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 @@ -1245,6 +1246,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 @@ -5749,6 +5799,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>(
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 @@ -698,7 +698,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

0 comments on commit 429b8b3

Please sign in to comment.