How autonomys/subspace works
Main subsystems
• Node/Client: Represented by the “subspace-node” crate (in crates/subspace-node) along with runtime components (subspace-runtime, subspace-runtime-primitives, etc.). This is the primary blockchain node that ties together chain specs, transaction execution, and consensus mechanisms.
• Farmer: Found in “subspace-farmer” (crates/subspace-farmer). This CLI application interacts with the node and implements the farming logic (proof-of-space aspects, plotting, etc.).
• Gateway: The “subspace-gateway” (crates/subspace-gateway) is a client for distributed storage network connectivity and serves as an interface for external RPC/HTTP communication.
• Domain Components: The “domains” directory contains execution and client code for decoupled execution (“domain-operator”, “block-preprocessor”, etc.), as well as pallets (located under domains/pallets) and runtime parts that extend the Substrate framework with domain-specific logic.
• Networking & Consensus Modules: The crates related to “subspace-networking”, “sc-consensus-subspace”, “sp-consensus-subspace”, and related libraries are responsible for peer-to-peer communication, slot-based consensus, and block relay.
• Archiving & Storage: There are specialized crates like “subspace-archiving” that handle piece reconstruction and storage, and “subspace-proof-of-space” and “subspace-proof-of-time” for consensus proofs.
• Shared Libraries: The “shared” folder holds common components (e.g., subspace-core-primitives, subspace-metrics, subspace-kzg, logging, etc.) used by the other parts.
Relationships and interactions
• The Node/Client is the central hub that houses the runtime logic, chain specifications, and handles blockchain state. It communicates with the Farmer (for block production and farming rewards) via RPC and direct network interactions.
• The Domain components (both runtime and client) plug in as separate execution environments or “sandboxes” that run on top of the core node. Link them to the Node with annotations to highlight the decoupled execution and custom pallet logic.
Architectural patterns and design principles
• The project leverages Substrate’s modular framework, evident in the separation between pallets (on-chain logic) and off-chain components (like the farmer and gateway).
• There is a clear separation of concerns with dedicated crates for consensus, networking, archiving, domains, etc.