# Aptos 第三次激励测试网搭建

By [Aczddd](https://paragraph.com/@aczddd) · 2022-08-21

---

前置准备
====

1.  需要有 Discord 账号并且已经加入 Aptos
    
2.  [https://aptoslabs.com/incentivized-testnet](https://aptoslabs.com/incentivized-testnet) 注册账号
    
3.  [https://aptos.dev/guides/install-petra-wallet-extension/](https://aptos.dev/guides/install-petra-wallet-extension/) 根据该教程安装钱包扩展
    
4.  购买服务器(可以用aws/google cloud这些比较贵，还有一些小厂的比如vultr之类的会稍微便宜一些)，选择ubuntu 20.04 amd64(大于20.04也可以，但我是用的ubuntu20.04)
    
    配置为: 8vCpu 32G内存 300G存储
    

部署验证节点
======

以下步骤全部使用root用户执行

### 格式化磁盘

    mkdir -p /opt/aptos
    mkdir -p /var/lib/docker
    mkfs.ext4 /dev/xxxx
    mount /dev/xxx /opt
    echo '/dev/xxxx        /var/lib/docker   ext4 defaults,noatime  0  0' >> /dev/fstab
    

*   把磁盘挂载到docker数据目录，后续aptos使用了docker volume
    

### 安装docker、docker-compose

    sudo apt-get install -y software-properties-common unzip
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg|sudo apt-key add -
    sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    apt install docker-ce
    curl -L "https://github.com/docker/compose/releases/download/1.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose && sudo chmod +x /usr/bin/docker-compose
    

*   /dev/xxxx 是你购买服务器添加的磁盘，每个云厂商名称不太固定，将磁盘挂载到/opt下
    
*   后续会把Aptos相关文件都放到/opt下
    

### 安装Cli

    wget https://github.com/aptos-labs/aptos-core/releases/download/aptos-cli-v0.3.1/aptos-cli-0.3.1-Ubuntu-x86_64.zip
    unzip aptos-cli-0.3.1-Ubuntu-x86_64.zip
    chmod +x aptos && mv aptos /usr/bin && source ~/.bashrc
    

### 生成docker-compose.yml validator.yaml

    cd /opt/aptos
    wget https://raw.githubusercontent.com/aptos-labs/aptos-core/main/docker/compose/aptos-node/docker-compose.yaml
    wget https://raw.githubusercontent.com/aptos-labs/aptos-core/main/docker/compose/aptos-node/validator.yaml
    

*   如果wget下载较慢，使用vpn直接访问wget后面网站，把内容复制到docker-compose.yml和validator.yaml
    

### 生成密钥

    aptos genesis generate-keys --output-dir /opt/aptos/keys
    

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

使用 ls /opt/aptos 检查是否生成以上4个文件

### 配置验证器信息

    cd /opt/aptos
    aptos genesis set-validator-configuration \
        --local-repository-dir ./ \
        --username $USERNAME \
        --owner-public-identity-file ~/$WORKSPACE/keys/public-keys.yaml \
        --validator-host <修改为你暴露的公网ip:port/dns ip:port> \
        --stake-amount 100000000000000
    

*   \--full-node-host <Full Node IP / DNS address>: 只搭建验证节点，去掉full node信息
    
*   示例配置
    
        # 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 \
            --stake-amount 100000000000000
        
        # For example, with DNS:
        
        aptos genesis set-validator-configuration \
            --local-repository-dir ~/$WORKSPACE \
            --username $USERNAME \
            --owner-public-identity-file ./keys/public-keys.yaml \
            --validator-host bot.aptosdev.com:6180 \
            --stake-amount 100000000000000
        
    
    ### 创建布局模板
    
        aptos genesis generate-layout-template --output-file /opt/aptos/layout.yaml
        
    
    修改layout.yaml users，如下
    
        cat /opt/aptos/layout.yaml
        ---
        root_key: D04470F43AB6AEAA4EB616B72128881EEF77346F2075FFE68E14BA7DEBD8095E
        users: ["root"]
        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
        
    
    ### 下载AptosFramework Move包
    
        wget https://github.com/aptos-labs/aptos-core/releases/download/aptos-framework-v0.3.0/framework.mrb -P /opt/aptos
        
    
    ### 编译 genesis blob 和 waypoint
    
        aptos genesis generate-genesis --local-repository-dir /opt/aptos --output-dir /opt/aptos
        
    
    ### 启动验证节点
    
        docker-compose -f /opt/aptos/docker-compose.yaml up -d
        
    
    完成其余步骤
    ======
    
    [https://aptoslabs.com/it3](https://aptoslabs.com/it3) 到这里将剩余步骤完成
    
    第四部注册节点时填写的key可以在 /opt/aptos/keys/public-keys.yaml 找到
    
    *   OWNER KEY: the first wallet public key. From Settings -> Credentials
        
    *   CONSENSUS KEY: consensus\_public\_key from `public-keys.yaml`
        
    *   CONSENSUS POP: consensus\_proof\_of\_possession from `public-keys.yaml`
        
    *   ACCOUNT KEY: account\_public\_key from `public-keys.yaml`
        
    *   VALIDATOR NETWORK KEY: validator\_network\_public\_key from `public-keys.yaml`
        
    
    ![](https://storage.googleapis.com/papyrus_images/1953d3f5a9164b42059f2f0fca263e060bb46293f50b33904b5ec0ca29214fdb.png)
    
    ![](https://storage.googleapis.com/papyrus_images/5cfc3c2bd097fe4d4b81d729b9fb6637aef0848c32887f19cecf4b81c6a9713b.png)
    
    参考链接
    ====
    
    • [https://aptos.dev/nodes/validator-node/run-validator-node-using-docker](https://aptos.dev/nodes/validator-node/run-validator-node-using-docker)
    
    有问题可以入群沟通，看到会解答
    
    ![](https://storage.googleapis.com/papyrus_images/dd9bfac6b87669e00a084823b683e498ab44cfa0e4f60a3305f32445ed6b1f57.jpg)

---

*Originally published on [Aczddd](https://paragraph.com/@aczddd/aptos)*
