@@ -3182,13 +3182,16 @@ async fn weak_subjectivity_sync_test(
31823182 assert_eq ! ( store. get_anchor_info( ) . state_upper_limit, Slot :: new( 0 ) ) ;
31833183}
31843184
3185+ // This test prunes data columns from epoch 0 and then tries to re-import them via
3186+ // the same code paths that custody backfill sync imports data columns
31853187#[ tokio:: test]
31863188async fn test_import_historical_data_columns_batch ( ) {
31873189 let spec = ForkName :: Fulu . make_genesis_spec ( E :: default_spec ( ) ) ;
31883190 let db_path = tempdir ( ) . unwrap ( ) ;
31893191 let store = get_store_generic ( & db_path, StoreConfig :: default ( ) , spec) ;
31903192 let start_slot = Epoch :: new ( 0 ) . start_slot ( E :: slots_per_epoch ( ) ) + 1 ;
31913193 let end_slot = Epoch :: new ( 0 ) . end_slot ( E :: slots_per_epoch ( ) ) ;
3194+ let cgc = 128 ;
31923195
31933196 let harness = get_harness_import_all_data_columns ( store. clone ( ) , LOW_VALIDATOR_COUNT ) ;
31943197
@@ -3208,6 +3211,7 @@ async fn test_import_historical_data_columns_batch() {
32083211
32093212 let mut data_columns_list = vec ! [ ] ;
32103213
3214+ // Get all data columns for epoch 0
32113215 for block in block_root_iter {
32123216 let ( block_root, _) = block. unwrap ( ) ;
32133217 let data_columns = harness. chain . store . get_data_columns ( & block_root) . unwrap ( ) ;
@@ -3227,6 +3231,7 @@ async fn test_import_historical_data_columns_batch() {
32273231
32283232 harness. advance_slot ( ) ;
32293233
3234+ // Prune data columns
32303235 harness
32313236 . chain
32323237 . store
@@ -3238,21 +3243,25 @@ async fn test_import_historical_data_columns_batch() {
32383243 . forwards_iter_block_roots_until ( start_slot, end_slot)
32393244 . unwrap ( ) ;
32403245
3246+ // Assert that data columns no longer exist for epoch 0
32413247 for block in block_root_iter {
32423248 let ( block_root, _) = block. unwrap ( ) ;
32433249 let data_columns = harness. chain . store . get_data_columns ( & block_root) . unwrap ( ) ;
32443250 assert ! ( data_columns. is_none( ) )
32453251 }
32463252
3253+ // Re-import deleted data columns
32473254 harness
32483255 . chain
3249- . import_historical_data_column_batch ( Epoch :: new ( 0 ) , data_columns_list)
3256+ . import_historical_data_column_batch ( Epoch :: new ( 0 ) , data_columns_list, cgc )
32503257 . unwrap ( ) ;
3258+
32513259 let block_root_iter = harness
32523260 . chain
32533261 . forwards_iter_block_roots_until ( start_slot, end_slot)
32543262 . unwrap ( ) ;
32553263
3264+ // Assert that data columns now exist for epoch 0
32563265 for block in block_root_iter {
32573266 let ( block_root, _) = block. unwrap ( ) ;
32583267 let data_columns = harness. chain . store . get_data_columns ( & block_root) . unwrap ( ) ;
@@ -3261,13 +3270,15 @@ async fn test_import_historical_data_columns_batch() {
32613270}
32623271
32633272// This should verify that a data column sidecar containing mismatched block roots should fail to be imported.
3273+ // This also covers any test cases related to data columns with incorrect/invalid/mismatched block roots.
32643274#[ tokio:: test]
32653275async fn test_import_historical_data_columns_batch_mismatched_block_root ( ) {
32663276 let spec = ForkName :: Fulu . make_genesis_spec ( E :: default_spec ( ) ) ;
32673277 let db_path = tempdir ( ) . unwrap ( ) ;
32683278 let store = get_store_generic ( & db_path, StoreConfig :: default ( ) , spec) ;
32693279 let start_slot = Slot :: new ( 1 ) ;
32703280 let end_slot = Slot :: new ( E :: slots_per_epoch ( ) * 2 - 1 ) ;
3281+ let cgc = 128 ;
32713282
32723283 let harness = get_harness_import_all_data_columns ( store. clone ( ) , LOW_VALIDATOR_COUNT ) ;
32733284
@@ -3287,6 +3298,8 @@ async fn test_import_historical_data_columns_batch_mismatched_block_root() {
32873298
32883299 let mut data_columns_list = vec ! [ ] ;
32893300
3301+ // Get all data columns from start_slot to end_slot
3302+ // and mutate the data columns with an invalid block root
32903303 for block in block_root_iter {
32913304 let ( block_root, _) = block. unwrap ( ) ;
32923305 let data_columns = harness. chain . store . get_data_columns ( & block_root) . unwrap ( ) ;
@@ -3312,6 +3325,7 @@ async fn test_import_historical_data_columns_batch_mismatched_block_root() {
33123325
33133326 harness. advance_slot ( ) ;
33143327
3328+ // Prune blobs
33153329 harness
33163330 . chain
33173331 . store
@@ -3323,17 +3337,20 @@ async fn test_import_historical_data_columns_batch_mismatched_block_root() {
33233337 . forwards_iter_block_roots_until ( start_slot, end_slot)
33243338 . unwrap ( ) ;
33253339
3340+ // Assert there are no columns between start_slot and end_slot
33263341 for block in block_root_iter {
33273342 let ( block_root, _) = block. unwrap ( ) ;
33283343 let data_columns = harness. chain . store . get_data_columns ( & block_root) . unwrap ( ) ;
33293344 assert ! ( data_columns. is_none( ) )
33303345 }
33313346
3347+ // Attempt to import data columns with invalid block roots and expect a failure
33323348 let error = harness
33333349 . chain
33343350 . import_historical_data_column_batch (
33353351 start_slot. epoch ( E :: slots_per_epoch ( ) ) ,
33363352 data_columns_list,
3353+ cgc,
33373354 )
33383355 . unwrap_err ( ) ;
33393356
@@ -3343,84 +3360,6 @@ async fn test_import_historical_data_columns_batch_mismatched_block_root() {
33433360 ) ) ;
33443361}
33453362
3346- // This should verify that a data column sidecar associated to a block root that doesn't exist in the store cannot
3347- // be imported.
3348- #[ tokio:: test]
3349- async fn test_import_historical_data_columns_batch_no_block_found ( ) {
3350- let spec = ForkName :: Fulu . make_genesis_spec ( E :: default_spec ( ) ) ;
3351- let db_path = tempdir ( ) . unwrap ( ) ;
3352- let store = get_store_generic ( & db_path, StoreConfig :: default ( ) , spec) ;
3353- let start_slot = Slot :: new ( 1 ) ;
3354- let end_slot = Slot :: new ( E :: slots_per_epoch ( ) * 2 - 1 ) ;
3355-
3356- let harness = get_harness_import_all_data_columns ( store. clone ( ) , LOW_VALIDATOR_COUNT ) ;
3357-
3358- harness
3359- . extend_chain (
3360- ( E :: slots_per_epoch ( ) * 2 ) as usize ,
3361- BlockStrategy :: OnCanonicalHead ,
3362- AttestationStrategy :: AllValidators ,
3363- )
3364- . await ;
3365- harness. advance_slot ( ) ;
3366-
3367- let block_root_iter = harness
3368- . chain
3369- . forwards_iter_block_roots_until ( start_slot, end_slot)
3370- . unwrap ( ) ;
3371-
3372- let mut data_columns_list = vec ! [ ] ;
3373-
3374- for block in block_root_iter {
3375- let ( block_root, _) = block. unwrap ( ) ;
3376- let data_columns = harness. chain . store . get_data_columns ( & block_root) . unwrap ( ) ;
3377- assert ! ( data_columns. is_some( ) ) ;
3378-
3379- for data_column in data_columns. unwrap ( ) {
3380- let mut data_column = ( * data_column) . clone ( ) ;
3381- data_column. signed_block_header . message . body_root = Hash256 :: ZERO ;
3382- data_columns_list. push ( Arc :: new ( data_column) ) ;
3383- }
3384- }
3385-
3386- harness
3387- . extend_chain (
3388- ( E :: slots_per_epoch ( ) * 4 ) as usize ,
3389- BlockStrategy :: OnCanonicalHead ,
3390- AttestationStrategy :: AllValidators ,
3391- )
3392- . await ;
3393-
3394- harness. advance_slot ( ) ;
3395-
3396- harness
3397- . chain
3398- . store
3399- . try_prune_blobs ( true , Epoch :: new ( 2 ) )
3400- . unwrap ( ) ;
3401-
3402- let block_root_iter = harness
3403- . chain
3404- . forwards_iter_block_roots_until ( start_slot, end_slot)
3405- . unwrap ( ) ;
3406-
3407- for block in block_root_iter {
3408- let ( block_root, _) = block. unwrap ( ) ;
3409- let data_columns = harness. chain . store . get_data_columns ( & block_root) . unwrap ( ) ;
3410- assert ! ( data_columns. is_none( ) )
3411- }
3412-
3413- let error = harness
3414- . chain
3415- . import_historical_data_column_batch ( Epoch :: new ( 0 ) , data_columns_list)
3416- . unwrap_err ( ) ;
3417-
3418- assert ! ( matches!(
3419- error,
3420- HistoricalDataColumnError :: NoBlockFound { .. }
3421- ) ) ;
3422- }
3423-
34243363/// Test that blocks and attestations that refer to states around an unaligned split state are
34253364/// processed correctly.
34263365#[ tokio:: test]
0 commit comments