Running a Dedicated Ethereum RPC Node in a Virtual Machine
Ayush kumar
Posted on October 18, 2024
Remote procedure calls, or RPC nodes, are a useful feature on nodes that link dApps to Blockchain networks. RPC nodes may also facilitate simpler access to user data and allow web3 applications to communicate with blockchain technology.
Understanding the RPC Node
Another crucial point in the Remote Procedure Call introduction guide is the definition of RPC nodes. RPC nodes are machines running Blockchain client software, like a server powering both the infrastructure of the Consensus Layer and the Execution Layer. The various kinds of nodes on Ethereum include an explanation of a Remote Procedure Call node. Full nodes, light nodes, and archival nodes are the common varieties of Ethereum nodes.
Solana Blockchain, on the other hand, may support RPC nodes and validators. By executing the Solana consensus mechanism, validator nodes could obtain the rewards required for block validation. Solana dApps can access pertinent Blockchain data through the Solana RPC nodes. An RPC node is any node that may reply to requests for remote procedure calls.
Ethereum RPC
Computers running blockchain client software are known as Ethereum RPC nodes. A server that manages both the Ethereum blockchain's Consensus Layer and Execution Layer infrastructure is one example of an RPC node.
On the Ethereum blockchain network, nodes exist in a variety of forms. These include light nodes, archive nodes, and full nodes. In contrast, RPC nodes and a validator are elements of the Solana blockchain. Running the Solana consensus procedure and receiving incentives for validating blocks are the responsibilities of the validator nodes. The Solana RPC nodes serve as entry points for Solana dApps to access pertinent blockchain data.
Any node that has installed the necessary software could efficiently reply to RPC requests. A typical feature of RPC endpoints running on a node is a service that aids dApps in getting blockchain data from users. As a result, every RPC endpoint operates on an RPC node, and every RPC node has an RPC endpoint.
Prerequisites
✅ A cloud VM (like NodeShift) with at least:
✅ 4 vCPUs
✅ 8GB RAM
✅ 100GB SSD
✅ Ubuntu 22.04 installed
✅ A domain or subdomain if you want to access the node via HTTP(Optional)
✅ Basic knowledge of blockchain and RPC services
✅ Access to your server via SSH
Step-by-Step process to Running a Dedicated Ethereum RPC Node in NodeShift Cloud
For the purpose of this tutorial, we will use a CPU-powered Virtual Machine offered by NodeShift; however, you can replicate the same steps with any other cloud provider of your choice. NodeShift provides the most affordable Virtual Machines at a scale that meets GDPR, SOC2, and ISO27001 requirements.
Step 1: Sign Up and Set Up a NodeShift Cloud Account
- Visit the NodeShift Platform and create an account.
- Once you have signed up, log into your account.
- Follow the account setup process and provide the necessary details and information.
Step 2: Create a Compute Node (CPU Virtual Machine)
NodeShift Compute Nodes offers flexible and scalable on-demand resources like NodeShift Virtual Machines which are easily deployed and come with general-purpose, CPU-powered, or storage-optimized nodes.
- Navigate to the menu on the left side.
- Select the Compute Nodes option.
- Click the Create Compute Nodes button in the Dashboard to make your first deployment.
Step 3: Select a Region and Choose VM Configuration
- In the "Compute Nodes" tab, select a geographical region where you want to launch the Virtual Machine (e.g., the United States).
- In the Choose VM Configuration section, select the number of cores, amount of memory, boot disk type, and size that best suits your needs.
- You will have at least 100 GB of storage for the node to run smoothly. If you use NodeShift and need more resources, you can always resize to add more CPUs and RAM.
Step 4: Choose an Image
Next, you will need to choose an image for your Virtual Machine. We will deploy the VM on Ubuntu, but you can choose according to your preference. Other options like CentOS and Debian are also available to Running a Dedicated Ethereum RPC Node.
Step 5: Choose the Billing Cycle & Authentication Method
- Select the billing cycle that best suits your needs. Two options are available: Hourly, ideal for short-term usage and pay-as-you-go flexibility, or Monthly, perfect for long-term projects with a consistent usage rate and potentially lower overall cost.
- Select the authentication method. There are two options: Password and SSH Key. SSH keys are a more secure option. To create them, refer to our official documentation.
Step 6: Additional Details & Complete Deployment
- The ‘Finalize Details' section allows users to configure the final aspects of the Virtual Machine.
- After finalizing the details, click the 'Create' button, and your Virtual Machine will be deployed.
Step 7: Virtual Machine Successfully Deployed
You will get visual confirmation that your node is up and running.
Step 8: Connect via SSH
- Open your terminal
- Run the SSH command:
For example, if your username is root, the command would be:
ssh root@ip
- If SSH keys are set up, the terminal will authenticate using them automatically.
- If prompted for a password, enter the password associated with the username on the VM.
- You should now be connected to your VM!
Step 9: Update Your Server
Run the following command to update the server:
sudo apt update && sudo apt upgrade -y
Step 10: Install Required Dependencies
Run the following command to install the dependencies:
sudo apt install git curl build-essential -y
The command sudo apt install git curl build-essential -y is used in Ubuntu and other Debian-based Linux distributions to install three essential software packages: git, curl, and build-essential.
Breakdown of the Command
- sudo: sudo is an abbreviation of "super user do" and is a Linux command that allows programs to be executed as a super user (aka root user) or another user. It's basically the Linux/Mac equivalent of the runas command in Windows.
- apt: apt-get is a command-line tool that helps handle packages in Linux. Its main task is to retrieve the information and packages from the authenticated sources for installation, upgrade, and removal of packages along with their dependencies.
- install: This command within APT specifies you want to install the listed packages.
- git: Git is a set of command line utility programs that are designed to execute on a Unix style command-line environment. Modern operating systems like Linux and macOS both include built-in Unix command line terminals. This makes Linux and macOS mandatory operating systems when working with Git. It is widely used in software development cycle.
- curl: Curl is a command line tool that enables data transfer over various network protocols. It communicates with a web, application server by focus on a relevant URL and the data that need to be sent or received.
- build-essential: This is a meta-package which includes a collection of packages essential for building software from source and starting. It typically includes compilers (like gcc) and libraries necessary for compiling applications.
- -y: This option automatically answers "yes" to any prompts during the installation process, allowing the command to run without user interfere.
Step 11: Install Node.js and NPM(Node Package Manager)
Run the following command to install the Node.js and NPM:
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt install -y nodejs
Node.js is an open-source, cross-platform JavaScript runtime environment that allows developers to execute JavaScript code outside of a web browser. Built on the V8 JavaScript engine from Google Chrome, it enables server-side programming and is designed for building scalable network applications using an event-driven, non-blocking I/O model.
NPM (Node Package Manager) is a package management system for JavaScript that comes bundled with Node.js.
Step 12: Install Docker
Docker can simplify the management of blockchain services. Run the following command to install the docker:
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install docker.io -y
Docker is an open-source platform that enables developers to create, deploy, and manage applications within lightweight, portable units called containers.
Next, Verify the installation by checking the docker version:
docker --version
Then, Run the following command to start docker and enable it to start on boot:
sudo systemctl start docker
sudo systemctl enable docker
Step 13: Install Go
Run the following commands to install Go on your server:
Download the Go package:
wget https://go.dev/dl/go1.21.0.linux-amd64.tar.gz
Extract the archive to /usr/local:
sudo tar -C /usr/local -xzf go1.21.0.linux-amd64.tar.gz
Set up the Go environment by adding the Go binary path to your system's $PATH:
echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.profile
Reload the profile to apply the changes:
source ~/.profile
Verify the installation by checking the Go version:
go version
Go was specifically designed to handle the complexities involved in building large scale systems. This makes it a versatile and reliable choice for applications within the open source programming community.
Step 14: Clone and download the RPC Node Repository
Run the following command to clone and download the RPC Node Repository:
git clone https://github.com/ethereum/go-ethereum.git
For this example, we’ll use an Ethereum-based RPC node. Most blockchain RPC nodes have open-source repositories. Let’s use Geth (Go Ethereum):
Run the following command to, navigate into the repository folder:
cd go-ethereum
Step 15: Build the Node from Source
Next, Run the following command to build the node from source:
make geth
This will compile the Geth client, allowing you to run your Ethereum node.
Step 16: Start and Monitor the RPC Node
After building the node, Run the following command to start the RPC Node:
./build/bin/geth --http --http.addr 0.0.0.0 --http.port 8545 --http.api eth,web3,net --datadir ~/.ethereum --syncmode "snap"
Here’s a breakdown of the command:
- --http: Enables the HTTP-RPC server.
- --http.addr 0.0.0.0: Binds the HTTP-RPC server to all available interfaces.
- --http.port 8545: Specifies the HTTP-RPC server port.
- --http.api eth,web3,net: Specifies the Ethereum-related APIs to expose over the HTTP interface.
- --datadir ~/.ethereum: The directory where your blockchain data will be stored.
- --syncmode "fast": Fast-syncs the blockchain.
Next, Run the following command to monitor the status of the RPC Node:
./build/bin/geth --http --http.addr 0.0.0.0 --http.port 8545 --http.api eth,web3,net --datadir ~/.ethereum --syncmode "snap" --verbosity 3
Conclusion
In this guide, we explain the Ethereum RPC Node prerequisites and provided a step-by-step guide on running a Dedicated Ethereum RPC Node in NodeShift Cloud. From installing the Required Software, Essential tools, Golang, package, clone repo, build the node and to start, monitor the RPC Node.
For more information about NodeShift:
Posted on October 18, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.