associated_types.rs

Overview

The associated_types.rs file defines key data types, enumerations, traits, and implementations related to node operation within the system, particularly focusing on node identifiers, block acknowledgments (Ack), negative acknowledgments (Nack), attestations, and synchronization results. It establishes the types associated with node messaging envelopes and processing outcomes, supporting cryptographic signing and deserialization/serialization for network communication. This file is central to managing node identities, block validation responses, and synchronization workflows in the distributed environment.


Detailed Descriptions

Type Aliases


Structs and Enums

NodeIdentifier

Represents a unique identifier for a node. It wraps around the AccountAddress type and provides serialization, deserialization, string parsing, and display formatting.

Usage example:

let node_id: NodeIdentifier = "81a6bea128f5...".parse().unwrap();
println!("{}", node_id);

NackReason

An enum representing reasons for negative acknowledgment (Nack) of blocks.

Implementation details: Uses cryptographic hash calculations and state repository lookups to associate Nack reasons with node metadata.


Trait NodeAssociatedTypes

Defines associated envelope types for a node, representing different types of signed messages.


Enum SynchronizationResult<TNetworkMessage>

Describes outcomes of node synchronization processes.


Enum ExecutionResult

Represents results of block execution attempts.


Enum BlockStatus

Indicates the processing status of a block.


Struct AckData

Data carried in an acknowledgment message.


Struct NackData

Data carried in a negative acknowledgment message.


Enum AttestationTargetType

Defines the type of attestation target.


Struct AttestationData

Represents data for block attestation messages.


Struct SyncFinalizedData

Data structure representing finalized synchronization information.


Implementation Details and Algorithms


Interactions with Other System Components


Visual Diagram

classDiagram
class NodeIdentifier {
+AccountAddress value
+some_id()
+test(seed)
+from_str()
+to_string()
}
class NackReason {
<<enum>>
+BadBlock
+TooComplexExecution
+WrongNack
+get_hash_nack()
+get_node_data()
}
class NodeAssociatedTypes {
<<trait>>
+CandidateBlock
+Ack
+Nack
+BlockAttestation
}
class SynchronizationResult {
<<enum>>
+Ok
+Forward
+Interrupted
}
class ExecutionResult {
<<enum>>
+SynchronizationRequired
+Disconnected
}
class BlockStatus {
<<enum>>
+Ok
+Skipped
+BadBlock
+BlockCantBeApplied
+SynchronizationRequired
}
class AckData {
+BlockIdentifier block_id
+BlockSeqNo block_seq_no
}
class NackData {
+BlockIdentifier block_id
+BlockSeqNo block_seq_no
+NackReason reason
}
class AttestationTargetType {
<<enum>>
+Primary
+Fallback
}
class AttestationData {
+BlockIdentifier parent_block_id
+BlockIdentifier block_id
+BlockSeqNo block_seq_no
+AckiNackiEnvelopeHash envelope_hash
+AttestationTargetType target_type
}
class SyncFinalizedData {
+BlockIdentifier block_identifier
+BlockSeqNo block_seq_no
+BTreeMap thread_refs
}
NodeAssociatedTypes <|.. Node
NodeAssociatedTypes <|.. BlockRequestService
NackData --> NackReason
AttestationData --> AttestationTargetType
SyncFinalizedData --> BTreeMap
NackReason --> BlockStateRepository : uses
NodeIdentifier --> AccountAddress

This diagram illustrates the main data types, their relationships, and their role in representing node-related data and message envelopes within the system. The trait NodeAssociatedTypes connects node implementations to their associated envelope types, while enums and structs model processing results and block metadata.