NAC_Blockchain/docs/CONSENSUS_QUICK_REF.md

125 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# NAC共识机制快速参考
## 🚨 核心记忆
```
┌─────────────────────────────────────────────┐
│ NAC = CBPP共识 ≠ DAG共识 │
│ │
│ CBPP = Constitutional Block Production │
│ Protocol │
│ (宪政区块生产协议) │
└─────────────────────────────────────────────┘
```
## 📋 CBPP四大组件
| 组件 | 英文 | 作用 |
|------|------|------|
| **宪法收据** | Constitutional Receipt (CR) | 交易上链的唯一凭证 |
| **开放生产网络** | Open Production Network (OPN) | 去中心化的区块生产 |
| **流体区块** | Fluid Block Model (FBM) | 动态区块大小 |
| **三维坐标** | 3D Block Coordinate | Epoch-Round-Branch |
## ⚠️ 不是什么
| ❌ 不是 | 原因 |
|---------|------|
| DAG共识 | NAC不使用有向无环图共识 |
| PoW | 不需要挖矿和算力竞争 |
| PoS | 不基于代币质押 |
| 传统BFT | 不是PBFT/Tendermint |
## 🔑 关键概念
### 宪法即共识
- 所有共识逻辑都基于**宪法**
- 不是基于算力、权益或投票
- 宪法定义了区块生产规则
### 宪法收据
```rust
pub struct ConstitutionalReceipt {
pub transaction_hash: [u8; 48], // 交易哈希
pub constitutional_hash: [u8; 48], // 宪法版本哈希
pub clause_index: u64, // 触发的宪法条款
pub execution_result_hash: [u8; 48], // AI执行结果
pub receipt_id: [u8; 48], // 收据ID
}
```
### 三维区块坐标
```rust
pub struct BlockCoordinate {
pub epoch: u64, // 纪元(宪法版本)
pub round: u64, // 轮次(共识轮次)
pub branch: [u8; 32], // 分支(并行区块)
}
```
## 📁 核心文件
| 文件 | 用途 | 状态 |
|------|------|------|
| `constitutional_receipt.rs` | 宪法收据系统 | ✅ 完成 |
| `cbpp_integration.rs` | CBPP集成 | ✅ 完成 |
| `block_coordinate.rs` | 三维区块坐标 | ✅ 完成 |
| `open_production_network.rs` | 开放生产网络 | ✅ 完成 |
| `fluid_block.rs` | 流体区块模型 | ✅ 完成 |
| `dag.rs` | ⚠️ 需要检查 | ⚠️ 可能错误 |
## 🎯 开发检查清单
开发任何共识相关功能时,问自己:
- [ ] 这是基于CBPP的吗
- [ ] 是否涉及宪法收据?
- [ ] 是否符合开放生产网络的规则?
- [ ] 是否使用三维区块坐标?
- [ ] 是否误用了DAG共识概念
## 🔍 代码审查要点
### ✅ 正确的代码特征
```rust
// 使用宪法收据
let receipt = constitutional_receipt_manager.issue_receipt(...);
// 使用三维坐标
let coord = BlockCoordinate::new(epoch, round, branch);
// 基于宪法验证
if receipt.matches_constitution(constitutional_hash) { ... }
```
### ❌ 错误的代码特征
```rust
// 实现DAG共识算法
pub fn dag_consensus(...) { ... }
// 使用DAG作为共识机制
let consensus = DagConsensus::new(...);
// 混淆数据结构和共识
// "DAG图结构和共识算法" ← 这是错误的
```
## 📚 记忆口诀
```
NAC共识不是DAG
CBPP宪法来当家。
收据、网络、流体块,
三维坐标定天下。
```
## 🔗 相关文档
- [NAC共识机制核心知识](./NAC_CONSENSUS_CORE.md)
- [CBPP技术白皮书](./CBPP_WHITEPAPER.md)
- [类型系统规范](./NAC_TYPE_SYSTEM.md)
---
**最后提醒:遇到"DAG"时,先问自己:这是数据结构还是共识机制?如果是共识机制,那就是错的!**