# 系统拓扑图 System Diagram

## 完整组件视图

```
┌──────────────────────────────────────────────────────────┐
│  Ethereum L1 (主网部署后)                                 │
│  ┌────────────────────────────────────────────────────┐  │
│  │  - DiamondProxy / Mailbox (来自 zksync-era-contracts)│ │
│  │  - L1 Verifier (Boojum / Plonky2 / Halo2)           │ │
│  │  - L1BridgeContract (deposit/withdraw)              │ │
│  │  - L1 Oracle aggregator (Chainlink / Pyth)          │ │
│  └────────────────────────────────────────────────────┘  │
└──────────────┬───────────────────────────────────────────┘
               │ (1) batch + ZK proof + state root
               │ (2) bridge messages
               │ (3) L1 prices via Mailbox proof
               ▼
┌──────────────────────────────────────────────────────────┐
│  L2 Sequencer (chain 391: anvil-zksync 单节点)            │
│  ┌────────────────────────────────────────────────────┐  │
│  │  - Tx pool / mempool                                │ │
│  │  - State keeper (TPS 0.64 → 5+ tuned)               │ │
│  │  - eth_tx_manager (L1 commit/prove/execute)         │ │
│  │  - Bootloader (system contract execution)           │ │
│  └────────────────────────────────────────────────────┘  │
└──────────────┬───────────────────────────────────────────┘
               │ batch tx
               ▼
┌──────────────────────────────────────────────────────────┐
│  L2 应用合约层 (33 contracts)                             │
│  ┌──── L0 行为记录 ────┐  ┌──── L1 决策回执 ────┐         │
│  │ PoBRegistry         │  │ PoDRegistry         │         │
│  │ BehaviorSpecRegistry│  │ ModelRegistry       │         │
│  │ StakeManager        │  │ EcdsaInferenceVerif │         │
│  │ ChallengeManager    │  │ TeeInferenceVerif   │         │
│  │ Groth16PoBVerifier  │  │ ZkmlInferenceVerif  │         │
│  └─────────────────────┘  │ CausalChainLinker   │         │
│                            └─────────────────────┘         │
│  ┌──── L2 策略 ──────┐    ┌──── L3 解释 ────┐             │
│  │ PolicyRegistry    │    │ ExplanationRegistry            │
│  └───────────────────┘    └─────────────────────┘         │
│  ┌──── Oracle / DID ────┐ ┌──── Bridge ────────┐         │
│  │ OracleHub (0x8016)   │ │ L2BridgeContract   │         │
│  │ L1OracleReader       │ │ FastWithdrawalPoolV2│         │
│  │ DIDRegistry (0x8017) │ └─────────────────────┘         │
│  │ CredentialReg (0x8018)│                                │
│  │ IdentityVerif (0x8019)│                                │
│  │ EnterpriseIAMLocal    │                                │
│  └───────────────────────┘                                │
└─────────────────┬─────────────────────────────────────────┘
                  ▲
                  │ submit batch / open challenge / register / push price
                  │
┌─────────────────────────────────────────────────────────┐
│  链下基础设施 (Off-chain)                                │
│  ┌──── Rust workspace (baby-modules/) ──────────────┐    │
│  │ baby-pob-aggregator  - Merkle batch + 上链        │    │
│  │ baby-pob-challenger  - Fraud detector + open       │    │
│  │ baby-pod-aggregator  - Receipt 提交               │    │
│  │ baby-explanation     - SLM stub 摘要              │    │
│  │ baby-opa-policy      - Rego eval                  │    │
│  │ baby-zkml            - Halo2 stub                 │    │
│  │ baby-tee-attestor    - DCAP stub                  │    │
│  │ baby-behavior-spec   - DSL parser                 │    │
│  │ baby-credit-score    - 5-dim scoring              │    │
│  │ baby-bridge-enhancer - L1↔L2 helper              │    │
│  │ baby-oracle-wiring   - Sequencer integration      │    │
│  │ baby-oracle-system-contract                       │    │
│  │ baby-did-circuits    - 6 个 Circom 电路           │    │
│  └────────────────────────────────────────────────────┘    │
│                                                          │
│  ┌──── TypeScript (sdk/) ──────────────────────────┐     │
│  │ @babydriver/sdk - viem 客户端 + 9 client class  │     │
│  └─────────────────────────────────────────────────┘     │
│                                                          │
│  ┌──── 监控 / 运维 ─────────────────────────────────┐    │
│  │ Oracle Price Pusher (Rust + alloy)              │    │
│  │ G3 稳定性 harness (bash + jq)                    │    │
│  │ Blockscout (chain 391 区块浏览器)                │    │
│  └─────────────────────────────────────────────────┘     │
└─────────────────────────────────────────────────────────┘
```

## 数据流：一次 PoB submitBatch

```
Agent ──BehaviorEvent──▶ baby-pob-aggregator (Rust)
                              │
                              │ build Merkle batch
                              │ ECDSA sign header
                              ▼
                       PoBRegistry.submitBatch (L2 tx)
                              │
                              │ emit BatchSubmitted event
                              ▼
              baby-pob-challenger (持续监听)
                              │
                              │ FraudDetector.detect()
                              ├─ NoFraud → 跳过
                              └─ Fraud(claim) → ChallengeManager.open(0.1 ETH bond)
                                            │
                                            │ 7 days timeout
                                            ▼
                              ChallengeManager.resolveExpired
                                            │
                                            │ StakeManager.slash 0.5 ETH
                                            ▼
                              status=ResolvedFraud, _slashedAmount[id]=0.5e18
                                            │
                                            ▼
                              challenger.claim() → bond 退回 + 50% reward
```

## 主网部署 vs 当前 PoC

| 组件             | 当前 PoC                      | 主网                                 |
| -------------- | --------------------------- | ---------------------------------- |
| L1             | Sepolia (test)              | Ethereum mainnet                   |
| L2 sequencer   | 单 anvil-zksync              | 3-5 节点 + multi-AZ                  |
| L1 verifier    | Mock                        | Real Boojum / Plonky2              |
| Prover         | 不存在                         | GPU cluster (4-8x H100)            |
| DA             | 内存 + JSONL                  | Ethereum blob 或 EigenDA / Celestia |
| RPC            | 单节点                         | 多节点 + load balancer                |
| Block explorer | Blockscout (chain 391 only) | 主网生产部署                             |

详见 [非主网就绪](/legal-and-disclaimers/not-mainnet-ready.md)。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yellowpaper.axblade.io/overview/system-diagram.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
