feat: finish phase 2 decentralized memory and storage tasks
This commit is contained in:
@@ -29,7 +29,8 @@ from .routers import (
|
|||||||
cache_management,
|
cache_management,
|
||||||
agent_identity,
|
agent_identity,
|
||||||
global_marketplace,
|
global_marketplace,
|
||||||
cross_chain_integration
|
cross_chain_integration,
|
||||||
|
global_marketplace_integration
|
||||||
)
|
)
|
||||||
from .routers.ml_zk_proofs import router as ml_zk_proofs
|
from .routers.ml_zk_proofs import router as ml_zk_proofs
|
||||||
from .routers.community import router as community_router
|
from .routers.community import router as community_router
|
||||||
@@ -229,6 +230,7 @@ def create_app() -> FastAPI:
|
|||||||
app.include_router(agent_identity, prefix="/v1")
|
app.include_router(agent_identity, prefix="/v1")
|
||||||
app.include_router(global_marketplace, prefix="/v1")
|
app.include_router(global_marketplace, prefix="/v1")
|
||||||
app.include_router(cross_chain_integration, prefix="/v1")
|
app.include_router(cross_chain_integration, prefix="/v1")
|
||||||
|
app.include_router(global_marketplace_integration, prefix="/v1")
|
||||||
|
|
||||||
# Add Prometheus metrics endpoint
|
# Add Prometheus metrics endpoint
|
||||||
metrics_app = make_asgi_app()
|
metrics_app = make_asgi_app()
|
||||||
|
|||||||
@@ -3,10 +3,16 @@ pragma solidity ^0.8.19;
|
|||||||
|
|
||||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||||
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
|
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
|
||||||
|
import "./ZKReceiptVerifier.sol";
|
||||||
|
|
||||||
contract AgentMemory is Ownable, ReentrancyGuard {
|
contract AgentMemory is Ownable, ReentrancyGuard {
|
||||||
|
ZKReceiptVerifier public zkVerifier;
|
||||||
|
|
||||||
struct MemoryAnchor {
|
struct MemoryAnchor {
|
||||||
string cid;
|
string cid;
|
||||||
|
string memoryType; // e.g., "vector_db", "knowledge_graph"
|
||||||
|
bytes32 zkProofHash;
|
||||||
|
bool isEncrypted;
|
||||||
uint256 timestamp;
|
uint256 timestamp;
|
||||||
uint256 version;
|
uint256 version;
|
||||||
}
|
}
|
||||||
@@ -14,26 +20,74 @@ contract AgentMemory is Ownable, ReentrancyGuard {
|
|||||||
mapping(address => MemoryAnchor[]) public agentMemories;
|
mapping(address => MemoryAnchor[]) public agentMemories;
|
||||||
mapping(address => uint256) public agentMemoryVersions;
|
mapping(address => uint256) public agentMemoryVersions;
|
||||||
|
|
||||||
event MemoryAnchored(address indexed agent, string cid, uint256 version, uint256 timestamp);
|
event MemoryAnchored(
|
||||||
|
address indexed agent,
|
||||||
|
string cid,
|
||||||
|
string memoryType,
|
||||||
|
bytes32 zkProofHash,
|
||||||
|
bool isEncrypted,
|
||||||
|
uint256 version,
|
||||||
|
uint256 timestamp
|
||||||
|
);
|
||||||
|
|
||||||
function anchorMemory(string calldata _cid) external nonReentrant {
|
constructor(address _zkVerifierAddress) {
|
||||||
|
if (_zkVerifierAddress != address(0)) {
|
||||||
|
zkVerifier = ZKReceiptVerifier(_zkVerifierAddress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateZKVerifier(address _newVerifier) external onlyOwner {
|
||||||
|
require(_newVerifier != address(0), "Invalid address");
|
||||||
|
zkVerifier = ZKReceiptVerifier(_newVerifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
function anchorMemory(
|
||||||
|
string calldata _cid,
|
||||||
|
string calldata _memoryType,
|
||||||
|
bytes32 _zkProofHash,
|
||||||
|
bytes calldata _proof,
|
||||||
|
bool _isEncrypted
|
||||||
|
) external nonReentrant {
|
||||||
require(bytes(_cid).length > 0, "Invalid CID");
|
require(bytes(_cid).length > 0, "Invalid CID");
|
||||||
|
require(bytes(_memoryType).length > 0, "Invalid memory type");
|
||||||
|
|
||||||
|
// Verify ZK Proof if provided and verifier is set
|
||||||
|
if (_zkProofHash != bytes32(0) && address(zkVerifier) != address(0)) {
|
||||||
|
require(_proof.length > 0, "Proof required for hash");
|
||||||
|
bool isValid = zkVerifier.verifyReceipt(_proof, _zkProofHash);
|
||||||
|
require(isValid, "ZK Proof verification failed");
|
||||||
|
}
|
||||||
|
|
||||||
uint256 nextVersion = agentMemoryVersions[msg.sender] + 1;
|
uint256 nextVersion = agentMemoryVersions[msg.sender] + 1;
|
||||||
|
|
||||||
agentMemories[msg.sender].push(MemoryAnchor({
|
agentMemories[msg.sender].push(MemoryAnchor({
|
||||||
cid: _cid,
|
cid: _cid,
|
||||||
|
memoryType: _memoryType,
|
||||||
|
zkProofHash: _zkProofHash,
|
||||||
|
isEncrypted: _isEncrypted,
|
||||||
timestamp: block.timestamp,
|
timestamp: block.timestamp,
|
||||||
version: nextVersion
|
version: nextVersion
|
||||||
}));
|
}));
|
||||||
|
|
||||||
agentMemoryVersions[msg.sender] = nextVersion;
|
agentMemoryVersions[msg.sender] = nextVersion;
|
||||||
|
|
||||||
emit MemoryAnchored(msg.sender, _cid, nextVersion, block.timestamp);
|
emit MemoryAnchored(
|
||||||
|
msg.sender,
|
||||||
|
_cid,
|
||||||
|
_memoryType,
|
||||||
|
_zkProofHash,
|
||||||
|
_isEncrypted,
|
||||||
|
nextVersion,
|
||||||
|
block.timestamp
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLatestMemory(address _agent) external view returns (MemoryAnchor memory) {
|
function getLatestMemory(address _agent) external view returns (MemoryAnchor memory) {
|
||||||
require(agentMemories[_agent].length > 0, "No memory anchored");
|
require(agentMemories[_agent].length > 0, "No memory anchored");
|
||||||
return agentMemories[_agent][agentMemories[_agent].length - 1];
|
return agentMemories[_agent][agentMemories[_agent].length - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getMemoryCount(address _agent) external view returns (uint256) {
|
||||||
|
return agentMemories[_agent].length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,42 +17,104 @@ contract KnowledgeGraphMarket is Ownable, ReentrancyGuard {
|
|||||||
uint256 id;
|
uint256 id;
|
||||||
address creator;
|
address creator;
|
||||||
string cid;
|
string cid;
|
||||||
|
string metadataURI; // Added to match broader plan
|
||||||
uint256 price;
|
uint256 price;
|
||||||
uint256 totalSales;
|
uint256 totalSales;
|
||||||
bool isActive;
|
bool isActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Purchase {
|
||||||
|
uint256 graphId;
|
||||||
|
address buyer;
|
||||||
|
uint256 timestamp;
|
||||||
|
string encryptedKey; // The decryption key encrypted with the buyer's public key
|
||||||
|
}
|
||||||
|
|
||||||
mapping(uint256 => KnowledgeGraph) public graphs;
|
mapping(uint256 => KnowledgeGraph) public graphs;
|
||||||
mapping(uint256 => mapping(address => bool)) public hasPurchased;
|
mapping(uint256 => mapping(address => bool)) public hasPurchased;
|
||||||
|
|
||||||
event GraphListed(uint256 indexed id, address indexed creator, string cid, uint256 price);
|
// graphId => array of purchases
|
||||||
|
mapping(uint256 => Purchase[]) public purchases;
|
||||||
|
|
||||||
|
event GraphListed(uint256 indexed id, address indexed creator, string cid, string metadataURI, uint256 price);
|
||||||
|
event GraphUpdated(uint256 indexed id, uint256 newPrice, bool isActive);
|
||||||
event GraphPurchased(uint256 indexed id, address indexed buyer, uint256 price);
|
event GraphPurchased(uint256 indexed id, address indexed buyer, uint256 price);
|
||||||
|
event KeyDelivered(uint256 indexed id, address indexed buyer, string encryptedKey);
|
||||||
|
|
||||||
constructor(address _aitbcToken) {
|
constructor(address _aitbcToken) {
|
||||||
aitbcToken = IERC20(_aitbcToken);
|
aitbcToken = IERC20(_aitbcToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
function listGraph(string calldata _cid, uint256 _price) external returns (uint256) {
|
function listGraph(string calldata _cid, string calldata _metadataURI, uint256 _price) external returns (uint256) {
|
||||||
uint256 id = graphCounter++;
|
uint256 id = graphCounter++;
|
||||||
graphs[id] = KnowledgeGraph(id, msg.sender, _cid, _price, 0, true);
|
graphs[id] = KnowledgeGraph(id, msg.sender, _cid, _metadataURI, _price, 0, true);
|
||||||
emit GraphListed(id, msg.sender, _cid, _price);
|
emit GraphListed(id, msg.sender, _cid, _metadataURI, _price);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateGraph(uint256 _id, uint256 _newPrice, bool _isActive) external {
|
||||||
|
KnowledgeGraph storage graph = graphs[_id];
|
||||||
|
require(graph.creator == msg.sender, "Not creator");
|
||||||
|
|
||||||
|
graph.price = _newPrice;
|
||||||
|
graph.isActive = _isActive;
|
||||||
|
|
||||||
|
emit GraphUpdated(_id, _newPrice, _isActive);
|
||||||
|
}
|
||||||
|
|
||||||
function purchaseGraph(uint256 _id) external nonReentrant {
|
function purchaseGraph(uint256 _id) external nonReentrant {
|
||||||
KnowledgeGraph storage graph = graphs[_id];
|
KnowledgeGraph storage graph = graphs[_id];
|
||||||
require(graph.isActive, "Graph inactive");
|
require(graph.isActive, "Graph inactive");
|
||||||
require(!hasPurchased[_id][msg.sender], "Already purchased");
|
require(!hasPurchased[_id][msg.sender], "Already purchased");
|
||||||
|
require(graph.creator != msg.sender, "Cannot buy own graph");
|
||||||
|
|
||||||
uint256 fee = (graph.price * platformFeePercentage) / 10000;
|
uint256 fee = (graph.price * platformFeePercentage) / 10000;
|
||||||
uint256 creatorAmount = graph.price - fee;
|
uint256 creatorAmount = graph.price - fee;
|
||||||
|
|
||||||
aitbcToken.safeTransferFrom(msg.sender, address(this), graph.price);
|
aitbcToken.safeTransferFrom(msg.sender, address(this), fee); // Treasury
|
||||||
aitbcToken.safeTransfer(graph.creator, creatorAmount);
|
aitbcToken.safeTransferFrom(msg.sender, graph.creator, creatorAmount);
|
||||||
|
|
||||||
graph.totalSales++;
|
graph.totalSales++;
|
||||||
hasPurchased[_id][msg.sender] = true;
|
hasPurchased[_id][msg.sender] = true;
|
||||||
|
|
||||||
|
purchases[_id].push(Purchase({
|
||||||
|
graphId: _id,
|
||||||
|
buyer: msg.sender,
|
||||||
|
timestamp: block.timestamp,
|
||||||
|
encryptedKey: ""
|
||||||
|
}));
|
||||||
|
|
||||||
emit GraphPurchased(_id, msg.sender, graph.price);
|
emit GraphPurchased(_id, msg.sender, graph.price);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deliverDecryptionKey(uint256 _id, address _buyer, string calldata _encryptedKey) external {
|
||||||
|
KnowledgeGraph storage graph = graphs[_id];
|
||||||
|
require(graph.creator == msg.sender, "Not creator");
|
||||||
|
require(hasPurchased[_id][_buyer], "Buyer has not purchased");
|
||||||
|
|
||||||
|
Purchase[] storage graphPurchases = purchases[_id];
|
||||||
|
bool found = false;
|
||||||
|
for (uint i = 0; i < graphPurchases.length; i++) {
|
||||||
|
if (graphPurchases[i].buyer == _buyer) {
|
||||||
|
graphPurchases[i].encryptedKey = _encryptedKey;
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
require(found, "Purchase record not found");
|
||||||
|
|
||||||
|
emit KeyDelivered(_id, _buyer, _encryptedKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMyPurchaseKey(uint256 _id) external view returns (string memory) {
|
||||||
|
require(hasPurchased[_id][msg.sender], "Not purchased");
|
||||||
|
|
||||||
|
Purchase[] storage graphPurchases = purchases[_id];
|
||||||
|
for (uint i = 0; i < graphPurchases.length; i++) {
|
||||||
|
if (graphPurchases[i].buyer == msg.sender) {
|
||||||
|
return graphPurchases[i].encryptedKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ The platform now features a complete agent-first architecture with 6 enhanced se
|
|||||||
|
|
||||||
## 🎯 **Next Priority Areas - Code Development Focus**
|
## 🎯 **Next Priority Areas - Code Development Focus**
|
||||||
Strategic code development focus areas for the next phase:
|
Strategic code development focus areas for the next phase:
|
||||||
- **🔴 HIGH PRIORITY**: Global Marketplace API Implementation
|
- **✅ COMPLETE**: Global Marketplace API Implementation - Multi-region marketplace with cross-chain integration
|
||||||
- **✅ COMPLETE**: Cross-Chain Integration - Multi-blockchain wallet and bridge development
|
- **✅ COMPLETE**: Cross-Chain Integration - Multi-blockchain wallet and bridge development
|
||||||
- **✅ COMPLETE**: Agent Identity SDK - Cross-chain agent identity management
|
- **✅ COMPLETE**: Agent Identity SDK - Cross-chain agent identity management
|
||||||
- **✅ COMPLETE**: Cross-Chain Reputation System - Multi-chain reputation aggregation and analytics
|
- **✅ COMPLETE**: Cross-Chain Reputation System - Multi-chain reputation aggregation and analytics
|
||||||
@@ -34,7 +34,7 @@ Strategic code development focus areas for the next phase:
|
|||||||
|
|
||||||
## Q2-Q3 2026 Global Marketplace Development Plan
|
## Q2-Q3 2026 Global Marketplace Development Plan
|
||||||
|
|
||||||
### Phase 1: Global Marketplace Launch (Weeks 1-4) 🔄 NEXT
|
### Phase 1: Global Marketplace Launch (Weeks 1-4) ✅ COMPLETE
|
||||||
**Objective**: Launch the OpenClaw AI Power Marketplace globally with multi-region support and cross-chain economics.
|
**Objective**: Launch the OpenClaw AI Power Marketplace globally with multi-region support and cross-chain economics.
|
||||||
|
|
||||||
#### 1.1 Global Infrastructure Code
|
#### 1.1 Global Infrastructure Code
|
||||||
@@ -42,6 +42,7 @@ Strategic code development focus areas for the next phase:
|
|||||||
- ✅ **COMPLETE**: Implement geographic load balancing algorithms
|
- ✅ **COMPLETE**: Implement geographic load balancing algorithms
|
||||||
- ✅ **COMPLETE**: Create dynamic pricing API for GPU providers
|
- ✅ **COMPLETE**: Create dynamic pricing API for GPU providers
|
||||||
- ✅ **COMPLETE**: Build multi-language support APIs for agent interactions
|
- ✅ **COMPLETE**: Build multi-language support APIs for agent interactions
|
||||||
|
- ✅ **COMPLETE**: Global Marketplace Integration - Unified cross-chain marketplace platform
|
||||||
|
|
||||||
#### 1.2 Cross-Chain Code Development
|
#### 1.2 Cross-Chain Code Development
|
||||||
- ✅ **COMPLETE**: Develop multi-chain wallet integration libraries
|
- ✅ **COMPLETE**: Develop multi-chain wallet integration libraries
|
||||||
@@ -56,20 +57,20 @@ Strategic code development focus areas for the next phase:
|
|||||||
- ✅ **COMPLETE**: Build on-chain governance voting mechanisms
|
- ✅ **COMPLETE**: Build on-chain governance voting mechanisms
|
||||||
- ✅ **COMPLETE**: Trading Protocols Implementation - Advanced portfolio management, AMM, and cross-chain bridge
|
- ✅ **COMPLETE**: Trading Protocols Implementation - Advanced portfolio management, AMM, and cross-chain bridge
|
||||||
|
|
||||||
### Phase 2: Decentralized AI Memory & Storage (Weeks 5-8) 🔄 FUTURE
|
### Phase 2: Decentralized AI Memory & Storage (Weeks 5-8) ✅ COMPLETE
|
||||||
**Objective**: Provide persistent, decentralized memory for agents using global IPFS/Filecoin networks.
|
**Objective**: Provide persistent, decentralized memory for agents using global IPFS/Filecoin networks.
|
||||||
|
|
||||||
#### 2.1 Storage Integration Code
|
#### 2.1 Storage Integration Code
|
||||||
- Develop decentralized storage adapter libraries
|
- ✅ **COMPLETE**: Develop decentralized storage adapter libraries
|
||||||
- Implement content-addressed memory replication systems
|
- ✅ **COMPLETE**: Implement content-addressed memory replication systems
|
||||||
- Create agent memory marketplace APIs
|
- ✅ **COMPLETE**: Create agent memory marketplace APIs
|
||||||
- Build ZK-proof verification systems for memory retrieval
|
- ✅ **COMPLETE**: Build ZK-proof verification systems for memory retrieval
|
||||||
|
|
||||||
#### 2.2 Knowledge Graph Code
|
#### 2.2 Knowledge Graph Code
|
||||||
- Develop global knowledge graph marketplace APIs
|
- ✅ **COMPLETE**: Develop global knowledge graph marketplace APIs
|
||||||
- Implement cross-agent knowledge sharing protocols
|
- ✅ **COMPLETE**: Implement cross-agent knowledge sharing protocols
|
||||||
- Create federated learning system frameworks
|
- ✅ **COMPLETE**: Create federated learning system frameworks
|
||||||
- Build AI model versioning and distribution networks
|
- ✅ **COMPLETE**: Build AI model versioning and distribution networks
|
||||||
|
|
||||||
### Phase 3: Developer Ecosystem & Global DAO (Weeks 9-12) 🔄 FUTURE
|
### Phase 3: Developer Ecosystem & Global DAO (Weeks 9-12) 🔄 FUTURE
|
||||||
**Objective**: Bootstrap the global network with developer grants and decentralized governance.
|
**Objective**: Bootstrap the global network with developer grants and decentralized governance.
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ This directory contains the active planning documents for the current developmen
|
|||||||
- `multi-language-apis-completed.md`: ✅ COMPLETE - Multi-Language API system with 50+ language support, translation engine, caching, and quality assurance (Feb 28, 2026)
|
- `multi-language-apis-completed.md`: ✅ COMPLETE - Multi-Language API system with 50+ language support, translation engine, caching, and quality assurance (Feb 28, 2026)
|
||||||
- `dynamic_pricing_implementation_summary.md`: ✅ COMPLETE - Dynamic Pricing API with real-time GPU/service pricing, 7 strategies, market analysis, and forecasting (Feb 28, 2026)
|
- `dynamic_pricing_implementation_summary.md`: ✅ COMPLETE - Dynamic Pricing API with real-time GPU/service pricing, 7 strategies, market analysis, and forecasting (Feb 28, 2026)
|
||||||
- `06_trading_protocols.md`: ✅ COMPLETE - Advanced Trading Protocols with portfolio management, AMM, and cross-chain bridge (Feb 28, 2026)
|
- `06_trading_protocols.md`: ✅ COMPLETE - Advanced Trading Protocols with portfolio management, AMM, and cross-chain bridge (Feb 28, 2026)
|
||||||
|
- `02_decentralized_memory.md`: ✅ COMPLETE - Decentralized AI Memory & Storage, including IPFS storage adapter, AgentMemory.sol, KnowledgeGraphMarket.sol, and Federated Learning Framework (Feb 28, 2026)
|
||||||
|
|
||||||
## Workflow Integration
|
## Workflow Integration
|
||||||
To automate the transition of completed items out of this folder, use the Windsurf workflow:
|
To automate the transition of completed items out of this folder, use the Windsurf workflow:
|
||||||
|
|||||||
@@ -3,7 +3,16 @@
|
|||||||
## Executive Summary
|
## Executive Summary
|
||||||
**✅ WORKFLOW COMPLETED SUCCESSFULLY** - All documentation has been comprehensively updated, quality-checked, and organized. The AITBC project documentation is now in an optimal state with consistent status indicators, validated cross-references, and clean organization. Latest update: Trading Protocols implementation completion.
|
**✅ WORKFLOW COMPLETED SUCCESSFULLY** - All documentation has been comprehensively updated, quality-checked, and organized. The AITBC project documentation is now in an optimal state with consistent status indicators, validated cross-references, and clean organization. Latest update: Trading Protocols implementation completion.
|
||||||
|
|
||||||
## Latest Update: Multi-Chain Wallet and Atomic Swaps Implementation Completion
|
## Latest Update: Decentralized AI Memory & Storage Implementation Completion (Phase 2)
|
||||||
|
**✅ PHASE 2 DECENTRALIZED MEMORY DEVELOPMENT COMPLETED** - Successfully updated all documentation references to reflect the completion of the Phase 2 tasks including IPFS storage adapters, AgentMemory.sol smart contract, KnowledgeGraphMarket.sol, and Federated Learning Frameworks.
|
||||||
|
|
||||||
|
### Updated Files:
|
||||||
|
- **`docs/10_plan/00_nextMileston.md`**: Marked Decentralized AI Memory & Storage (Phase 2) tasks as ✅ COMPLETE
|
||||||
|
- **`docs/10_plan/README.md`**: Added `02_decentralized_memory.md` to completed implementations
|
||||||
|
- **Cross-references**: Validated consistency across all documentation
|
||||||
|
- **Technical achievements**: Reached 100% completion for Phase 2 Decentralized AI Memory & Storage
|
||||||
|
|
||||||
|
## Previous Update: Multi-Chain Wallet and Atomic Swaps Implementation Completion
|
||||||
**✅ PHASE 1 CROSS-CHAIN DEVELOPMENT COMPLETED** - Successfully updated all documentation references to reflect the completion of the remaining cross-chain integration tasks including multi-chain wallet libraries and atomic swap protocol.
|
**✅ PHASE 1 CROSS-CHAIN DEVELOPMENT COMPLETED** - Successfully updated all documentation references to reflect the completion of the remaining cross-chain integration tasks including multi-chain wallet libraries and atomic swap protocol.
|
||||||
|
|
||||||
### Updated Files:
|
### Updated Files:
|
||||||
|
|||||||
Reference in New Issue
Block a user