zakura-state 8.0.0

State contextual verification and storage code for the Zakura node. Internal crate, published to support cargo install zakura
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
use super::*;

pub(super) fn crash_fixture_selected_auxiliary_repair_reopens_complete_before_or_after() {
    for (index, target) in FaultPoint::ALL.into_iter().enumerate() {
        let cache = tempfile::tempdir().expect("the test cache directory is created");
        let db_config = Config {
            cache_dir: cache.path().to_owned(),
            ephemeral: false,
            debug_skip_non_finalized_state_backup_task: true,
            ..Config::default()
        };
        let (engine_config, anchor, metadata) = fixture();
        let network = engine_config.network().clone();
        let db = open(&db_config, &network);
        let store = HeaderChainStore::new(db.clone());
        store
            .initialize(metadata, anchor.clone())
            .expect("the empty schema initializes");
        let (runtime, _) = store
            .startup(&engine_config)
            .expect("the initial store audits");
        let initial = runtime.publisher().snapshot();
        let anchor_frontier = Frontier::new(anchor.height, anchor.hash);
        let lease = runtime
            .reader()
            .validation_context(anchor.hash)
            .expect("the anchor validation context is coherent")
            .expect("the initialized anchor is retained");
        let rules = HeaderRules::for_validation_lease(&lease)
            .expect("the authenticated regtest policy is valid");
        let marker = u8::try_from(index + 0x10).expect("the fault-point list fits in u8");
        let mut child_header = *anchor.header;
        child_header.previous_block_hash = anchor.hash;
        child_header.time += chrono::Duration::seconds(1);
        child_header.nonce.0[0] = marker;
        let child_header = Arc::new(child_header);
        let headers = [child_header.clone()];
        let insertion_batch = zakura_header_chain::prepare_headers(
            HeaderBatchInput::new(&headers),
            lease.parent(),
            &rules,
            &SystemClock,
        )
        .expect("the selected repair fixture passes production validation");
        let child = Frontier::new(
            anchor
                .height
                .next()
                .expect("the genesis anchor has a next height"),
            child_header.hash(),
        );
        let insertion_owner = header_owner(&initial, child.hash, 51, 52);
        let insertion_context = TransitionContext {
            config: &engine_config,
            clock: &SystemClock,
            full_state_authority: None,
            retention_references: &[],
        };
        runtime
            .apply(
                TransitionRequest {
                    expected_version: initial.state_version,
                    event: TransitionEvent::InsertHeaders(Box::new(InsertHeaders {
                        owner: insertion_owner,
                        source: SourceId::from_digest([marker.wrapping_add(1); 32]),
                        parent_hash: anchor.hash,
                        target_tip_hash: child.hash,
                        completion: TargetCompletion::TargetComplete {
                            common_ancestor: anchor_frontier,
                        },
                        batch: insertion_batch,
                        aux: Vec::new(),
                    })),
                },
                &insertion_context,
            )
            .expect("the selected repair target inserts without auxiliary metadata");
        let before = runtime.publisher().snapshot();
        assert_eq!(before.frontiers.header_best, child);
        assert!(runtime
            .store
            .aux_deliveries(child.hash)
            .expect("the initial auxiliary index is readable")
            .is_empty());

        let repair_lease = runtime
            .reader()
            .validation_context(anchor.hash)
            .expect("the repair validation context is coherent")
            .expect("the repair parent remains retained");
        let repair_rules = HeaderRules::for_validation_lease(&repair_lease)
            .expect("the authenticated repair policy is valid");
        let repair_batch = zakura_header_chain::prepare_headers(
            HeaderBatchInput::new(&headers),
            repair_lease.parent(),
            &repair_rules,
            &SystemClock,
        )
        .expect("the selected header redelivery passes production validation");
        let repair_owner = zakura_header_chain::BodyWorkAuthority::for_snapshot(&before)
            .bind(53, NonZeroU64::new(54).expect("fifty-four is nonzero"));
        let repair_episode = runtime
            .reader()
            .vct_repair_context(repair_owner, child.height)
            .expect("the selected repair context is coherent")
            .expect("the selected repair target remains current")
            .episode;
        let source = SourceId::from_digest([marker.wrapping_add(2); 32]);
        let delivery = AuxDelivery::new(
            EvidenceId::from_digest([marker.wrapping_add(3); 32]),
            child.hash,
            source,
            repair_owner.into(),
            zakura_header_chain::BodySizeHint::Unknown,
            Some(zakura_header_chain::TreeAuxRecordV1 {
                height: child.height,
                sapling_root: Default::default(),
                orchard_root: Default::default(),
                ironwood_root: Default::default(),
                sapling_tx_count: 4,
                orchard_tx_count: 5,
                ironwood_tx_count: 6,
                auth_data_root: zakura_chain::block::merkle::AuthDataRoot::from(
                    [marker.wrapping_add(4); 32],
                ),
            }),
        );
        let context = TransitionContext {
            config: &engine_config,
            clock: &SystemClock,
            full_state_authority: None,
            retention_references: &[],
        };
        let marker_key = [marker; 4];
        let mut full_state_batch = DiskWriteBatch::new();
        runtime
            .store
            .put_raw(
                &mut full_state_batch,
                ZAKURA_HEADER_BODY_SIZE_BY_HEIGHT,
                marker_key,
                [marker],
            )
            .expect("the paired selected-repair marker can be staged");
        let memory_swapped = Arc::new(AtomicBool::new(false));
        let swap_probe = memory_swapped.clone();
        let result = runtime.apply_combined_with_fault(
            TransitionRequest {
                expected_version: before.state_version,
                event: TransitionEvent::InsertHeaders(Box::new(InsertHeaders {
                    owner: repair_owner.into(),
                    source,
                    parent_hash: anchor.hash,
                    target_tip_hash: child.hash,
                    completion: TargetCompletion::SelectedAuxiliaryRepair {
                        common_ancestor: anchor_frontier,
                        selected_target: child,
                        episode: repair_episode,
                    },
                    batch: repair_batch,
                    aux: vec![delivery],
                })),
            },
            &context,
            full_state_batch,
            move || swap_probe.store(true, Ordering::SeqCst),
            |point| {
                if point == target {
                    Err(HeaderChainStoreError::InjectedCrash(point))
                } else {
                    Ok(())
                }
            },
        );
        assert!(matches!(
            result,
            Err(HeaderChainStoreError::InjectedCrash(point)) if point == target
        ));

        let observation = observe_transition_crash(
            target,
            runtime,
            db,
            &db_config,
            &network,
            &engine_config,
            &before,
            &memory_swapped,
            Some(marker_key),
        );
        let committed = target.commit_completed();
        let committed_version = before
            .state_version
            .checked_next()
            .expect("the short fixture state version can advance");
        let durable = &observation.durable;
        assert_eq!(
            durable.state_version,
            if committed {
                committed_version
            } else {
                before.state_version
            },
            "{target:?}"
        );
        assert_eq!(durable.frontiers, before.frontiers, "{target:?}");
        assert_eq!(
            durable.header_generation, before.header_generation,
            "{target:?}"
        );
        assert_eq!(
            durable.verified_generation, before.verified_generation,
            "{target:?}"
        );
        let child_node = observation
            .reopened
            .store
            .header_node(child.hash)
            .expect("the selected repair node read succeeds")
            .expect("the selected repair target remains retained");
        assert_eq!(
            child_node.aux_delivery_ids,
            if committed {
                vec![delivery.delivery_id]
            } else {
                Vec::new()
            },
            "{target:?}"
        );
        let stored_deliveries = observation
            .reopened
            .store
            .aux_deliveries(child.hash)
            .expect("the selected repair auxiliary index is readable");
        assert_eq!(
            stored_deliveries,
            if committed {
                vec![delivery]
            } else {
                Vec::new()
            },
            "{target:?}"
        );
        assert_eq!(
            observation.startup.current.state_version,
            if committed {
                committed_version
            } else {
                before.state_version
            },
            "{target:?}"
        );
        assert_eq!(
            observation.startup.current.frontiers, before.frontiers,
            "{target:?}"
        );
        let reopened_child = observation
            .reopened
            .store
            .header_node(child.hash)
            .expect("the reopened selected repair node read succeeds")
            .expect("the reopened selected repair target remains retained");
        assert_eq!(
            reopened_child.aux_delivery_ids,
            if committed {
                vec![delivery.delivery_id]
            } else {
                Vec::new()
            },
            "{target:?}"
        );
        assert_eq!(
            observation
                .reopened
                .store
                .aux_deliveries(child.hash)
                .expect("the reopened selected repair auxiliary index is readable"),
            if committed {
                vec![delivery]
            } else {
                Vec::new()
            },
            "{target:?}"
        );
    }
}

pub(super) fn crash_fixture_aux_authentication_reopens_complete_before_or_after() {
    const AUX_FAULT_POINTS: [FaultPoint; 4] = FaultPoint::ALL;

    for (index, target) in AUX_FAULT_POINTS.into_iter().enumerate() {
        let cache = tempfile::tempdir().expect("the test cache directory is created");
        let db_config = Config {
            cache_dir: cache.path().to_owned(),
            ephemeral: false,
            debug_skip_non_finalized_state_backup_task: true,
            ..Config::default()
        };
        let (engine_config, anchor, metadata) = fixture();
        let network = engine_config.network().clone();
        let db = open(&db_config, &network);
        let store = HeaderChainStore::new(db.clone());
        store
            .initialize(metadata, anchor.clone())
            .expect("the empty schema initializes");
        let (runtime, _) = store
            .startup(&engine_config)
            .expect("the initial store audits");
        let initial = runtime.publisher().snapshot();
        let anchor_frontier = Frontier::new(anchor.height, anchor.hash);
        let lease = runtime
            .reader()
            .validation_context(anchor.hash)
            .expect("the anchor validation context is coherent")
            .expect("the initialized anchor is retained");
        let rules = HeaderRules::for_validation_lease(&lease)
            .expect("the authenticated regtest policy is valid");
        let marker = u8::try_from(index + 0xe0).expect("the fault-point list fits in u8");

        let mut current_header = *anchor.header;
        current_header.previous_block_hash = anchor.hash;
        current_header.time += chrono::Duration::seconds(1);
        current_header.nonce.0[0] = marker;
        let current_header = Arc::new(current_header);
        let mut boundary_header = *current_header;
        boundary_header.previous_block_hash = current_header.hash();
        boundary_header.time += chrono::Duration::seconds(1);
        boundary_header.nonce.0[0] = marker.wrapping_add(1);
        let boundary_header = Arc::new(boundary_header);
        let headers = [current_header.clone(), boundary_header.clone()];
        let batch = zakura_header_chain::prepare_headers(
            HeaderBatchInput::new(&headers),
            lease.parent(),
            &rules,
            &SystemClock,
        )
        .expect("the auxiliary fixture headers pass production validation");
        let current_height = anchor
            .height
            .next()
            .expect("the genesis anchor has a next height");
        let boundary_height = current_height
            .next()
            .expect("the first child has a next height");
        let current = Frontier::new(current_height, current_header.hash());
        let boundary = Frontier::new(boundary_height, boundary_header.hash());
        let insertion_owner = header_owner(&initial, boundary.hash, 21, 22);
        let source = SourceId::from_digest([marker.wrapping_add(2); 32]);
        let delivery = AuxDelivery::new(
            EvidenceId::from_digest([marker.wrapping_add(3); 32]),
            current.hash,
            source,
            insertion_owner,
            zakura_header_chain::BodySizeHint::Unknown,
            Some(zakura_header_chain::TreeAuxRecordV1 {
                height: current.height,
                sapling_root: Default::default(),
                orchard_root: Default::default(),
                ironwood_root: Default::default(),
                sapling_tx_count: 1,
                orchard_tx_count: 2,
                ironwood_tx_count: 3,
                auth_data_root: zakura_chain::block::merkle::AuthDataRoot::from(
                    [marker.wrapping_add(4); 32],
                ),
            }),
        );
        let insertion_context = TransitionContext {
            config: &engine_config,
            clock: &SystemClock,
            full_state_authority: None,
            retention_references: &[],
        };
        runtime
            .apply(
                TransitionRequest {
                    expected_version: initial.state_version,
                    event: TransitionEvent::InsertHeaders(Box::new(InsertHeaders {
                        owner: insertion_owner,
                        source,
                        parent_hash: anchor.hash,
                        target_tip_hash: boundary.hash,
                        completion: TargetCompletion::TargetComplete {
                            common_ancestor: anchor_frontier,
                        },
                        batch,
                        aux: vec![delivery],
                    })),
                },
                &insertion_context,
            )
            .expect("the unauthenticated delivery inserts with its exact headers");

        let before = runtime.publisher().snapshot();
        let observation = zakura_header_chain::AuxObservationV1::from_vct(
            body_owner(
                &before,
                insertion_owner.session_id(),
                insertion_owner.request_id().get(),
            ),
            vec![delivery],
            zakura_header_chain::AuxVerificationFactV1::current_delivery_verified(),
            Some([marker.wrapping_add(5); 32].into()),
        )
        .expect("the authentication observation is valid");
        let evidence = EvidenceId::from_digest(observation.observation_id().digest());
        let authority = Authority(evidence);
        let context = TransitionContext {
            config: &engine_config,
            clock: &SystemClock,
            full_state_authority: Some(&authority),
            retention_references: &[],
        };
        let request = TransitionRequest {
            expected_version: before.state_version,
            event: TransitionEvent::AuxEvidence(Box::new(
                zakura_header_chain::AuxEvidence::observed(observation),
            )),
        };
        let marker_key = [marker; 4];
        let mut full_state_batch = DiskWriteBatch::new();
        runtime
            .store
            .put_raw(
                &mut full_state_batch,
                ZAKURA_HEADER_BODY_SIZE_BY_HEIGHT,
                marker_key,
                [marker],
            )
            .expect("the paired auxiliary marker can be staged");
        let memory_swapped = Arc::new(AtomicBool::new(false));
        let swap_probe = memory_swapped.clone();
        let result = runtime.apply_combined_with_fault(
            request,
            &context,
            full_state_batch,
            move || swap_probe.store(true, Ordering::SeqCst),
            |point| {
                if point == target {
                    Err(HeaderChainStoreError::InjectedCrash(point))
                } else {
                    Ok(())
                }
            },
        );
        assert!(matches!(
            result,
            Err(HeaderChainStoreError::InjectedCrash(point)) if point == target
        ));

        let observation = observe_transition_crash(
            target,
            runtime,
            db,
            &db_config,
            &network,
            &engine_config,
            &before,
            &memory_swapped,
            Some(marker_key),
        );
        let committed = target.commit_completed();
        let committed_version = before
            .state_version
            .checked_next()
            .expect("the short fixture state version can advance");
        let durable = &observation.durable;
        assert_eq!(
            durable.state_version,
            if committed {
                committed_version
            } else {
                before.state_version
            },
            "{target:?}"
        );
        assert_eq!(durable.frontiers, before.frontiers, "{target:?}");
        assert_eq!(
            durable.header_generation, before.header_generation,
            "{target:?}"
        );
        assert_eq!(
            durable.verified_generation, before.verified_generation,
            "{target:?}"
        );
        let stored_delivery = observation
            .reopened
            .store
            .aux_deliveries(current.hash)
            .expect("the auxiliary row read succeeds");
        assert_eq!(stored_delivery.len(), 1, "{target:?}");
        assert!(stored_delivery[0].is_unauthenticated(), "{target:?}");
        let current_node = observation
            .reopened
            .store
            .header_node(current.hash)
            .expect("the auxiliary header node read succeeds")
            .expect("the auxiliary header remains retained");
        assert_eq!(
            current_node.aux_delivery_ids,
            vec![delivery.delivery_id],
            "{target:?}"
        );
        assert_eq!(
            observation.startup.current.state_version,
            if committed {
                committed_version
            } else {
                before.state_version
            },
            "{target:?}"
        );
        assert_eq!(
            observation.startup.current.frontiers, before.frontiers,
            "{target:?}"
        );
        let reopened_delivery = observation
            .reopened
            .store
            .aux_deliveries(current.hash)
            .expect("the reopened auxiliary row is readable");
        assert_eq!(reopened_delivery.len(), 1, "{target:?}");
        assert!(reopened_delivery[0].is_unauthenticated(), "{target:?}");
    }
}

pub(super) fn crash_fixture_two_delivery_aux_rejection_never_partially_commits() {
    const REJECTION_FAULT_POINTS: [FaultPoint; 4] = FaultPoint::ALL;

    for (index, target) in REJECTION_FAULT_POINTS.into_iter().enumerate() {
        let cache = tempfile::tempdir().expect("the test cache directory is created");
        let db_config = Config {
            cache_dir: cache.path().to_owned(),
            ephemeral: false,
            debug_skip_non_finalized_state_backup_task: true,
            ..Config::default()
        };
        let (engine_config, mut anchor, metadata) = fixture();
        let network = engine_config.network().clone();
        let db = open(&db_config, &network);
        let store = HeaderChainStore::new(db.clone());
        store
            .initialize(metadata.clone(), anchor.clone())
            .expect("the empty schema initializes");
        let marker = u8::try_from(index + 0x80).expect("the rejection cases fit in u8");
        let delivery_owner =
            zakura_header_chain::BodyWorkAuthority::for_snapshot(&metadata.snapshot())
                .bind(61, NonZeroU64::new(62).expect("sixty-two is nonzero"));
        let first = AuxDelivery::new(
            EvidenceId::from_digest([marker.wrapping_add(1); 32]),
            anchor.hash,
            SourceId::from_digest([marker.wrapping_add(2); 32]),
            delivery_owner.into(),
            zakura_header_chain::BodySizeHint::Unknown,
            None,
        );
        let second = AuxDelivery::new(
            EvidenceId::from_digest([marker.wrapping_add(3); 32]),
            first.header_hash,
            SourceId::from_digest([marker.wrapping_add(4); 32]),
            first.owner,
            first.body_size,
            first.tree_aux,
        );
        anchor
            .aux_delivery_ids
            .extend([first.delivery_id, second.delivery_id]);
        let mut seed = DiskWriteBatch::new();
        store
            .put_value(
                &mut seed,
                HEADER_NODE_BY_HASH,
                anchor.hash.0,
                &HeaderNodeDisk::from_domain(&anchor),
            )
            .expect("the two-delivery anchor node encodes");
        for delivery in [first, second] {
            store
                .put_value(
                    &mut seed,
                    HEADER_AUX_DELIVERY,
                    HeaderAuxDeliveryKey {
                        header: delivery.header_hash,
                        delivery: delivery.delivery_id,
                    }
                    .as_bytes(),
                    &delivery,
                )
                .expect("the unauthenticated auxiliary delivery encodes");
        }
        db.write(seed)
            .expect("the coherent two-delivery fixture commits");
        let (runtime, _) = store
            .startup(&engine_config)
            .expect("the two-delivery fixture audits");
        let before = runtime.publisher().snapshot();
        let observation = zakura_header_chain::AuxObservationV1::from_vct(
            zakura_header_chain::BodyWorkAuthority::for_snapshot(&before)
                .bind(delivery_owner.session_id, delivery_owner.request_id),
            vec![first],
            zakura_header_chain::AuxVerificationFactV1::successor_delivery_failed(1),
            Some([marker.wrapping_add(5); 32].into()),
        )
        .expect("the rejection observation is valid");
        let evidence = EvidenceId::from_digest(observation.observation_id().digest());
        let authority = Authority(evidence);
        let context = TransitionContext {
            config: &engine_config,
            clock: &SystemClock,
            full_state_authority: Some(&authority),
            retention_references: &[],
        };
        let marker_key = [marker; 4];
        let mut full_state_batch = DiskWriteBatch::new();
        runtime
            .store
            .put_raw(
                &mut full_state_batch,
                ZAKURA_HEADER_BODY_SIZE_BY_HEIGHT,
                marker_key,
                [marker],
            )
            .expect("the paired rejection marker can be staged");
        let memory_swapped = Arc::new(AtomicBool::new(false));
        let swap_probe = memory_swapped.clone();
        let result = runtime.apply_combined_with_fault(
            TransitionRequest {
                expected_version: before.state_version,
                event: TransitionEvent::AuxEvidence(Box::new(
                    zakura_header_chain::AuxEvidence::observed(observation),
                )),
            },
            &context,
            full_state_batch,
            move || swap_probe.store(true, Ordering::SeqCst),
            |point| {
                if point == target {
                    Err(HeaderChainStoreError::InjectedCrash(point))
                } else {
                    Ok(())
                }
            },
        );
        assert!(matches!(
            result,
            Err(HeaderChainStoreError::InjectedCrash(point)) if point == target
        ));

        let observation = observe_transition_crash(
            target,
            runtime,
            db,
            &db_config,
            &network,
            &engine_config,
            &before,
            &memory_swapped,
            Some(marker_key),
        );
        let committed = target.commit_completed();
        let committed_version = before
            .state_version
            .checked_next()
            .expect("the short fixture state version can advance");
        let durable = &observation.durable;
        assert_eq!(
            durable.state_version,
            if committed {
                committed_version
            } else {
                before.state_version
            },
            "{target:?}"
        );
        assert_eq!(durable.frontiers, before.frontiers, "{target:?}");
        let stored = observation
            .reopened
            .store
            .aux_deliveries(anchor.hash)
            .expect("the rejected delivery rows are readable");
        assert_eq!(stored.len(), 2);
        assert!(stored[0].is_unauthenticated());
        assert!(stored[1].is_unauthenticated());
        assert_eq!(
            observation
                .reopened
                .store
                .header_node(anchor.hash)
                .expect("the rejection anchor node read succeeds")
                .expect("the rejection anchor remains retained")
                .aux_delivery_ids,
            vec![first.delivery_id, second.delivery_id]
        );
        assert_eq!(
            observation.startup.current.state_version,
            if committed {
                committed_version
            } else {
                before.state_version
            },
            "{target:?}"
        );
        let reopened_deliveries = observation
            .reopened
            .store
            .aux_deliveries(anchor.hash)
            .expect("the reopened rejected delivery rows are readable");
        assert_eq!(reopened_deliveries.len(), 2);
        assert!(reopened_deliveries[0].is_unauthenticated());
        assert!(reopened_deliveries[1].is_unauthenticated());
    }
}