Skip to content

Commit ad6b113

Browse files
authored
Merge branch 'ab/leaf2-migration' into ab/epoch-integration-test
2 parents f91bfdd + 5324304 commit ad6b113

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

hotshot-task-impls/src/helpers.rs

+17-7
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,14 @@ pub async fn validate_proposal_safety_and_liveness<
591591
proposed_leaf.parent_commitment() == parent_leaf.commit(),
592592
"Proposed leaf does not extend the parent leaf."
593593
);
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+
);
596602

597603
let state = Arc::new(
598604
<TYPES::ValidatedState as ValidatedState<TYPES>>::from_header(proposal.data.block_header()),
@@ -614,9 +620,7 @@ pub async fn validate_proposal_safety_and_liveness<
614620
UpgradeCertificate::validate(
615621
proposal.data.upgrade_certificate(),
616622
&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,
620624
&validation_info.upgrade_lock,
621625
)
622626
.await?;
@@ -639,8 +643,14 @@ pub async fn validate_proposal_safety_and_liveness<
639643
// The proposal is safe if
640644
// 1. the proposed block and the justify QC block belong to the same epoch or
641645
// 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+
);
644654
ensure!(
645655
proposal_epoch == justify_qc_epoch
646656
|| consensus_reader.check_eqc(&proposed_leaf, &parent_leaf),

0 commit comments

Comments
 (0)