hotstuff_rs::block_tree::invariants

Function safe_pc

source
pub(crate) fn safe_pc<K: KVStore>(
    pc: &PhaseCertificate,
    block_tree: &BlockTreeSingleton<K>,
    chain_id: ChainID,
) -> Result<bool, BlockTreeError>
Expand description

Check whether pc can safely cause updates to block_tree, given the replica’s chain_id.

§Conditional checks

safe_pc returns true in case all of the following predicates are true:

  1. Either pc.chain_id equals chain_id, or pc is the Genesis PC.
  2. Either block_tree contains pc.block, or pc is the Genesis PC.
  3. Either pc.view is (strictly) greater than block_tree’s locked_pc.view, or pc.block extends from locked_pc.block.
  4. If pc.phase is Prepare, Precommit, Commit, or Decide, pc.block is a validator set updating block. Else, if pc.phase is Generic, pc.block is not a validator set updating block.

§Precondition

is_correct is true for block.justify.