Move BlockProcessingResult match out of block lookups (#9327)

- https://github.com/sigp/lighthouse/pull/9155 remove the trait abstraction for processing block / blobs / columns / payloads

As a result we would have to duplicate x3 the big match on `BlockProcessingResult` we currently have in block lookups mod.rs

This PR moves the match of `BlockProcessingResult` to `sync_methods` to reduce the diff of https://github.com/sigp/lighthouse/pull/9155. There are some subtle changes that deserve dedicated attention, and may be drowned in the bigger diff of https://github.com/sigp/lighthouse/pull/9155 otherwise:

| Unstable | This PR / #9115 |
| - | - |
| Some error conditions immediately `Drop` the lookup (no retries). For example for "internal" errors like the BeaconChainError | Retries ALL errors 4 times. I believe assuming some errors are internal is risky as dropping a lookup drops all its children potentially forcing the node to resync a lot of blocks because of an internal timeout


  


Co-Authored-By: dapplion <35266934+dapplion@users.noreply.github.com>
This commit is contained in:
Lion - dapplion
2026-06-02 04:50:56 +02:00
committed by GitHub
parent b781227f1d
commit bbe7ead813
10 changed files with 214 additions and 167 deletions

View File

@@ -1,17 +1,19 @@
use super::*;
use crate::NetworkMessage;
use crate::network_beacon_processor::BlockProcessingResult;
use crate::network_beacon_processor::sync_methods::WhichPeerToPenalize;
use crate::network_beacon_processor::{
ChainSegmentProcessId, InvalidBlockStorage, NetworkBeaconProcessor,
};
use crate::sync::block_lookups::{BlockLookupSummary, PARENT_DEPTH_TOLERANCE};
use crate::sync::{
SyncMessage,
manager::{BatchProcessResult, BlockProcessType, BlockProcessingResult, SyncManager},
manager::{BatchProcessResult, BlockProcessType, SyncManager},
};
use beacon_chain::block_verification_types::LookupBlock;
use beacon_chain::custody_context::NodeCustodyType;
use beacon_chain::{
AvailabilityProcessingStatus, BlockError, EngineState, NotifyExecutionLayer,
AvailabilityProcessingStatus, EngineState, NotifyExecutionLayer,
block_verification_types::{AsBlock, AvailableBlockData},
test_utils::{
AttestationStrategy, BeaconChainHarness, BlockStrategy, EphemeralHarnessType, NumBlobs,
@@ -1947,7 +1949,14 @@ async fn too_many_processing_failures(depth: usize) {
r.build_chain_and_trigger_last_block(depth).await;
// Simulate that a peer always returns empty
r.simulate(
SimulateConfig::new().with_process_result(|| BlockError::BlockSlotLimitReached.into()),
SimulateConfig::new().with_process_result(|| BlockProcessingResult::Error {
penalty: Some((
PeerAction::MidToleranceError,
WhichPeerToPenalize::BlockPeer,
"lookup_block_processing_failure",
)),
reason: "lookup_block_processing_failure".to_string(),
}),
)
.await;
// We register multiple penalties, the lookup fails and sync does not progress
@@ -1991,15 +2000,21 @@ async fn unknown_parent_does_not_add_peers_to_itself() {
}
#[tokio::test]
/// Assert that if the beacon processor returns Ignored, the lookup is dropped
/// Assert that a non-attributable processing error (e.g. processor overloaded) is retried up to
/// `SINGLE_BLOCK_LOOKUP_MAX_ATTEMPTS`, no peer is penalized, and the lookup is then dropped.
async fn test_single_block_lookup_ignored_response() {
let mut r = TestRig::default();
r.build_chain_and_trigger_last_block(1).await;
// Send an Ignored response, the request should be dropped
r.simulate(SimulateConfig::new().with_process_result(|| BlockProcessingResult::Ignored))
.await;
r.simulate(
SimulateConfig::new().with_process_result(|| BlockProcessingResult::Error {
penalty: None,
reason: "processor_overloaded".to_string(),
}),
)
.await;
// The block was not actually imported
r.assert_head_slot(0);
r.assert_no_penalties();
assert_eq!(r.created_lookups(), 1, "no created lookups");
assert_eq!(r.dropped_lookups(), 1, "no dropped lookups");
assert_eq!(r.completed_lookups(), 0, "some completed lookups");
@@ -2013,7 +2028,7 @@ async fn test_single_block_lookup_duplicate_response() {
// Send a DuplicateFullyImported response, the lookup should complete successfully
r.simulate(
SimulateConfig::new()
.with_process_result(|| BlockError::DuplicateFullyImported(Hash256::ZERO).into()),
.with_process_result(|| BlockProcessingResult::Imported(true, "duplicate")),
)
.await;
// The block was not actually imported
@@ -2392,7 +2407,7 @@ async fn crypto_on_fail_with_invalid_block_signature() {
r.assert_no_penalties();
} else {
r.assert_failed_lookup_sync();
r.assert_penalties_of_type("lookup_block_processing_failure");
r.assert_penalties_of_type("InvalidSignature");
}
}
@@ -2410,7 +2425,7 @@ async fn crypto_on_fail_with_bad_column_proposer_signature() {
r.assert_no_penalties();
} else {
r.assert_failed_lookup_sync();
r.assert_penalties_of_type("lookup_custody_column_processing_failure");
r.assert_penalties_of_type("InvalidSignature");
}
}
@@ -2428,6 +2443,6 @@ async fn crypto_on_fail_with_bad_column_kzg_proof() {
r.assert_no_penalties();
} else {
r.assert_failed_lookup_sync();
r.assert_penalties_of_type("lookup_custody_column_processing_failure");
r.assert_penalties_of_type("AvailabilityCheck");
}
}