Skip to content

Instantly share code, notes, and snippets.

@Validatrium
Last active June 16, 2022 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Validatrium/afc7ad51427b8c1b999ffe07b7e5a3df to your computer and use it in GitHub Desktop.
Save Validatrium/afc7ad51427b8c1b999ffe07b7e5a3df to your computer and use it in GitHub Desktop.
Run Aptos Devnet on ubuntu 20.04

Info

about

steps

  • Install dependencies and binaries
  • Configure your node
  • Configure public identity
  • Run node
  • Setup monitoring tool

links

Setup

Install dependencies and binaries

# upgrade ubuntu 
apt update && apt upgrade -y

# install yq:
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod a+x /usr/local/bin/yq

# clone aptos repo
git clone https://github.com/aptos-labs/aptos-core.git
cd aptos-core
# install dependencies
./scripts/dev_setup.sh

# compile binaries
source ~/.cargo/env
git checkout --track origin/devnet
cargo build -p aptos-node --release 
cargo build -p aptos-operational-tool --release
cp -t /usr/local/bin target/release/aptos-node target/release/aptos-operational-tool

# verify everything is installed
aptos-node --version
aptos-operational-tool --version

Configure your node

useradd -mU aptos -G sudo -s /usr/bin/bash
passwd aptos # set sudo password for aptos
# copy node config file
cp config/src/config/test_data/public_full_node.yaml /home/aptos/
chown aptos:aptos /home/aptos/public_full_node.yaml
# login as user
su - aptos


mkdir config && cd config 
mv ../public_full_node.yaml .
# download genesis
wget https://devnet.aptoslabs.com/genesis.blob
# download waypoint.txt
wget https://devnet.aptoslabs.com/waypoint.txt


# configure config: 
# set home directory to $HOME/.aptos
sed -i.bak "s|data_dir:.*|data_dir: \"$HOME/.aptos\"|" public_full_node.yaml 
# set geensis.blob location
sed -i.bak "s|genesis_file_.*|genesis_file_location: \"$HOME/config/genesis.blob\"|" public_full_node.yaml
# set waypoint.txt location
sed -i.bak "s|from_file:.*|from_file: \"$HOME/config/waypoint.txt\"|" public_full_node.yaml

Configure public identity:

# make sure you're in config directory: 
cd $HOME/config

mkdir keystore
# generate private key: 
aptos-operational-tool generate-key --encoding hex --key-type x25519 --key-file keystore/private.key
# retrieve peer identity
aptos-operational-tool extract-peer-from-file --encoding hex --key-file keystore/private.key --output-file keystore/peer-info.yaml

# save values to variables:
PEER_ID=$(sed -n 2p keystore/peer-info.yaml | sed 's/.$//')
PRIVATE_KEY=$(cat keystore/private.key)

# set static identity
yq e -i '.full_node_networks[] +=  { "identity": {"type": "from_config", "key": "'$PRIVATE_KEY'", "peer_id": "'$PEER_ID'"} }' public_full_node.yaml
# allow others to connect
yq e -i '.full_node_networks[].listen_address="/ip4/0.0.0.0/tcp/6180"' public_full_node.yaml

Run node

You can run it in background using screen or tmux for example:

aptos-node -f $HOME/config/public_full_node.yaml

Or run this as a systemd service

sudo tee <<EOF >/dev/null /etc/systemd/system/aptosd.service
[Unit]
Description=Aptos Full Node
After=network-online.target
[Service]
User=$USER
ExecStart=$(which aptos-node) -f $HOME/config/public_full_node.yaml
Restart=on-failure
RestartSec=3
LimitNOFILE=4096
[Install]
WantedBy=multi-user.target
EOF

sudo systemctl enable aptosd
sudo systemctl start aptosd

MONITORING

Notifications you will recieve with this config

  • free disk space is less than 20% and 10% - (low disk space notification)
  • height is not changing - (network connection error notification)
  • node proccess is not running - (node has been turned off)
  • node hasn't peers - (no peers - no sync. It's important)
  • Metrics port are not availabel - (just make sure you are geting metrics )

Required:

  1. root account on server
  2. telegram bot token .You can follow this instruction
  3. Reciever chat_id. Follow this guide to get your telegram id:
cd /root
apt install monit -y

# clone our repository: 
git clone https://github.com/Validatrium/valmonit.git

# enable monitoring in monit configuration: 
echo "
include /root/valmonit/conf/aptos-devnet/*
include /root/valmonit/conf/system
" >> /etc/monit/monitrc

# set your telegram.conf
cd $HOME/valmonit
cp telegram.conf.example telegram.conf
# enter your "telegram-id" and "bot-token"
nano telegram.conf

# verify that you can get notifications: 
./bin/sendtelegram -m "hi there!" -c ./telegram.conf

# by default it's monitor metrics-port/9101
# if you run on other port you have to change it in: 
nano sh/aptos/1rpc-conf.sh

# you can enable web interface for your monitoring tool:
# but it's not actually required
cat <<EOF >> /etc/monit/monitrc
set httpd port 2812 and     # run on port 2812
  use      address 0.0.0.0  # run on internet interface 
  allow    * 		  	    # allow everyone connetc
  allow    admin:monit 	    # user:password pair
EOF

# restart monitoring tool 
systemctl restart monit

Tutorial created by Validatrium (more info on our projects at validatrium.com)

If you have any additional questions regarding this tutorial, please join Agoric official discord channel and tag Validatrium members.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment