@@ -1015,6 +1015,36 @@ mod test_compute_deltas {
10151015 assert ! ( !fc. is_descendant( not_finalized_desc, unknown) ) ;
10161016 }
10171017
1018+ /// This test covers an interesting case where a block can be a descendant
1019+ /// of the finalized *block*, but not a descenant of the finalized
1020+ /// *checkpoint*.
1021+ ///
1022+ /// ## Example
1023+ ///
1024+ /// Consider this block tree which has three blocks (`A`, `B` and `C`):
1025+ ///
1026+ /// ```ignore
1027+ /// [A] <--- [-] <--- [B]
1028+ /// |
1029+ /// |--[C]
1030+ /// ```
1031+ ///
1032+ /// - `A` (slot 31) is the common descendant.
1033+ /// - `B` (slot 33) descends from `A`, but there is a single skip slot
1034+ /// between it and `A`.
1035+ /// - `C` (slot 32) descends from `A` and conflicts with `B`.
1036+ ///
1037+ /// Imagine that the `B` chain is finalized at epoch 1. This means that the
1038+ /// finalized checkpoint points to the skipped slot at 32. The root of the
1039+ /// finalized checkpoint is `A`.
1040+ ///
1041+ /// In this scenario, the block `C` has the finalized root (`A`) as an
1042+ /// ancestor whilst simultaneously conflicting with the finalized
1043+ /// checkpoint.
1044+ ///
1045+ /// This means that to ensure a block does not conflict with finality we
1046+ /// must check to ensure that it's an ancestor of the finalized
1047+ /// *checkpoint*, not just the finalized *block*.
10181048 #[ test]
10191049 fn finalized_descendant_edge_case ( ) {
10201050 let get_block_root = |i| Hash256 :: from_low_u64_be ( i) ;
@@ -1072,6 +1102,10 @@ mod test_compute_deltas {
10721102 . unwrap ( ) ;
10731103 } ;
10741104
1105+ /*
1106+ * Start of interesting part of tests.
1107+ */
1108+
10751109 // Produce the 0th epoch of blocks. They should all form a chain from
10761110 // the genesis block.
10771111 for i in 1 ..MainnetEthSpec :: slots_per_epoch ( ) {
0 commit comments