How humanode-network/substrate works
This repository is the new consolidated Polkadot SDK – the result of merging the Substrate, Polkadot, and Cumulus repositories. Its purpose is to provide a unified, modular framework for developing Polkadot-based blockchains. The codebase is vast and highly segmented into logical modules such as client components, runtime modules (or “frame” pallets), primitives, networking, consensus mechanisms, database and state management, execution environments (including WASM runtimes), and assorted utilities and scripts for testing, CI, and debugging.
Main Components
• Node Client/Core Application – This includes the main runtime, executor, and client logic that orchestrate block building, validation, and chain state management. In the file tree, look at directories like “bin/node”, “client”, “primitives”, “runtime”, and “executor.”
• Runtime Module Layer (“Frame”):
– Contains the pallets that implement various blockchain features (e.g., balances, democracy, staking, consensus-related pallets, etc.). The “frame” directory and subdirectories (such as frame/contracts, frame/balances, frame/democracy, etc.) represent these components.
• Consensus and Networking:
– Structures in “client/consensus” (for Aura, Babe, Grandpa, etc.) and “client/network” represent the node-to-node communication protocols, block propagation, and consensus algorithms. These components interact closely with the client.
• RPC/API Layer and External Interfaces:
– The “client/rpc”, “client/rpc-api”, “client/rpc-servers” and similar directories expose REST/WebSocket endpoints, enabling communication with external services and front-end applications.
• Storage and Database:
– Modules under “client/db”, “client/state-db”, and “primitives/database” handle state persistence, key–value storage, and caching.
• Testing & Utilities:
– Directories such as “test-utils”, “scripts”, “utils”, “docker”, and “zombienet” support testing (including integration tests and performance benchmarks), build processes, and deployment automation.
Relationships and Interactions
• The Node Client is the central component. It invokes the WASM runtime (built from frame pallets) via the executor and interacts with the underlying state database.
• Consensus and Networking modules interact with the client to receive transactions/blocks, validate them, and propagate state:
– For instance, consensus engines such as Babe, Aura, or Grandpa are tightly integrated with the block builder and are depicted as separate but collaborating modules.
• The RPC/API layer sits on top, receiving requests from external applications and routing them to the client and runtime layers.
• Low-level primitives and storage libraries support all the above, providing cryptography, hashing, off-chain features, and other utilities.
• Testing frameworks (e.g., zombienet and test-utils) simulate a live network environment, helping validate consensus, networking, and runtime upgrades.
Architectural Patterns and Design Principles
• Modularity: The design emphasizes separation of concerns – runtime (“frame”) components are isolated from consensus and network modules, which are themselves separated from client and database components.
• Layering: The system is naturally layered from low-level primitives and storage up to high-level APIs. Each layer has clearly defined interactions with adjacent layers.
• Extensibility: There are several “pallet” modules (runtime modules) that can be independently developed, tested, or replaced. The project also supports multiple consensus algorithms allowing different network configurations.
• Build-time Tooling: Scripts and docker configurations help with continuous integration, multi-node simulations (using zombienet), and benchmarking.