# Windows

## 1. 安装 Docker

在运行节点之前，我们需要安装 Docker。 您可以从[这里](https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe)下载适用于 Windows 的 Docker Desktop。

下载完成后，您将在下载文件夹中找到可执行文件。

![Downloaded Docker](/files/r7WCjXHZOvcVyVMV3EYz)

打开 `Docker Desktop Installer.exe`，并开始安装过程。

安装完成后，Docker 会自动启动。

![Docker Installed](/files/GFJypsDR7hIew3I3dLeG)

## 2. 安装 WSL 2

Docker 需要安装额外的依赖项才能在 Windows 上运行 Linux 容器。

您将收到类似于以下通知的通知，单击提供的链接，将打开一个新的浏览器窗口，我们可以下载依赖项。

![WSL Notice](/files/oPuc30OCzQkRWNXkQrd9)

点击链接 "Download the latest package"

![Download WSL 2](/files/NHSsq4lVnsVB4yr048tt)

你可以在下载目录中找到可执行文件：

![WSL 2 Downloaded](/files/2dyOQhvAxJYA6jkwXscL)

点击可执行文件开始安装：

![Install WSL 2](/files/iQ8wyQSc2l7cM2CDK22J)

安装完成后你可以点击重启或 Restart。&#x20;

![Restart WSL 2](/files/4wUXrFr5GdS8dhaj1Hj7)

## 3. 启动 Docker Desktop

打开双击 Docker Desktop application you should see t应用程序，以下是启动中的截图：

![Docker Desktop App is starting](/files/GfbcKhMkmdQ9q9WmkNWQ)

当 Docker Desktop 启动成功后，黄色图标会变绿。

![Docker Desktop Started](/files/NRreCXRq0qKG5W2VDYBg)

## 4. 下载 Aptos 节点运行所需文件

### 4.1 新建 aptos-node 文件夹

您可以在 C 盘 或 D 盘下新建 aptos-node 文件夹。

{% hint style="info" %}
注意：

* 文件夹名称不要出现中文等特殊字符。
  {% endhint %}

### 4.2 下载节点文件

请将文件都下载到 aptos-node 目录下：&#x20;

* Docker 编排脚本：[docker-compose.yaml](https://raw.githubusercontent.com/jiangydev/aptos-node/main/docker-compose.yaml) （文件如下）

{% file src="/files/l1XljlYfFJ6rgPV0k3lN" %}

* 全节点配置文件：[public full node.yaml](https://raw.githubusercontent.com/jiangydev/aptos-node/main/public_full_node.yaml)（文件如下）

{% file src="/files/G3Vo0s3miQNgwQHucz9U" %}

* 创世区块文件：[genesis.blob](https://devnet.aptoslabs.com/genesis.blob) （文件可能会经常更新，所以请点击左侧链接下载最新）
* waypoint（可验证检查点）文件：[waypoint.txt](https://devnet.aptoslabs.com/waypoint.txt)（文件可能会经常更新，所以请点击左侧链接下载最新；如果没有自动下载，请在页面上 Ctrl + s 保存即会下载）

下载完成后：

![Download Aptos node files](/files/Bb54CtxzqB5SfVXVLf0K)

## 5. 创建静态身份

创建静态身份的目的是，每次启动都使用这个身份。

在文件夹内，地址栏中输入【powershell】，即可打开命令行界面：

![Open Powershell CLI](/files/qhV6xB9EqFLKShBvfckJ)

### 5.1 生成私钥、公钥和 Peer ID

在打开的命令行界面分别输入下面的命令生成私钥：

```
docker pull aptoslabs/tools:devnet
```

```powershell
sudo docker run --rm aptoslabs/tools:devnet sh -c "echo '开始生成私钥...' && aptos key generate --encoding hex --key-type x25519 --output-file /root/private-key.txt && echo '\n\n开始生成公钥和 Peer ID...' && aptos key extract-peer --encoding hex --private-key-file /root/private-key.txt --output-file /root/peer-info.yaml && echo '\n\n您的私钥：' && cat /root/private-key.txt && echo '\n\n您的公钥和 Peer ID 信息如下：' && cat /root/peer-info.yaml"
```

运行的结果如下：

```
开始生成私钥...
{
  "Result": "Success"
}


开始生成公钥和 Peer ID...
{
  "Result": {
    "3129d20a6ebb3a92be794db60416e6eb92c826d2733c391a4f8ee6d4e573b764": {
      "addresses": [],
      "keys": [
        "3129d20a6ebb3a92be794db60416e6eb92c826d2733c391a4f8ee6d4e573b764"
      ],
      "role": "Downstream"
    }
  }
}


您的私钥：
08500EDFBE94721A8D5614529AAC4E1AF427BB47498EC0E1A65815057137516A

您的公钥和 Peer ID 信息如下：
---
3129d20a6ebb3a92be794db60416e6eb92c826d2733c391a4f8ee6d4e573b764:
  addresses: []
  keys:
    - 3129d20a6ebb3a92be794db60416e6eb92c826d2733c391a4f8ee6d4e573b764
  role: Downstream
```

* `08500EDFBE94721A8D5614529AAC4E1AF427BB47498EC0E1A65815057137516A` 就是私钥；
* `3129d20a6ebb3a92be794db60416e6eb92c826d2733c391a4f8ee6d4e573b764` 是 Peer ID，也是公钥；

{% hint style="info" %}
⚠ 上面的私钥、公钥（Peer ID）都需要备份！
{% endhint %}

### 5.2 修改全节点的静态身份

打开 `public_full`\_`node.yaml` 文件【文件名上右击 -> 打开方式 -> 记事本】，并修改成如下信息：

{% hint style="info" %}
提醒：

* 请使用上一步自己生成的私钥和 Peer ID，以下示例仅供参考。
* 请妥善保存好私钥；（公钥和 Peer ID 是由私钥生成的）
* 一定要按如下格式修改。（下面有替换示例截图🙂）
  {% endhint %}

```yaml
base:
    # This is the location Aptos will store its database. It is backed by a dedicated docker volume
    # for persistence.
    data_dir: "/opt/aptos/data"
    role: "full_node"
    waypoint:
        # This is a checkpoint into the blockchain for added security.
        from_file: "/opt/aptos/etc/waypoint.txt"

execution:
    # Path to a genesis transaction. Note, this must be paired with a waypoint. If you update your
    # waypoint without a corresponding genesis, the file location should be an empty path.
    genesis_file_location: "/opt/aptos/etc/genesis.blob"

state_sync:
  state_sync_driver:
    enable_state_sync_v2: true

full_node_networks:
    - network_id: "public"
      discovery_method: "onchain"
      identity:
        type: "from_config"
        key: "这里换成自己生成的私钥"
        peer_id: "这里换成自己生成的PeerID"
      # The network must have a listen address to specify protocols. This runs it locally to
      # prevent remote, incoming connections.
      listen_address: "/ip4/0.0.0.0/tcp/6180"
      # Define the upstream peers to connect to
      seeds:
        bb14af025d226288a3488b4433cf5cb54d6a710365a2d95ac6ffbd9b9198a86a:
            addresses:
            - "/dns4/pfn0.node.devnet.aptoslabs.com/tcp/6182/noise-ik/bb14af025d226288a3488b4433cf5cb54d6a710365a2d95ac6ffbd9b9198a86a/handshake/0"
            role: "Upstream"
        7fe8523388084607cdf78ff40e3e717652173b436ae1809df4a5fcfc67f8fc61:
            addresses:
            - "/dns4/pfn1.node.devnet.aptoslabs.com/tcp/6182/noise-ik/7fe8523388084607cdf78ff40e3e717652173b436ae1809df4a5fcfc67f8fc61/handshake/0"
            role: "Upstream"
        f6b135a59591677afc98168791551a0a476222516fdc55869d2b649c614d965b:
            addresses:
            - "/dns4/pfn2.node.devnet.aptoslabs.com/tcp/6182/noise-ik/f6b135a59591677afc98168791551a0a476222516fdc55869d2b649c614d965b/handshake/0"
            role: "Upstream"

api:
    # This specifies your REST API endpoint. Intentionally on public so that Docker can export it.
    address: 0.0.0.0:8080

```

替换示例：

![](/files/wBR6J0eMSBiKUvNDdCRE)

## 6. 运行全节点

在前面的文件夹中，地址栏中输入【powershell】，打开命令行界面：

![Open Powershell CLI](/files/qhV6xB9EqFLKShBvfckJ)

在命令中分别输入如下命令：

```
docker-compose pull
```

```
docker-compose up -d
```

![Run aptos node](/files/rjFrf1b6IqJhrzAKoRms)

左侧是运行的结果，右侧是在 Docker Desktop 中看到运行中状态的节点。你可以在图形化界面中管理你的节点状态。

## 7. 检查节点

在浏览器中访问：<http://127.0.0.1:9101/metrics>

{% hint style="info" %}
确保节点是运行中，否则无法访问上面的地址！
{% endhint %}

### 7.1 查看 Peer ID

在页面搜索：peer

* Peer ID 要是上面自己填写的前缀；

![](/files/eJDjyhYpo25oDaQwphqC)

### 7.2 查看同步状态

在页面搜索：aptos\_state\_sync\_version

Aptos 网络看板可以查看当前区块高度（用于检查本地节点同步情况）：[https://status.devnet.aptos.dev](https://status.devnet.aptos.dev/)

## 8. 节点更新

{% hint style="info" %}
本节仅用于每周五的节点更新使用。
{% endhint %}

### 8.1 关闭节点

![](/files/0naa3o4WL3rNO6GcxetT)

### 8.2 删除数据文件

在【Volumes】中找到 node\_db 并点击删除。

![](/files/Sk3Ve9hOOdD0tG5bnBaT)

### 8.3 删除 `genesis.blob` 和 `waypoint.txt` 文件并重新下载

进入之前下载文件的目录，重新下载覆盖以下两个文件：

* 创世区块文件：[genesis.blob](https://devnet.aptoslabs.com/genesis.blob)&#x20;
* waypoint（可验证检查点）文件：[waypoint.txt](https://devnet.aptoslabs.com/waypoint.txt)

{% hint style="info" %}
注意：

* 2022年6月10日更新：<mark style="color:red;">本周必须更新</mark><mark style="color:red;">`public_full`</mark><mark style="color:red;">\_</mark><mark style="color:red;">`node.yaml`</mark> <mark style="color:red;"></mark><mark style="color:red;">文件</mark>。
  {% endhint %}

### 8.4 更新节点镜像

在更新文件的目录下进入命令行界面，并运行如下命令：

```
docker-compose pull
```

![](/files/aR4NfgCYwq6H7CZydO0o)

### 8.5 启动全节点

在上面的命令行界面中运行如下命令：

```
docker-compose up -d
```

![](/files/LperNvnxyt9q0NThYfh7)


---

# 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://wiki.aptos.movemove.org/jiao-cheng/kai-fa-wang-devnet/yun-xing-quan-jie-dian-she-qu-jiao-cheng/windows.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.
