How to Setup and Run a Solana RPC Node

Posted By : Suchit

May 01, 2024

Solana's RPC (Remote Procedure Call) node acts as a gateway to the network, allowing developers to interact with the blockchain for Solana blockchain development services. If you're looking to build dApps or interact with the Solana ecosystem, running your own RPC node offers several advantages:

 

  • Reduced Reliance: Free yourself from dependence on public RPC nodes, ensuring data sovereignty and potentially faster response times.
  • Customization: Tailor the node to your specific needs, enabling features like filtering or whitelisting requests.

 

Solana relies on validators, which are computers that maintain the network. Each validator runs a program to track accounts and validate transactions. Without validators, Solana wouldn't function.

 

Before diving into RPC, let's clarify a key distinction. The validator software offers two deployment options: voting/consensus nodes and RPC nodes. While both leverage the same software, RPC nodes prioritize performance and refrain from voting. Unlike validator nodes focused on consensus, RPC nodes serve a distinct purpose within the cluster. They act as information providers, responding to blockchain inquiries and facilitating transaction submissions from users.

 

Also, Read | A Guide to Meme Coin Development on Solana

 

Set Up and Run a Solana RPC Node

 

Solana Validator Requirements

 

Minimum SOL requirements

 

Running a Solana validator doesn't require a strict initial SOL investment. However, to participate in consensus and earn rewards, you'll need a vote account with a minimum balance of 0.02685864 SOL to cover rent exemption. Additionally, voting on blocks incurs daily transaction fees, estimated around 1.1 SOL.

 

Hardware recommendations:

 

You can check hardware requirements from the doc mentioned https://docs.solanalabs.com/operations/requirements#hardware-recommendations

 

Running the RPC node

 

To create your validator vote account, ensure you have the Solana command-line interface installed on your local computer.

 

Also, Check | Compressed NFTs (cNFTs) | Solana's Cost-Effective NFT standard

 

In this blog we are going to use linux for reference.

 

Install solana release using the following command 

 

sh -c "$(curl -sSfL https://release.solana.com/v1.18.12/install)"

 

Verify that you have the desired version of Solana installed by running the following command:

 

solana --version

 

After confirming successful installation of the Solana CLI (command-line interface), update your configuration to target the testnet cluster for interacting with the Solana test network.

 

solana config set --url https://api.testnet.solana.com

 

Create an identity keypair for your validator by running:

 

solana-keygen new -o ~/validator-keypair.json

 

You can view the identity public key by executing the following command:

 

solana-keygen pubkey ~/validator-keypair.json

 

To connect to the machine running the node, we recommend using a non-privileged user with sudo permissions. If necessary, you can SSH as root on remote machines. For local development, open a terminal and use sudo su to elevate your privileges.

 

Make sure you have the latest and greatest package versions on your server.

 

sudo apt update
sudo apt upgrade

 

Ensure you have a minimum of 2TB of disk space mounted on your Ubuntu computer. You can verify disk space using the "df" command.

 

df -h

 

Use the "list block devices" command to view the available hard disk devices.

 

lsblk -f

 

If you have an unformatted NVMe drive, you'll need to format it before you can proceed with mounting it. Once formatted, you can then proceed to mount it.

 

For example, if your computer has a device located at /dev/nvme0n1, then you can format the drive with the command:

 

sudo mkfs -t ext4 /dev/nvme0n1

 

Device names and locations can vary for different computers.

 

Next, confirm that you have a UUID assigned to the device by running:

 

Now that you've formatted the drive, it's time to mount it. Create a directory for mounting your drive:

 

sudo mkdir -p /mnt/ledger

 

Now you can mount the drive:

 

sudo mount /dev/nvme0n1 /mnt/ledger

 

To ensure optimal performance, consider mounting the accounts database on a separate hard drive. Follow a process similar to the ledger example mentioned earlier.

 

Also, Explore | Solana for Real Estate Asset Tokenization

 

If you have a device located at /dev/nvme1n1, format the device and verify its existence.

 

sudo mkfs -t ext4 /dev/nvme1n1

 

Create a directory for mounting:

 

sudo mkdir -p /mnt/accounts

 

And lastly, mount the drive:

 

sudo mount /dev/nvme1n1 /mnt/accounts

 

System Tuning

 

Proper system tuning is essential for the successful operation of your validator. Failure to implement the settings below may result in your validator failing to start.

 

Optimize sysctl knobs

 

sudo bash -c "cat >/etc/sysctl.d/21-solana-validator.conf <<EOF
# Increase UDP buffer sizes
net.core.rmem_default = 134217728
net.core.rmem_max = 134217728
net.core.wmem_default = 134217728
net.core.wmem_max = 134217728

# Increase memory mapped files limit
vm.max_map_count = 1000000

# Increase number of allowed open file descriptors
fs.nr_open = 1000000
EOF""‹
sudo sysctl -p /etc/sysctl.d/21-solana-validator.conf
 
Increase systemd and session file limits
Add

 

LimitNOFILE=1000000

 

to the [Service] section of your systemd service file, if you use one, otherwise add

 

DefaultLimitNOFILE=1000000

 

to the [Manager] section of /etc/systemd/system.conf.

 

sudo systemctl daemon-reload
sudo bash -c "cat >/etc/security/limits.d/90-solana-nofiles.conf <<EOF
# Increase process file descriptor count limit
* - nofile 1000000
EOF"


Transfer your validator-keypair.json and vote-account-keypair.json files securely from your personal computer to the validator server.

 

scp validator-keypair.json sol@<server.hostname>:
scp vote-account-keypair.json sol@<server.hostname>:
 
Create A Validator Startup Script"‹

 

n your sol home directory (e.g. /home/sol/), create a folder called bin. Inside that folder create a file called validator.sh and make it executable:

mkdir -p /home/sol/bin
touch /home/sol/bin/validator.sh
chmod +x /home/sol/bin/validator.sh

 

Next, open the validator.sh file for editing:

 

nano /home/sol/bin/validator.sh

 

Copy and paste the following contents into validator.sh then save the file:

 

Due to the Solana blockchain's high transaction throughput, storing the entire chain on an RPC node isn't feasible. Operators set block storage limits with the --limit-ledger-size flag in startup scripts. For historical data, RPC servers access older blocks via Solana's bigtable instance.

 

#!/bin/bash
exec solana-validator \
   --identity /home/sol/validator-keypair.json \
   --known-validator 5D1fNXzvv5NjV1ysLjirC4WY92RNsVH18vjmcszZd8on \
   --known-validator dDzy5SR3AXdYWVqbDEkVFdvSPCtS9ihF5kJkHCtXoFs \
   --known-validator eoKpUABi59aT4rR9HGS3LcMecfut9x7zJyodWWP43YQ \
   --known-validator 7XSY3MrYnK8vq693Rju17bbPkCN3Z7KvvfvJx4kdrsSY \
   --known-validator Ft5fbkqNa76vnsjYNwjDZUXoTWpP7VYm3mtsaQckQADN \
   --known-validator 9QxCLckBiJc783jnMvXZubK4wH86Eqqvashtrwvcsgkv \
   --only-known-rpc \
   --full-rpc-api \
   --no-voting \
   --ledger /mnt/ledger \
   --accounts /mnt/accounts \
   --log /home/sol/solana-rpc.log \
   --rpc-port 8899 \
   --rpc-bind-address 0.0.0.0 \
   --private-rpc \
   --dynamic-port-range 8000-8020 \
   --entrypoint entrypoint.testnet.solana.com:8001 \
   --entrypoint entrypoint2.testnet.solana.com:8001 \
   --entrypoint entrypoint3.testnet.solana.com:8001 \
   --expected-genesis-hash 4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY \
   --wal-recovery-mode skip_any_corrupted_record \
   --limit-ledger-size
 
You may also like | Exploring Solana Blockchain Development for Enterprises

 

Verifying your validator is working

 

Test that your validator.sh file is running properly by executing the validator.sh script:

 

/home/sol/bin/validator.sh

 

The script should initiate the solana-validator process. In a new terminal window, SSH into your server, then confirm that the process is running:

 

ps aux | grep solana-validator

 

You should encounter a line in the output containing "solana-validator" along with all the flags added to your validator.sh script.

 

Next, examine the logs to ensure smooth operation.

 

In a new terminal window, SSH into your validator machine, switch to the sol user, and tail the logs:

 

su - sol
tail -f solana-validator.log

 

The "tail" command continuously displays the output of a file as it changes. You should observe a continuous stream of log output as your validator runs. Watch for any lines indicating "_ERROR_".

 

If no error messages are visible, exit the command.

 

To confirm that your validator is running correctly, ensure that it has registered itself with the gossip network.

 

In a new terminal window, establish an SSH connection to your server. Identify your validator's pubkey:

 

solana-keygen pubkey ~/validator-keypair.json

 

The "solana gossip" command displays all validators registered with the protocol. To verify whether the newly set up validator is listed in gossip, we'll use "grep" to search for our pubkey in the output:

 

solana gossip | grep <pubkey>

 

If you don't observe any output after using "grep" on the gossip output, your validator might be encountering startup issues. In such a scenario, initiate debugging by examining the validator log output.


Once you've confirmed that your validator is in gossip, you can verify its network membership by using the "solana validators" command. This command provides a list of all validators in the network. You can filter the output to focus on the specific validator of interest using the "grep" command as before.

 

solana validators | grep <pubkey>

 

For more about Solana blockchain development, connect with our Solana blockchain developers.

 

Leave a

Comment

Name is required

Invalid Name

Comment is required

Recaptcha is required.

blog-detail

September 8, 2024 at 02:31 am

Your comment is awaiting moderation.

By using this site, you allow our use of cookies. For more information on the cookies we use and how to delete or block them, please read our cookie notice.

Chat with Us
Telegram Button
Youtube Button
Contact Us

Oodles | Blockchain Development Company

Name is required

Please enter a valid Name

Please enter a valid Phone Number

Please remove URL from text