File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1374,8 +1374,7 @@ where
13741374
13751375 /// Return `true` if `block_root` is equal to the finalized root, or a known descendant of it.
13761376 pub fn is_descendant_of_finalized ( & self , block_root : Hash256 ) -> bool {
1377- self . proto_array
1378- . is_descendant ( self . fc_store . finalized_checkpoint ( ) . root , block_root)
1377+ self . proto_array . is_finalized_descendant :: < E > ( block_root)
13791378 }
13801379
13811380 /// Returns `Ok(true)` if `block_root` has been imported optimistically or deemed invalid.
Original file line number Diff line number Diff line change @@ -482,6 +482,7 @@ impl ProtoArray {
482482 let latest_valid_ancestor_is_descendant =
483483 latest_valid_ancestor_root. map_or ( false , |ancestor_root| {
484484 self . is_descendant ( ancestor_root, head_block_root)
485+ // TODO(paul): should this be updated to the new method?
485486 && self . is_descendant ( self . finalized_checkpoint . root , ancestor_root)
486487 } ) ;
487488
Original file line number Diff line number Diff line change @@ -748,6 +748,12 @@ impl ProtoArrayForkChoice {
748748 . is_descendant ( ancestor_root, descendant_root)
749749 }
750750
751+ /// See `ProtoArray` documentation.
752+ pub fn is_finalized_descendant < E : EthSpec > ( & self , descendant_root : Hash256 ) -> bool {
753+ self . proto_array
754+ . is_finalized_descendant :: < E > ( descendant_root)
755+ }
756+
751757 pub fn latest_message ( & self , validator_index : usize ) -> Option < ( Hash256 , Epoch ) > {
752758 if validator_index < self . votes . 0 . len ( ) {
753759 let vote = & self . votes . 0 [ validator_index] ;
@@ -993,6 +999,11 @@ mod test_compute_deltas {
993999 assert ! ( !fc. is_descendant( finalized_root, not_finalized_desc) ) ;
9941000 assert ! ( !fc. is_descendant( finalized_root, unknown) ) ;
9951001
1002+ assert ! ( fc. is_finalized_descendant:: <MainnetEthSpec >( finalized_root) ) ;
1003+ assert ! ( fc. is_finalized_descendant:: <MainnetEthSpec >( finalized_desc) ) ;
1004+ assert ! ( !fc. is_finalized_descendant:: <MainnetEthSpec >( not_finalized_desc) ) ;
1005+ assert ! ( !fc. is_finalized_descendant:: <MainnetEthSpec >( unknown) ) ;
1006+
9961007 assert ! ( !fc. is_descendant( finalized_desc, not_finalized_desc) ) ;
9971008 assert ! ( fc. is_descendant( finalized_desc, finalized_desc) ) ;
9981009 assert ! ( !fc. is_descendant( finalized_desc, finalized_root) ) ;
You can’t perform that action at this time.
0 commit comments