July 27, 2022

APTOS | FullNodes guide

This tutorial explains how to configure a public FullNode to connect to the Aptos devnet


An Aptos node is an entity of the Aptos ecosystem that tracks the state of the Aptos Blockchain. Clients interact with the blockchain via Aptos nodes. There are two types of nodes:

Each Aptos node comprises several logical components:

The Aptos-core software can be configured to run as a validator node or as a FullNode.

FullNodes can be run by anyone. FullNodes re-execute all transactions in the history of the Aptos Blockchain. FullNodes replicate the entire state of the blockchain by synchronizing with upstream participants, e.g., other FullNodes or validator nodes. To verify blockchain state, FullNodes receive the set of transactions and the accumulator hash root of the ledger signed by the validators. In addition, FullNodes accept transactions submitted by Aptos clients and forward them directly (or indirecly) to validator nodes. While FullNodes and validators share the same code, FullNodes do not participate in consensus.


Hardware requirements

We recommend the following hardware resources:

  • For running a production grade FullNode:
    • CPU: 4 cores (Intel Xeon Skylake or newer);
    • Memory: 8GiB RAM.
  • For running the FullNode for development or testing:
    • CPU: 2 cores;
    • Memory: 4GiB RAM.

Storage requirements

The amount of data stored by Aptos depends on the ledger history (length) of the blockchain and the number of on-chain states (e.g., accounts). These values depend on several factors, including: the age of the blockchain, the average transaction rate and the configuration of the ledger pruner.

TIP
Given that devnet is currently being reset on a weekly basis, we estimate that Aptos will not require more than several GBs of storage. See the #devnet-release channel on Aptos Discord.

Configuring a FullNode

You can configure a public FullNode in two ways:

  1. Using the aptos-core source code.
  2. Using Docker.

In this guide we will look at both options.


Using Aptos-core source code

1. Clone the Aptos repo.

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

2. cd into aptos-core directory.

cd aptos-core

3. Run the scripts/dev_setup.sh Bash script as shown below. This will prepare your developer environment.

./scripts/dev_setup.sh

4. Update your current shell environment.

source ~/.cargo/env

With your development environment ready, now you can start to setup your FullNode.

5. Checkout the devnet branch using git checkout --track origin/devnet.

6. Make sure your current working directory is aptos-core. Run cp config/src/config/test_data/public_full_node.yaml fullnode.yaml to create a copy of the fullnode config template. You will edit this file to ensure that your FullNode:

    • Contains the correct genesis blob that is published by the Aptos devnet.
    • Synchronizes correctly with the devnet, by using the checkpoint file waypoint.txt published by the devnet, and
    • Stores the devnet database at a location of your choice on your local machine.

7. Make sure your current working directory is aptos-core. The Aptos devnet publishes the genesis.blob and waypoint.txt files. Download them:

    • Click here genesis or run the below command on your terminal:
curl -O https://devnet.aptoslabs.com/genesis.blob
    • Click here waypoint and save the file, or run the below command on your terminal:
curl -O https://devnet.aptoslabs.com/waypoint.txt

8. Edit the fullnode.yaml file in your current working directory as follows. See the example YAML file in: docker/compose/public_full_node/public_full_node.yaml.

    • Specify the correct path to the waypoint.txt you just downloaded by editing the base.waypoint.from_file in the fullnode.yaml. By default it points to waypoint.txt in the current working directory. E.g.
base:
 waypoint:
  from_file: "./waypoint.txt"
    • For the genesis_file_location key, provide the full path to the genesis.blob file. For example:
genesis_file_location: "./genesis.blob"
    • For the data_dir key in the base list, specify the directory where on your local computer you want to store the devnet database. This can be anywhere on your computer. For example, you can create a directory my-full-node/data in your home directory and specify it as:
data_dir: "/path/to/my/homedir/my-full-node/data"

9. Start your local FullNode by running the below command:

cargo run -p aptos-node --release -- -f ./fullnode.yaml

You have now successfully configured and started running a FullNode connected to Aptos devnet.

NOTE This will build a release binary: aptos-core/target/release/aptos-node. The release binaries tend to be substantially faster than debug binaries but lack debugging information useful for development. To build a debug binary, omit the --release flag.

Using Docker

This section describes how to configure and run your FullNode using Docker.

1. Install Docker including Docker-Compose.

2. Create a directory for your local public FullNode, and cd into it.

3. Download the following YAML configuration files:

wget https://raw.githubusercontent.com/aptos-labs/aptos-core/main/docker/compose/public_full_node/docker-compose.yaml

and

wget https://raw.githubusercontent.com/aptos-labs/aptos-core/main/docker/compose/public_full_node/public_full_node.yaml

4. The Aptos devnet publishes the genesis.blob and waypoint.txt files. Download them:

    • Click on genesis or run the below command on your terminal:
wget https://devnet.aptoslabs.com/genesis.blob
    • Click on waypoint and save the file, or run the below command on your terminal:
wget https://devnet.aptoslabs.com/waypoint.txt

5. Start Docker Compose by running the command:

docker-compose up

Verify the correctness of your FullNode

Verify initial synchronization

During the initial synchronization of your FullNode, there may be a lot of data to transfer. You can monitor the progress by querying the metrics port to see what version your node is currently synced to. Run the following command to see the current synced version of your node:

curl 127.0.0.1:9101/metrics 2> /dev/null | grep "aptos_state_sync_version{.*\"synced\"}" | awk '{print $2}'

The command will output the current synced version of your node. For example:

$ 4405197

Compare the synced version returned by this command (e.g., 4405197) with the Current Version (latest) shown on the Aptos status page. If your node is catching up to the current version, it is synchronizing correctly.

NOTE
It is fine if the status page differs by a few versions, as the status page does not automatically refresh.

Verify outbound network connections (Optional)

Optionally, you can check the output network connections. The number of outbound network connections should be more than 0. Run the following command:

curl 127.0.0.1:9101/metrics 2> /dev/null | grep "aptos_connections{direction=\"outbound\""

The above command will output the number of outbound network connections for your node. For example:

$ curl 127.0.0.1:9101/metrics 2> /dev/null | grep "aptos_connections{direction=\"outbound\""aptos_connections{direction="outbound",network_id="Public",peer_id="aabd651f",role_type="full_node"} 3

If the number of outbound connections returned is 0, then it means your node cannot connect to the Aptos blockchain. If this happens to you, follow these steps to resolve the issue:

  1. Update your node to the latest release by following the update instructions.
  2. Remove any seed peers you may have added to your public_full_node.yaml configuration file. The seeds may be preventing you from connecting to the network. Seed peers are discussed in the Add upstream seed peers section.

Examine Docker ledger size (Optional)

The blockchain ledger's volume for Aptos devnet can be monitored by entering the Docker container ID and checking the size. This will allow you to see how much storage the blockchain ledger is currently consuming.

  • First, run docker container ls on your terminal and copy the NAME field output. This will be a string similar to public_full_node_fullnode_1.
  • Next, run these commands to check the storage size consumed by the ledger, using the NAME field you copied over in place of public_full_node_fullnode_1:
# Obtain the container ID:
id=$(docker container ls | grep public_full_node_fullnode_1 | grep -oE "^[0-9a-zA-Z]+")
# Enter the container:
docker exec -it $id /bin/bash
# Observe the volume (ledger) size:
du -cs -BM /opt/aptos/data

Add upstream seed peers

TIP
You may see NoAvailablePeers in your node's error messages. This is normal when the node is first starting. Wait for the node to run for a few minutes to see if it connects to peers. If not, follow the below steps:

Devnet validator FullNodes will only accept a maximum of connections. If Aptos devnet is experiencing high network connection volume, your FullNode might not able to connect and you may see NoAvailablePeers continuously in your node's error messages. If this happens, manually add peer addresses in the seeds key in public_full_node.yaml, the FullNode configuration file. This will then connect your FullNode to the specified seed peer.

See below for a few seed peer addresses you can use in your public_full_node.yaml file.

TIP
You can also use the FullNode addresses provided by the Aptos community. Anyone already running a FullNode can provide their address for you to connect. See the channel #advertise-full-nodes in Aptos Discord.

Add these to your public_full_node.yaml configuration file under your discovery_method, as shown in the below example:

...
full_node_networks:
    - discovery_method: "onchain"
     # The network must have a listen address to specify protocols. This runs it locally to
     # prevent remote, incoming connections.
     listen_address: ...
     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"

Aptos links

Website | Twitter | Discord | GitHub | Medium | LinkedIn

Ambassadors School links

Website | Twitter | Discord | Telegram | GitHub