rdin777/sentinel-mantle
GitHub: rdin777/sentinel-mantle
Sentinel 是一款部署在 Mantle Network 上的 AI 驱动安全基础设施,通过实时不变量监控与预测性模拟来主动防御 DeFi 协议中的逻辑漏洞和资金泄露风险。
Stars: 0 | Forks: 0
# 🛡️ Sentinel:AI 驱动的安全基础设施
## 🚀 概述
在当前的 Web3 环境中,定期的临时审计不足以防止部署后出现的逻辑错误或基础设施漏洞。Sentinel 通过将高性能监控与预测性模拟相结合来解决这一问题。
### 核心关注领域:
* **不变量监控:** 实时追踪协议特定的不变量(例如,偿付能力、总供应量与抵押品的对比)。
* **漏洞预防:** 在异常情况(如“永久性破坏”或“微量泄露”)影响用户资金之前进行检测。
* **预测性防护:** 在敲定高价值 agentic 操作之前,在 fork 环境中运行并行模拟。
## 🛠️ 技术栈
* **区块链基础设施:** [Mantle Network](https://www.mantle.xyz/)
* **安全测试与模拟:** [Foundry](https://book.getfoundry.sh/) (Forge/Anvil)
* **链下监控逻辑:** [Clojure](https://clojure.org/)
* **框架:** OpenZeppelin、Solady
## 🏗️ 架构
1. **Observer (Clojure):** 以毫秒级延迟监控 Mantle RPC,以获取特定的事件日志和状态更改。
2. **Simulator (Foundry):** 当检测到可疑的状态更改时,agent 会在本地 fork 中触发 `forge test`,以预测交易的结果。
3. **Guardian (智能合约):** 如果模拟失败或违反了不变量,Guardian 合约将触发紧急缓解措施(例如,暂停 vault)。
## 📂 项目结构
```
.
├── src/ # Smart contracts for Sentinel Guardian
├── test/ # Foundry security tests & invariant simulations
├── monitoring/ # Clojure scripts for real-time RPC monitoring
└── script/ # Deployment scripts for Mantle Network
🛠️ Getting Started
Prerequisites
Foundry
Clojure/Leiningen
Installation
Bash
git clone [https://github.com/rdin777/sentinel-mantle](https://github.com/rdin777/sentinel-mantle)
cd sentinel-mantle
forge install
Running Simulations
Bash
forge test --match-path test/Sentinel.t.sol
📜 License
MIT
🛡️ Security Analysis: Invariant-Based Protection
The Core Vulnerability: Mathematical Invariants
In modern DeFi protocols (like Panoptic or Autonolas), the fundamental security of a vault or pool relies on strict mathematical invariants. One of the most critical invariants is the relationship between Assets and Shares:
Total Assets≥Total Shares×Exchange Rate
As discovered in recent research regarding "dust leak" and rounding error vulnerabilities, subtle discrepancies in calculation can lead to a state where:
Total Assets
标签:Clojure, Foundry, Mantle Network, Web3安全, 区块链基础设施, 异常检测, 智能合约监控