How asonnino/hotstuff works
Project’s Main Components
a. Node: The entry point for the distributed system (found in the “node” directory). The main node executable orchestrates the overall protocol run.
b. Consensus: The core of the protocol is implemented here (see the “consensus” directory). Break it down further into:
• Aggregator, Leader, Proposer, Synchronizer, and Timer (as supported by the individual source files).
c. Mempool: Manages and batches incoming transactions (the “mempool” directory).
d. Crypto: Provides real cryptography functions (in “crypto”) using libraries like ed25519-dalek.
e. Network: Handles the communications between nodes (see “network”) and uses asynchronous frameworks (tokio).
f. Store: Provides persistent storage for consensus data (the “store” module), integrating with rocksdb.
g. Benchmark: Although not part of the operational protocol, this directory (with Python scripts and Fabric configurations) enables local testing, deployment, and result aggregation.
Detail the Relationships and Interactions
• The Node (main executable) acts as the central unit that ties together:
• The Consensus module for handling BFT protocol steps.
• The Mempool module for transaction management.
• The Network layer ensuring communication between distributed nodes.
• The Crypto module, which supports signing and verifying messages throughout the protocol.
• The Store module for persistent storage of consensus decisions and blocks.
• Within Consensus, submodules (like proposer, synchronizer, etc.) collaborate to achieve consensus. For example, the leader node, after collecting proposals, communicates through the network layer.
• The Benchmark scripts (Python, using Fabric) trigger and manage node deployment/testing, invoking the compiled Rust components, gathering logs, and collecting metrics such as TPS (transaction per second) and latency.
Architectural Patterns and Design Principles
• Modular and layered design: Each core functionality is encapsulated in its own Rust crate (consensus, mempool, crypto, network, store), promoting separation of concerns.
• Asynchronous communication: The use of Tokio in the network layer suggests an event-driven and asynchronous design for inter-node communications.
• Real-world integration of libraries: The usage of dalek for cryptography and rocksdb for storage shows an intent to closely mimic production-like setups, even though the purpose here is benchmarking and prototyping.
• Testing emphasis: Each crate has a “tests” subdirectory, which implies the project strongly focuses on modular testing of each component.