Aptos AIT2 Validator Install Guide
First Published: July 1st, 2022
AIT2 is complete and closed down.
Please look at our guide for AIT3.
This is a quick guide for setting up a validator on the Second Aptos Incentivized Testnet (AIT-2). We will be compiling from source on Ubuntu 20.04.
A Testnet on any blockchain can be a very fluid situation and code, processes, and techniques can rapidly evolve. We will take steps to keep this guide updated with critical changes, however we can not promise that this will be up to date at all times. Furthermore, once AIT-2 is complete, this guide will likely be irrelevant. Please leave comments if you have questions!
Prerequisites
We strongly recommend that you run your node from a cloud provider or from a data center. Under no circumstances should you attempt to run a node from your home. The vast majority of homes do not have redundant power and internet connectivity, which means that it is likely that your node will be disconnected from the network at some point in time and you will not earn rewards.
A Quick Note on Cloud Providers
Generally speaking the major cloud providers such as AWS, Google (GCP), and Azure are heavily used by validators across the entire cryptoverse. Feel free to use a major provider, but in the interest of decentralization we ask you to consider a mid-tier cloud provider such as VULTR, OVH, Contabo, Digital Ocean, Linode, or Hetzner.
Hardware Requirements
As of the time of this writing, the hardware requirements for AIT-2 are quite small. Please check the official documentation for the most up to date information.
- CPU: 4 cores (Intel Xeon Skylake or newer).
- Memory: 8GiB RAM.
- 300GB SSD
Operating System
This guide has been tested on Ubuntu 20.04 and does work. Please be aware that as of the time of this writing, the rust compiler will break if you run it from Ubuntu 22.04. The Aptos team is aware and is diagnosing.
Initial Setup
Once you have logged into your Ubuntu 20.04 virtual server as root, the first step is to update your OS and install two packages: git and fail2ban.
sudo apt-get update -y && sudo apt-get upgrade -y && sudo apt-get install git -y && sudo apt-get install fail2ban -y
You will see some purple screens pop up every now again. Just press the ENTER
key.
Now we need to open your firewall so that the node can pass health checks. For this walkthrough we are using UFW (Uncomplicated FireWall). Press Y
when prompted to restart the firewall.
sudo ufw allow proto tcp from any to any port 6180
sudo ufw allow proto tcp from any to any port 8080
sudo ufw allow proto tcp from any to any port 9101
sudo ufw enable
Now you need to create a user that you will run Aptos from. It is extremely unwise to run your node under the root user. For this guide we will create a user called aptosnode. Please feel free to change the username to whatever you like. Just be sure to update the username throughout this process.
First create the user. You will be prompted to create a complex password. Be sure to save this password, you will need it regularly.
adduser aptosnode
Now we grant some user permissions and do a little housekeeping
usermod -aG sudo aptosnode
chown -R aptosnode:aptosnode /home/aptosnode/
rsync --archive --chown=aptosnode:aptosnode ~/.ssh /home/aptosnode
Now open a new terminal and log in to your server as aptosnode. DO NOT CLOSE your original terminal. If you are unable to log in as aptosnode, you made a mistake in the previous steps. You can correct your mistake in the first terminal session.
Compile Aptos
Now that you are logged in as aptosnode, the next step is to download the Aptos source code and compile it. This process does take a long time, be patient.
Clone the Aptos code repository on to your server and then change directory into the aptos-core folder.
cd ~
git clone https://github.com/aptos-labs/aptos-core.git
cd aptos-core
Now run the very helpful setup script that the Aptos team built for us. This script will take about 30 minutes to complete.
./scripts/dev_setup.sh
Now set the cargo environment variable and then check out the testnet branch.
source ~/.cargo/envgit checkout --track origin/testnet
The next step is to create the workspace folder
export WORKSPACE=testnet
mkdir ~/$WORKSPACE
Now we will generate the keys. This process will take some time as well.
cargo run --release -p aptos -- genesis generate-keys --output-dir ~/$WORKSPACE
Now you need to set the validator configuration. You will need to think of a name for your node and get the IP address of your virtual server. Replace your node name and your IP in the last two lines of the command below and then run it.
cargo run --release -p aptos -- genesis set-validator-configuration \
--keys-dir ~/$WORKSPACE --local-repository-dir ~/$WORKSPACE \
--username yourNodeName \
--validator-host your.server.ip.address:6180
For example, if you decided that your node was to be l33tNodes and your IP address is 192.168.0.66 then you would run the following command:
----EXAMPLE COMMAND! DO NOT ACTUALLY RUN THIS!----
cargo run --release -p aptos -- genesis set-validator-configuration \
--keys-dir ~/$WORKSPACE --local-repository-dir ~/$WORKSPACE \
--username l33tNodes \
--validator-host 192.168.0.66:6180
Now create the layout.yaml
file by opening it in nano
sudo nano ~/$WORKSPACE/layout.yaml
Paste the following into the layout.yaml
file and then update your node name to match the name you used in the previous step.
---
root_key: "F22409A93D1CD12D2FC92B5F8EB84CDCD24C348E32B3E7A720F3D2E288E63394"
users:
- "<username you specified from previous step>"
chain_id: 40
min_stake: 0
max_stake: 100000
min_lockup_duration_secs: 0
max_lockup_duration_secs: 2592000
epoch_duration_secs: 86400
initial_lockup_timestamp: 1656615600
min_price_per_gas_unit: 1
allow_new_validators: true
for example, if your node was named l33tNodes you would paste the following into the layout.yaml
file
--- EXAMPLE! DO NOT ACTUALLY USE THIS!!! ---
root_key: "F22409A93D1CD12D2FC92B5F8EB84CDCD24C348E32B3E7A720F3D2E288E63394"
users:
- "l33tNodes"
chain_id: 40
min_stake: 0
max_stake: 100000
min_lockup_duration_secs: 0
max_lockup_duration_secs: 2592000
epoch_duration_secs: 86400
initial_lockup_timestamp: 1656615600
min_price_per_gas_unit: 1
allow_new_validators: true
Once you have pasted the text, save and exit by pressing the following on your keyboard. CTL + X
, Y
, ENTER
Now compile the Aptos Framework. This will take some time as well.
cargo run --release --package framework -- --package aptos-framework --output current
Create the framework folder
mkdir ~/$WORKSPACE/framework
Now move the framework modules that you compiled into the new framework folder that you just created.
mv aptos-framework/releases/artifacts/current/build/**/bytecode_modules/*.mv ~/$WORKSPACE/framework/
mv aptos-framework/releases/artifacts/current/build/**/bytecode_modules/dependencies/**/*.mv ~/$WORKSPACE/framework/
Generate the genesis blob. This takes time too!
cargo run --release -p aptos -- genesis generate-genesis --local-repository-dir ~/$WORKSPACE --output-dir ~/$WORKSPACE
Create the validator config folder
mkdir ~/$WORKSPACE/config
Copy the config templates over to the config folder
cp docker/compose/aptos-node/validator.yaml ~/$WORKSPACE/validator.yaml
cp docker/compose/aptos-node/fullnode.yaml ~/$WORKSPACE/fullnode.yaml
Now we need to edit the validator.yaml
file
sudo nano ~/$WORKSPACE/validator.yaml
This part can be tricky. Go slow and be careful! Any typos here will quickly turn into a nightmare. If you feel like you have messed this file up so bad that you need to restart, do not panic. Just exit nano and run this command to copy over a fresh validator.yaml
file: cp docker/compose/aptos-node/validator.yaml ~/$WORKSPACE/validator.yaml
We are assuming that you are using the aptosnode
username. If you are not, remember to change the username. Just replace the word aptosnode
with your username.
You need to change the directory references in the validator.yaml
file. There are four sections that you need to change - base:
, consensus:
, execution
:, and validator_network:
You should not change the other sections.
Here is an example of what the validator.yaml
should look like. You can copy and paste this.
base:
role: "validator"
data_dir: "/home/aptosnode/testnet/data"
waypoint:
from_file: "/home/aptosnode/testnet/waypoint.txt"consensus:
safety_rules:
service:
type: "local"
backend:
type: "on_disk_storage"
path: /home/aptosnode/testnet/data/secure-data.json
namespace: ~
initial_safety_rules_config:
from_file:
waypoint:
from_file: /home/aptosnode/testnet/waypoint.txt
identity_blob_path: /home/aptosnode/testnet/validator-identity.yaml
quorum_store_poll_count: 1execution:
genesis_file_location: "/home/aptosnode/testnet/genesis.blob"
concurrency_level: 4validator_network:
discovery_method: "onchain"
mutual_authentication: true
identity:
type: "from_file"
path: /home/aptosnode/testnet/validator-identity.yamlfull_node_networks:
- network_id:
private: "vfn"
listen_address: "/ip4/0.0.0.0/tcp/6181"
identity:
type: "from_config"
key: "b0f405a3e75516763c43a2ae1d70423699f34cd68fa9f8c6bb2d67aa87d0af69"
peer_id: "00000000000000000000000000000000d58bc7bb154b38039bc9096ce04e1237"api:
enabled: true
address: "0.0.0.0:8080"
Now run your validator and see if you set it up correctly. If the node crashes and exits out to the prompt, you made a mistake somewhere in this guide. If you see an endless stream of text on your screen and it does not exit to the command prompt, then your node is running.
The initial compile process will take time, please be patient.
cargo run -p aptos-node --release -- -f ~/$WORKSPACE/validator.yaml
Once your node is running, press CTL + C
to shut down Aptos.
Set up Aptos as a Service
This is a critical step, do not skip this.
This section will show you how to run Aptos as a service. This will run Aptos in the background which will enable you to log out of your server without halting your node. Additionally, the service will automatically launch Aptos after a reboot. This is very helpful!
First, we need to build the Aptos binary. It will take less than 1 second to do this.
cd ~/aptos-core
cargo build -p aptos-node --release
Now build the service file.
sudo nano /etc/systemd/system/aptosd.service
Paste the following in the file. Make sure to replace REPLACE_WITH_YOUR_USERNAME
with the linux username that you are running the service under.
[Unit]
Description=Aptos Daemon
After=network-online.target[Service]
User=REPLACE_WITH_YOUR_USERNAME
ExecStart=/home/REPLACE_WITH_YOUR_USERNAME/aptos-core/target/release/aptos-node --config /home/REPLACE_WITH_YOUR_USERNAME/testnet/validator.yaml
Restart=always
RestartSec=5
LimitNOFILE=infinity[Install]
WantedBy=multi-user.target
Restart systemctl
and then launch the service.
sudo -S systemctl daemon-reload
sudo -S systemctl enable aptosd
sudo -S systemctl start aptosd
Now Aptos will be running in the background as a service. At any point in time you can jump into the logs and see what is happening in Aptos with this command
sudo journalctl -f -u aptosd
You can exit out of this screen by pressing CTL + C
You can stop the Aptos service with
sudo -S systemctl stop aptosd
That is it! Enjoy your new node and happy staking!!! 🥩🥩🥩