Skip to content

Commit

Permalink
Merge branch 'unstable' into das
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion committed May 16, 2024
2 parents 500b828 + 1d61605 commit 7c3c173
Show file tree
Hide file tree
Showing 20 changed files with 348 additions and 345 deletions.
14 changes: 11 additions & 3 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2886,6 +2886,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
signature_verified_block.block_root(),
signature_verified_block,
notify_execution_layer,
BlockImportSource::RangeSync,
|| Ok(()),
)
.await
Expand Down Expand Up @@ -3168,16 +3169,21 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
self: &Arc<Self>,
block_root: Hash256,
unverified_block: B,
block_source: BlockImportSource,
notify_execution_layer: NotifyExecutionLayer,
) -> Result<AvailabilityProcessingStatus, BlockError<T::EthSpec>> {
self.reqresp_pre_import_cache
.write()
.insert(block_root, unverified_block.block_cloned());

let r = self
.process_block(block_root, unverified_block, notify_execution_layer, || {
Ok(())
})
.process_block(
block_root,
unverified_block,
notify_execution_layer,
block_source,
|| Ok(()),
)
.await;
self.remove_notified(&block_root, r)
}
Expand All @@ -3200,6 +3206,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
block_root: Hash256,
unverified_block: B,
notify_execution_layer: NotifyExecutionLayer,
block_source: BlockImportSource,
publish_fn: impl FnOnce() -> Result<(), BlockError<T::EthSpec>> + Send + 'static,
) -> Result<AvailabilityProcessingStatus, BlockError<T::EthSpec>> {
// Start the Prometheus timer.
Expand Down Expand Up @@ -3260,6 +3267,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
"Beacon block imported";
"block_root" => ?block_root,
"block_slot" => block_slot,
"source" => %block_source,
);

// Increment the Prometheus counter for block processing successes.
Expand Down
2 changes: 2 additions & 0 deletions beacon_node/beacon_chain/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1881,6 +1881,7 @@ where
block_root,
RpcBlock::new(Some(block_root), block, sidecars).unwrap(),
NotifyExecutionLayer::Yes,
BlockImportSource::RangeSync,
|| Ok(()),
)
.await?
Expand All @@ -1907,6 +1908,7 @@ where
block_root,
RpcBlock::new(Some(block_root), block, sidecars).unwrap(),
NotifyExecutionLayer::Yes,
BlockImportSource::RangeSync,
|| Ok(()),
)
.await?
Expand Down
7 changes: 7 additions & 0 deletions beacon_node/beacon_chain/tests/block_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ async fn assert_invalid_signature(
)
.unwrap(),
NotifyExecutionLayer::Yes,
BlockImportSource::Lookup,
|| Ok(()),
)
.await;
Expand Down Expand Up @@ -541,6 +542,7 @@ async fn invalid_signature_gossip_block() {
signed_block.canonical_root(),
Arc::new(signed_block),
NotifyExecutionLayer::Yes,
BlockImportSource::Lookup,
|| Ok(()),
)
.await,
Expand Down Expand Up @@ -875,6 +877,7 @@ async fn block_gossip_verification() {
gossip_verified.block_root,
gossip_verified,
NotifyExecutionLayer::Yes,
BlockImportSource::Lookup,
|| Ok(()),
)
.await
Expand Down Expand Up @@ -1165,6 +1168,7 @@ async fn verify_block_for_gossip_slashing_detection() {
verified_block.block_root,
verified_block,
NotifyExecutionLayer::Yes,
BlockImportSource::Lookup,
|| Ok(()),
)
.await
Expand Down Expand Up @@ -1196,6 +1200,7 @@ async fn verify_block_for_gossip_doppelganger_detection() {
verified_block.block_root,
verified_block,
NotifyExecutionLayer::Yes,
BlockImportSource::Lookup,
|| Ok(()),
)
.await
Expand Down Expand Up @@ -1342,6 +1347,7 @@ async fn add_base_block_to_altair_chain() {
base_block.canonical_root(),
Arc::new(base_block.clone()),
NotifyExecutionLayer::Yes,
BlockImportSource::Lookup,
|| Ok(()),
)
.await
Expand Down Expand Up @@ -1477,6 +1483,7 @@ async fn add_altair_block_to_base_chain() {
altair_block.canonical_root(),
Arc::new(altair_block.clone()),
NotifyExecutionLayer::Yes,
BlockImportSource::Lookup,
|| Ok(()),
)
.await
Expand Down
6 changes: 5 additions & 1 deletion beacon_node/beacon_chain/tests/payload_invalidation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ async fn invalidates_all_descendants() {
fork_block.canonical_root(),
fork_block,
NotifyExecutionLayer::Yes,
BlockImportSource::Lookup,
|| Ok(()),
)
.await
Expand Down Expand Up @@ -802,6 +803,7 @@ async fn switches_heads() {
fork_block.canonical_root(),
fork_block,
NotifyExecutionLayer::Yes,
BlockImportSource::Lookup,
|| Ok(()),
)
.await
Expand Down Expand Up @@ -1061,7 +1063,7 @@ async fn invalid_parent() {

// Ensure the block built atop an invalid payload is invalid for import.
assert!(matches!(
rig.harness.chain.process_block(block.canonical_root(), block.clone(), NotifyExecutionLayer::Yes,
rig.harness.chain.process_block(block.canonical_root(), block.clone(), NotifyExecutionLayer::Yes, BlockImportSource::Lookup,
|| Ok(()),
).await,
Err(BlockError::ParentExecutionPayloadInvalid { parent_root: invalid_root })
Expand Down Expand Up @@ -1352,6 +1354,7 @@ async fn build_optimistic_chain(
block.canonical_root(),
block,
NotifyExecutionLayer::Yes,
BlockImportSource::Lookup,
|| Ok(()),
)
.await
Expand Down Expand Up @@ -1926,6 +1929,7 @@ async fn recover_from_invalid_head_by_importing_blocks() {
fork_block.canonical_root(),
fork_block.clone(),
NotifyExecutionLayer::Yes,
BlockImportSource::Lookup,
|| Ok(()),
)
.await
Expand Down
3 changes: 3 additions & 0 deletions beacon_node/beacon_chain/tests/store_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,7 @@ async fn weak_subjectivity_sync_test(slots: Vec<Slot>, checkpoint_slot: Slot) {
full_block.canonical_root(),
RpcBlock::new(Some(block_root), Arc::new(full_block), Some(blobs)).unwrap(),
NotifyExecutionLayer::Yes,
BlockImportSource::Lookup,
|| Ok(()),
)
.await
Expand Down Expand Up @@ -2676,6 +2677,7 @@ async fn process_blocks_and_attestations_for_unaligned_checkpoint() {
invalid_fork_block.canonical_root(),
invalid_fork_block.clone(),
NotifyExecutionLayer::Yes,
BlockImportSource::Lookup,
|| Ok(()),
)
.await
Expand All @@ -2689,6 +2691,7 @@ async fn process_blocks_and_attestations_for_unaligned_checkpoint() {
valid_fork_block.canonical_root(),
valid_fork_block.clone(),
NotifyExecutionLayer::Yes,
BlockImportSource::Lookup,
|| Ok(()),
)
.await
Expand Down
4 changes: 3 additions & 1 deletion beacon_node/beacon_chain/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ use lazy_static::lazy_static;
use operation_pool::PersistedOperationPool;
use state_processing::{per_slot_processing, per_slot_processing::Error as SlotProcessingError};
use types::{
BeaconState, BeaconStateError, EthSpec, Hash256, Keypair, MinimalEthSpec, RelativeEpoch, Slot,
BeaconState, BeaconStateError, BlockImportSource, EthSpec, Hash256, Keypair, MinimalEthSpec,
RelativeEpoch, Slot,
};

// Should ideally be divisible by 3.
Expand Down Expand Up @@ -686,6 +687,7 @@ async fn run_skip_slot_test(skip_slots: u64) {
harness_a.chain.head_snapshot().beacon_block_root,
harness_a.get_head_block(),
NotifyExecutionLayer::Yes,
BlockImportSource::Lookup,
|| Ok(()),
)
.await
Expand Down
34 changes: 13 additions & 21 deletions beacon_node/client/src/notifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,9 @@ async fn capella_readiness_logging<T: BeaconChainTypes>(
.canonical_head
.cached_head()
.snapshot
.beacon_block
.message()
.body()
.execution_payload()
.map_or(false, |payload| payload.withdrawals_root().is_ok());
.beacon_state
.fork_name_unchecked()
>= ForkName::Capella;

let has_execution_layer = beacon_chain.execution_layer.is_some();

Expand Down Expand Up @@ -496,11 +494,9 @@ async fn deneb_readiness_logging<T: BeaconChainTypes>(
.canonical_head
.cached_head()
.snapshot
.beacon_block
.message()
.body()
.execution_payload()
.map_or(false, |payload| payload.blob_gas_used().is_ok());
.beacon_state
.fork_name_unchecked()
>= ForkName::Deneb;

let has_execution_layer = beacon_chain.execution_layer.is_some();

Expand Down Expand Up @@ -549,17 +545,13 @@ async fn electra_readiness_logging<T: BeaconChainTypes>(
beacon_chain: &BeaconChain<T>,
log: &Logger,
) {
// TODO(electra): Once Electra has features, this code can be swapped back.
let electra_completed = false;
//let electra_completed = beacon_chain
// .canonical_head
// .cached_head()
// .snapshot
// .beacon_block
// .message()
// .body()
// .execution_payload()
// .map_or(false, |payload| payload.electra_placeholder().is_ok());
let electra_completed = beacon_chain
.canonical_head
.cached_head()
.snapshot
.beacon_state
.fork_name_unchecked()
>= ForkName::Electra;

let has_execution_layer = beacon_chain.execution_layer.is_some();

Expand Down
7 changes: 4 additions & 3 deletions beacon_node/http_api/src/publish_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ use tokio::sync::mpsc::UnboundedSender;
use tree_hash::TreeHash;
use types::data_column_sidecar::DataColumnSidecarList;
use types::{
AbstractExecPayload, BeaconBlockRef, BlobSidecarList, DataColumnSubnetId, EthSpec, ExecPayload,
ExecutionBlockHash, ForkName, FullPayload, FullPayloadBellatrix, Hash256, SignedBeaconBlock,
SignedBlindedBeaconBlock, VariableList,
AbstractExecPayload, BeaconBlockRef, BlobSidecarList, BlockImportSource, DataColumnSubnetId,
EthSpec, ExecPayload, ExecutionBlockHash, ForkName, FullPayload, FullPayloadBellatrix, Hash256,
SignedBeaconBlock, SignedBlindedBeaconBlock, VariableList,
};
use warp::http::StatusCode;
use warp::{reply::Response, Rejection, Reply};
Expand Down Expand Up @@ -305,6 +305,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten
block_root,
gossip_verified_block,
NotifyExecutionLayer::Yes,
BlockImportSource::HttpApi,
publish_fn,
))
.await
Expand Down
4 changes: 4 additions & 0 deletions beacon_node/network/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ lazy_static! {
"sync_lookups_completed_total",
"Total count of sync lookups completed",
);
pub static ref SYNC_LOOKUPS_STUCK: Result<IntGauge> = try_create_int_gauge(
"sync_lookups_stuck",
"Current count of sync lookups that may be stuck",
);

/*
* Block Delay Metrics
Expand Down
17 changes: 11 additions & 6 deletions beacon_node/network/src/network_beacon_processor/gossip_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
use store::hot_cold_store::HotColdDBError;
use tokio::sync::mpsc;
use types::{
Attestation, AttesterSlashing, BlobSidecar, DataColumnSidecar, DataColumnSubnetId, EthSpec,
Hash256, IndexedAttestation, LightClientFinalityUpdate, LightClientOptimisticUpdate,
ProposerSlashing, SignedAggregateAndProof, SignedBeaconBlock, SignedBlsToExecutionChange,
SignedContributionAndProof, SignedVoluntaryExit, Slot, SubnetId, SyncCommitteeMessage,
SyncSubnetId,
beacon_block::BlockImportSource, Attestation, AttesterSlashing, BlobSidecar, DataColumnSidecar,
DataColumnSubnetId, EthSpec, Hash256, IndexedAttestation, LightClientFinalityUpdate,
LightClientOptimisticUpdate, ProposerSlashing, SignedAggregateAndProof, SignedBeaconBlock,
SignedBlsToExecutionChange, SignedContributionAndProof, SignedVoluntaryExit, Slot, SubnetId,
SyncCommitteeMessage, SyncSubnetId,
};

use beacon_processor::{
Expand Down Expand Up @@ -1398,7 +1398,12 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {

let result = self
.chain
.process_block_with_early_caching(block_root, verified_block, NotifyExecutionLayer::Yes)
.process_block_with_early_caching(
block_root,
verified_block,
BlockImportSource::Gossip,
NotifyExecutionLayer::Yes,
)
.await;

match &result {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use store::KzgCommitment;
use tokio::sync::mpsc;
use types::beacon_block_body::format_kzg_commitments;
use types::blob_sidecar::FixedBlobSidecarList;
use types::{DataColumnSidecar, Epoch, Hash256};
use types::{BlockImportSource, DataColumnSidecar, Epoch, Hash256};

/// Id associated to a batch processing request, either a sync batch or a parent lookup.
#[derive(Clone, Debug, PartialEq)]
Expand Down Expand Up @@ -156,7 +156,12 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {

let result = self
.chain
.process_block_with_early_caching(block_root, block, NotifyExecutionLayer::Yes)
.process_block_with_early_caching(
block_root,
block,
BlockImportSource::Lookup,
NotifyExecutionLayer::Yes,
)
.await;

metrics::inc_counter(&metrics::BEACON_PROCESSOR_RPC_BLOCK_IMPORTED_TOTAL);
Expand Down
Loading

0 comments on commit 7c3c173

Please sign in to comment.