|
1 | 1 | use crate::network_beacon_processor::NetworkBeaconProcessor;
|
2 |
| -use crate::sync::manager::{BlockProcessType, SyncManager}; |
3 |
| -use crate::sync::peer_sampling::SamplingConfig; |
4 |
| -use crate::sync::range_sync::RangeSyncType; |
5 |
| -use crate::sync::{SamplingId, SyncMessage}; |
| 2 | +use crate::sync::block_lookups::{ |
| 3 | + BlockLookupSummary, PARENT_DEPTH_TOLERANCE, SINGLE_BLOCK_LOOKUP_MAX_ATTEMPTS, |
| 4 | +}; |
| 5 | +use crate::sync::{ |
| 6 | + manager::{BlockProcessType, BlockProcessingResult, SyncManager}, |
| 7 | + peer_sampling::SamplingConfig, |
| 8 | + SamplingId, SyncMessage, |
| 9 | +}; |
6 | 10 | use crate::NetworkMessage;
|
7 | 11 | use std::sync::Arc;
|
| 12 | +use std::time::Duration; |
8 | 13 |
|
9 | 14 | use super::*;
|
10 | 15 |
|
11 | 16 | use crate::sync::block_lookups::common::ResponseType;
|
12 |
| -use beacon_chain::blob_verification::GossipVerifiedBlob; |
13 |
| -use beacon_chain::block_verification_types::BlockImportData; |
14 |
| -use beacon_chain::builder::Witness; |
15 |
| -use beacon_chain::data_availability_checker::Availability; |
16 |
| -use beacon_chain::eth1_chain::CachingEth1Backend; |
17 |
| -use beacon_chain::test_utils::{ |
18 |
| - build_log, generate_rand_block_and_blobs, generate_rand_block_and_data_columns, test_spec, |
19 |
| - BeaconChainHarness, EphemeralHarnessType, LoggerType, NumBlobs, |
20 |
| -}; |
21 |
| -use beacon_chain::validator_monitor::timestamp_now; |
22 | 17 | use beacon_chain::{
|
23 |
| - AvailabilityPendingExecutedBlock, PayloadVerificationOutcome, PayloadVerificationStatus, |
| 18 | + blob_verification::GossipVerifiedBlob, |
| 19 | + block_verification_types::{AsBlock, BlockImportData}, |
| 20 | + data_availability_checker::Availability, |
| 21 | + test_utils::{ |
| 22 | + build_log, generate_rand_block_and_blobs, generate_rand_block_and_data_columns, test_spec, |
| 23 | + BeaconChainHarness, EphemeralHarnessType, LoggerType, NumBlobs, |
| 24 | + }, |
| 25 | + validator_monitor::timestamp_now, |
| 26 | + AvailabilityPendingExecutedBlock, AvailabilityProcessingStatus, BlockError, |
| 27 | + PayloadVerificationOutcome, PayloadVerificationStatus, |
24 | 28 | };
|
25 | 29 | use beacon_processor::WorkEvent;
|
26 |
| -use lighthouse_network::rpc::{RPCError, RequestType, RpcErrorResponse}; |
27 |
| -use lighthouse_network::service::api_types::{ |
28 |
| - AppRequestId, DataColumnsByRootRequestId, DataColumnsByRootRequester, Id, SamplingRequester, |
29 |
| - SingleLookupReqId, SyncRequestId, |
| 30 | +use lighthouse_network::{ |
| 31 | + rpc::{RPCError, RequestType, RpcErrorResponse}, |
| 32 | + service::api_types::{ |
| 33 | + AppRequestId, DataColumnsByRootRequestId, DataColumnsByRootRequester, Id, |
| 34 | + SamplingRequester, SingleLookupReqId, SyncRequestId, |
| 35 | + }, |
| 36 | + types::SyncState, |
| 37 | + NetworkConfig, NetworkGlobals, PeerId, |
30 | 38 | };
|
31 |
| -use lighthouse_network::types::SyncState; |
32 |
| -use lighthouse_network::NetworkConfig; |
33 |
| -use lighthouse_network::NetworkGlobals; |
34 | 39 | use slog::info;
|
35 |
| -use slot_clock::{ManualSlotClock, SlotClock, TestingSlotClock}; |
36 |
| -use store::MemoryStore; |
| 40 | +use slot_clock::{SlotClock, TestingSlotClock}; |
37 | 41 | use tokio::sync::mpsc;
|
38 |
| -use types::data_column_sidecar::ColumnIndex; |
39 |
| -use types::test_utils::TestRandom; |
40 | 42 | use types::{
|
41 |
| - test_utils::{SeedableRng, XorShiftRng}, |
42 |
| - BlobSidecar, ForkName, MinimalEthSpec as E, SignedBeaconBlock, Slot, |
| 43 | + data_column_sidecar::ColumnIndex, |
| 44 | + test_utils::{SeedableRng, TestRandom, XorShiftRng}, |
| 45 | + BeaconState, BeaconStateBase, BlobSidecar, DataColumnSidecar, Epoch, EthSpec, ForkName, |
| 46 | + Hash256, MinimalEthSpec as E, SignedBeaconBlock, Slot, |
43 | 47 | };
|
44 |
| -use types::{BeaconState, BeaconStateBase}; |
45 |
| -use types::{DataColumnSidecar, Epoch}; |
46 |
| - |
47 |
| -type T = Witness<ManualSlotClock, CachingEth1Backend<E>, E, MemoryStore<E>, MemoryStore<E>>; |
48 |
| - |
49 |
| -/// This test utility enables integration testing of Lighthouse sync components. |
50 |
| -/// |
51 |
| -/// It covers the following: |
52 |
| -/// 1. Sending `SyncMessage` to `SyncManager` to trigger `RangeSync`, `BackFillSync` and `BlockLookups` behaviours. |
53 |
| -/// 2. Making assertions on `WorkEvent`s received from sync |
54 |
| -/// 3. Making assertion on `NetworkMessage` received from sync (Outgoing RPC requests). |
55 |
| -/// |
56 |
| -/// The test utility covers testing the interactions from and to `SyncManager`. In diagram form: |
57 |
| -/// +-----------------+ |
58 |
| -/// | BeaconProcessor | |
59 |
| -/// +---------+-------+ |
60 |
| -/// ^ | |
61 |
| -/// | | |
62 |
| -/// WorkEvent | | SyncMsg |
63 |
| -/// | | (Result) |
64 |
| -/// | v |
65 |
| -/// +--------+ +-----+-----------+ +----------------+ |
66 |
| -/// | Router +----------->| SyncManager +------------>| NetworkService | |
67 |
| -/// +--------+ SyncMsg +-----------------+ NetworkMsg +----------------+ |
68 |
| -/// (RPC resp) | - RangeSync | (RPC req) |
69 |
| -/// +-----------------+ |
70 |
| -/// | - BackFillSync | |
71 |
| -/// +-----------------+ |
72 |
| -/// | - BlockLookups | |
73 |
| -/// +-----------------+ |
74 |
| -struct TestRig { |
75 |
| - /// Receiver for `BeaconProcessor` events (e.g. block processing results). |
76 |
| - beacon_processor_rx: mpsc::Receiver<WorkEvent<E>>, |
77 |
| - beacon_processor_rx_queue: Vec<WorkEvent<E>>, |
78 |
| - /// Receiver for `NetworkMessage` (e.g. outgoing RPC requests from sync) |
79 |
| - network_rx: mpsc::UnboundedReceiver<NetworkMessage<E>>, |
80 |
| - /// Stores all `NetworkMessage`s received from `network_recv`. (e.g. outgoing RPC requests) |
81 |
| - network_rx_queue: Vec<NetworkMessage<E>>, |
82 |
| - /// Receiver for `SyncMessage` from the network |
83 |
| - sync_rx: mpsc::UnboundedReceiver<SyncMessage<E>>, |
84 |
| - /// To send `SyncMessage`. For sending RPC responses or block processing results to sync. |
85 |
| - sync_manager: SyncManager<T>, |
86 |
| - /// To manipulate sync state and peer connection status |
87 |
| - network_globals: Arc<NetworkGlobals<E>>, |
88 |
| - /// Beacon chain harness |
89 |
| - harness: BeaconChainHarness<EphemeralHarnessType<E>>, |
90 |
| - /// `rng` for generating test blocks and blobs. |
91 |
| - rng: XorShiftRng, |
92 |
| - fork_name: ForkName, |
93 |
| - log: Logger, |
94 |
| -} |
95 | 48 |
|
96 | 49 | const D: Duration = Duration::new(0, 0);
|
97 | 50 | const PARENT_FAIL_TOLERANCE: u8 = SINGLE_BLOCK_LOOKUP_MAX_ATTEMPTS;
|
|
0 commit comments