How cerebellum-network/blockchain-node works
Main components
• Blockchain Node Binary: The central executable built from Cargo (the Cargo.toml files at the root and in subprojects). This includes the core node under “node” (with subcomponents like cli, client, rpc, service) and is the entrypoint for running the blockchain.
• Runtime Layer: Located under the “runtime” directory (with “cere” and “cere-dev” folders) as well as “runtime/common”. This layer encapsulates the business logic, governance, consensus parameters, weights, and migration functions.
• Pallets: Found in the “pallets” folder with multiple pallets (e.g., chainbridge, ddc-clusters, ddc-customers, ddc-nodes, ddc-payouts, ddc-staking, ddc-verification, erc20, erc721, origins). Each pallet represents a modular component that extends the blockchain’s functionality.
• API and External Interfaces: The “ddc-api” directory includes API endpoints (and serialization logic via JSON and Protobuf definitions) that likely are used for external communication.
• Off-chain Tools & Supporting Modules: Tools like Zombienet (for testing ephemeral networks), various scripts (in the “scripts” directory), and Docker configurations (Dockerfile, docker-compose.yml) which help with deployment and testing.
• Developer and CI/CD Infrastructure: GitHub workflows, Docker deployment, and continuous integration files that ensure code quality and automated testing.
Analysing Relationships and Interactions
• The Node Component (esp. under “node/service”, “node/cli”, “node/rpc”) interacts with the Runtime Layer by initializing the chain state, loading runtime logic, and providing node services (e.g., RPC endpoints for querying, P2P networking for consensus).
• The Runtime Layer loads the configured pallets (from “pallets”) which collectively provide the blockchain’s modular logic—each pallet has its responsibilities (from metrics, staking, and verification, to ERC token standards) forming the core business logic.
• The API Layer (“ddc-api”) acts as an interface for external services to interact with the node, handling JSON or Protobuf requests, likely communicating with internal client and runtime modules.
• Testing, development, and orchestration tools (Zombienet, docker-compose, shell scripts) ensure that nodes, networks, and deployments are correctly configured for various environments (development chain, testnet, mainnet, etc.).
• Supporting infrastructure such as configuration files (.envrc, .cargo, Dockerfiles, and GitHub workflows) provide environment configuration, dependency management, and deployment instructions.
Architectural Patterns and Design Principles
• A layered architecture is evident: the lower layers (networking, consensus, storage) are abstracted away from the business logic in runtimes and pallets.
• Modular design using pallets supports extensibility; each pallet is self-contained with its own tests, migrations, and benchmarks.
• Separation of concerns is maintained by isolating command-line interfaces (CLI), client services, and APIs in the “node” and “ddc-api” directories.
• Containers and CI/CD pipelines are integrated via Docker, GitHub workflows, and shell scripts, ensuring consistent build and deployment practices.
Relevant Technologies, Frameworks, and Libraries
• Rust and Cargo are core to building the project.
• Substrate framework: The use of pallets, runtimes, and node service structure hints at Substrate’s design patterns.
• Docker and GitHub Actions: For containerization, continuous integration, and deployment.
• Zombienet: For testing network scenarios and ephemeral blockchain networks.
• Tools like dprint, rustfmt, and local script-based tooling support code formatting and pre-commit checks.
Elements
– Node (with subcomponents: CLI, Client, RPC, Service)
– Runtime (with sublayers: governance, weights, chain specs, off-chain workers possibly)
– API Layer (ddc-api) connected to the Node and external clients
– External Integration/Testing Tools (Zombienet, Docker, scripts)
– Data flow (e.g., user/CLI commands to the node, RPC calls to runtime and back)
– Dependencies (node initializes and loads runtime which, in turn, integrates pallets)
– Rectangles for execution modules (node, API)
– Rounded rectangles for logical layers (runtime, pallets)