Modular Architecture and Smart Contract Interactions
In Cortensor, a decentralized AI inference network, several smart contract modules interact with the binary that runs on community nodes. These modules, similar to microservices in modern software architecture, are designed to scale efficiently and allow upgrades over time. The binary interacts with various smart contracts, coordinating tasks for mining and serving user requests across different blockchain layers. This modular design ensures scalability, upgradability, and adaptability as the network expands and evolves.
Modular Smart Contracts & Microservices Approach
The architecture follows a modular design pattern, with each module containing its own data and functions. These modules can call functions from other modules, making the system flexible for upgrades and feature additions. This is akin to a microservices architecture, where each service operates independently but communicates with others through well-defined interfaces. This logical separation allows Cortensor to scale as more functionalities are added, such as enterprise-level modules or specialized AI features. Over time, we plan to decouple the data within modules to further enhance modularity and ensure each service operates autonomously.
Core Smart Contract Modules
ACL (Access Control Layer)
The ACL module functions similarly to an access management system. It controls global network access, acting as the gateway for node registration and verification. In the current alpha phase, this module is used to whitelist nodes that can register and join the network, enabling the controlled onboarding of miners and other nodes. ACL also provides a safety measure by allowing the network to blocklist bad actors or nodes that violate network rules. Future iterations will involve setting up ACLs for each module to enhance security by defining access privileges for different modules.
IAM (Identity and Access Management)
IAM is responsible for managing node registrations and maintaining node profiles within the Cortensor network. Each node—whether it’s a miner, router, client, or oracle—must register through IAM before interacting with other modules. It ensures that all participants have defined roles, creating a structured ecosystem. This module acts as the entry point for nodes into the broader network.
Cognitive
The Cognitive module serves as the core of Cortensor’s Proof of Useful Work (PoUW) system, regulating the mining process. It implements the state machine logic that orchestrates AI inference tasks across nodes. This module tracks mining sessions, controls transitions between states (such as Request, Create, Prepare, Precommit, and Commit), and ensures that the tasks are completed within set time limits. The Cognitive module interacts with the Oracle node to monitor session times, selects miners via the IAM module, and tracks miner performance via the NodeStats module.
For more detailed information on the Cognitive module and state machine, refer to these resources: Mining Overview PoUW State Machine
NodeStats
NodeStats is the module responsible for collecting and analyzing node behavior and performance. Each time a node completes a task or state transition in the mining process, the NodeStats module records its performance using simple metrics like counters and points. Counters track task entry, while points measure whether tasks are completed successfully. This information helps classify nodes and monitor long-term behavior. Over time, these metrics will help categorize nodes and determine their eligibility to serve user requests, laying the groundwork for the node reputation system.
NodeStats also incorporates a heartbeat function, requiring nodes to ping the network to prove they are active. This data is used to determine which nodes are available for task assignment, making NodeStats an essential part of the network’s monitoring and performance evaluation system.
Session
The Session module handles user requests and AI task configurations. When a user initiates a session, they configure the task requirements, such as desired accuracy and correctness. The user deposits $COR tokens to cover the costs of the task, and miners are assigned based on these configurations. The session also logs the results of each task, storing relevant data in decentralized storage like IPFS, with only the CID (Content Identifier) stored on-chain. This modular approach allows for flexible storage solutions, providing the potential for enterprise-level privacy and data security features.
SessionQueue
The SessionQueue is the task queue that manages job assignments for user sessions. When a session is created, the router node interacts with both the Session and SessionQueue modules. The SessionQueue assigns tasks to miner nodes based on the session’s configurations. Miner nodes can be randomly selected as ephemeral nodes to serve specific tasks within a session, ensuring that tasks are completed efficiently. Over time, SessionQueue will evolve into a smart job router, capable of assigning tasks to nodes based on their capabilities and the complexity of the task at hand.
Runtime
The Runtime module integrates into the binary running on community nodes, acting as a simple key-value storage. This enables:
Dynamic Configuration: Runtime can store values or addresses that control binary behavior without requiring manual configuration updates.
Hot-Swapping: Modules or parameters can be updated in real-time to address issues or optimize performance.
Operational Flexibility: By decoupling configuration updates from the binary itself, Runtime ensures efficient network operations and adaptability to changing requirements.
Web2 Context for Runtime
In Web2 systems, runtime configurations are often updated dynamically to manage application behavior without requiring a complete redeployment. Similarly, Cortensor’s Runtime module provides flexibility and operational resilience, ensuring the network remains responsive to real-world demands.
Future Modules
As the network grows, additional modules may be introduced to support new functionalities and improve network scalability. This modular approach will allow Cortensor to quickly adapt and expand, introducing features like enterprise-level modules or performance optimizations without affecting the overall network.
Conclusion
Cortensor’s modular, microservice-inspired design allows for seamless upgrades, efficient scaling, and enhanced security. Each module operates independently but can interact with others through well-defined interfaces, ensuring the network remains adaptable to evolving needs. From controlling network access with ACL to handling AI task distribution with the Cognitive and Session modules, Cortensor’s architecture is designed for long-term growth, security, and scalability.
This modular approach enables Cortensor to meet the demands of various industries while maintaining a decentralized and efficient AI network.
Last updated