Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Cognitive Routing Protocol (CRP)
# Cognitive Routing Protocol (CRP) — Simulation Prototype

[![Project Status: Prototype Complete](https://img.shields.io/badge/status-prototype_complete-brightgreen.svg)](https://github.com/Yudis-bit/Cognitive-Routing-Protocol)
[![Project Status: Prototype Complete](https://img.shields.io/badge/status-prototype-green.svg)](https://github.com/Yudis-bit/Cognitive-Routing-Protocol)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

This repository contains the complete architecture and functional prototype for the **Cognitive Routing Protocol (CRP)**, a Layer-0/Layer-1 enhancement protocol designed to fundamentally reshape the efficiency, resilience, and profitability of Decentralized Physical Infrastructure Networks (DePIN).
A seeded Python simulation exploring adaptive routing with Multi-Armed Bandit reinforcement learning, comparing a cognitive router against a static Dijkstra baseline. Includes a reference Solidity `NodeRegistry` contract for on-chain node registration and staking.

---

Expand Down Expand Up @@ -83,7 +83,7 @@ To run this project locally, you'll need to set up both the simulation and contr
* [x] **Phase 2: "Dumb" Router (Baseline)** - Dijkstra's algorithm implementation for benchmarking.
* [x] **Phase 3: Cognitive Node (AI Core)** - AI agent implementation with a Multi-Armed Bandit model.
* [x] **Phase 4: Integration & Comparative Analysis** - Validation of CRP's performance benefits.
* [x] **Phase 5: On-Chain Component Design (Solidity)** - Smart contract architecture for trust and staking.
* [x] **Phase 5: On-Chain Component Design (Solidity)** — Reference interface and stub contract implemented; on-chain integration and testing is future work.

## Contributing

Expand Down
9 changes: 9 additions & 0 deletions contracts/contracts/INodeRegistry.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface INodeRegistry {
function registerNode(bytes32 nodeId) external;
function stake(bytes32 nodeId) external payable;
function getTrustScore(bytes32 nodeId) external view returns (uint256);
function isRegistered(bytes32 nodeId) external view returns (bool);
}
29 changes: 29 additions & 0 deletions contracts/contracts/NodeRegistry.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {INodeRegistry} from "./INodeRegistry.sol";

contract NodeRegistry is INodeRegistry {
mapping(bytes32 => bool) private _registered;
mapping(bytes32 => uint256) private _stakes;
mapping(bytes32 => uint256) private _trustScores;

function registerNode(bytes32 nodeId) external override {
require(!_registered[nodeId], "already registered");
_registered[nodeId] = true;
_trustScores[nodeId] = 100;
}

function stake(bytes32 nodeId) external payable override {
require(_registered[nodeId], "not registered");
_stakes[nodeId] += msg.value;
}

function getTrustScore(bytes32 nodeId) external view override returns (uint256) {
return _trustScores[nodeId];
}

function isRegistered(bytes32 nodeId) external view override returns (bool) {
return _registered[nodeId];
}
}
6 changes: 6 additions & 0 deletions contracts/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require("@nomicfoundation/hardhat-toolbox");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.20",
};
4 changes: 4 additions & 0 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
"hardhat": "^2.22.0"
},
"dependencies": {
"@openzeppelin/contracts": "^5.4.0"
}
Expand Down
Loading