{"id":13456995,"url":"https://github.com/CryptoManufaktur-io/solana-rpc","last_synced_at":"2025-03-24T11:32:18.360Z","repository":{"id":37410595,"uuid":"432484569","full_name":"CryptoManufaktur-io/solana-rpc","owner":"CryptoManufaktur-io","description":"Solana RPC only node with traefik","archived":false,"fork":false,"pushed_at":"2024-07-17T15:12:58.000Z","size":67,"stargazers_count":39,"open_issues_count":0,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-07-31T08:18:57.296Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CryptoManufaktur-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-27T14:36:19.000Z","updated_at":"2024-07-17T15:13:02.000Z","dependencies_parsed_at":"2023-12-16T15:32:36.160Z","dependency_job_id":"78255c43-e547-4d38-ad5f-929302bc3339","html_url":"https://github.com/CryptoManufaktur-io/solana-rpc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CryptoManufaktur-io%2Fsolana-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CryptoManufaktur-io%2Fsolana-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CryptoManufaktur-io%2Fsolana-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CryptoManufaktur-io%2Fsolana-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CryptoManufaktur-io","download_url":"https://codeload.github.com/CryptoManufaktur-io/solana-rpc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221962483,"owners_count":16908339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T08:01:31.514Z","updated_at":"2025-03-24T11:32:18.353Z","avatar_url":"https://github.com/CryptoManufaktur-io.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# solana-rpc\n\nSolana RPC only node with traefik. Solana runs in systemd, and traefik in Docker.\n\n# Prerequisites\n\nDocker, e.g.\n\n`sudo apt update \u0026\u0026 sudo apt -y install docker.io docker-compose`\n\n# Setting up Traefik\n\n`cp default.env .env \u0026\u0026 cp traefik-dynamic.sample traefik-dynamic.toml`\n\nEdit `.env` to choose CloudFlare or AWS as your DNS provider, and adjust API keys and\ndomain name. See [Reverse Proxy](https://eth-docker.net/docs/Usage/ReverseProxy) docs\nfor details.\n\nEdit `traefik-dynamic.toml` to adjust the host name and domain name of your Solana node,\nand the host IP of the host this traefik runs on and that Solana runs on.\n\nAnd start it all with `docker-compose up -d`. Add `sudo` if your user isn't part of the\n`docker` group.\n\n## UFW considerations\n\nPlace ufw \"in the path\" of docker, see [instructions](https://eth-docker.net/docs/Support/Cloud).\n\nWhat you'd typically want is that traefik can access the Solana RPC ports, but nothing else can;\nand that traefik is only reachable by allow-listed IPs.\n\nYou can achieve this by something like this:\n\n```\nsudo ufw allow OpenSSH \nsudo ufw allow proto tcp from 172.16.0.0/12 to any port 8899 comment \"Traefik to Solana RPC\"\nsudo ufw allow proto tcp from 172.16.0.0/12 to any port 8900 comment \"Traefik to Solana WS\"\nsudo ufw allow proto tcp from 192.168.0.0/16 to any port 8899 comment \"Traefik to Solana RPC\"\nsudo ufw allow proto tcp from 192.168.0.0/16 to any port 8900 comment \"Traefik to Solana WS\"\nsudo ufw allow proto tcp from 10.0.0.0/8 to any port 8899 comment \"Traefik to Solana RPC\"\nsudo ufw allow proto tcp from 10.0.0.0/8 to any port 8900 comment \"Traefik to Solana WS\"\nsudo ufw allow 8001/tcp comment \"Solana Gossip\"\nsudo ufw allow 8000:8020/udp comment \"Solana QUIC\"\nsudo ufw allow proto tcp from SOURCEIP1 to any port 443 \nsudo ufw allow proto tcp from SOURCEIP2 to any port 443 \nsudo ufw deny proto tcp from any to any port 443 \nsudo ufw enable\n```\n\nNote Solana will use UDP ports 8000-10000 locally, after receiving data on the QUIC TPU; but you only need to open the `--dynamic-port-range` to Internet.\n\n## HAProxy\n\n`sol-haproxy.cfg` is an example configuration file for haproxy. It assumes that haproxy has `ca-certificates` available, see `haproxy.yml` for a sample setup.\n\n# Setting up Solana\n\n## Resources\n\nThe [official Solana docs](https://docs.solana.com/running-validator) and the [devnet notes](https://github.com/agjell/sol-tutorials/blob/master/setting-up-a-solana-devnet-validator.md) are both helpful.\nThe following is an opiniated amalgam of both, for Solana mainnet.\n\n# Hardware\n\nDedicated / baremetal, Solana will run in systemd, not docker.\n\n- 16 or 24 core CPU that can boost above 3GHz, for example EPYC 7443p\n- 1 TiB of physical RAM if [full indices](https://docs.solana.com/running-validator/validator-start#account-indexing) are desired\n- 1TB (or better) of NVMe disk\n- Avoid hardware RAID unless it's 9400/9500 tri mode series, e.g. Dell PERC11. You need TRIM commands to get through to the NVMe\n\n## Linux prep\n### Linux tuning\n\nUbuntu 22.04 or 24.04 LTS, because that's the supported distribution.\n\n`sudo nano /etc/fstab` and add `,noatime` to options of `/`. Also comment out current swap entries, as you won't need swap.\n\n`sudo nano /etc/default/grub` and add `mitigations=off` to `GRUB_CMDLINE_LINUX`. We can do this because it's bare metal. Then `sudo update-grub`.\n\nConsider setting up [unattended-upgrades](https://haydenjames.io/how-to-enable-unattended-upgrades-on-ubuntu-debian/) as well. You can use [msmtp](https://caupo.ee/blog/2020/07/05/how-to-install-msmtp-to-debian-10-for-sending-emails-with-gmail/) to email you in case of failure.\n\n### Set up user\n\nAdd a service user for Solana:\n\n```\nsudo adduser sol\nsudo usermod -aG docker sol\n```\n\n### Set up log rotation\n\nTo keep the log disk from filling up\n\n`sudo nano /etc/logrotate.d/solana`\n\nand paste the following inside it.\n\n```\n/home/sol/validator.log {\n  su sol sol\n  daily\n  rotate 7\n  compress\n  delaycompress\n  missingok\n  postrotate\n    systemctl kill -s USR1 validator.service\n  endscript\n}\n```\n\nAnd then `sudo systemctl restart logrotate`\n\n## Solana client\n### Download client\n\nBecome user `sol`: `sudo su - sol`\n\nDownload and install Solana Agave, replacing the version with the current one:\n\n`export VERSION=v2.1.9`\n`sh -c \"$(curl -sSfL https://release.anza.xyz/${VERSION}/install)\"`\n\nPaste this to the end of `nano .profile` and then `source .profile`.\n\n```\nexport SOLANA_METRICS_CONFIG=\"host=https://metrics.solana.com:8086,db=mainnet-beta,u=mainnet-beta_write,p=password\"\n```\n\n### Set up for mainnet, generate account\n\n\nMainnet beta.\n\n`solana config set --url https://api.mainnet-beta.solana.com`\n\nGenerate identity. We won't need wallet etc because we won't be validating. Keep the mnemonic / seed phrase securely offline.\n\n`solana-keygen new --outfile ~/validator-keypair.json`\n\n### Prep start command\n\nYou can use the `start-validator.sh` from this repo or `nano ~/start-validator.sh` and paste\n\n```\n#!/bin/sh\nexec agave-validator \\\n    --identity ~/validator-keypair.json \\\n    --no-voting \\\n    --ledger ~/ledger \\\n    --rpc-port 8899 \\\n    --gossip-port 8001 \\\n    --dynamic-port-range 8000-8020 \\\n    --known-validator 7Np41oeYqPefeNQEHSv1UDhYrehxin3NStELsSKCT4K2 \\\n    --known-validator GdnSyH3YtwcxFvQrVVJMm1JhTS4QVX7MFsX56uJLUfiZ \\\n    --known-validator DE1bawNcRJB9rVm3buyMVfr8mBEoyyu73NBovf2oXJsJ \\\n    --known-validator CakcnaRDHka2gXyfbEd2d3xsvkJkqsLw2akB3zsN1D2S \\\n    --entrypoint entrypoint.mainnet-beta.solana.com:8001 \\\n    --entrypoint entrypoint2.mainnet-beta.solana.com:8001 \\\n    --entrypoint entrypoint3.mainnet-beta.solana.com:8001 \\\n    --entrypoint entrypoint4.mainnet-beta.solana.com:8001 \\\n    --entrypoint entrypoint5.mainnet-beta.solana.com:8001 \\\n    --expected-genesis-hash 5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d \\\n    --wal-recovery-mode skip_any_corrupted_record \\\n    --limit-ledger-size 50000000 \\\n    --log ~/validator.log \\\n    --account-index program-id spl-token-owner spl-token-mint \\\n    --account-index-exclude-key kinXdEcpDQeHPEuQnqmUgtYykqKGVFq6CeVX5iAHJq6 \\\n    --account-index-exclude-key TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA \\\n    --only-known-rpc \\\n    --enable-rpc-transaction-history \\\n    --full-rpc-api \\\n    --rpc-bind-address 0.0.0.0 \\\n    --private-rpc \\\n    --use-snapshot-archives-at-startup when-newest \\\n    --block-verification-method unified-scheduler \\\n    --unified-scheduler-handler-threads 12 \\\n    --no-snapshot-fetch\n```\n\nNote the indices take a lot of RAM and are only needed for `getProgram` and `getToken` calls. With them, a 1 TiB RAM machine is recommended; without them, a 512 GiB RAM machine will suffice.\n\nThen `chmod +x ~/start-validator.sh`\n\n`--no-voting` makes this RPC only, and keeps us from having to pay 1 to 1.1 SOL/day in fees.\n`--enable-rpc-transaction-history` is necessary for websocket subscriptions to work.\n\n### Set up systemd service file\n\nCome back out of the sol user so you're on a user with root privileges again: `exit`\n\nCreate a service for the Solana validator service.\n\nYou can use the `validator.service` from this repo or `sudo nano /etc/systemd/system/validator.service` and paste\n\n```\n[Unit]\nDescription=Solana Validator\nAfter=network.target\nStartLimitIntervalSec=0\n\n[Service]\nType=simple\nRestart=always\nRestartSec=1\nLimitNOFILE=2000000\nLogRateLimitIntervalSec=0\nUser=sol\nEnvironment=PATH=/home/sol/.local/share/solana/install/active_release/bin:/usr/bin:/bin\nEnvironment=SOLANA_METRICS_CONFIG=host=https://metrics.solana.com:8086,db=mainnet-beta,u=mainnet-beta_write,p=password\nExecStart=/home/sol/start-validator.sh\n\n[Install]\nWantedBy=multi-user.target\n```\n\n### Tune the system\n\nFollow [the instructions](https://docs.solana.com/running-validator/validator-start#system-tuning), then log out and back in. Tuning is a required step.\n\n### Grab initial snapshots\n\nThe validator is set to start without fetching snapshots, which speeds up startup and keeps it from hanging if an RPC server with highest snapshot isn't actually reachable.\nGet snapshots manually, once, with `./solana-get-snapshots.sh`\n\n### Enable and start system service\n\n```\nsudo systemctl enable --now validator.service\n```\n\nCheck status:\n\n```\nsudo systemctl status validator.service\n```\n\nResolve any issues\n\n### Check that validator is running, useful commands\n\n`./agave-update.sh` - helper script to update Solana, from the main system user that can sudo\n\n`./agave-restart.sh` - helper script to safely restart Solana, from the main system user that can sudo\n\n`./solana-get-snapshots.sh` - helper script to fetch snapshots from Solana Foundation, from the main system user that can sudo. This would only be used during cluster restarts.\n\n`sudo su - sol` to become user `sol` again and run the below commands\n\n`tail -f ~/validator.log` to see the logs of the Solana node\n\n`agave-validator monitor` to monitor it\n\n`solana catchup --our-localhost` to see how far it is from chain head.\n\nIt is normal for Solana to take ~20 minutes to catch up after a fresh start.\n\n`grep --extended-regexp 'ERROR|WARN' ~/validator.log` to see error and warn logs.\n\n`solana epoch-info` to get information about the epoch.\n\n`solana validators` to get a list of validators, their stake %age and version.\n\n`df -h` to see fill status of disks.\n\n`htop` to see CPU and memory use.\n\n`sudo iostat -mdx` as a root-capable user to see NVMe utilization, of interest are `r_await` and `w_await`.\n\n`agave-install init x.y.z` to pull a new version of Solana.\n\n`agave-validator exit -m` for a safe exit of the validator when it has a fresh snapshot and isn't scheduled to be leader\n\nThis is solana-rpc v1\n\n## Metrics and logs\n\nTo get metrics and logs from solana-watchtower, you need to run `watchtower.sh` which will run agave-watchtower with 15 seconds interval and write the logs to a file watchtower.log in the same directory. Promtail can then be configured to send those logs to a central logging system as required.\n\nThere is also an option of running another container watchtower metrics that will monitor the file and read the latest values. It will also publish those metrics on port 8000 so prometheus can scrape them. To run that, just add `watchtower-metrics.yml` to `.env` file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCryptoManufaktur-io%2Fsolana-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCryptoManufaktur-io%2Fsolana-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCryptoManufaktur-io%2Fsolana-rpc/lists"}