# 使用 Aptos-core 源代码

1. 复制 Aptos 存储库。

   ```
   git clone <https://github.com/aptos-labs/aptos-core.git>
   ```

2. 将`cd`放入 `aptos-core` 目录。

   ```
   cd aptos-core
   ```

3. 运行`scripts/dev_setup.sh`脚本，如下所示。这将为您的开发人员环境做好准备。

   ```jsx
   ./scripts/dev_setup.sh
   ```

4. 更新当前的 shell 环境。

   ```jsx
   source ~/.cargo/env
   ```

   开发环境就绪后，现在可以开始设置验证器节点。

5. 使用 `git checkout --track origin/testnet` 签出 `testnet` 分支。

6. 为您的 Aptos 节点组成创建一个目录，并为您的节点选择一个用户名。例如

   ```javascript
   export WORKSPACE=testnet
   export USERNAME=alice
   mkdir ~/$WORKSPACE
   ```

   ```
   💡 安装APTOS CLI 在继续之前，请安装Aptos CLI 0.3.1：
   https://aptos.dev/cli-tools/aptos-cli-tool/install-aptos-cli
   ```

7. 在工作目录中生成密钥对（节点所有者、投票人、操作员密钥、共识密钥和网络密钥）。

   ```jsx
   aptos genesis generate-keys --output-dir ~/$WORKSPACE/keys
   ```

   这将创建4个关键文件在 `~/$WORKSPACE/keys` 目录下：

   * `public-keys.yaml`
   * `private-keys.yaml`
   * `validator-identity.yaml`,和
   * `validator-full-node-identity.yaml`.

   💡 **需要注意**：

   将您的私钥文件备份到安全的地方。这些关键文件对于您建立节点的所有权很重要。 **永远不要与任何人共享私钥。**

8. 配置验证器信息。您需要设置节点可以使用的静态 IP/DNS 地址（首选DNS），并确保网络/防火墙正确配置为接受外部连接。

   您需要这些信息才能稍后在 Aptos 社区网站上注册。

   &#x20;💡 **提示**

   `--full-node-host`  标志是可选的。

   ```jsx
   cd ~/$WORKSPACE
   aptos genesis set-validator-configuration \\
       --local-repository-dir ~/$WORKSPACE \\
       --username $USERNAME \\
       --owner-public-identity-file ~/$WORKSPACE/keys/public-keys.yaml \\
       --validator-host <Validator Node IP / DNS address>:<Port> \\
       --full-node-host <Full Node IP / DNS address>:<Port> \\
       --stake-amount 100000000000000

   # for example, with IP:

   aptos genesis set-validator-configuration \\
       --local-repository-dir ~/$WORKSPACE \\
       --username $USERNAME \\
       --owner-public-identity-file ~/$WORKSPACE/keys/public-keys.yaml \\
       --validator-host 35.232.235.205:6180 \\
       --full-node-host 34.135.169.144:6182 \\
       --stake-amount 100000000000000

   # For example, with DNS:

   aptos genesis set-validator-configuration \\
       --local-repository-dir ~/$WORKSPACE \\
       --username $USERNAME \\
       --owner-public-identity-file ~/$WORKSPACE/keys/public-keys.yaml \\
       --validator-host bot.aptosdev.com:6180 \\
       --full-node-host fn.bot.aptosdev.com:6182 \\
       --stake-amount 100000000000000
   ```

   这将创建2个 YAML 文件在 `~/$WORKSPACE/$USERNAME` 目录下： `owner.yaml` 和 `operator.yaml`.

9. 创建一个布局模板文件，该文件定义了 Aptos `validatorSet` 中的节点。

   ```
   aptos genesis generate-layout-template --output-file ~/$WORKSPACE/layout.yaml
   ```

   编辑 `layout.yaml`, 增加 `root_key`, 验证者节点用户名，和 `chain_id`:

   ```
   root_key: "D04470F43AB6AEAA4EB616B72128881EEF77346F2075FFE68E14BA7DEBD8095E"
   users: ["<username you specified from previous step>"]
   chain_id: 43
   allow_new_validators: false
   epoch_duration_secs: 7200
   is_test: true
   min_stake: 100000000000000
   min_voting_threshold: 100000000000000
   max_stake: 100000000000000000
   recurring_lockup_duration_secs: 86400
   required_proposer_stake: 100000000000000
   rewards_apy_percentage: 10
   voting_duration_secs: 43200
   voting_power_increase_limit: 20
   ```

   请确保使用与示例中所示相同的根公钥和相同的链ID，这些配置将在注册期间用于验证节点。

10. 构建 AptosFramework Move包并将其复制到 `~/$WORKSPACE` 目录中作为 `framework.mrb` 存储，如下所示：

    <pre><code><strong>cd ~/aptos-core
    </strong>cargo run --package framework -- release
    cp head.mrb ~/$WORKSPACE/framework.mrb
    </code></pre>

11. 编译 genesis blob 和路标

    ```
    aptos genesis generate-genesis --local-repository-dir ~/$WORKSPACE --output-dir ~/$WORKSPACE
    ```

    这将在您的工作目录下创建2个文件： `genesis.blob` 和 `waypoint.txt`.

12. 复制 `validator.yaml`, `fullnode.yaml` 文件到该目录下。

    ```
    mkdir ~/$WORKSPACE/config
    cp docker/compose/aptos-node/validator.yaml ~/$WORKSPACE/config/validator.yaml
    cp docker/compose/aptos-node/fullnode.yaml ~/$WORKSPACE/config/fullnode.yaml
    ```

    修改配置文件以更新数据目录、关键路径、成因文件路径、路标路径。用户必须具有对数据目录的写访问权限。

13. 总而言之，在您的工作目录（`~/$WORKSPACE`）中，您应该有一个文件列表：
    * `config` 文件夹，包括：
      * `validator.yaml` 验证者配置文件
      * `fullnode.yaml` 全节点配置文件
    * `keys` 文件，包括：
      * `public-keys.yaml`: 所有者帐户、共识和网络的公钥（来自步骤7）。
      * `private-keys.yaml`: 所有者帐户、共识和网络的私钥（来自步骤7）。
      * `validator-identity.yaml`: 用于设置验证器身份的私钥（来自步骤7）。
      * `validator-full-node-identity.yaml`: 用于设置验证器完整节点标识的私钥（来自步骤7）。
    * `username` 文件夹，包括：
      * `owner.yaml`: 定义所有者、操作员和投票人映射。在测试模式下，它们都是相同的帐户（来自步骤8）。
      * `operator.yaml`: 将用于验证者和全节点的节点信息（来自步骤8）。
    * `layout.yaml`: 布局文件包含根密钥、验证器用户和链ID的键值（来自步骤9）。
    * `framework.mrb`: AptosFramework Move下载包（来自步骤10）。
    * `waypoint.txt`: genesis交易的路标（来自步骤11）。
    * `genesis.blob` genesis二进制文件，包含关于框架、验证器集等的所有信息（来自步骤11）。

14. 通过运行以下命令启动本地验证器：

```
cargo run -p aptos-node --release -- -f ~/$WORKSPACE/config/validator.yaml
```

在另一个机器上运行全节点：

```
cargo run -p aptos-node --release -- -f ~/$WORKSPACE/config/fullnode.yaml
```

现在您已经成功地完成了在测试模式下的节点设置。您可以跳转到 Aptos 社区平台来进行注册。


---

# 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://gushi10546.gitbook.io/aptos-kai-fa-zhe-wen-dang/jie-dian/validators/shi-yong-aptoscore-yuan-dai-ma.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.
