> For the complete documentation index, see [llms.txt](https://docs.rome.builders/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rome.builders/zh/kuai-su-ru-men/architecture.md).

# 架构

Rome 在 Solana 链上程序内嵌入了一个 EVM 字节码解释器。用户通过标准的 Ethereum JSON-RPC 与 Rome Proxy 通信，而该代理会将其交易直接提交到 Solana 上的 Rome EVM 程序。无需单独的执行层保持同步——EVM 状态 *是* Solana 状态。

## 系统概览

<figure><img src="/files/70bb7499fb26d2d1916e2f4627882d0cdfedaf92" alt="User to Rome Proxy to the Rome EVM program on Solana, with Hercules indexing back"><figcaption></figcaption></figure>

## 组件

### Rome EVM 程序（链上）

Rome 的核心——一个包含完整 EVM 字节码解释器（SputnikVM 分支）的 Solana BPF 程序。它：

* 将序列化的 EVM 交易作为 Solana 指令接收
* 在 Solana 运行时中执行 Solidity 字节码
* 将每个 Ethereum 地址（H160）映射到一个 Solana PDA
* 除标准 Ethereum 预编译外，还提供用于调用 Solana 的预编译（CPI、System、Helper、Withdraw）
* 将 EVM 状态（余额、nonce、代码、存储）存储为 Solana 账户数据

### Rome Proxy（JSON-RPC 服务器）

一个运行在 9090 端口上的标准 Ethereum JSON-RPC 服务器——面向公共链的入口点。它会将 Ethereum API 调用转换为 Solana 活动：

* `eth_sendRawTransaction` → 序列化 EVM 交易 → 提交一个 Solana 指令
* `eth_call` → 通过 Mollusk SVM 模拟器在链下模拟执行
* `eth_estimateGas` → 模拟以估算 Gas
* `eth_getBalance`, `eth_getCode`, `eth_getBlockByNumber`、回执、日志 → 由索引状态提供

它还公开 Rome 扩展： `rome_emulateTx`, `rome_emulateRegRollup`, `rome_mintId`, `rome_buildInfo`, `rome_getResources`，以及更多。

### Hercules（索引器）

监视 Solana 上的 Rome EVM 程序，并重建与 Ethereum 兼容的区块——交易、回执、日志和状态变更——由 PostgreSQL 提供支持。在公共链上，它以 slot 对齐模式运行，因此区块编号映射到 Solana slot，同一个 slot 在任何索引器上都会得到相同的区块。代理将这些区块提供给钱包和区块浏览器。

### 预编译合约

Rome 实现了标准 Ethereum 预编译（ecrecover、SHA-256、RIPEMD-160、identity、modexp、BN254 曲线运算、blake2f），其语义与主网等效，并额外提供可访问 Solana 的非 EVM 预编译： **CpiProgram** (`0xFF…08`（任意 CPI）， **System** (`0xFF…07`（PDA 推导和 base58 辅助函数）， **HelperProgram** (`0xFF…09`（ATA/PDA 创建、SPL 转账、gas↔lamports），以及 **Withdraw** (`0x42…16`)。请参阅 [合约地址](/zh/can-kao-wen-dang/contract-addresses.md) 参考文档以查看完整表格。

## 执行模式

Rome 以两种方式之一执行 EVM 交易：

### 原子式（VmAt）

单个 Solana 交易。整个 EVM 交易在一个 Solana 交易的计算预算内执行（约 140 万计算单元）。用于大多数操作——转账、普通合约调用、交换。

### 迭代式（VmIt）

用于超出单个交易预算的工作。执行会拆分为多个 Solana 交易：

1. 每一步（一个 Solana 交易）会运行尽可能多、且能装入其计算预算的 EVM 操作码——步长是自适应的，而非固定的
2. VM 状态会通过 Borsh 序列化到一个 `StateHolder` 账户中，介于各步骤之间
3. 账户在执行期间会被 TTL 锁定数秒
4. 用于 BN254 配对等重型操作

## 账户映射

每个 Ethereum 地址都会根据链 ID 以及 Rome EVM 程序下的该地址，确定性地映射到一个 Solana PDA。该 PDA 持有该账户的余额（作为 SPL 代币账户）、合约代码、存储槽和 nonce——全部作为 Solana 账户数据。

## Holder 账户

Solana 交易的上限为 1,232 字节，但 EVM 交易（尤其是合约部署）可以大得多。Rome 会将大型交易分阶段写入 **holder 账户**：交易会被拆分为若干块，按顺序写入 holder（最多 80 KB），然后在链上组装并执行。Rome SDK 会透明地管理这一过程。

## Gas 和定价

每条链都有其自己的 gas 代币——任意 SPL 代币。Gas 定价会读取 Meteora DAMM 池（v1 或 v2，可配置），以在 gas 代币与 SOL 之间换算底层 Solana 交易费用。

## 接下来

* [网络](/zh/wang-luo/networks.md) — 连接到 Martius 或 Hadrian
* [快速开始](/zh/kuai-su-ru-men/quickstart.md) — 部署你的第一个合约
* [执行模型](/zh/he-xin-gai-nian/execution-model.md) — 原子执行与迭代执行详解


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.rome.builders/zh/kuai-su-ru-men/architecture.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
