Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version gate epoch safety check #2637

Merged
merged 2 commits into from
Feb 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions hotshot-task-impls/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,14 @@ pub async fn validate_proposal_safety_and_liveness<
proposed_leaf.parent_commitment() == parent_leaf.commit(),
"Proposed leaf does not extend the parent leaf."
);
let proposal_epoch =
epoch_from_block_number(proposed_leaf.height(), validation_info.epoch_height);
let proposal_epoch = option_epoch_from_block_number::<TYPES>(
validation_info
.upgrade_lock
.epochs_enabled(proposed_leaf.view_number())
.await,
proposed_leaf.height(),
validation_info.epoch_height,
);

let state = Arc::new(
<TYPES::ValidatedState as ValidatedState<TYPES>>::from_header(proposal.data.block_header()),
Expand All @@ -614,9 +620,7 @@ pub async fn validate_proposal_safety_and_liveness<
UpgradeCertificate::validate(
proposal.data.upgrade_certificate(),
&validation_info.membership,
proposed_leaf
.with_epoch
.then(|| TYPES::Epoch::new(proposal_epoch)), // #3967 how do we know if proposal_epoch should be Some() or None?
proposal_epoch,
&validation_info.upgrade_lock,
)
.await?;
Expand All @@ -639,8 +643,14 @@ pub async fn validate_proposal_safety_and_liveness<
// The proposal is safe if
// 1. the proposed block and the justify QC block belong to the same epoch or
// 2. the justify QC is the eQC for the previous block
let justify_qc_epoch =
epoch_from_block_number(parent_leaf.height(), validation_info.epoch_height);
let justify_qc_epoch = option_epoch_from_block_number::<TYPES>(
validation_info
.upgrade_lock
.epochs_enabled(proposed_leaf.view_number())
.await,
parent_leaf.height(),
validation_info.epoch_height,
);
ensure!(
proposal_epoch == justify_qc_epoch
|| consensus_reader.check_eqc(&proposed_leaf, &parent_leaf),
Expand Down
Loading