Subspace Network Daemon (SND), a CLI built using Commander
Run with bin/subspace.js from the root of the repository or just using subspace when installed globally using npm install -g @subspace/subspace-core.
A simple GUI can be viewed from /app/web/index.html built with vanilla Vue and Bulma. This will run the browserified version of the protocol as a standalone network node with its own copy of the ledger from genesis -- primarily for testing purposes right now.
For the purposes of this document, a module refers to top level directory within the src folder that organizes some code. External npm modules are referred to as dependencies. We are taking a monorepo approach. Instead of using separate NPM modules and git repositories for each module we will simply use different folders within the same core project. Later, we may use Lerna to separate each folder into a discrete module, which may all be managed from the core project.
Currently there are ten modules. Main wraps Node, which is the base class for a network node. Wallet, Farm, Ledger, Network, and Storage are sub classes that provide specific functionality. Utils, Crypto and Codes are collections of logically grouped helper functions.
Entry point for the project through index.ts. Also defines the constants and shared Typescript interfaces for the project. Essentially a wrapper around the core functionality provide by the Node class that allows for one more layer of abstraction when defining initialization and environment parameters.
Manages plots for this node. A node may have many plots. A plot is a set of encoded pieces under a given node id (address). If the ledger is small, nodes must have many plots to fully utilize their free disk. Once the ledger is large (> 16 TB) we would expect most nodes to have a single plot. Multiple plots per node will make testing sybil attacks far easier as well. Farming is purely optional and not required to query the network or maintain a copy of the Ledger. Each plot is initialized with a different path, which may be on different drives.
Encodes pieces under a node id and persists them through a plot mode.
Current modes include pure in-memory (mem-db) and on-disk (rocks-db). Future modes include raw-disk and on-the-fly computation from unencoded pieces stored in memory (for security analysis).
Uses a Red Black tree that combines memory and disk storage for indexing a plot with fast lookups.
Retrieves encodings from a piece id and returns the encoding or original pieces (storage and codes modules)
A convenience wrapper around a set of standard cryptographic primitives. Goal is to convert all to Rust and expose via WASM for performance.
Implements basic hash functions from the Node JS crypto standard library.
Implements a secure pseudo random number generator via a Poisson process (pending)
Implements binary merkle tree library. Currently Typescript based, eventually port to WASM via Rust.
Implements a Jump Consistent Hash function to assign blocks to chains. Currently Typescript based, eventually port to WASM via Rust.
Implements Chia Network BLS Signature library via WASM port. Provides deterministic key generation that supports HD Wallets and a unique signature scheme with aggregation.
A convenience wrapper around a set of algorithms for encoding and decoding pieces of the ledger. Goal is to convert all to Rust and expose via WASM for performance.
Level Coding: Slices a level (set of proofs and unique contents across many new blocks) into a set of 4096 byte content-addressed pieces, padding the last piece.
Erasure Codes: Create a set of parity pieces that may be used to recover a level given a constant subset of pieces. Currently uses Backblaze Reed-Solomon implementation ported to Node JS. Attempting to user a more efficient port to Rust. Need to benchmark and compare some other, possibly faster libraries written in C++
Piece Coding: A simple Pseudo Random Permutation (PRP) CBC XOR cipher that uses the node id as the initialization vector. Encoding is inherently sequential with a variable number of rounds. Decoding is inherently parallelizable.
Hourglass Function: A second PRP that applies a slow, time-delay encoding to the encoded piece that is efficiently reversible. Candidate function include memory hard encoding, verifiable delay encoding, random permutations, and Poehling-Hellman ciphers.