>>FIRST MISSION//LOGS//crypto//create-solana-validator-rpc-only-node-part-2.MD
[ + ] TARGET_LOCKED200 OK
MAR 18, 2022timer 3 MIN READSYS_TAG: crypto STATUS: VERIFIED_WORKING

Create Solana Validator RPC Only Node Part 2

ENGINE: KERNEL // STABLE
BASE_ARCH: x86_64
HOST: VASTORIGINS.COM
GPG: OKSIG_ID: 0x4EB27DB0
Create Solana Validator RPC Only Node Part 2
SPEC_IMAGE // PROVENANCE_VERIFIED

This image has an empty alt attribute; its file name is image.png

If you haven’t checked out the first part yet, make sure to check it out on this link. In that part we set up the disks, which is the foundation everything else stands on. Now it is time to bring the validator itself to life.

Setup the Solana Validator

Before you start, make sure you install the Solana CLI first, which you can find information on how to install the latest package here. Reboot your computer to make sure everything is going okay; disk mounts and kernel settings settle in properly after a fresh boot, and you do not want to debug a mount problem in the middle of this guide.

On this config we will connect directly as a validator (non-voting) for Solana mainnet-beta. A non-voting validator, also called an RPC node, participates in the network, serves data, and helps decentralize it, all without the responsibility of producing blocks. First, configure the Solana tools that you installed:

solana config set --url https://api.mainnet-beta.solana.com

Then run the sys-tuner one time. This configures your computer’s internals to the recommended setup:

sudo $(command -v solana-sys-tuner) --user $(whoami) > sys-tuner.log 2>&1 &

This will run one time, and you need to run it again after you reboot your system. Since remembering to do that is exactly the kind of thing I always forget, there is another way: configure a systemd service so it runs automatically. To configure a systemd service, create a file named solana-sys-tuner.service in the directory /etc/systemd/system.

sudo cat > /etc/systemd/system/solana-sys-tuner.service << EOF
[Unit]
Description=Solana System Tuner
After=network.target
Before=sol.service

[Service]
Type=simple
Restart=always
RestartSec=1
User=root
ExecStart=/home/ubuntu/solana-sys-tuner.sh

[Install]
WantedBy=multi-user.target
WantedBy=sol.service
EOF

This will create the service, and now you can run sudo systemctl enable --now solana-sys-tuner.service to enable it at boot and start the service right away. You can also do it the manual way without having to run the solana-sys-tuner binary, just follow this tutorial from the official documentation here.

Also, don’t forget to create the solana-sys-tuner.sh on your user home root directory:

cat > ~/solana-sys-tuner.sh << EOF
#!/usr/bin/env bash
set -ex

exec /home/ubuntu/.local/share/solana/install/active_release/bin/solana-sys-tuner --user ubuntu
EOF

Now you can start the validator, but first prepare a validator keypair:

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

This will create a validator keypair at your user home directory. Don’t forget to save the output generated BIP39 seedphrase. DON’T FORGET. If you lose that seedphrase, you lose the keypair forever, and there is no support desk on the blockchain that can hand it back to you. Once done, if you forgot your public key, you can view it using the command solana-keygen pubkey ~/validator-keypair.json. You will need the public key for later commands.

Set the validator keypair in your Solana CLI tool:

solana config set --keypair ~/validator-keypair.json

That’s all for configuration, we can now start the validator. Create a simple shell script to contain the run parameters of the solana-validator command, so it will be easier to modify and adjust later on:

cat > validator.sh << EOF
#!/usr/bin/env bash

set -e

exec solana-validator \
    --no-voting \
    --identity ~/validator-keypair.json \
    --known-validator 7Np41oeYqPefeNQEHSv1UDhYrehxin3NStELsSKCT4K2 \
    --known-validator GdnSyH3YtwcxFvQrVVJMm1JhTS4QVX7MFsX56uJLUfiZ \
    --known-validator DE1bawNcRJB9rVm3buyMVfr8mBEoyyu73NBovf2oXJsJ \
    --known-validator CakcnaRDHka2gXyfbEd2d3xsvkJkqsLw2akB3zsN1D2S \
    --only-known-rpc \
    --ledger /mnt/disks/solana-ledger \
    --accounts /mnt/disks/solana-account \
    --rpc-port 8899 \
    --rpc-bind-address [IP_ADDRESS] \
    --dynamic-port-range 8000-8020 \
    --entrypoint entrypoint.mainnet-beta.solana.com:8001 \
    --entrypoint entrypoint2.mainnet-beta.solana.com:8001 \
    --entrypoint entrypoint3.mainnet-beta.solana.com:8001 \
    --entrypoint entrypoint4.mainnet-beta.solana.com:8001 \
    --entrypoint entrypoint5.mainnet-beta.solana.com:8001 \
    --expected-genesis-hash 5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d \
    --wal-recovery-mode skip_any_corrupted_record \
    --limit-ledger-size \
    --no-port-check \
    --enable-rpc-transaction-history \
    --full-rpc-api \
    --log /mnt/disks/solana-spare/logs/solana-validator.log
EOF

These validator flags specify that RPC is open to the public, and that it is RPC-only mode due to the --no-voting flag. The flags also specify that the RPC transaction history is enabled, which will make the ledger disk big, so check the flag --enable-rpc-transaction-history before you commit to it. Read every flag from the solana-validator binary by executing the --help flag; it is the most reliable documentation you will find.

Wait for a while, it will download a very big snapshot so you could catch up to the latest transactions. The ledger will only contain all the latest transaction history of the Solana chain. This will take time depending on the speed of your machine and your network. Once you see there are no percentages or anything moving anymore, then it’s good to go.

Make sure it’s on the list of validator nodes using the solana gossip command:

solana gossip | grep <pubkey>

That’s all, now you’re part of the validators, or very close to it. Another thing: in order to run it on reboot, add the systemd service file. Create the file using the command below, in the same directory as the solana-sys-tuner.service:

sudo cat > /etc/systemd/system/sol.service << EOF
[Unit]
Description=Solana Validator
After=network.target
Wants=solana-sys-tuner.service
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
User=ubuntu
LimitNOFILE=1000000
LogRateLimitIntervalSec=0
Environment="PATH=/bin:/usr/bin:/home/ubuntu/.local/share/solana/install/active_release/bin"
ExecStart=/home/ubuntu/validator.sh

[Install]
WantedBy=multi-user.target
EOF

Then enable it at boot using the command sudo systemctl enable --now sol.service. Make sure that it doesn’t have errors by checking the service status with systemctl status sol.service. Last thing to mention: logs can become large quickly, so make sure to create a logrotate rule. The command below is one I grabbed from the official documentation:

cat > logrotate.sol <<EOF
/home/sol/solana-validator.log {
  rotate 7
  daily
  missingok
  postrotate
    systemctl kill -s USR1 sol.service
  endscript
}
EOF

sudo cp logrotate.sol /etc/logrotate.d/sol
systemctl restart logrotate.service

🧠 Final Thoughts

And that is the whole setup. From bare disks in part 1 to a validator that picks itself up after every reboot: systemd services for both the sys-tuner and the validator, a keypair you have actually backed up, and logs that rotate themselves. Running a node is a long game, and the machines that keep working are the ones set up with this kind of care. Now reboot and celebrate 🎉! Don’t forget to share and leave a comment if you like this kind of articles.

[ SIGNATURE VERIFIED // GPG 0x4EB27DB0 // PROVENANCE SECURE ]
➔ RETURN TO LOGS