Select Page

How to set up and run a full node on Polkadot?

Polkadot node setup

Blockchain existed in 2008, but it started getting huge traction in the past few years. Now that the world is witnessing the potential of blockchain technology, businesses are upgrading their existing infrastructure to the decentralized blockchain ecosystem.

With multiple iterations, various new and improved blockchains are being introduced. About the recent buzz, third-generation blockchain networks are growing in demand. Polkadot is a third-generation web3 blockchain that is rising in popularity. More enterprises are building dApps and custom blockchains on Polkadot. Hence, developers are required to build and run nodes on Polkadot.

Blockchain uses a distributed ledger technology based on peer-to-peer network topology. For the decentralized ledger to function and perform the intended actions, nodes play a crucial role. Nodes, a component of the huge distributed ledger, are responsible for verifying the transactions, establishing real-time communication with the networks worldwide and validating the data. Let’s discuss how to set up a full node on Polkadot and run it in this regard.

Overview of Polkadot nodes

Polkadot is a decentralized layer-0 protocol designed to enable interoperability in the blockchain ecosystem. The network features a main blockchain called “Relay chain” and various user-created parallel chains called parachains.

Developers willing to build decentralized applications or parachain on Polkadot, Kusama and Substrate infrastructure may require to run Polkadot-node as a backend. By allowing it to run a node on its ecosystem, Polkadot eliminates the risk of third-party hosted infrastructure across the vast decentralized world.

Overview of Polkadot’s architecture

Polkadot has a multichain architecture with true interoperability and shared security. Polkadot uses combined consensus, proof of work and proof of stake consensus to make the entire Polkadot network more efficient and scalable. The Polkadot ecosystem comprises Parachain, Parathreads, Relaychain and bridges. Let’s decode the Polkadot architecture in brief:

Components

  • Relay chain
    The relay chain is like the foundation of the Polkadot Network as it is responsible for uniting the various parachains built on the Polkadot ecosystem, enabling interoperability and robust security.
  • Parachain and Parathread Slots
    Parachains and Parathreads are the customized blockchains built and managed on their core slots on the Polkadot ecosystem. Besides managing the chains, these slots are responsible for facilitating easy upgradability and unparalleled security to the chains.
  • Shared Security
    Polkadot architecture is designed with the Relay chain as the foundation and various Parachains as connecting or parent chains. Here, the Relay chain provides security to the entire Parachains and unites them in terms of communication.

Interoperability

  • Bridges
    Any blockchain built using a Substrate framework or built as Parachain/Parathread is inherently interoperable with each other. For non- Substrate and non-Parachains, Polkadot offers cross-chain bridges that enable true interoperability between two independent and inherently different blockchains.
  • XCM
    XCM and XCMP refer to the cross-chain messaging protocol and cross-chain message, respectively. XCMP mechanism and XCM (the message that gets delivered) together power the Polkadot ecosystem with interoperability element, enabling a seamless cross-chain communication through messaging.

Main actors

  • Validators
    Validators are responsible for producing blocks on the Relay chain. Also, validators are entitled to receive staking rewards against their acceptance of proof of valid state.
  • Nominators
    Nominators are responsible for bonding their stake for specific validators, allowing them to show up as active visitors and thus contribute to producing new blocks.
  • Collators
    Collators represent the full node on the Relay chain and the Parachain. Their main responsibility includes collecting transactions on Parachains and producing transition proof for Relay chain’s validators.

What are the different types of Polkadot nodes?

The Polkadot ecosystem has three main types of nodes; an archive node, a full node and a light node. Let’s understand the mechanism of these nodes:

Archive node

An archive is responsible for keeping a record of entire past blocks, making it convenient to query any blocks of the chain whenever required. Using active nodes, users can easily query the past blocks whenever required. Furthermore, these nodes help find out what’s the account balance of a certain block to ensure fast operations. That being said, an archive node can consume high disk space, up to Kusama’s 12 millionth block’s space, which is around 660GB.

Full node

Full node on the Polkadot discards existing finalized blocks that are older than a configurable number except the genesis block. By default, a full node is the 256 blocks from the last completed blocks. How a full node is pruned is very convenient to save space compared to an archive node.

Light node

The light node is another Polkadot node that keeps a record of only runtime and the current state. It only does runtime and current state without storing the details about past blocks. Consequently, the light node cannot track or read historical data instead of requesting the data from the node.

How to set up and run a full node on Polkadot?

This guide aims to provide a Polkadot node setup and running for Windows, Linux and Ubuntu. Follow a step-by-step guide to set up and run a full node on Polkadot.

Node installation and running guide For Windows:

1 Install WSL

2 Next, Install Ubuntu

3 Make sure you have the latest version of the Polkadot binary.

4 Run the following command to download the accurate Polkadot binary within Ubuntu. Now, replace the *VERSION* with the latest version. Use the following code:

curl -sL https: //github.com/paritytech/polkadot/releases/download/*VERSION*/polkadot -o polkadot

5 Now, run the following command:

sudo chmod +x polkadot

6 Get started with running your code:

./target/release/Polkadot --name "Your Node's Name"

7 Discover your node on Telemetry.

Get Substrate

Follow the quick Substrate installation guide to install this framework. Prefer using a virtual machine to deal with the challenges associated with Substrate installation in Windows. Now, test the installation by running the following code:

λ cargo --version
cargo 1.41.0 (626f0f40e 2019-12-03)

Clone and Build

The following Polkadot code is available in the paritytech/Polkadot repo’s master branch:

git clone https:// http://github.com/paritytech/  polkadot polkadot
cd Polkadot
./scripts/init.sh
cargo build --release

Either way, you can use a specific release to check out a specific tag as below mentioned:

git clone https: //GitHub .com/paritytech/Polkadot Polkadot
cd Polkadot
git checkout tags/v0.8.3
./scripts/init.sh
cargo build --release

Run

The built binary resides in the target/release folder, Polkadot.

Polkadot:

./target/release/Polkadot --name "Your Node's Name"

Furthermore, you can determine which flags you can use while running the node. For instance, you may need to use –ws-external and –RPC-cors all to remotely connect to nodes.

Running an Archive Node

When you run a simple sync node, only the past 256 blocks are kept. When validating, it defaults to archive mode. To keep the full state, use the –pruning flag:

Polkadot:

./target/release/Polkadot --name "My node's name" --pruning archive

You can quadruple the synchronization speed using the additional flag: –wasm-execution Compiled. Remember that this approach requires higher computing resources through CPU and RAM.

Node installation and running guide For macOS:

Run the following command in the terminal to install Homebrew

/bin/bash -c "$(curl -fsSL https:// raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Next, run the following command
brew install OpenSSL cmake llvm
Install Rust using the below command in the terminal:

curl --proto '=https' --tlsv1.2 -sSf https:// sh.rustup.rs | sh

Right after RUST installation, run the following command:

git clone GitHub - paritytech/Polkadot: Polkadot Node Implementation Polkadot
cd Polkadot
./scripts/init.sh
cargo build --release

Now, start your node:

./target/release/Polkadot --name "Your Node's Name"

Now, finally, set up your node on Telemetry.

Get Substrate

Follow the instructions on the Substrate Quick Starter guide to install Substrate. Note that Windows users might have to undergo challenges. Therefore, prefer using the virtual machine.
Once installed, test your Substrate installation by running the following command cargo –version:

λ cargo --version
cargo 1.41.0 (626f0f40e 2019-12-03)

Clone and Build

Run the following code from paritytech/Polkadot repo’s master branch as it contains Polkadot code:

git clone GitHub - paritytech/Polkadot: Polkadot Node Implementation Polkadot
cd Polkadot
./scripts/init.sh
cargo build --release

Either way, you can use a specific release by checking out the specific tag v0.8.3 as given in the following example:

git clone GitHub - paritytech/Polkadot: Polkadot Node Implementation Polkadot
cd Polkadot
git checkout tags/v0.8.3
./scripts/init.sh
cargo build --release

Run an Archive Node

Running a simple sync node can only keep records of the past 256 blocks. During the validation process, the same simple node is by default. Use the full state to keep the –pruning flag:

Run the following command:

./target/release/Polkadot --name "My node's name" --pruning archive

Also, you can accelerate the synchronization speed by running this code: –wasm-execution Compiled. This approach uses high CPU and RAM computing resources, turning it off once the node is synched.

Using Docker

Finishing up, you need to use Docker to run your code. Since this process is a bit advanced, you need to be familiar with Docker and node setup experience using Docker. Also, when you run a Polkadot node, the process only listens to the local host by default.

Instructions For Linux

*Ensure you have the last version of the Polkadot binary.

Run the following command to download:

sudo chmod +x polkadot

Run the below command:

./target/release/Polkadot --name "Your Node's Name"

Also, search your desired node on Telemetry.

Get Substrate

Instead of Windows, use the virtual machine to get the best experience with Substrate. Follow the step-by-step instructions added in Substrate’s docs regarding the installation.

Once the installation is completed, test your installation by running the following command line:

git clone https://github.com/paritytech/polkadot Polkadot
cd Polkadot
./scripts/init.sh
cargo build --release

Clone and Build

Execute the following Polkadot code that is available in the paritytech/Polkadot repo’s master branch:

git clone GitHub - paritytech/Polkadot: Polkadot Node Implementation Polkadot
cd Polkadot
./scripts/init.sh
cargo build --release

Either way, you can use a specific release, then check the specific tag v0.8.3 given in the example below; run the following command:

git clone https:// http://github.com/paritytech/polkadot  Polkadot
cd Polkadot
git checkout tags/v0.8.3
./scripts/init.sh
cargo build --release

Run

The built binary reflects in the target/release folder, Polkadot.

Run the following code on the Polkadot command prompt:

./target/release/Polkadot --name "Your Node's Name"

Now, you can use -the-help flag to determine which flags you should use for running the node. For instance, if you want to connect to your node remotely, you need to use -rpc-cors all and-was-external.

Note that synching process takes time depending on the bandwidth capacity of your system, disk speed, disk space, and RAM.

Running an Archive Node

When you run a simple sync node, only the records of past blocks are kept. During validation, the node defaults to the archive node. Also, you can keep the full state of blogs using –the pruning flag:

Run the following command on the Polkadot:

./target/release/Polkadot --name "My node's name" --pruning archive

It is possible to almost quadruple synchronization speed by using an additional flag: –wasm-execution Compiled. Note that this uses much more CPU and RAM, so turn it off after the node is in sync.

Using Docker

Finishing up, you need to use Docker to run your code. Since this process is a bit advanced, you need to be familiar with Docker and node setup experience using Docker. Also, when you run a Polkadot node, the process only listens to the local host by default.

Polkadot blockchain development by LeewayHertz

Parachain development

Using the Polkadot-compatible Substrate framework, we build custom Parachain and integrate them with Relaychain. From slot leasing to launch, we offer end-to-end parachain development.

Sidechain Integration

We can integrate an existing Substrate-powered Relay chain or dApp to connect to other chains or Polkadot for improved interoperability.

Smart contract development

We develop smart contracts for all types of parachains that support arbitrary state transitions. We ensure that the smart contracts securely function on the Polkadot ecosystem while embodying your business logic.

Custom dApp development

From DeFi apps, digital wallets, IoT applications, and gaming apps to Web 3.0 Infrastructure, we build and deploy a range of interoperable dApps as parachains.

NFT Marketplaces

With extensive experience using Polkadot SDKs like Substrate and Cumulus, SDKs, and other tools, we develop and launch interoperable NFT marketplaces to support advanced NFT projects.

Decentralized Exchange

Using the interoperable web3 Polkadot’s ecosystem, we build cross-chain DEX platforms, enabling quick and seamless exchange of tokens, arbitrary data and resources across multiple parachains.

Conclusion

Built on the Substrate framework, Polkadot facilitates the development of interoperable blockchains and decentralized solutions. By running various types of nodes-as-a-backend, developers can build innovative dApps and run them on the Polkadot ecosystem for unparalleled security and flexibility in upgrading the existing functionalities.

If you are interested in launching and running your Polkadot- based node, we are here to assist you. Connect with our Polkadot blockchain experts.

Webinar Details

Author’s Bio

Akash Takyar
Akash Takyar
CEO LeewayHertz
Akash Takyar is the founder and CEO at LeewayHertz. The experience of building over 100+ platforms for startups and enterprises allows Akash to rapidly architect and design solutions that are scalable and beautiful.
Akash's ability to build enterprise-grade technology solutions has attracted over 30 Fortune 500 companies, including Siemens, 3M, P&G and Hershey’s. Akash is an early adopter of new technology, a passionate technology enthusiast, and an investor in AI and IoT startups.

Start a conversation by filling the form

Once you let us know your requirement, our technical expert will schedule a call and discuss your idea in detail post sign of an NDA.

All information will be kept confidential.

 

Insights