hotstuff_rs::block_tree::invariants

Function pc_to_lock

source
pub(crate) fn pc_to_lock<K: KVStore>(
    justify: &PhaseCertificate,
    block_tree: &BlockTreeSingleton<K>,
) -> Result<Option<PhaseCertificate>, BlockTreeError>
Expand description

Get the PC (if any) that should be set as the Locked PC after the replica sees the given justify.

§Precondition

The block or nudge containing this justify must satisfy safe_block or safe_nudge respectively.

§pc_to_lock logic

pc_to_lock’s return value depends on justify’s phase and whether or not it is the Genesis PC. What pc_to_lock returns in every case is summarized in the below table:

justify is the/aPC to lock if not already the current locked PC
Genesis PCNone
Generic PCjustify.block.justify
Prepare PCNone
Precommit PCjustify
Commit PCjustify
Decide PCjustify

§Rationale

The rationale behind pc_to_lock’s logic is explained in the “Locking” module-level docs.