1
1
#![ cfg( not( debug_assertions) ) ]
2
2
3
3
use beacon_chain:: attestation_verification:: Error as AttnError ;
4
- use beacon_chain:: block_verification_types:: RpcBlock ;
5
4
use beacon_chain:: builder:: BeaconChainBuilder ;
6
5
use beacon_chain:: data_availability_checker:: AvailableBlock ;
7
6
use beacon_chain:: schema_change:: migrate_schema;
@@ -82,13 +81,26 @@ fn get_harness(
82
81
reconstruct_historic_states : true ,
83
82
..ChainConfig :: default ( )
84
83
} ;
85
- get_harness_generic ( store, validator_count, chain_config)
84
+ get_harness_generic ( store, validator_count, chain_config, false )
85
+ }
86
+
87
+ fn get_harness_import_all_data_columns (
88
+ store : Arc < HotColdDB < E , BeaconNodeBackend < E > , BeaconNodeBackend < E > > > ,
89
+ validator_count : usize ,
90
+ ) -> TestHarness {
91
+ // Most tests expect to retain historic states, so we use this as the default.
92
+ let chain_config = ChainConfig {
93
+ reconstruct_historic_states : true ,
94
+ ..ChainConfig :: default ( )
95
+ } ;
96
+ get_harness_generic ( store, validator_count, chain_config, true )
86
97
}
87
98
88
99
fn get_harness_generic (
89
100
store : Arc < HotColdDB < E , BeaconNodeBackend < E > , BeaconNodeBackend < E > > > ,
90
101
validator_count : usize ,
91
102
chain_config : ChainConfig ,
103
+ import_all_data_columns : bool ,
92
104
) -> TestHarness {
93
105
let harness = TestHarness :: builder ( MinimalEthSpec )
94
106
. spec ( store. get_chain_spec ( ) . clone ( ) )
@@ -97,6 +109,7 @@ fn get_harness_generic(
97
109
. fresh_disk_store ( store)
98
110
. mock_execution_layer ( )
99
111
. chain_config ( chain_config)
112
+ . import_all_data_columns ( import_all_data_columns)
100
113
. build ( ) ;
101
114
harness. advance_slot ( ) ;
102
115
harness
@@ -2286,7 +2299,12 @@ async fn weak_subjectivity_sync_test(slots: Vec<Slot>, checkpoint_slot: Slot) {
2286
2299
2287
2300
let temp1 = tempdir ( ) . unwrap ( ) ;
2288
2301
let full_store = get_store ( & temp1) ;
2289
- let harness = get_harness ( full_store. clone ( ) , LOW_VALIDATOR_COUNT ) ;
2302
+
2303
+ // Run a supernode so the node has full blobs stored.
2304
+ // This may not be required in the future if we end up implementing downloading checkpoint
2305
+ // blobs from p2p peers:
2306
+ // https://github.com/sigp/lighthouse/issues/6837
2307
+ let harness = get_harness_import_all_data_columns ( full_store. clone ( ) , LOW_VALIDATOR_COUNT ) ;
2290
2308
2291
2309
let all_validators = ( 0 ..LOW_VALIDATOR_COUNT ) . collect :: < Vec < _ > > ( ) ;
2292
2310
@@ -2319,10 +2337,8 @@ async fn weak_subjectivity_sync_test(slots: Vec<Slot>, checkpoint_slot: Slot) {
2319
2337
. unwrap ( ) ;
2320
2338
let wss_blobs_opt = harness
2321
2339
. chain
2322
- . store
2323
- . get_blobs ( & wss_block_root)
2324
- . unwrap ( )
2325
- . blobs ( ) ;
2340
+ . get_or_reconstruct_blobs ( & wss_block_root)
2341
+ . unwrap ( ) ;
2326
2342
let wss_state = full_store
2327
2343
. get_state ( & wss_state_root, Some ( checkpoint_slot) )
2328
2344
. unwrap ( )
@@ -2395,14 +2411,16 @@ async fn weak_subjectivity_sync_test(slots: Vec<Slot>, checkpoint_slot: Slot) {
2395
2411
. await
2396
2412
. unwrap ( )
2397
2413
. unwrap ( ) ;
2414
+ // This test may break in the future if we no longer store the full checkpoint data columns.
2398
2415
let store_wss_blobs_opt = beacon_chain
2399
- . store
2400
- . get_blobs ( & wss_block_root)
2401
- . unwrap ( )
2402
- . blobs ( ) ;
2416
+ . get_or_reconstruct_blobs ( & wss_block_root)
2417
+ . unwrap ( ) ;
2403
2418
2404
2419
assert_eq ! ( store_wss_block, wss_block) ;
2405
- assert_eq ! ( store_wss_blobs_opt, wss_blobs_opt) ;
2420
+ // TODO(fulu): Remove this condition once #6760 (PeerDAS checkpoint sync) is merged.
2421
+ if !beacon_chain. spec . is_peer_das_scheduled ( ) {
2422
+ assert_eq ! ( store_wss_blobs_opt, wss_blobs_opt) ;
2423
+ }
2406
2424
2407
2425
// Apply blocks forward to reach head.
2408
2426
let chain_dump = harness. chain . chain_dump ( ) . unwrap ( ) ;
@@ -2418,15 +2436,15 @@ async fn weak_subjectivity_sync_test(slots: Vec<Slot>, checkpoint_slot: Slot) {
2418
2436
. await
2419
2437
. unwrap ( )
2420
2438
. unwrap ( ) ;
2421
- let blobs = harness . chain . get_blobs ( & block_root ) . expect ( "blobs" ) . blobs ( ) ;
2439
+
2422
2440
let slot = full_block. slot ( ) ;
2423
2441
let state_root = full_block. state_root ( ) ;
2424
2442
2425
2443
beacon_chain. slot_clock . set_slot ( slot. as_u64 ( ) ) ;
2426
2444
beacon_chain
2427
2445
. process_block (
2428
2446
full_block. canonical_root ( ) ,
2429
- RpcBlock :: new ( Some ( block_root) , Arc :: new ( full_block) , blobs ) . unwrap ( ) ,
2447
+ harness . build_rpc_block_from_store_blobs ( Some ( block_root) , Arc :: new ( full_block) ) ,
2430
2448
NotifyExecutionLayer :: Yes ,
2431
2449
BlockImportSource :: Lookup ,
2432
2450
|| Ok ( ( ) ) ,
@@ -2480,13 +2498,12 @@ async fn weak_subjectivity_sync_test(slots: Vec<Slot>, checkpoint_slot: Slot) {
2480
2498
. await
2481
2499
. expect ( "should get block" )
2482
2500
. expect ( "should get block" ) ;
2483
- let blobs = harness. chain . get_blobs ( & block_root) . expect ( "blobs" ) . blobs ( ) ;
2484
2501
2485
2502
if let MaybeAvailableBlock :: Available ( block) = harness
2486
2503
. chain
2487
2504
. data_availability_checker
2488
2505
. verify_kzg_for_rpc_block (
2489
- RpcBlock :: new ( Some ( block_root) , Arc :: new ( full_block) , blobs ) . unwrap ( ) ,
2506
+ harness . build_rpc_block_from_store_blobs ( Some ( block_root) , Arc :: new ( full_block) ) ,
2490
2507
)
2491
2508
. expect ( "should verify kzg" )
2492
2509
{
@@ -2587,7 +2604,7 @@ async fn process_blocks_and_attestations_for_unaligned_checkpoint() {
2587
2604
reconstruct_historic_states : false ,
2588
2605
..ChainConfig :: default ( )
2589
2606
} ;
2590
- let harness = get_harness_generic ( store. clone ( ) , LOW_VALIDATOR_COUNT , chain_config) ;
2607
+ let harness = get_harness_generic ( store. clone ( ) , LOW_VALIDATOR_COUNT , chain_config, false ) ;
2591
2608
2592
2609
let all_validators = ( 0 ..LOW_VALIDATOR_COUNT ) . collect :: < Vec < _ > > ( ) ;
2593
2610
0 commit comments