@@ -591,8 +591,14 @@ pub async fn validate_proposal_safety_and_liveness<
591
591
proposed_leaf. parent_commitment( ) == parent_leaf. commit( ) ,
592
592
"Proposed leaf does not extend the parent leaf."
593
593
) ;
594
- let proposal_epoch =
595
- epoch_from_block_number ( proposed_leaf. height ( ) , validation_info. epoch_height ) ;
594
+ let proposal_epoch = option_epoch_from_block_number :: < TYPES > (
595
+ validation_info
596
+ . upgrade_lock
597
+ . epochs_enabled ( proposed_leaf. view_number ( ) )
598
+ . await ,
599
+ proposed_leaf. height ( ) ,
600
+ validation_info. epoch_height ,
601
+ ) ;
596
602
597
603
let state = Arc :: new (
598
604
<TYPES :: ValidatedState as ValidatedState < TYPES > >:: from_header ( proposal. data . block_header ( ) ) ,
@@ -614,9 +620,7 @@ pub async fn validate_proposal_safety_and_liveness<
614
620
UpgradeCertificate :: validate (
615
621
proposal. data . upgrade_certificate ( ) ,
616
622
& validation_info. membership ,
617
- proposed_leaf
618
- . with_epoch
619
- . then ( || TYPES :: Epoch :: new ( proposal_epoch) ) , // #3967 how do we know if proposal_epoch should be Some() or None?
623
+ proposal_epoch,
620
624
& validation_info. upgrade_lock ,
621
625
)
622
626
. await ?;
@@ -639,8 +643,14 @@ pub async fn validate_proposal_safety_and_liveness<
639
643
// The proposal is safe if
640
644
// 1. the proposed block and the justify QC block belong to the same epoch or
641
645
// 2. the justify QC is the eQC for the previous block
642
- let justify_qc_epoch =
643
- epoch_from_block_number ( parent_leaf. height ( ) , validation_info. epoch_height ) ;
646
+ let justify_qc_epoch = option_epoch_from_block_number :: < TYPES > (
647
+ validation_info
648
+ . upgrade_lock
649
+ . epochs_enabled ( proposed_leaf. view_number ( ) )
650
+ . await ,
651
+ parent_leaf. height ( ) ,
652
+ validation_info. epoch_height ,
653
+ ) ;
644
654
ensure ! (
645
655
proposal_epoch == justify_qc_epoch
646
656
|| consensus_reader. check_eqc( & proposed_leaf, & parent_leaf) ,
0 commit comments