# 与 zkSync-era 的关系

## Fork 基线

| 项              | 值                                                                   |
| -------------- | ------------------------------------------------------------------- |
| 上游             | [matter-labs/zksync-era](https://github.com/matter-labs/zksync-era) |
| Fork 时间        | 2026-Q1                                                             |
| Era version    | v25.x (Boojum prover stack)                                         |
| Era contracts  | era-contracts v0.27.x                                               |
| Rust toolchain | nightly-2025-03-19                                                  |

**整个 era-core 200+ Rust crate 我们都 in-tree fork 修改过**（`era-core/` 在 .gitignore，因为是独立 git repo）。

## 添加了什么 (delta vs upstream)

### 1. 系统合约槽位扩展

zkSync-era 把 0x80xx 范围的地址作为 system contract slot（bootloader 直接 inject）。我们注入了 4 个新 system contract：

| Slot     | 合约                 | 用途                              |
| -------- | ------------------ | ------------------------------- |
| `0x8016` | OracleHub          | L2 价格 feed (替代 Chainlink on L2) |
| `0x8017` | DIDRegistry        | did:ethr:baby identity          |
| `0x8018` | CredentialRegistry | Verifiable Credential 签发/撤销     |
| `0x8019` | IdentityVerifier   | 合规验证 (ECDSA → ZK 双模)            |

修改：`SCRATCH_SPACE_BEGIN_SLOT` 从 8 移到 32（让 8-31 留给 Oracle calldata）。

### 2. Bootloader 修改

* bootloader 启动时调用 OracleHub.batchUpdatePrices (heartbeat-mode)
* DIDRegistry / IdentityVerifier 自动 init at genesis

### 3. 应用层合约 (33 个)

完全 in-tree 自研，与 era-contracts 解耦：见 [Chain 391 合约地址](/consolidated-resources/contract-addresses-chain-391.md)。

## G1-blocked-structural

### 问题

Fork 后跑 ZK Rollup pipeline 时，**第一个 batch 在 L1 commit 阶段撞 logs root mismatch**。Era node 期望的 logs root 与 L1 verifier 计算的不一致。

### 现状

* chain 391 用 `anvil-zksync` 单节点 EVM 模拟器跑 demo（不出真 ZK proof）
* 真 ZK Rollup 流水**无法 finalize batch #1**
* 详见仓库内 [`memory/project_real_zk_rollup_blocked.md`](https://github.com/leeleeEcho/babyDriver_Layer2)

### 两个分支选择

**(A)** 继续 era-core fork debug — 估 3-12 个月工程 **(B)** 弃 fork，整合现成 L2 框架（Caldera / Conduit / Hyperchain / Polygon CDK / OP Stack）— 估 6-12 个月

主网前必须做出决策。详见 [非主网就绪 §1](/legal-and-disclaimers/not-mainnet-ready.md)。

## 升级策略

| 时间点        | 策略                                                          |
| ---------- | ----------------------------------------------------------- |
| 当前 (PoC)   | 不 sync upstream（fork base 锁定）                               |
| Phase A 启动 | 评估 zksync-era latest stable, 选择性 cherry-pick security patch |
| Phase B 启动 | 决定是否升级 fork base 或 pivot                                    |
| 主网前 6 个月   | 锁定最终 fork base + 审计独立 audit                                 |

## 致谢

AxBlade 整个底层依赖 Matter Labs 的 zksync-era + zksync-era-contracts。我们的 5 层应用协议是上层 add-on，不是替代品。


---

# 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/about-axblade/relationship-to-zksync-era.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.
