xlnfinance/xln
GitHub: xlnfinance/xln
XLN 是一个面向 EVM 链和未来 CBDC 辖区的信用与抵押净额结算第二层解决方案,通过链下即时结算和链上最终性提升交易效率与安全性。
Stars: 103 | Forks: 22
# XLN - 跨本地网络
**链下即时结算,链上最终性。**
拜占庭共识遇见彭博终端遇见VR。在浏览器中运行完整的经济模拟——无需后端。
## 🌐 目录结构
```
Core:
/docs/ Philosophy, architecture, eternal specs
/runtime/ Consensus engine (BFT entity + bilateral account state machines)
/account-tx/ Account transaction handlers
/entity-tx/ Entity transaction handlers
/scenarios/ Economic simulations (ahb.ts, grid.ts, etc.)
/evms/ EVM integrations (BrowserVM, remote)
/jurisdictions/ Solidity contracts (Ethereum, Polygon, Arbitrum, ...)
/frontend/ Main xln.finance app + 3D visualization
/src/lib/components/ UI panels (Entity, Network, TimeMachine, etc.)
/tests/ E2E tests (Playwright)
Dev:
/scripts/ Utilities (playwright helpers, deployment, debug)
/ai/ AI integrations (STT server, telegram bot, council)
bootstrap.sh One-command setup
CLAUDE.md AI instructions
.archive/ Old implementations (historical reference)
---
## ll professional terms, proper nouns, tool/library/framework names, and technical jargon in their original English form." So, for terms like "Frontend", "Testing", "Development", they might not be considered technical jargon that should be kept in English; they are common in software development but are often translated. In the example, "API Reference" has "API" kept, but "Reference" translated. So, I should translate descriptive parts and keep proper nouns or specific terms.
```bash
# Let me list each with potential translations:
bun run dev
# 1. 🚀 Quick Start – Translate "Quick Start" to "快速开始", keep emoji. So, "🚀 快速开始"
open http://localhost:8080
```
**首次运行:** 约2-3分钟(安装Foundry)
**之后:** 约10秒
## 🎯 什么是XLN?
跨本地网络使实体能够:
- **链下即时**交换价值(BFT共识)
- 将最终状态**锚定在链上**(Ethereum, Polygon, Arbitrum)
- 在浏览器中运行完整的**经济模拟**(BrowserVM - 无需后端!)
- 在**VR**中可视化(兼容Quest/Vision Pro)
**想象一下:** 闪电网络 + 拜占庭共识 + 彭博终端 + Blender。
### 金融是信任的物理学
## 🏗️ 架构(J-E-A层级)
### J - 辖区层(链上)
- **功能:** 管理储备金、抵押品、结算的Solidity合约
- **位置:** `/jurisdictions/contracts/`
- **合约:**
- `Depository.sol` - 实现 `IDepository`(未来ERC标准)
- `EntityProvider.sol` - 实体注册 + 法定人数验证
- **部署:** Ethereum, Polygon, Arbitrum,任何EVM链
### E - 实体层(链下BFT共识)
- **功能:** 具有阈值签名的分布式组织
- **流程:** ADD_TX → PROPOSE → SIGN → COMMIT
- **源码:** `/runtime/entity-consensus.ts`
- **确定性:** 基于Nonce的排序,Merkle状态根
### A - 账户层(双边通道)
- **功能:** 实体对之间的支付通道
- **视角:** 左/右,并具有规范排序(entityA < entityB)
- **源码:** `/runtime/account-consensus.ts`
- **结算:** 使用Merkle证明进行双边状态验证
## 💻 关键命令
```
# 2. Install + start everything – Translate to "安装 + 启动所有". I think "everything" can be "所有" or "一切". I'll use "所有".
bun run dev # Full stack (jurisdictions + runtime + frontend)
bun run check # TypeScript + Svelte validation
bun run build # Build runtime.js for browser
# 3. Open browser – Translate to "打开浏览器"
bun run env:build # Compile Solidity
bun run env:deploy # Deploy to local network
bun run dev:reset # Reset all networks + redeploy
# 4. Development – Translate to "开发". This is common.
cd frontend && bun run dev # Vite dev server
cd frontend && bun run build # Production build
# 5. Jurisdictions (Contracts) – Here, "Jurisdictions" might be a technical term. I'll keep "Jurisdictions" and "Contracts" in English, as per instruction. So, "Jurisdictions (Contracts)" remains as is, but since it's a heading, I should output it in Chinese? No, the instruction says to translate headings to Simplified Chinese, so I need to translate the words. I think for "Jurisdictions", if it's a key term, I might keep it, but let's see the example: "Running Naabu" has "Running" translated, "Naabu" kept. So, "Jurisdictions" could be considered like "Naabu" if it's a proper noun. But "Jurisdictions" is not a tool name; it's a concept. I'll translate it to "管辖区" and "Contracts" to "合同". But to be safe, since the instruction emphasizes keeping technical jargon, and "Jurisdictions" in legal context might be technical, I'll keep it in English. However, the user said "translate each of the following headings", so I should translate all words. Let's check the output format: only output translations. I think for consistency with the example, I'll translate common words and keep specific terms.
bun run test:e2e # Fast E2E: 8 core scenarios in parallel
bun run test:e2e:fast # Same fast bar, explicit name
bun run test:e2e:full # Full E2E: every tests/e2e*.spec.ts target
bun run test:e2e:parallel:isolated # Raw isolated E2E runner for custom targets
# Look at the example: 'Running Naabu' -> '运行 Naabu', so "Running" is translated, "Naabu" is kept.
bun run bench:radapter:hub1m # 1M saved hub accounts, 1% hot set, real /rpc WebSocket
bun run bench:radapter:hub1m:allmem # Same, but materialize all 1M accounts into runtime memory
```
## 🎨 XLNView 面板系统
**彭博终端风格的工作区。可拖动、停靠、浮动、标签化——完整的Chrome开发者工具用户体验。**
### 核心4面板(默认开启)
1. **🌐 Graph3D** - 力导向网络可视化(WebGL/WebGPU切换)
2. **🏢 实体** - 实时实体列表(储备金、账户、活动)
3. **💰 存款库** - 链上J状态查看器(BrowserVM查询)
4. **🎬 设计师** - 上帝模式控制(5种模式:探索/构建/经济/治理/解决)
### 布局
- **默认**:4面板工作区
- **分析师**:Graph3D + 存款库 + 控制台(研究模式)
- **构建者**:设计师 + Graph3D + 实体(创建模式)
- **嵌入式**:仅Graph3D(用于文档/博客文章)
**技术:** Dockview(2.8k星),Svelte响应式,localStorage持久化
**源码:** `/frontend/src/lib/components/` + `/docs/xlnview.md`
## 🧪 Simnet(浏览器中的离线区块链)
**无需localhost:8545。无需云RPC。纯浏览器。**
- **引擎:** @ethereumjs/vm v10(以太坊基金会官方实现)
- **已部署:** Depository.sol + 500个预资助实体
- **代币:** USDC (id=1), ETH (id=2)
- **重置:** 刷新页面 = 新宇宙
- **持久化:** 可选IndexedDB(恢复会话)
**配置:** `runtime/evms/browser-evm.ts`中的创世配置
**演示:** 加载任何场景(AHB, Grid)- BrowserVM自动部署合约
## 🎮 VR/Quest支持
- **WebXR:** 默认启用(WebGL渲染器)
- **离线:** Simnet无需网络即可工作(非常适合VR演示)
- **性能:** Quest 3下72fps
- **未来:** 手部追踪、语音命令、空间UI
## 📚 文档树
```
Root:
readme.md This file - project overview
todo.md Active TODO/NEXT backlog
CLAUDE.md AI assistant instructions
CHANGELOG.md Version history
/docs/
├── contributing/ How to develop on XLN
│ ├── workflow.md Daily commands (bun run dev, etc)
│ ├── bug-prevention.md Pre-commit checklist
│ ├── agentic.md AI autonomous execution (80% rule)
│ └── adhd-format.md Response formatting guide
│
├── research/ Explorations & specifications
│ ├── insurance/ Insurance layer designs
│ │ ├── claude-analysis.md
│ │ ├── codex-analysis.md
│ │ └── gemini-analysis.md
│ ├── depository-core.md Contract logic summary
│ └── rollups-position.md XLN vs rollups comparison
│
├── status.md Current launch state and blocker order
├── mainnet.md Real-user-fund release bar
├── roadmap.md Strategic rollout plan
├── recovery-watchtower-protocol.md
│ Recovery, tower backup, and last-resort dispute spec
├── deployment/ Deploy and ops runbooks
├── archive/ Historical snapshots only
│
├── about/ Philosophy & origin
│ ├── homakov.md Founder's vision
│ └── repo-structure.md Private vs public repos
│
├── testing/ Test procedures
│ └── ahb-demo.md AHB demo steps
│
└── docs/ Core architecture (existing)
├── rjea.md R→E→A→J flow explanation
├── xlnview.md Panel architecture
├── flow.md Transaction flow
└── ... (eternal specs)
```
**快速链接:**
- XLN新手?从 [docs/readme.md](docs/readme.md) 开始
- 当前优先事项?查看 [todo.md](todo.md)
- 当前发布状态?阅读 [docs/status.md](docs/status.md)
- 主网标准?阅读 [docs/mainnet.md](docs/mainnet.md)
## 🔥 最近更新(`0.1.5` - 2026年5月)
- ✅ **官方守望塔** - 同源 `/api/tower/*`,独立守护进程,定时清理,且不公开暴露 `/api/watchtower/*` 清理接口
- ✅ **加密恢复** - 塔备份包和延迟的最后手段主动修复已加密;明文主动修复被拒绝
- ✅ **恢复端到端** - 浏览器清除后的塔恢复和恢复后通道支付已通过浏览器测试覆盖
- ✅ **生产健康** - 做市商/重置恢复和生产支付冒烟测试在 `0.1.5` 发布中通过
- ✅ **计划清理** - 实时的TODO/NEXT工作已整合到 [todo.md](todo.md) 中
## 🛠️ 技术栈
**运行时:** TypeScript + Bun
**前端:** Svelte + Vite + Three.js
**合约:** Solidity + Hardhat
**区块链:** @ethereumjs/vm(模拟网)→ Hardhat(本地)→ Ethereum/L2s(生产)
**面板:** Dockview(2.8k⭐)
**测试:** Playwright
## 🗺️ 网络路线图
当前版本线是生产演示/公共测试网级别,尚非
主网就绪。活跃的阻塞点顺序在 [todo.md](todo.md) 中,当前
状态在 [docs/status.md](docs/status.md) 中,真实用户资金标准在
[docs/mainnet.md](docs/mainnet.md) 中。
当前重点:
- 保持本地和类生产的端到端测试(支付、交换、争议、恢复、守望塔操作)为绿色状态;
- 完成对等状态刷新和账户级恢复覆盖的用户体验;
- 在任何主网候选声明前运行发布时长的浸入测试/门控检查;
- 使链/RPC、运营商密钥、塔燃气策略和监控变得明确;
- 在真实资金前准备外部审计材料。
## 📖 了解更多
**从这里开始:**
1. [docs/readme.md](docs/readme.md) - 文档索引
2. [todo.md](todo.md) - 活跃的TODO/NEXT积压工作
3. [docs/status.md](docs/status.md) - 当前发布状态
4. [docs/mainnet.md](docs/mainnet.md) - 主网发布标准
5. [docs/recovery-watchtower-protocol.md](docs/recovery-watchtower-protocol.md) - 恢复与守望塔协议
**深入了解:** [docs/readme.md](docs/readme.md)
**许可证:** AGPL-3.0
**状态:** 活跃开发中,主网前 `0.1.5` 版本
**网站:** https://xln.finance
标签:Blender, Bun, CBDC集成, EVM兼容, Mutation, Playwright, Solidity, XLN, 主权退出, 二层网络, 二层解决方案, 以太坊虚拟机, 信用网络, 共识算法, 分布式账本, 区块链, 单播优化, 即时结算, 去中心化金融, 可视化, 央行数字货币, 抵押净额, 拜占庭共识, 智能合约, 本地状态, 浏览器应用, 浏览器虚拟机, 特征检测, 经济仿真, 经济模拟, 自动化攻击, 虚拟现实, 跨境支付, 跨本地网络, 金融模拟, 链上最终性, 链下交易, 风险链上管理