Skip to content

Commit 2970dd3

Browse files
authored
Check the block height before the epoch in process_timeout (#4811)
## Motivation When processing a timeout, we check whether the epoch of the certificate is correct before checking whether the height is correct - this may lead to spurious `InvalidEpoch` errors. ## Proposal Validate the height first. ## Test Plan CI ## Release Plan - These changes should be backported to the latest `testnet` branch, then - be released in a new SDK, - be released in a validator hotfix. ## Links <!-- Optional section for related PRs, related issues, and other references. If needed, please create issues to track future improvements and link them here. --> - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent ee94a3a commit 2970dd3

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

linera-core/src/chain_worker/state.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -565,14 +565,6 @@ where
565565
// Verify the certificate. Returns a catch-all error to make client code more robust.
566566
self.initialize_and_save_if_needed().await?;
567567
let (chain_epoch, committee) = self.chain.current_committee()?;
568-
ensure!(
569-
certificate.inner().epoch() == chain_epoch,
570-
WorkerError::InvalidEpoch {
571-
chain_id: certificate.inner().chain_id(),
572-
chain_epoch,
573-
epoch: certificate.inner().epoch()
574-
}
575-
);
576568
certificate.check(committee)?;
577569
if self
578570
.chain
@@ -582,6 +574,14 @@ where
582574
{
583575
return Ok((self.chain_info_response(), NetworkActions::default()));
584576
}
577+
ensure!(
578+
certificate.inner().epoch() == chain_epoch,
579+
WorkerError::InvalidEpoch {
580+
chain_id: certificate.inner().chain_id(),
581+
chain_epoch,
582+
epoch: certificate.inner().epoch()
583+
}
584+
);
585585
let old_round = self.chain.manager.current_round();
586586
self.chain
587587
.manager

0 commit comments

Comments
 (0)