How informalsystems/tendermint-rs works
Main components
• Core Libraries: At the heart are the crates providing the core data structures and serialization – for example, the "tendermint" crate (which handles Tendermint’s blockchain data structures, block headers, signatures, etc.) and "tendermint-proto" (dealing with protobuf generated types and wire-level interaction).
• ABCI Layer: The "abci" crate forms a low-level framework for building ABCI applications (used by blockchain applications to interface with the Tendermint consensus engine).
• Light Client Functionality: Note the “light-client” crate for verifying signed headers and tracking validator set changes, the "light-client-detector" for detecting attacks, and related CLI/JS wrappers ("light-client-cli" and "light-client-js").
• RPC and P2P: The "tendermint-rpc" crate provides client functionality for Tendermint’s RPC and “p2p” offers peer connectivity (using the secret connection protocol).
• Configuration and Testing: There are supplementary crates such as "config", "test", and "testgen" supporting configuration and property-based testing.
• Tools and Docker: Also, tools for generating test data, building images, and even a proto-compiler exist under the “tools” directory.
• Documentation and Specifications: The "docs" directory (with ADRs, specifications, and TLA+ models) shows that the system is grounded in formal specifications, and there’s an emphasis on adhering to a rigorous design.
Relationships and interactions
• The RPC client ("tendermint-rpc") interacts with external Tendermint nodes (written in Go) and uses the “proto” crate for protobuf serialization.
• The light client components verify block headers and validator sets by consuming data structures from the core "tendermint" library and interacting with the RPC and P2P layers.
• The ABCI library is used to build blockchain applications that communicate with Tendermint for consensus.
• The “p2p” crate handles secure network communication (via secret connections), which might feed data to the light client or RPC components.
• Tools and testing utilities (found in "tools", "test", and "testgen") connect to these libraries to simulate, test, and validate consensus and blockchain behavior based on TLA+ specifications.
Architectural patterns and design principles
• Modular design through distinct crates: each library is responsible for a well-defined domain (e.g., core data structures, ABCI interfacing, light client verification, network communication).
• Protocol separation: There are clear interfaces between the RPC, P2P, and application layers. The use of a dedicated "proto" crate reinforces separation between protocol representation and business logic.
• Layering: For example, the light client uses core blockchain structures, interacts with the RPC layer for network data, and employs consensus verification that aligns with the TLA+ protocols.
• Testability: A robust suite of tests (unit tests, model-based tests in the "light-client" and "rpc" directories, etc.) is an integral part of the design.
• Extensibility: With multiple language interfaces (Rust libraries, a CLI, and even a JavaScript (or WASM) interface), the architecture is designed to be accessed from different runtimes and contexts.
Elements
– RPC <-> Tendermint Nodes (external system)
– P2P feeds into the light client for header verification
– The CLI and JS interfaces function as wrappers for light client capabilities
• Also depicting the role of configuration and testing tools, positioned in a secondary layer outside the runtime system.