# 节点设置

本节将展示如何设置Story网络节点。Story从以太坊权益证明中汲取灵感，将执行客户端和共识客户端分离。执行客户端`story-geth`通过Engine ABI将EVM区块中继到`Story`共识客户端，并使用ABCI++适配器使EVM与CometBFT状态兼容。在这种架构下，共识效率不再受执行交易吞吐量的限制。

<figure><img src="/files/kWFVUiwdXpUPJm3r7msf" alt=""><figcaption></figcaption></figure>

`story`和`geth` binary文件是运行Story节点所需的客户端，可从Story Github最新`release`页面获取：

* **`story-geth`执行客户端:**
  * 版本链接：[story-geth/releases](https://github.com/piplabs/story-geth/releases)
  * 最新稳定版 (v0.10.0)：[story-geth/v0.10.0](https://github.com/piplabs/story-geth/releases/tag/v0.10.0)
* **`story`共识客户端:**
  * 版本链接：[story/releases](https://github.com/piplabs/story/releases)
  * 最新稳定版  (v0.12.1)：[story/v0.12.1](https://github.com/piplabs/story/releases/tag/v0.12.1)

{% hint style="info" %}
**重要提示：对于Odyssey测试网，必须从v0.12.0版本开始，因为后续升级都需要先安装此版本。请先下载此版本，以确保与测试网环境兼容。此外，请确认下载的binary文件与你的系统架构适配。**
{% endhint %}

### 硬件要求

| 硬件  | 最低要求      |
| --- | --------- |
| CPU | 4 核处理器    |
| 内存  | 16 GB     |
| 硬盘  | 200 GB    |
| 带宽  | 25 MBit/s |

如果在AWS服务器上运行节点，建议使用M6i、R6i或C6i系列。

### 端口设置

确保已开启以下节点运行所需的所有端口。

* `story-geth`
  * 8545
    * 如果希望节点通过HTTP上的JSON-RPC API交互，该端口必需开启。
  * 8546
    * WebSockets交互需要。
  * 30303 (TCP + API)
    * 开放点对点通信。
* `story`
  * 26656
    * 开放共识客户端点对点通信。
  * 26657
    * 如果希望节点连接Tendermint RPC接口，该端口必需开启。
  * 26660
    * 如果希望公开prometheus指标，该端口必需开启。

### 默认文件路径

默认情况下，共识和执行客户端设置在以下数据文件夹：

* Mac OS X
  * `story` 根目录:  `~/Library/Story/story`
  * `story-geth`根目录:  `~/Library/Story/geth`
* Linux
  * `story`根目录:  `~/.story/story`
  * `story-geth`根目录: `~/.story/geth`

在本节教程中，我们将`story`数据根目录命名为`${STORY_DATA_ROOT}`，将`geth`数据根目录命名为`${GETH_DATA_ROOT}`。

你可以通过设置`--home ${STORY_CONFIG_FOLDER}`在`story`客户端覆盖这些默认配置。同样，对于`geth`，你可以设置`--config ${GETH_CONFIG_FOLDER}`。更多详细信息，请查看Story Github的自述文件：[Creating a private network](https://github.com/piplabs/story?tab=readme-ov-file#creating-a-private-network)。

下载Story binary文件时，请注意，文件名会根据操作系统而有所不同。例如，在AMD64架构的Linux系统中，binary文件可能命名为`story-linux-amd64`或`geth-linux-amd`。这种命名方式有助于识别版本兼容性，但为简单起见，建议在下载后将binary文件重命名为`story`。

```bash
mv story-linux-amd64 story
```

运行上方代码，接下来，你可以直接在终端中使用`story`命令来执行程序。在本文档的其余部分，我们将默认使用`story`命令。

### 执行客户端设置 (story-geth)

1. 在Mac OS X系统中，OS X binary文件尚未通过Story构建流程签名，因此可能需要手动解除隔离：

```bash
sudo xattr -rd com.apple.quarantine ./geth
```

2. 接下来，使用下方代码，运行 `geth`：

```bash
./geth --odyssey --syncmode full
```

* 目前，默认的 `snap` 节点同步模式仍在开发中。

#### 状态清除

如果遇到问题，并希望从初始状态加入网络，请运行下方代码：

```bash
rm -rf ${GETH_DATA_ROOT} && ./geth --odyssey --syncmode full
```

* Mac OS X: `rm -rf ~/Library/Story/geth/* && ./geth --odyssey --syncmode full` Mac OS X： `rm -rf ~/Library/Story/geth/* && ./geth --odyssey --syncmode full`
* Linux: `rm -rf ~/.story/geth/* && ./geth --odyssey --syncmode full` Linux的： `rm -rf ~/.story/geth/* && ./geth --odyssey --syncmode full`

#### 状态调试

如果你想在`geth`运行时检查其状态，可以通过其内置的IPC-RPC服务器进行通信，运行下方代码：

```bash
geth attach ${GETH_DATA_ROOT}/geth.ipc
```

* Mac OS X：
  * `geth attach ~/Library/Story/geth/odyssey/geth.ipc`
* Linux：
  * `geth attach ~/.story/geth/odyssey/geth.ipc`

这将连接到你的IPC服务器，你可以运行以下命令以查询相关信息：

* `eth.blockNumber` : 列出geth同步的最新区块——如果显示值为`undefined`，则连接或同步故障。
* `admin.peers` : 列出客户端连接的其他`geth`节点列表——如果列表为空，则连接或同步故障。
* `eth.syncing` : 如果geth正在同步，将返回`true`值，反之，则返回`false`值。

### 共识客户端设置 (story)


---

# 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://www.docszh.com/story-docs/network/guide/node-setup.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.
