How to Deploy a Polygon Node on Linux

How to Deploy a Polygon Node on Linux
How to Deploy a Polygon Node

Deploying a Polygon node on Linux may seem daunting, but fear not. With our step-by-step instructions, you'll gain valuable insights into node requirements and how to set up a node to support the network.

Polygon Node: An Overview

Polygon: A Brief Background

The most effective approach to fostering a dynamic ecosystem is through collaborative efforts. Polygon, formerly recognized as Matic Network, emerged with this principle.

Setting eyes on the overall user experience and dApps' development, the project aims to address the scalability challenges that impede blockchain adoption. Polygon empowers users with faster, cost-effective transactions and heightened scalability. Its position within the cryptocurrency landscape undoubtedly remains rock solid.

What is a Polygon node?

Before learning about Polygon nodes, let's first browse the Polygon's architecture. Polygon has a unique three-layer architecture, with each layer taking a specific responsibility:

  • Ethereum layer: The base layer consists of smart contracts on the Ethereum mainnet. Its purposes are to enable staking and checkpoint storage and support future interoperability.
  • Heimdall layer: The Proof-of-Stake layer runs in parallel with the base layer. Heimdall nodes validate blocks, generate checkpoints with Merkle roots, and publish them to Ethereum, providing finality and proof of burn. Validators act as block producers and commit checkpoints based on their stake ratio.
  • Bor Layer: Lastly, we have the Bor layer. This layer is made up of special nodes called Bor nodes. Bor nodes take all the transactions in the network and put them together into blocks. They work closely with Heimdall nodes to ensure the blocks are valid and secure.

Running a full node on Polygon is commonly known as running both Heimdall and Bor nodes. So what is a full node?

According to Polygon Wiki, 'a full node is a fully synced sentry node running both Heimdall and Bor.' Full nodes are responsible for storing the entire history of the Polygon blockchain. This includes all transactions, blocks, and contract states. Full nodes are used by validators to verify transactions and blocks and by users to access historical data.

There are also sentry nodes. These nodes are a type of full node responsible for downloading data from other nodes on the network and propagating that data to other sentry nodes.

Validator and archive nodes are also part of the Polygon network but are not our focus in this article.

Polygon Full Node Requirements

For both the Sentry node and Validator node in the Polygon network, it is essential to meet the system requirements. Please note that the Sentry node and Validator node should always be run on separate machines.

Minimum Requirements:

  • RAM: 32 GB
  • CPU: 8-core
  • Storage: 2.5 TB SSD

Recommended Requirements:

  • RAM: 64 GB
  • CPU: 16-core
  • Storage: 5 TB SSD
  • Bandwidth: 1 Gbit/s

Please ensure that your setup meets the minimum requirements to run the nodes. However, meeting the recommended requirements ensures future-proofing. There are no upper limits for future-proofing your nodes.

For Amazon Web Services (AWS) users, the equivalent instances are:

Minimum Requirements:

  • Sentry Node: c5.2xlarge
  • Validator Node: c5.4xlarge

Recommended Requirements:

  • Instance: m5d.4xlarge

For OVH users, the equivalent instance for the recommended requirements is infra-3.

Keep in mind that network usage may involve transferring approximately 3-5 TB of data per month.

By meeting these requirements, you can optimize the performance and reliability of your Polygon nodes, enabling seamless participation in the network.

How to Set Up a Polygon Node

Set up Binaries

  • Prepare the machine

Before deploying a Polygon node, it is necessary to ensure the machine is ready for installation. Start by installing the 'build-essential' package required for the full node. Use the following commands to update the system and install the package:

sudo apt-get update

sudo apt-get install build-essential

  • Install Heimdall and Bor binaries

It is crucial to install and run both binaries in the correct order for the node to function properly.

To install Heimdall, run the following command, replacing <heimdall_version>, <network_type>, and <node_type> with the appropriate values:

curl -L | bash -s -- <heimdall_version> <network_type> <node_type>

For example, to install Heimdall version 0.3.4 for the mainnet and as a sentry node, use:

curl -L | bash -s -- v0.3.4 mainnet sentry

Verify the installation by checking the Heimdall version:

heimdalld version --long

Next, install Bor by running the following command, replacing <bor_version>, <network_type>, and <node_type> with the appropriate values:

curl -L | bash -s -- <bor_version> <network_type> <node_type>

For example, to install Bor version 0.3.0 for the mainnet and as a sentry node, use:

curl -L | bash -s -- v0.3.0 mainnet sentry

Verify the installation by checking the Bor version:

bor version

  • Configure bor seeds (mainnet):

sed -i 's|.*\[p2p.discovery\]|  \[p2p.discovery\] |g' /var/lib/bor/config.toml

sed -i 's|.*bootnodes =.*|    bootnodes = ["enode://0cb82b395094ee4a2915e9714894627de9ed8498fb881cec6db7c65e8b9a5bd7f2f25cc84e71e89d0947e51c76e85d0847de848c7782b13c0255247a6758178c@","enode://88116f4295f5a31538ae409e4d44ad40d22e44ee9342869e7d68bdec55b0f83c1530355ce8b41fbec0928a7d75a5745d528450d30aec92066ab6ba1ee351d710@","enode://4be7248c3a12c5f95d4ef5fff37f7c44ad1072fdb59701b2e5987c5f3846ef448ce7eabc941c5575b13db0fb016552c1fa5cca0dda1a8008cf6d63874c0f3eb7@","enode://32dd20eaf75513cf84ffc9940972ab17a62e88ea753b0780ea5eca9f40f9254064dacb99508337043d944c2a41b561a17deaad45c53ea0be02663e55e6a302b2@"]|g' /var/lib/bor/config.toml

chown bor /var/lib/bor

Configure bor seeds (mumbai):

sed -i 's|.*\[p2p.discovery\]|  \[p2p.discovery\] |g' /var/lib/bor/config.toml

sed -i 's|.*bootnodes =.*|    bootnodes = ["enode://320553cda00dfc003f499a3ce9598029f364fbb3ed1222fdc20a94d97dcc4d8ba0cd0bfa996579dcc6d17a534741fb0a5da303a90579431259150de66b597251@","enode://f0f48a8781629f95ff02606081e6e43e4aebd503f3d07fc931fad7dd5ca1ba52bd849a6f6c3be0e375cf13c9ae04d859c4a9ae3546dc8ed4f10aa5dbb47d4998@"]|g' /var/lib/bor/config.toml

chown bor /var/lib/bor

  • Update service config user permission:

sed -i 's/User=heimdall/User=root/g' /lib/systemd/system/heimdalld.service

sed -i 's/User=bor/User=root/g' /lib/systemd/system/bor.service

2. Start Services

Run the full Heimdall node with the following command on your Sentry Node:

sudo service heimdalld start

To check if Heimdall is synced, run the command:

curl localhost:26657/status

Once Heimdall is synced, run the following command to start Bor:

sudo service bor start

3. Logs

To check Heimdall node logs, use the command:

journalctl -u heimdalld.service -f

To check Heimdall Rest-server logs, use the command:

journalctl -u heimdalld-rest-server.service -f

To check Bor Rest-server logs, use the command:

journalctl -u bor.service -f

4. Ports and Firewall Setup:

  • Open ports 22, 26656, and 30303 to the world ( on your sentry node firewall. You can use a VPN to restrict access to port 22 based on your security guidelines.

That's it! You've successfully deployed a Polygon full node. We encourage you to check Polygon Wiki - Full Node Deployment for up-to-date information.

Looking to maximize your rewards on the Polygon network? Explore the benefits of staking your Polygon with validators and unlock greater earning potential!

Read more