Using Source Code
This is a step-by-step guide to deploy an Aptos validator and validator fullnode (VFN) using source code. Using this guide, the validator and VFN will be deployed on separate machines.
Deployment Steps
Section titled “Deployment Steps”-
Follow the steps in Building Aptos From Source to download the
aptos-core
repository and source code. -
Checkout the
mainnet
branch usinggit checkout --track origin/mainnet
. Note: if you want to deploy a validator and VFN on another network, use the appropriate branch name (e.g.,testnet
). -
Create a working directory for your Aptos nodes, and pick a username for your nodes, e.g.,
Terminal window export WORKSPACE=mainnetexport USERNAME=alicemkdir ~/$WORKSPACE -
Generate the key pairs for your nodes in your working directory. You can do this by running the following command with the Aptos CLI:
Terminal window aptos genesis generate-keys --output-dir ~/$WORKSPACE/keysThis will create 4 key files under
~/$WORKSPACE/keys
directory:public-keys.yaml
: This file contains all public keys for your validator and VFN, as well as your account address.private-keys.yaml
: This file contains all private keys for your validator and VFN.validator-identity.yaml
: This file contains the public and private keys for your validator, as well as your account address.validator-full-node-identity.yaml
: This file contains the public and private keys for your VFN, as well as your account address.
-
Next, you will need to set your validator configuration. This includes setting the validator and VFN host names, which may be IP addresses or DNS addresses.
You can set your validator configuration by running the following command with the Aptos CLI:
Terminal window # Replace <validator node IP / DNS address> and <Full Node IP / DNS address> below,# with the appropriate IP or DNS address for your nodes.cd ~/$WORKSPACEaptos 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, if you are using IP addresses: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# Otherwise, if you are using DNS addresses: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 100000000000000Configuring the validator will create two YAML files in the
~/$WORKSPACE/$USERNAME
directory:owner.yaml
andoperator.yaml
. These will be useful for connecting your nodes to the Aptos network (later). -
Download the following files by following the instructions on the Node Files pages. You will need to select the appropriate network (e.g.,
mainnet
,testnet
,devnet
) and download the following files:validator.yaml
fullnode.yaml
genesis.blob
waypoint.txt
-
Next, copy the
validator.yaml
andfullnode.yaml
template files (that were just downloaded) into the~/$WORKSPACE/config/
directory. This can be done by running the following commands:Terminal window mkdir ~/$WORKSPACE/configcp validator.yaml ~/$WORKSPACE/config/validator.yamlcp fullnode.yaml ~/$WORKSPACE/config/fullnode.yamlThese will be the primary configuration files for your validator and VFN, respectively.
-
Now, modify the
validator.yaml
andfullnode.yaml
template files to contain the appropriate information and working directories for your validator and VFN.For the
validator.yaml
file, you will need to modify the following fields:base.data_dir
: The directory where the blockchain data will be stored.base.waypoint
: The waypoint for the genesis transaction on the network you are connecting to.consensus.initial_safety_rules_config
: The waypoint for the genesis transaction on the network you are connecting to, as well as thevalidator-identity.yaml
file location.execution.genesis_file_location
: The genesis blob for the network you are connecting to.storage.rocksdb_configs.enable_storage_sharding
: Set totrue
.validator_network.identity
: Thevalidator-identity.yaml
file location.
For the
fullnode.yaml
file, you will need to modify the following fields:-
base.data_dir
: The directory where the blockchain data will be stored. -
base.waypoint
: The waypoint for the genesis transaction on the network you are connecting to. -
execution.genesis_file_location
: The genesis blob for the network you are connecting to. -
storage.rocksdb_configs.enable_storage_sharding
: Set totrue
. -
full_node_networks
: - Thepublic
network will need to be updated with thevalidator-full-node-identity.yaml
file location. - Thevfn
network will need to be updated with the correct IP address or DNS address of the validator. For example, if you are using IP addresses, you will need to update theaddresses
field as follows:---addresses:- "/ip4/100.100.100.100/tcp/6181/noise-ik/..." # Set the IP Address of the validatorOtherwise, if you are using DNS addresses, you will need to update the
addresses
field as follows:---addresses:- "/dns/example.com/tcp/6181/noise-ik/..." # Set the DNS Address of the validator
-
To recap, in your working directory (
~/$WORKSPACE
), you should have a list of files:config
folder containing:validator.yaml
: The validator config file.fullnode.yaml
: The VFN config file.
keys
folder containing:public-keys.yaml
: Public keys for both nodes.private-keys.yaml
: Private keys for both nodes.validator-identity.yaml
: Key and account information for the validator.validator-full-node-identity.yaml
: Key and account information for the VFN.
$username
folder containing:owner.yaml
: The owner, operator and voter mappings.operator.yaml
: Validator and VFN operator information.
waypoint.txt
: The waypoint for the genesis transaction on the network you are connecting to.genesis.blob
The genesis blob for the network you are connecting to.
-
Now that you have set up your configuration files, you can start your validator and VFN. To start your validator, run the following commands, with the paths assuming you are in the root of the
aptos-core
directory:Terminal window cargo cleancargo build -p aptos-node --releasesudo mv target/release/aptos-node /usr/local/binaptos-node -f ~/$WORKSPACE/config/validator.yamlTo start your VFN, run the following commands on a separate, dedicated VFN machine. You will need to download the
aptos-core
source code and build the binary on the VFN machine. Likewise, you will need to copy across the keys and configuration files from the validator machine.Start your VFN by running the following commands, with the paths assuming you are in the root of the
aptos-core
directory:Terminal window cargo cleancargo build -p aptos-node --releasesudo mv target/release/aptos-node /usr/local/binaptos-node -f ~/$WORKSPACE/config/fullnode.yaml
(Optional) Running as a Service
Section titled “(Optional) Running as a Service”If you want to run aptos-node
as a service, you can set it up to run as a service controlled by systemctl
.
This is optional, and can be done using the service template below. You will need to modify the template
to match your environment and configuration.
[Unit]Description=Aptos Node Service
[Service]User=nodeuserGroup=nodeuser
LimitNOFILE=500000
#Environment="RUST_LOG=error"WorkingDirectory=/home/nodeuser/aptos-coreExecStart=/usr/local/bin/aptos-node -f /home/nodeuser/aptos-mainnet/config/validator.yaml
Restart=on-failureRestartSec=3s
StandardOutput=journalStandardError=journalSyslogIdentifier=aptos-node
[Install]WantedBy=multi-user.target
Connecting to the Aptos Network
Section titled “Connecting to the Aptos Network”You have now completed setting up your validator and VFN using source code. Proceed to Connect Nodes for the next steps.