attestation_target_checkpoints.rs

Overview

This file defines structures and logic for managing attestation target checkpoints related to block finalization in a blockchain consensus context. It tracks the progress and validation status of ancestor blocks through a system of checkpoints that represent deadlines and required attestation counts for blocks to be considered finalized. The main entities encapsulate checkpoint data, their validation results, and mechanisms to inherit and update checkpoint states as new blocks are added.

Key Components

Structs and Enums

AttestationTargetCheckpoint

AttestationTargetCheckpointCheckResult (enum)

AncestorBlocksFinalizationCheckpoints

InheritedAncestorBlocksFinalizationCheckpoints

AncestorBlocksFinalizationCheckpointsConstructor

AncestorBlocksFinalizationCheckpointsConstructorResults

Functions

inherit_checkpoint(mut checkpoint: AttestationTargetCheckpoint) -> AttestationTargetCheckpoint

inherit_ancestor_blocks_finalization_distances

fn inherit_ancestor_blocks_finalization_distances(
    parent_block_state: &BlockState,
    block_state: &BlockState,
) -> anyhow::Result<InheritedAncestorBlocksFinalizationCheckpoints>

Implementation Details and Algorithms

Interactions with Other System Components

Visual Diagram

classDiagram
class AttestationTargetCheckpoint {
+current_distance: usize
+deadline: usize
+required_attestation_count: usize
+attestation_target_type: AttestationTargetType
+check()
}
class AncestorBlocksFinalizationCheckpoints {
+primary: HashMap<BlockIdentifier, AttestationTargetCheckpoint>
+fallback: HashMap<BlockIdentifier, Vec<AttestationTargetCheckpoint>>
}
class InheritedAncestorBlocksFinalizationCheckpoints {
-ancestor_checkpoints: AncestorBlocksFinalizationCheckpoints
+into_builder()
}
class AncestorBlocksFinalizationCheckpointsConstructor {
-inherited_checkpoints: AncestorBlocksFinalizationCheckpoints
-passed_primary: Vec<BlockIdentifier>
-passed_fallback: Vec<BlockIdentifier>
-passed_fallback_preattestation_checkpoint: Vec<BlockIdentifier>
+update()
+note()
+complete()
}
class AncestorBlocksFinalizationCheckpointsConstructorResults {
+remaining_checkpoints: AncestorBlocksFinalizationCheckpoints
+passed_primary: Vec<BlockIdentifier>
+passed_fallback: Vec<BlockIdentifier>
+passed_fallback_preattestation_checkpoint: Vec<BlockIdentifier>
+transitioned_to_fallback: Vec<BlockIdentifier>
+failed: Vec<BlockIdentifier>
}
AttestationTargetCheckpoint --|> AttestationTargetCheckpointCheckResult
InheritedAncestorBlocksFinalizationCheckpoints --> AncestorBlocksFinalizationCheckpointsConstructor
AncestorBlocksFinalizationCheckpointsConstructor --> AncestorBlocksFinalizationCheckpointsConstructorResults
AncestorBlocksFinalizationCheckpointsConstructor *-- AncestorBlocksFinalizationCheckpoints
AncestorBlocksFinalizationCheckpointsConstructorResults *-- AncestorBlocksFinalizationCheckpoints

This diagram illustrates the core data structures and their relationships, highlighting the flow from inherited checkpoints through the constructor to update results.