A production-grade decentralized module registry built on Substrate with IPFS integration for secure, distributed metadata storage.
- Multi-chain Module Registry: Manage modules across different blockchain networks
- IPFS-Powered Storage: Decentralized metadata storage using IPFS
- Type-safe Python Client: Easy integration with existing Python projects
- Production-Ready: Comprehensive CI/CD, testing, and documentation
- Modular Architecture: Extensible design for custom implementations
graph TD
A[Module Registry Pallet] -->|Stores| B[(IPFS CIDs)]
C[Python Client] -->|Interacts with| A
C -->|Manages| B
D[Frontend] -->|Uses| C
E[External Services] -->|Integrates with| A
-
Module Registry Pallet
- On-chain storage for module metadata references
- Multi-chain public key support
- Efficient storage using IPFS CIDs
-
IPFS Integration
- Distributed metadata storage
- Content-addressable architecture
- Off-chain data availability
-
Python Client
- Type-safe API client
- Asynchronous operations
- Comprehensive error handling
- Rust (latest stable, install via rustup)
- Python 3.10+
- IPFS daemon (installation guide)
- Substrate dependencies:
curl https://getsubstrate.io -sSf | bash -s -- --fast
-
Clone the repository
git clone --recursive https://github.com/Bakobiibizo/mod-net-modules.git cd mod-net-modules/modules
-
Build the node
cargo build --release
-
Set up Python environment
# Using standard venv python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate # Install development dependencies pip install -r requirements-dev.txt # Alternative: Using uv (faster) # pip install uv # uv venv # source .venv/bin/activate # uv pip install -r requirements-dev.txt
-
Start IPFS daemon
ipfs daemon
-
Run the node
./target/release/node-template --dev
- Architecture - High-level system design
- API Reference - Detailed API documentation
- Development Guide - Setting up a development environment
- Deployment Guide - Production deployment instructions
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT-0 License - see the LICENSE file for details.
Project Link: https://github.com/Bakobiibizo/mod-net-modules
- Built on Substrate
- Uses IPFS for distributed storage
- Inspired by the Substrate Node Template
- Rust and Substrate dependencies (installation guide)
- Python 3.10 or higher
- UV package manager (
pip install uv
) - IPFS daemon (installation guide)
-
Clone and Build
git clone --recursive https://github.com/your-org/mod-net.git cd mod-net/modules cargo build --release
-
Python Environment Setup
uv venv source .venv/bin/activate uv pip install -r requirements.txt
-
IPFS Setup
# Start IPFS daemon ipfs daemon # Default endpoints: # - API: http://localhost:5001 # - Gateway: http://localhost:8080
Fetch solochain template code:
git clone https://github.com/paritytech/polkadot-sdk-solochain-template.git solochain-template
cd solochain-template
- No TODOs, placeholders, or mock implementations
- All code must be production-ready with thorough testing
- Type hints and documentation required for all code
- Strict adherence to code formatting and linting rules
-
Branch Naming
- Features:
feature/descriptive-name
- Fixes:
fix/issue-description
- Documentation:
docs/topic-name
- Features:
-
Commit Messages Follow the Conventional Commits standard:
type(scope): description [optional body] [optional footer]
-
Rust Tests
# Run all Rust tests cargo test --all # Run specific pallet tests cargo test -p pallet-module-registry
-
Python Tests
# Run Python tests with coverage pytest tests/ --cov=mod_net_client
-
Integration Tests
# Ensure IPFS daemon is running ./scripts/run-integration-tests.sh
-
Rust
# Format code cargo fmt --all # Run clippy cargo clippy --all-targets --all-features
-
Python
# Format code black mod_net_client tests isort mod_net_client tests # Run linters ruff check mod_net_client tests mypy mod_net_client tests
After you build the project, you can use the following command to explore its parameters and subcommands:
./target/release/solochain-template-node -h
You can generate and view the Rust Docs for this template with this command:
cargo +nightly doc --open
The following command starts a single-node development chain that doesn't persist state:
./target/release/solochain-template-node --dev
To purge the development chain's state, run the following command:
./target/release/solochain-template-node purge-chain --dev
To start the development chain with detailed logging, run the following command:
RUST_BACKTRACE=1 ./target/release/solochain-template-node -ldebug --dev
Development chains:
- Maintain state in a
tmp
folder while the node is running. - Use the Alice and Bob accounts as default validator authorities.
- Use the Alice account as the default
sudo
account. - Are preconfigured with a genesis state (
/node/src/chain_spec.rs
) that includes several pre-funded development accounts.
To persist chain state between runs, specify a base path by running a command similar to the following:
// Create a folder to use as the db base path
$ mkdir my-chain-state
// Use of that folder to store the chain state
$ ./target/release/solochain-template-node --dev --base-path ./my-chain-state/
// Check the folder structure created inside the base path after running the chain
$ ls ./my-chain-state
chains
$ ls ./my-chain-state/chains/
dev
$ ls ./my-chain-state/chains/dev
db keystore network
After you start the node locally, you can interact with it using the hosted
version of the Polkadot/Substrate Portal
front-end by connecting to the local node endpoint. Note: WebSocket uses the
same RPC port as HTTP (defaults to 9933), there is no separate WS port. A hosted version is also
available on IPFS. You can
also find the source code and instructions for hosting your own instance in the
polkadot-js/apps
repository.
If you want to see the multi-node consensus algorithm in action, see Simulate a network.
The Mod-Net module registry consists of several key components:
The core Substrate pallet (pallet-module-registry
) provides:
- On-chain module registration and verification
- Module metadata management with IPFS integration
- Version control and dependency tracking
- Access control and permissions
The commune-ipfs
submodule provides:
- Distributed storage for module metadata
- FastAPI backend for IPFS interaction
- Redundant storage and content addressing
- Default endpoints:
- API: http://localhost:5001
- Gateway: http://localhost:8080
The mod_net_client
package provides:
- Type-safe interface to the module registry
- IPFS metadata management
- Substrate RPC interaction
- Comprehensive test suite
A blockchain node is an application that allows users to participate in a blockchain network. Substrate-based blockchain nodes expose a number of capabilities:
- Networking: Substrate nodes use the
libp2p
networking stack to allow the nodes in the network to communicate with one another. - Consensus: Blockchains must have a way to come to consensus on the state of the network. Substrate makes it possible to supply custom consensus engines and also ships with several consensus mechanisms that have been built on top of Web3 Foundation research.
- RPC Server: A remote procedure call (RPC) server is used to interact with Substrate nodes.
There are several files in the node
directory. Take special note of the
following:
chain_spec.rs
: A chain specification is a source code file that defines a Substrate chain's initial (genesis) state. Chain specifications are useful for development and testing, and critical when architecting the launch of a production chain. Take note of thedevelopment_config
andtestnet_genesis
functions. These functions are used to define the genesis state for the local development chain configuration. These functions identify some well-known accounts and use them to configure the blockchain's initial state.service.rs
: This file defines the node implementation. Take note of the libraries that this file imports and the names of the functions it invokes. In particular, there are references to consensus-related topics, such as the block finalization and forks and other consensus mechanisms such as Aura for block authoring and GRANDPA for finality.
The Mod-Net runtime extends the Substrate runtime with our custom module registry pallet. Key features include:
- Module registration and verification logic
- IPFS CID storage and validation
- Access control and permissions management
- Version control and dependency resolution The Substrate project in this repository uses FRAME to construct a blockchain runtime. FRAME allows runtime developers to declare domain-specific logic in modules called "pallets". At the heart of FRAME is a helpful macro language that makes it easy to create pallets and flexibly compose them to create blockchains that can address a variety of needs.
Review the FRAME runtime implementation included in this template and note the following:
- This file configures several pallets to include in the runtime. Each pallet
configuration is defined by a code block that begins with
impl $PALLET_NAME::Config for Runtime
. - The pallets are composed into a single runtime by way of the #[runtime] macro, which is part of the core FRAME pallet library.
Comprehensive GitHub Actions workflows ensure code quality:
-
Rust CI (
rust.yml
)- Cargo check and build
- Clippy linting
- Documentation generation
- Unit and integration tests
-
Python CI (
python.yml
)- Black and isort formatting
- Ruff and mypy linting
- Unit tests with coverage
- Type checking
-
Integration Tests (
integration.yml
)- IPFS service container
- Combined Rust/Python testing
- End-to-end workflow validation
A FRAME pallet is comprised of a number of blockchain primitives, including:
- Storage: FRAME defines a rich set of powerful storage abstractions that makes it easy to use Substrate's efficient key-value database to manage the evolving state of a blockchain.
- Dispatchables: FRAME pallets define special types of functions that can be invoked (dispatched) from outside of the runtime in order to update its state.
- Events: Substrate uses events to notify users of significant state changes.
- Errors: When a dispatchable fails, it returns an error.
Each pallet has its own Config
trait which serves as a configuration interface
to generically define the types and parameters it depends on.
Instead of installing dependencies and building this source directly, consider the following alternatives.
Install nix and
nix-direnv for a fully
plug-and-play experience for setting up the development environment. To get all
the correct dependencies, activate direnv direnv allow
.
Please follow the Substrate Docker instructions here to build the Docker container with the Substrate Node Template binary.