Franlinozz/Archon
GitHub: Franlinozz/Archon
一个面向 Mantle 主网的智能合约审计与 Gas 优化工具,提供基于回执校准的成本分析和链上可验证的审计证明。
Stars: 1 | Forks: 0
审计它。优化它。证明它。
Mantle 的可验证 DevTools 层 — AI 辅助的智能合约审计、基于回执校准的 gas 优化,以及为每份报告提供链上证明。
## Archon 的功能
- **针对 Mantle 审计** Solidity:确定性检测(solc + Slither + 特定的 Mantle 规则引擎)、有边界的 AI 解释,以及生成的 Foundry 回归测试 — 始终保持只读。
- **基于回执而非经验优化 gas:** 每份报告都将 L2 执行与数据可用性(DA)分开,根据 Mantle 回执的真实基准数据(`l1Fee`)进行定价,而非使用传统的预言机。
- **链上证明:** 权威报告哈希锚定到 ERC-8004 Agent #97 下的 ArchonProofRegistry,任何人都可以在没有钱包的情况下重新验证或挑战报告。
## 在线访问
| 页面 | URL |
| --- | --- |
| 应用 |
|
| 文档 | |
| 白皮书 (PDF) | |
| Gas 排行榜 | |
| Gas 观测台 | |
| 地址概览(示例) | |
| 公开报告示例 | |
| 证明交易示例 | [MantleScan 上的 `0x141e3973…c88c10b`](https://mantlescan.xyz/tx/0x141e3973a3dc4a5f8b2dec3c6bf0ed6f1f8132ba1be4e9b8086e0fab9c88c10b) |
| CI Action 演示(真实 PR) | [绿色运行 + gas 评论](https://github.com/Franlinozz/archon-gas-action-demo/pull/1) · [回归测试上的红色运行](https://github.com/Franlinozz/archon-gas-action-demo/pull/2) |
## 架构

一个流水线,三个产物(审计报告、gas 报告、链上证明),七个可独立改进的层。详细信息请参阅[白皮书](https://archonaudit.xyz/whitepaper.pdf)(§03)和[文档](https://archonaudit.xyz/docs)。
## 已部署的合约 (Mantle Mainnet · 5000)
| 合约 | 地址 | 备注 |
| --- | --- | --- |
| **ArchonProofRegistry** | [`0xe7043e2ec95eF357FbBa3359BA2f1edb10cEAD2a`](https://mantlescan.xyz/address/0xe7043e2ec95eF357FbBa3359BA2f1edb10cEAD2a#code) | Archon 自己的证明锚点 — **已验证源码**。`logAuditProof()` 发布确定性报告哈希 + IPFS 元数据 URI + 风险评分;无许可且每个哈希具有幂等性。部署交易 [`0xb9ce87de…a1a7c5`](https://mantlescan.xyz/tx/0xb9ce87de86b212b91eb64012bbdab91014373da1f6d960470b340e1991a1a7c5),证明交易示例 [`0x82d99588…088ef`](https://mantlescan.xyz/tx/0x82d99588e5f1bff33d618743025d598445493032637de25844a67aa8e88088ef)。源码 + Foundry 测试:`contracts/`。 |
| ERC-8004 Identity Registry | [`0x8004A169FB4a3325136EB29fA0ceB6D2e539a432`](https://mantlescan.xyz/address/0x8004A169FB4a3325136EB29fA0ceB6D2e539a432) | 官方注册表;Archon 是 **Agent #97**([清单](https://archonaudit.xyz/.well-known/archon-agent.json))。 |
| ERC-8004 Reputation Registry | [`0x8004BAa17C55a88189AE136b182e5fdA19dE9b63`](https://mantlescan.xyz/address/0x8004BAa17C55a88189AE136b182e5fdA19dE9b63) | 官方注册表;包含 Archon 早期基于声誉锚定的证明记录。 |
## 为什么我们的 DA 数据基于回执校准
在真实的 Mantle 交易中,传统的 `GasPriceOracle.getL1Fee` **少报了链实际收取的 DA 费用约 99.96%** — 回执中的 `l1Fee` 大约是预言机预测值的 2,200–2,900 倍(在两笔真实交易中测得 99.955% / 99.966% 的偏差)。
任何引用该预言机的工具在 Mantle 的 DA 经济模型上都会不知不觉地出错。
因此,Archon 根据回执的真实基准数据(一种针对实时交易校准的零/非零调用数据字节模型)对 DA 进行定价,并将每个数字标记为**实测、预估或未计价**。
方法论、交易哈希和验证误差:[ADR 0007](docs/decisions/0007-mantle-gas-oracle-verification.md) · 白皮书 v2 §05,表 1。
## 功能矩阵
| 界面 | 状态 | 功能 | 位置 |
| --- | --- | --- | --- |
| **Audit Studio + 7 阶段流水线** | ✅ 上线 | 具有文件/行证据的严重性分级发现、Mantle 特定风险、AI 解释、生成的 Foundry 测试 | [Audit Studio](https://archonaudit.xyz/app/audit/new) |
| **报告 + 公开查看器** | ✅ 上线 | 每份报告都有一个永久的、无需钱包的公开页面,可重新生成哈希并显示链上证明 | [/r/<id>](https://archonaudit.xyz/proofs) |
| **Gas Optimizer** | ✅ 上线 | 优化目录、已验证的补丁、基于回执校准的 L2/DA 分拆、既定假设下的年化节省 | [Gas Optimizer](https://archonaudit.xyz/app/gas) |
| **Cost Guard** | ✅ 上线 | 来自持久化 gas 报告和优化的真实开销遥测 | [Cost Guard](https://archonaudit.xyz/app/cost-guard) |
| **链上证明** | ✅ 上线 | 锚定到 ArchonProofRegistry 的权威报告哈希,**并且**作为针对 Agent #97(feedbackHash = 报告哈希)的 ERC-8004 Reputation 条目附加;公开、无需钱包的验证 | [/proofs](https://archonaudit.xyz/proofs) |
| **CI (CLI + Action)** | ✅ 上线 | 带有 `--fail-on` 门控的 `archon-scan` CLI + 发布真实 gas 差异 PR 评论的 GitHub Action | [CLI](https://archonaudit.xyz/docs/platform-api/cli) · [Action](https://archonaudit.xyz/docs/gas-optimizer/ci-github-action) |
| **Sentinel** | ✅ 上线 | 持续监控已部署的合约:漂移检测(字节码、EIP-1967、所有者)、带发现差异的自动重新扫描、审计新鲜度评分、webhook 警报 | [Sentinel 文档](https://archonaudit.xyz/docs/audit/sentinel) |
| **Verified builds** | ✅ 上线 | 确定性源码→字节码证明(屏蔽了 immutables,具备元数据感知能力),带有公开验证页面和可锚定的哈希 | [Verified builds 文档](https://archonaudit.xyz/docs/on-chain-proofs/verified-builds) |
| **Gas Observatory** | ✅ 上线 | 关于 Mantle DA 经济学的公开真实基准:基于回执校准的 DA 成本/字节、L2 基础费、趋势,以及实时的预言机与回执差异(可嵌入) | [/observatory](https://archonaudit.xyz/observatory) |
| **GitHub App + autofix** | ✅ 上线 | PR 检查 + 单个更新评论(发现、gas 差异),通过 `archon.config.json` 配置策略,`/archon fix` 在 Archon 自己的分支上打开经编译验证的 autofix PR(已安装在 `Franlinozz/Archon` + `archon-gas-action-demo` 上) | [GitHub App 文档](https://archonaudit.xyz/docs/platform-api/github-app) |
| **Agent Trust API + MCP** | ✅ 上线 | 签名的合约信任裁决 API(恢复为 Agent #97)+ 具有四个工具的 MCP server — 作为 AI agent 安全感官的 Archon | [面向 agents](https://archonaudit.xyz/docs/platform-api/for-agents) |
| **地址页面 + 徽章** | ✅ 上线 | 为每个 Mantle 合约提供永久的公开安全 URL(审计时间线、证明、新鲜度、gas、挑战)+ README 徽章 + 可嵌入的卡片 | [公开页面文档](https://archonaudit.xyz/docs/platform-api/public-pages-badges) |
| **VS Code 插件** | ✅ 上线 (Open VSX) | 编辑器中的诊断、作为 Code Actions 的安全 gas 快速修复、逐个机会的 gas 透镜 — 公共 API 的瘦客户端([Open VSX](https://open-vsx.org/extension/archon/archon-mantle) · [v0.1.2 发布](https://github.com/Franlinozz/Archon/releases/tag/vscode-v0.1.2);MS Marketplace 申诉待处理) | [编辑器文档](https://archonaudit.xyz/docs/platform-api/editor-integration) |
| **Gas 排行榜** | ✅ 上线 | 已完成 gas 报告的公开排名(示例行已标记) | [/gas-leaderboard](https://archonaudit.xyz/gas-leaderboard) |
| **挑战账本** | ✅ 上线 | 针对报告和优化的公开挑战记录(质押挑战已设计,但未部署 — ADR 0014) | [安全与保障模型](https://archonaudit.xyz/docs/resources/security-safety-model) |
| **Tencent COS 备份** | ✅ 上线 | 尽力而为的产物备份(证明/报告 JSON)到 Tencent COS(`ap-hongkong`);从不阻塞 IPFS/Postgres 主要路径 — 状态见 [/api/providers](https://archonaudit.xyz/api/providers) | [云提供商](https://archonaudit.xyz/docs/platform-api/cloud-providers) |
| **Tencent Hunyuan** | 🟢 就绪(可选) | OpenAI 兼容的富化适配器,已构建但目前处于非活跃状态,等待推理密钥 — **OpenAI `gpt-4o-mini` 仍然是活跃的富化模型** | [云提供商](https://archonaudit.xyz/docs/platform-api/cloud-providers) |
## 为 Agent 经济而生
Archon 是第一个具有链上身份的 MCP 原生审计器。任何 AI agent 都可以问 Archon “我可以信任这个合约吗?”并获得一个**签名裁决**,该裁决可恢复至 Archon 的 ERC-8004 **Agent #97** — 任何消费者都可以离线验证其来源。
- **裁决 API:** `GET /api/v1/verdict/5000/` → EIP-191 签名的 `{riskScore, auditFreshness, attestation, openCritical, proofTx, agentId: 97, signature}`。
- **MCP server:** `npx github:Franlinozz/archon-mcp` 向 Claude Desktop/Code 及任何 MCP 客户端暴露 `archon_scan_source`、`archon_verdict`、`archon_gas_report`、`archon_verify_proof`。
文档:[面向 agents](https://archonaudit.xyz/docs/platform-api/for-agents)。
## 快速开始
**使用应用:** 打开 ,点击 **Start Audit**,粘贴 Solidity 或从 GitHub/地址导入。
**CLI**(零依赖,Node ≥ 18):
```
npx --yes github:Franlinozz/archon-cli scan contracts/Vault.sol --gas --fail-on high
```
**GitHub Action**(带有 L2 + DA 列的 PR gas 差异评论):
```
permissions: { contents: read, pull-requests: write }
steps:
- uses: actions/checkout@v4
- uses: Franlinozz/Archon@main
with:
source-file: contracts/YourContract.sol
github-token: ${{ secrets.GITHUB_TOKEN }}
```
**API:** OpenAPI 3.1 位于 [/api/openapi](https://archonaudit.xyz/api/openapi),交互式参考位于 [/api-reference](https://archonaudit.xyz/api-reference)。
**VS Code:** 从 [Open VSX](https://open-vsx.org/extension/archon/archon-mantle) 安装(Cursor / VSCodium / Windsurf),或获取 [`vscode-v0.1.2` 发布](https://github.com/Franlinozz/Archon/releases/tag/vscode-v0.1.2) `.vsix`:
```
code --install-extension archon-mantle-0.1.2.vsix
```
**MCP(面向 agents):** `npx github:Franlinozz/archon-mcp` 暴露 `archon_scan_source`、`archon_verdict`、`archon_gas_report`、`archon_verify_proof`。[白皮书](https://archonaudit.xyz/whitepaper.pdf) · [agent 清单](https://archonaudit.xyz/.well-known/archon-agent.json)。
## 技术栈
Next.js 15 · TypeScript · Tailwind · BullMQ + Redis · Supabase Postgres · solc/Slither · Foundry · viem/wagmi · 可插拔的 AI 提供商(OpenAI `gpt-4o-mini` 运行中;Tencent Cloud Hunyuan 适配器已内置,但在等待推理密钥期间处于非活跃状态,[状态](https://archonaudit.xyz/api/providers))· Pinata/IPFS 主节点(+ **Tencent COS 产物备份,已在** `ap-hongkong` **上线**)· 单台虚拟机上的 PM2 + Caddy。
扫描流水线是只读的。唯一预期的交易路径是明确经用户批准的证明日志,并由模拟和成本检查加以保护。
## 黑客松
为 **Tencent Cloud × Mantle** 黑客松(Cookathon)而构建。Archon 将其**自己的**链上证明合约作为主要的、有获奖的部署发布:**ArchonProofRegistry**(已在 MantleScan 上验证,见上表)— `logAuditProof()` 在链上发布 AI 推理结果(确定性报告哈希 + IPFS 元数据 URI + AI 衍生的风险评分),无许可且对每个报告哈希具有幂等性,因此无 gas 和自我托管证明路径都可以在没有 ERC-8004 自我反馈限制的情况下工作。AI 富化和产物存储运行在[可插拔提供商层](https://archonaudit.xyz/docs/platform-api/cloud-providers)上,具备一流的 Tencent Cloud(Hunyuan、COS)适配器。
## 截图
| | |
| --- | --- |
|  |  |

## 本地开发
```
pnpm install
cp .env.example .env.local # set DATABASE_URL, REDIS_URL, Mantle RPC
pnpm dev # web app
pnpm worker # scan worker
```
可选:`OPENAI_API_KEY`(或 `AI_PROVIDER` + 匹配的密钥)用于实时 AI 富化 — 确定性回退机制使得应用在没有它的情况下依然可用;`IPFS_PIN_TOKEN` 用于证明元数据锁定。
**验证门控:** `pnpm typecheck · lint · test · secret-scan · scope-grep · build` — CI 运行相同的集合。
## 仓库映射
```
app/ Next.js app + API routes (app/r/[reportId] = public report viewer)
components/ UI components (archon/, marketing/, nav/, docs/, theme/)
contracts/ ArchonProofRegistry (Foundry) + sample inputs and fixtures
docs/ architecture assets, ADRs, DOC-SYNC ritual, whitepaper, submission notes
lib/ scan pipeline, gas engine, proof layer, AI providers, chain helpers
packages/cli/ archon-scan CLI (mirrored to Franlinozz/archon-cli for npx)
worker/ BullMQ scan worker entrypoint
action.yml the Archon Gas Action (composite)
```
## 贡献与许可
欢迎提交 Issues 和 PRs — 请在提交前运行验证门控。基于 [MIT](LICENSE) 许可。标签:AI辅助分析, Gas优化, LNA, Mantle, Solidity, Web3, 区块链, 搜索引擎查询, 智能合约审计, 自动化攻击