基于论文 AIArena: A Blockchain-Based Decentralized AI Training Platform (WWW'25 Companion) 的改进原型,实现包含"任务创建 → 模型训练与提交 → 多验证者评分 → 奖励计算与分配"的完整工作流,并集成"验证者评分聚合与信誉机制"核心改进点。
- 智能合约:任务管理、模型提交、验证者评分聚合(质押+信誉加权)、奖励分配、委托机制
- 链下实验:评分聚合仿真、模型训练(MNIST/CIFAR-10)、非线性权重计算
- 前端演示:任务看板、实验数据可视化、合约交互
- Node.js ≥ 18
- Python 3.10(建议,版本过高可能存在依赖问题)
# 安装依赖
npm install
# 编译合约
npm run compile
# 启动本地节点并部署(包含测试数据)
npm run node # 终端1
npm run deploy-and-setup # 终端2(自动部署并创建测试数据)# 方式1:从根目录
npm run dev:frontend
# 方式2:进入前端目录
cd frontend
npm install
npm run dev访问 http://localhost:5173 查看演示页面。
cd offchain
# 创建虚拟环境(Windows)
python -m venv .venv
.venv\Scripts\activate
# 安装依赖
pip install -r requirements.txt
# 运行实验
python reputation_experiment.py help
py reputation_experiment.py with_model mnist # 结合MNIST模型
├── contracts/ # 智能合约
│ ├── AIArenaCore.sol # 核心工作流(任务、提交、奖励)
│ ├── AIArenaReputation.sol # 信誉加权聚合
│ └── AIArenaToken.sol # ERC20代币
├── frontend/ # React前端
│ └── src/
│ ├── components/ # TaskBoard组件(实验看板)
│ └── services/ # 合约服务
├── offchain/ # 链下实验
│ ├── reputation_experiment.py # 评分聚合实验
│ ├── training_task.py # 模型训练
│ └── weight_api.py # 权重计算API
├── scripts/ # 部署与测试脚本
└── test/ # 合约测试
| 命令 | 说明 |
|---|---|
npm run compile |
编译智能合约 |
npm test |
运行合约测试 |
npm run node |
启动本地Hardhat节点 |
npm run deploy |
部署合约到本地网络 |
npm run deploy-and-setup |
部署合约并创建测试数据(推荐) |
npm run dev:frontend |
启动前端开发服务器 |
- 合约:Solidity, Hardhat, OpenZeppelin
- 前端:React, TypeScript, Vite, Recharts, Ethers.js
- 链下:Python, PyTorch, NumPy