How to run a full node with Ansible on Polygon network
This tutorial guides you through starting and running a full node on the Polygon network using Ansible. Before starting, ensure that you have installed Ansible on your local machine with Python3.x and Go is not installed in your environment. You will also need to make sure that your VM or machine does not have any previous setups for Polygon Validator, Heimdall or Bor. The process of syncing the Heimdall and Bor services can take several days, but you can also use a maintained snapshot to reduce the sync time to a few hours. Follow the steps in the guide, including cloning the Polygon PoS Ansible repository and editing the inventory.yml file, to set up your full node
Minimum Hardware Configuration
This is the minimum hardware configuration required to setup a full node:
RAM: 16-32 GB
CPU: 4-8 core CPU (For AWS: t3.2xlarge)
Storage: 2.5TB to 5TB SSD (make sure it is extendable)
The minimum storage requirements will change over time as the network grows. It is recommended to use more than the minimum requirements to run a robust full node.
While we do not favor any operating system, more secure and stable Linux server distributions (like CentOS) should be preferred over desktop operating systems (like Mac OS and Windows).
Run a full node with Ansible
This tutorial guides you through starting and running a full node using Ansible.
Steps in this guide involve waiting for the Heimdall and Bor services to sync fully. This process takes several days to complete.
Alternatively, you can use a maintained snapshot, reducing the sync time to a few hours. For detailed instructions, see Snapshot Instructions for Heimdall and Bor.
For snapshot download links, see the Polygon Chains Snapshots page.
Install Ansible on your local machine with Python3.x. The setup will not work if you have Python2.x.
To install Ansible with Python 3.x, you can use pip. If you do not have pip on your machine, follow the steps outlined here. Run
pip3 install ansibleto install Ansible.
Check the Polygon PoS Ansible repository for requirements.
You will also need to ensure that Go is not installed in your environment. You will run into issues if you attempt to set up your full node through Ansible with Go installed as Ansible requires specific packages of Go to be installed.
You will also need to make sure that your VM / Machine does not have any previous setups for Polygon Validator or Heimdall or Bor. You will need to delete them as your setup will run into issues.
HEIMDALL SOURCE ENHANCEMENTS
The latest Heimdall version, v.0.3.0, contains a few enhancements. The delay time between the contract events of different validators has been increased to ensure that the mempool doesn’t get filled quickly in case of a burst of events that could hamper the chain’s progress.
Additionally, the data size has been restricted in state sync txs to 30Kb (when represented in bytes) and 60Kb (when defined as string). For example:
Data - "abcd1234" Length in string format - 8 Hex Byte representation - [171 205 18 52] Length in byte format - 4
Full node setup
Ensure you have access to the remote machine or VM on which the full node is being set up.
Navigate into the node-ansible folder:
inventory.ymlfile and insert your IP(s) in the
Check if the remote machine is reachable by running:
ansible sentry -m ping
To test if the correct machine is configured, run the following command:
# Mainnet: ansible-playbook playbooks/network.yml --extra-var="bor_version=v0.3.3 heimdall_version=v0.3.0 network=mainnet node_type=sentry" --list-hosts # Testnet: ansible-playbook playbooks/network.yml --extra-var="bor_version=v0.3.3 heimdall_version=v0.3.0 network=mumbai node_type=sentry" --list-hosts
- Next, set up the full node with this command:
# Mainnet: ansible-playbook playbooks/network.yml --extra-var="bor_version=v0.3.3 heimdall_version=v0.3.0 network=mainnet node_type=sentry" # Testnet: ansible-playbook playbooks/network.yml --extra-var="bor_version=v0.3.3 heimdall_version=v0.3.0 network=mumbai node_type=sentry"
- In case you run into any issues, delete and clean the whole setup using:
- Once you initiate the Ansible playbook, log in to the remote machine.
Heimdall seed nodes:
moniker=<enter unique identifier> # Mainnet: seeds="email@example.com:26656,firstname.lastname@example.org:26656,email@example.com:26656,firstname.lastname@example.org:26656,email@example.com:26656,firstname.lastname@example.org:26656,email@example.com:26656,firstname.lastname@example.org:26656,email@example.com:26656" # Testnet: seeds="firstname.lastname@example.org:26656,email@example.com:26656,firstname.lastname@example.org:26656"
# Mainnet: bootnode ["enode://email@example.com:30303,enode://firstname.lastname@example.org:30303","enode://email@example.com:30303","enode://firstname.lastname@example.org:30303"] # Testnet: bootnodes ["enode://email@example.com:30303","enode://firstname.lastname@example.org:30303"]
To check if Heimdall is synced
On the remote machine/VM, run
In the output,
catching_upvalue should be
Once Heimdall is synced, run
sudo service bor start
You have successfully set up a full node with Ansible.
If Bor presents an error of permission to data, run this command to make the Bor user the owner of the Bor files:
sudo chown bor /var/lib/bor
Logs can be managed by the
journalctl linux tool. Here is a tutorial for advanced usage: How To Use Journalctl to View and Manipulate Systemd Logs.
Check Heimdall node logs
journalctl -u heimdalld.service -f
Check Bor Rest-server logs
journalctl -u bor.service -f
Ports and Firewall Setup
Open ports 22, 26656 and 30303 to world (0.0.0.0/0) on sentry node firewall.
You can use VPN to restrict access for port 22 as per your requirement and security guidelines.