# 初始化你的 L2

**注意：我们将“Proxy”和“Light Client”这两个术语互换使用。**

## 导航到 rome-setup/docker 目录

```
cd rome-setup/docker
```

## 设置环境变量

```bash
export ROME_APPS_TAG=v1.0.1
export DEPOSIT_UI_TAG=v1.0.1
export GETH_TAG=v1.0.1

solana config set -u https://node3.devnet-us-sol-api.devnet.romeprotocol.xyz
```

## 生成 Solana 密钥对

在 rome-apps/docker/keys 中生成两个新的 Solana 密钥对，命名为 **Rhea 密钥对** 和 **Proxy 密钥对**。这些密钥对将由 Rhea 和 Light Client 服务（在下一页解释）用于对 Solana 交易进行签名并支付费用。

```bash
solana-keygen new -o keys/rhea-sender.json --no-bip39-passphrase --force
solana-keygen new -o keys/proxy-sender.json --no-bip39-passphrase --force
```

## 空投 SOL

向您的账户空投 SOL **Rhea** 和 **Proxy 密钥对** 使用以下命令：

```bash
solana -ud airdrop 1 $(solana address -k keys/rhea-sender.json)
solana -ud airdrop 1 $(solana address -k keys/proxy-sender.json)
```

如果您在空投时遇到问题， [在我们的 Discord 上联系我们](https://discord.com/invite/romeprotocol).

## 生成 JWT 秘钥

生成一个 [JWT 秘钥](https://jwt.io/introduction) 该秘钥将由 Geth 使用。请将此秘钥妥善保管。

```
openssl rand -hex 32
```

以下为示例值。

```
7ff586310476ffc476995fa0cd3a80be82e2aba650dddc885ac26c82af29c40d
```

## 检查 Solana 插槽

检查 Solana 插槽，并将 rome-setup/docker/cfg 中的 proxy-config.yml 和 rhea-config.yml 中的 start\_slot 更新为当前插槽。

```bash
solana slot
```

此插槽将被 Rhea 和 Light Client（即 Proxy）用于基于从起始插槽开始的 Solana 交易历史确定 rollup 的当前状态。

## 复制 Nginx 证书

如果在远程服务器上设置，请将 nginx 证书复制到您的本地目录。如果在本地设置，则跳过此步骤。

**注意：将下面的文件路径替换为您证书的实际位置。**

<pre class="language-bash"><code class="lang-bash">mkdir -p ./nginx/ssl
<strong>sudo cp /etc/letsencrypt/live/caesar.internal.romeprotocol.xyz/fullchain.pem ./nginx/ssl/
</strong><strong>sudo cp /etc/letsencrypt/live/caesar.internal.romeprotocol.xyz/privkey.pem ./nginx/ssl/
</strong></code></pre>

## 更新配置文件

### Docker Compose

1. 更新 `docker-compose.yml` 以替换 CHAIN\_ID 和 JWT\_SECRET 值。

<pre class="language-yaml"><code class="lang-yaml">geth：
  image: romelabs/rollup-op-geth:${GETH_TAG:-main}
  logging: *logging-config
  hostname: geth
  container_name: geth
  environment：
<strong>    CHAIN_ID: '98989897'
</strong><strong>    JWT_SECRET: '7ff586310476ffc476995fa0cd3a80be82e2aba650dddc885ac26c82af29c40d'
</strong>...
</code></pre>

2. 如果您在远程服务器上设置 L2，则取消注释 romenginx 容器在 `docker-compose.yml`。否则如果在本地机器上设置，则跳过此步骤。

### Rhea 配置

更新 rhea-config.yml 以设置 chain\_id、solana rpc\_urls 和 payers。

<pre class="language-yaml"><code class="lang-yaml"><strong>chain_id: 98989897 # 用您注册的链 ID 替换此值
</strong><strong>rpc_urls: ["https://node3.devnet-us-sol-api.devnet.romeprotocol.xyz"] # 用 Rome Solana RPC 替换此值
</strong>program_id: "RPDwFyw4ekzzgyJfSrVmJgmfi51ovyqzLckYGchLpKX"
commitment: "confirmed"
payers：
  - payer_keypair: "/opt/keys/rhea-sender.json"
    fee_recipients：
      - 0x5f5d351dB427d1131D8Dcd4F151185E6E6111907
geth_indexer：
  geth_http_addr: "http://geth:8545"
  geth_poll_interval_ms: 100
mempool_ttl: 15 #（秒）与真实 op-geth TTL 相近或更高的值将防止 rhea 重复发送
</code></pre>

### Hercules 配置

更新 hercules-config.yml 以设置 chain\_id、start\_slot、solana rpc、geth\_engine\_secret 和 payers。

<pre class="language-yaml"><code class="lang-yaml"><strong>start_slot: 385523275 # 用您最新的 solana 插槽替换此值
</strong>admin_rpc: "0.0.0.0:8000"
mode: Indexer
block_loader：
  program_id: "RPDwFyw4ekzzgyJfSrVmJgmfi51ovyqzLckYGchLpKX"
  batch_size: 64
  block_retries: 100
  tx_retries: 100
  retry_int_sec: 1
  commitment: "confirmed"
  client：
    providers：
<strong>      - "https://node3.devnet-us-sol-api.devnet.romeprotocol.xyz" # 用 Rome Solana RPC 替换此值
</strong>storage：
  connection：
    database_url: "postgres://hercules:qwerty123@postgres_rome/test_rollup"
    max_connections: 16
    connection_timeout_sec: 30
rollup_indexer：
  max_slot_history: 4096
  block_parser：
    program_id: "RPDwFyw4ekzzgyJfSrVmJgmfi51ovyqzLckYGchLpKX"
<strong>    chain_id: 98989897 # 用您注册的 Chain ID 替换此值
</strong>    parse_mode: engine_api
  block_producer：
    type: engine_api
    geth_engine：
      geth_engine_addr: "http://geth:8551"
<strong>      geth_engine_secret: "7ff586310476ffc476995fa0cd3a80be82e2aba650dddc885ac26c82af29c40d" # 用您生成的 JWT 秘钥替换此值
</strong>    geth_api: "http://geth:8545"
</code></pre>

### Proxy 配置

更新 proxy-config.yml 以设置 chain\_id、start\_slot、solana rpc\_url 和 payers。

<pre class="language-yaml"><code class="lang-yaml"><strong>chain_id: 98989897 # 用您注册的链 ID 替换此值
</strong><strong>start_slot: 385523275 # 用您最新的 solana 插槽替换此值
</strong>program_id: "RPDwFyw4ekzzgyJfSrVmJgmfi51ovyqzLckYGchLpKX"
solana：
<strong>  rpc_url: "https://node3.devnet-us-sol-api.devnet.romeprotocol.xyz" # 用 Rome Solana RPC 替换此值
</strong>  commitment: "confirmed"
payers：
  - payer_keypair: "/opt/keys/proxy-sender.json"
    fee_recipients：
      - 0x5f5d351dB427d1131D8Dcd4F151185E6E6111907
ethereum_storage：
  type: "pg_storage"
  connection：
    database_url: "postgres://hercules:qwerty123@postgres_rome/test_rollup"
    max_connections: 16
proxy_host: "0.0.0.0:9090"
max_slot_history: 4096
gas_price: 1000000000
</code></pre>

### Deposit UI 配置

修改下面两个文件。

* `rome-setup/docker/depositui/chains.yml` 以指定 `chainId` .
* `rome-setup/docker/depositui/env.depositui` 以指定 `NEXT_PUBLIC_SOLANA_RPC_URL` .

### 指定 payers

指定多个 payers 以提高吞吐量，因为更多的交易可以通过更多的付款方并行执行。

### 指定 fee\_recipients

将 fee\_recipients 指定为以太坊地址，这些地址将接收作为执行 Solana 交易补偿的 L2 原生代币。

如果未指定 fee\_recipient，则不会转移任何 L2 原生代币作为补偿。

指定多个 fee\_recipients 以提高吞吐量，因为通过更多的费用接收方可以并行执行更多交易。


---

# 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://docs.rome.builders/zh/legacy/rome-l2-setup/setup-your-l2/initialize-your-l2.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.
