hotstuff_rs::block_tree::invariants

Function block_to_commit

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

Get the Block in block_tree (if any) that, along with all of its uncommitted predecessors, should be committed after the replica sees justify.

§Preconditions

The Block or Nudge containing justify must satisfy safe_block or safe_nudge respectively.

§block_to_commit logic

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

justify.phase is aBlock to commit if it satisfies the consecutive views rule and is not already committed yet
Generic PCjustify.block.justify.block.justify.block
Prepare PCNone
Precommit PCNone
Commit PCjustify.block
Decide PCjustify.block

§Rationale

The rationale behind block_to_commit’s logic is explained in the “Committing” section of safety’s module-level docs.