state.rs

Overview

This file defines the core data structure and associated logic for tracking the state of blocks within the system's consensus and validation layer. The primary entity is the AckiNackiBlockState, which serves as a comprehensive, write-once ledger of signals and facts about a block's status as it progresses through various stages such as validation, attestation, finalization, and storage.

The AckiNackiBlockState encapsulates metadata about a block, its relationships to other blocks, attestation proofs, verification flags, and bookkeeping related to block keepers and attestations. This structure enables the system to apply deterministic rules about block acceptance and finalization, critical for maintaining consensus integrity.

Supporting types like AttestationTarget, AttestationTargets, and EventTimestamps provide abstractions for attestation thresholds and timing metrics relevant to block processing.


Detailed Descriptions

Constants


Structs

AttestationTarget

AttestationTargets


AckiNackiBlockState


EventTimestamps


Trait Implementations


Important Implementation Details and Algorithms


Interactions with Other Components


Usage Examples

use some_crate::state::AckiNackiBlockState;
use some_crate::types::{BlockIdentifier, Envelope, GoshBLS, AttestationData};

// Create a new block state for a block
let block_id = BlockIdentifier::new(...);
let mut block_state = AckiNackiBlockState::new(block_id);

// Add detached attestations
let attestation: Envelope<GoshBLS, AttestationData> = ...;
block_state.add_detached_attestations(attestation);

// Check if attestation targets have been met
if block_state.has_attestations_target_met() {
    // Proceed with finalization
}

// Mark block as finalized
block_state.set_finalized()?;

Visual Diagram

classDiagram
    class AckiNackiBlockState {
        +block_seq_no: Option<BlockSeqNo>
        +block_identifier: BlockIdentifier
        +thread_identifier: Option<ThreadIdentifier>
        +parent_block_identifier: Option<BlockIdentifier>
        +ancestors: Option<Vec<BlockIdentifier>>
        +block_round: Option<BlockRound>
        +block_height: Option<BlockHeight>
        +producer: Option<NodeIdentifier>
        +signatures_verified: Option<bool>
        +finalized: Option<bool>
        +invalidated: Option<bool>
        +verified_attestations: HashMap<(BlockIdentifier, AttestationTargetType), HashSet<SignerIndex>>
        +known_children: HashMap<ThreadIdentifier, HashSet<BlockIdentifier>>
        +bad_block_accusers: Vec<(HashMap<SignerIndex, u16>, Signature)>
        +notifications: Vec<Notification>
        +event_timestamps: EventTimestamps
        +add_detached_attestations()
        +can_be_finalized