Skip to content

Commit 4daa015

Browse files
authored
Remove peer sampling code (#7768)
Peer sampling has been completely removed from the spec. This PR removes our partial implementation from the codebase. ethereum/consensus-specs#4393
1 parent c4b973f commit 4daa015

File tree

17 files changed

+11
-1509
lines changed

17 files changed

+11
-1509
lines changed

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2959,16 +2959,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
29592959
ChainSegmentResult::Successful { imported_blocks }
29602960
}
29612961

2962-
/// Updates fork-choice node into a permanent `available` state so it can become a viable head.
2963-
/// Only completed sampling results are received. Blocks are unavailable by default and should
2964-
/// be pruned on finalization, on a timeout or by a max count.
2965-
pub async fn process_sampling_completed(self: &Arc<Self>, block_root: Hash256) {
2966-
// TODO(das): update fork-choice, act on sampling result, adjust log level
2967-
// NOTE: It is possible that sampling complets before block is imported into fork choice,
2968-
// in that case we may need to update availability cache.
2969-
info!(%block_root, "Sampling completed");
2970-
}
2971-
29722962
/// Returns `Ok(GossipVerifiedBlock)` if the supplied `block` should be forwarded onto the
29732963
/// gossip network. The block is not imported into the chain, it is just partially verified.
29742964
///
@@ -7043,15 +7033,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
70437033
&& self.spec.is_peer_das_enabled_for_epoch(block_epoch)
70447034
}
70457035

7046-
/// Returns true if we should issue a sampling request for this block
7047-
/// TODO(das): check if the block is still within the da_window
7048-
pub fn should_sample_slot(&self, slot: Slot) -> bool {
7049-
self.config.enable_sampling
7050-
&& self
7051-
.spec
7052-
.is_peer_das_enabled_for_epoch(slot.epoch(T::EthSpec::slots_per_epoch()))
7053-
}
7054-
70557036
/// Gets the `LightClientBootstrap` object for a requested block root.
70567037
///
70577038
/// Returns `None` when the state or block is not found in the database.

beacon_node/beacon_chain/src/chain_config.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ pub struct ChainConfig {
9696
pub enable_light_client_server: bool,
9797
/// The number of data columns to withhold / exclude from publishing when proposing a block.
9898
pub malicious_withhold_count: usize,
99-
/// Enable peer sampling on blocks.
100-
pub enable_sampling: bool,
10199
/// Number of batches that the node splits blobs or data columns into during publication.
102100
/// This doesn't apply if the node is the block proposer. For PeerDAS only.
103101
pub blob_publication_batches: usize,
@@ -148,7 +146,6 @@ impl Default for ChainConfig {
148146
epochs_per_migration: crate::migrate::DEFAULT_EPOCHS_PER_MIGRATION,
149147
enable_light_client_server: true,
150148
malicious_withhold_count: 0,
151-
enable_sampling: false,
152149
blob_publication_batches: 4,
153150
blob_publication_batch_interval: Duration::from_millis(300),
154151
sync_tolerance_epochs: DEFAULT_SYNC_TOLERANCE_EPOCHS,

beacon_node/beacon_processor/src/lib.rs

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ use types::{
6767
BeaconState, ChainSpec, EthSpec, Hash256, RelativeEpoch, SignedAggregateAndProof,
6868
SingleAttestation, Slot, SubnetId,
6969
};
70+
use work_reprocessing_queue::IgnoredRpcBlock;
7071
use work_reprocessing_queue::{
7172
spawn_reprocess_scheduler, QueuedAggregate, QueuedLightClientUpdate, QueuedRpcBlock,
7273
QueuedUnaggregate, ReadyWork,
7374
};
74-
use work_reprocessing_queue::{IgnoredRpcBlock, QueuedSamplingRequest};
7575

7676
mod metrics;
7777
pub mod scheduler;
@@ -112,12 +112,9 @@ pub struct BeaconProcessorQueueLengths {
112112
gossip_proposer_slashing_queue: usize,
113113
gossip_attester_slashing_queue: usize,
114114
unknown_light_client_update_queue: usize,
115-
unknown_block_sampling_request_queue: usize,
116115
rpc_block_queue: usize,
117116
rpc_blob_queue: usize,
118117
rpc_custody_column_queue: usize,
119-
rpc_verify_data_column_queue: usize,
120-
sampling_result_queue: usize,
121118
column_reconstruction_queue: usize,
122119
chain_segment_queue: usize,
123120
backfill_chain_segment: usize,
@@ -183,9 +180,6 @@ impl BeaconProcessorQueueLengths {
183180
rpc_blob_queue: 1024,
184181
// TODO(das): Placeholder values
185182
rpc_custody_column_queue: 1000,
186-
rpc_verify_data_column_queue: 1000,
187-
unknown_block_sampling_request_queue: 16384,
188-
sampling_result_queue: 1000,
189183
column_reconstruction_queue: 64,
190184
chain_segment_queue: 64,
191185
backfill_chain_segment: 64,
@@ -487,10 +481,6 @@ impl<E: EthSpec> From<ReadyWork> for WorkEvent<E> {
487481
process_fn,
488482
},
489483
},
490-
ReadyWork::SamplingRequest(QueuedSamplingRequest { process_fn, .. }) => Self {
491-
drop_during_sync: true,
492-
work: Work::UnknownBlockSamplingRequest { process_fn },
493-
},
494484
ReadyWork::BackfillSync(QueuedBackfillBatch(process_fn)) => Self {
495485
drop_during_sync: false,
496486
work: Work::ChainSegmentBackfill(process_fn),
@@ -582,9 +572,6 @@ pub enum Work<E: EthSpec> {
582572
parent_root: Hash256,
583573
process_fn: BlockingFn,
584574
},
585-
UnknownBlockSamplingRequest {
586-
process_fn: BlockingFn,
587-
},
588575
GossipAggregateBatch {
589576
aggregates: Vec<GossipAggregatePackage<E>>,
590577
process_batch: Box<dyn FnOnce(Vec<GossipAggregatePackage<E>>) + Send + Sync>,
@@ -611,8 +598,6 @@ pub enum Work<E: EthSpec> {
611598
process_fn: AsyncFn,
612599
},
613600
RpcCustodyColumn(AsyncFn),
614-
RpcVerifyDataColumn(AsyncFn),
615-
SamplingResult(AsyncFn),
616601
ColumnReconstruction(AsyncFn),
617602
IgnoredRpcBlock {
618603
process_fn: BlockingFn,
@@ -652,7 +637,6 @@ pub enum WorkType {
652637
GossipAggregate,
653638
UnknownBlockAggregate,
654639
UnknownLightClientOptimisticUpdate,
655-
UnknownBlockSamplingRequest,
656640
GossipAggregateBatch,
657641
GossipBlock,
658642
GossipBlobSidecar,
@@ -668,8 +652,6 @@ pub enum WorkType {
668652
RpcBlock,
669653
RpcBlobs,
670654
RpcCustodyColumn,
671-
RpcVerifyDataColumn,
672-
SamplingResult,
673655
ColumnReconstruction,
674656
IgnoredRpcBlock,
675657
ChainSegment,
@@ -720,8 +702,6 @@ impl<E: EthSpec> Work<E> {
720702
Work::RpcBlock { .. } => WorkType::RpcBlock,
721703
Work::RpcBlobs { .. } => WorkType::RpcBlobs,
722704
Work::RpcCustodyColumn { .. } => WorkType::RpcCustodyColumn,
723-
Work::RpcVerifyDataColumn { .. } => WorkType::RpcVerifyDataColumn,
724-
Work::SamplingResult { .. } => WorkType::SamplingResult,
725705
Work::ColumnReconstruction(_) => WorkType::ColumnReconstruction,
726706
Work::IgnoredRpcBlock { .. } => WorkType::IgnoredRpcBlock,
727707
Work::ChainSegment { .. } => WorkType::ChainSegment,
@@ -741,7 +721,6 @@ impl<E: EthSpec> Work<E> {
741721
Work::LightClientUpdatesByRangeRequest(_) => WorkType::LightClientUpdatesByRangeRequest,
742722
Work::UnknownBlockAttestation { .. } => WorkType::UnknownBlockAttestation,
743723
Work::UnknownBlockAggregate { .. } => WorkType::UnknownBlockAggregate,
744-
Work::UnknownBlockSamplingRequest { .. } => WorkType::UnknownBlockSamplingRequest,
745724
Work::UnknownLightClientOptimisticUpdate { .. } => {
746725
WorkType::UnknownLightClientOptimisticUpdate
747726
}
@@ -884,14 +863,8 @@ impl<E: EthSpec> BeaconProcessor<E> {
884863
let mut rpc_block_queue = FifoQueue::new(queue_lengths.rpc_block_queue);
885864
let mut rpc_blob_queue = FifoQueue::new(queue_lengths.rpc_blob_queue);
886865
let mut rpc_custody_column_queue = FifoQueue::new(queue_lengths.rpc_custody_column_queue);
887-
let mut rpc_verify_data_column_queue =
888-
FifoQueue::new(queue_lengths.rpc_verify_data_column_queue);
889-
// TODO(das): the sampling_request_queue is never read
890-
let mut sampling_result_queue = FifoQueue::new(queue_lengths.sampling_result_queue);
891866
let mut column_reconstruction_queue =
892867
FifoQueue::new(queue_lengths.column_reconstruction_queue);
893-
let mut unknown_block_sampling_request_queue =
894-
FifoQueue::new(queue_lengths.unknown_block_sampling_request_queue);
895868
let mut chain_segment_queue = FifoQueue::new(queue_lengths.chain_segment_queue);
896869
let mut backfill_chain_segment = FifoQueue::new(queue_lengths.backfill_chain_segment);
897870
let mut gossip_block_queue = FifoQueue::new(queue_lengths.gossip_block_queue);
@@ -1058,13 +1031,8 @@ impl<E: EthSpec> BeaconProcessor<E> {
10581031
Some(item)
10591032
} else if let Some(item) = rpc_custody_column_queue.pop() {
10601033
Some(item)
1061-
// TODO(das): decide proper prioritization for sampling columns
10621034
} else if let Some(item) = rpc_custody_column_queue.pop() {
10631035
Some(item)
1064-
} else if let Some(item) = rpc_verify_data_column_queue.pop() {
1065-
Some(item)
1066-
} else if let Some(item) = sampling_result_queue.pop() {
1067-
Some(item)
10681036
// Check delayed blocks before gossip blocks, the gossip blocks might rely
10691037
// on the delayed ones.
10701038
} else if let Some(item) = delayed_block_queue.pop() {
@@ -1224,9 +1192,6 @@ impl<E: EthSpec> BeaconProcessor<E> {
12241192
Some(item)
12251193
} else if let Some(item) = dcbrange_queue.pop() {
12261194
Some(item)
1227-
// Prioritize sampling requests after block syncing requests
1228-
} else if let Some(item) = unknown_block_sampling_request_queue.pop() {
1229-
Some(item)
12301195
// Check slashings after all other consensus messages so we prioritize
12311196
// following head.
12321197
//
@@ -1379,10 +1344,6 @@ impl<E: EthSpec> BeaconProcessor<E> {
13791344
Work::RpcCustodyColumn { .. } => {
13801345
rpc_custody_column_queue.push(work, work_id)
13811346
}
1382-
Work::RpcVerifyDataColumn(_) => {
1383-
rpc_verify_data_column_queue.push(work, work_id)
1384-
}
1385-
Work::SamplingResult(_) => sampling_result_queue.push(work, work_id),
13861347
Work::ColumnReconstruction(_) => {
13871348
column_reconstruction_queue.push(work, work_id)
13881349
}
@@ -1425,9 +1386,6 @@ impl<E: EthSpec> BeaconProcessor<E> {
14251386
Work::UnknownLightClientOptimisticUpdate { .. } => {
14261387
unknown_light_client_update_queue.push(work, work_id)
14271388
}
1428-
Work::UnknownBlockSamplingRequest { .. } => {
1429-
unknown_block_sampling_request_queue.push(work, work_id)
1430-
}
14311389
Work::ApiRequestP0 { .. } => api_request_p0_queue.push(work, work_id),
14321390
Work::ApiRequestP1 { .. } => api_request_p1_queue.push(work, work_id),
14331391
};
@@ -1451,9 +1409,6 @@ impl<E: EthSpec> BeaconProcessor<E> {
14511409
WorkType::UnknownLightClientOptimisticUpdate => {
14521410
unknown_light_client_update_queue.len()
14531411
}
1454-
WorkType::UnknownBlockSamplingRequest => {
1455-
unknown_block_sampling_request_queue.len()
1456-
}
14571412
WorkType::GossipAggregateBatch => 0, // No queue
14581413
WorkType::GossipBlock => gossip_block_queue.len(),
14591414
WorkType::GossipBlobSidecar => gossip_blob_queue.len(),
@@ -1473,8 +1428,6 @@ impl<E: EthSpec> BeaconProcessor<E> {
14731428
WorkType::RpcBlock => rpc_block_queue.len(),
14741429
WorkType::RpcBlobs | WorkType::IgnoredRpcBlock => rpc_blob_queue.len(),
14751430
WorkType::RpcCustodyColumn => rpc_custody_column_queue.len(),
1476-
WorkType::RpcVerifyDataColumn => rpc_verify_data_column_queue.len(),
1477-
WorkType::SamplingResult => sampling_result_queue.len(),
14781431
WorkType::ColumnReconstruction => column_reconstruction_queue.len(),
14791432
WorkType::ChainSegment => chain_segment_queue.len(),
14801433
WorkType::ChainSegmentBackfill => backfill_chain_segment.len(),
@@ -1600,8 +1553,7 @@ impl<E: EthSpec> BeaconProcessor<E> {
16001553
}),
16011554
Work::UnknownBlockAttestation { process_fn }
16021555
| Work::UnknownBlockAggregate { process_fn }
1603-
| Work::UnknownLightClientOptimisticUpdate { process_fn, .. }
1604-
| Work::UnknownBlockSamplingRequest { process_fn } => {
1556+
| Work::UnknownLightClientOptimisticUpdate { process_fn, .. } => {
16051557
task_spawner.spawn_blocking(process_fn)
16061558
}
16071559
Work::DelayedImportBlock {
@@ -1612,8 +1564,6 @@ impl<E: EthSpec> BeaconProcessor<E> {
16121564
Work::RpcBlock { process_fn }
16131565
| Work::RpcBlobs { process_fn }
16141566
| Work::RpcCustodyColumn(process_fn)
1615-
| Work::RpcVerifyDataColumn(process_fn)
1616-
| Work::SamplingResult(process_fn)
16171567
| Work::ColumnReconstruction(process_fn) => task_spawner.spawn_async(process_fn),
16181568
Work::IgnoredRpcBlock { process_fn } => task_spawner.spawn_blocking(process_fn),
16191569
Work::GossipBlock(work)

beacon_node/beacon_processor/src/metrics.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,6 @@ pub static BEACON_PROCESSOR_REPROCESSING_QUEUE_MATCHED_ATTESTATIONS: LazyLock<Re
9898
"Number of queued attestations where as matching block has been imported.",
9999
)
100100
});
101-
// TODO: This should be labeled instead of N single metrics
102-
pub static BEACON_PROCESSOR_REPROCESSING_QUEUE_MATCHED_SAMPLING_REQUESTS: LazyLock<
103-
Result<IntCounter>,
104-
> = LazyLock::new(|| {
105-
try_create_int_counter(
106-
"beacon_processor_reprocessing_queue_matched_sampling_requests",
107-
"Number of queued sampling requests where a matching block has been imported.",
108-
)
109-
});
110101

111102
/*
112103
* Light client update reprocessing queue metrics.

0 commit comments

Comments
 (0)