Setup a RPC Node
In the blockchain networks, RPC (Remote Procedure Call) nodes are a critical component that enables communication between nodes on the network. The primary purpose of RPC nodes is to facilitate communication and interaction between nodes, enabling the network to function efficiently and securely.
Pre-requisites:
Software: A Linux-based operating system Ubuntu 22.04 with a compatible architecture ( x86_64).
Network connection: A stable and high-speed 10 Gbps internet connection.
Minimum Hardware Requirements: A reliable server with a minimum of 8 CPU cores, 32 GB RAM, and 500 GB storage.
Recommended Hardware Requirements: A reliable server with a minimum of 16 CPU cores, 64 GB RAM, and 1 TB storage.
Preferred Region (low Carbon Data Centers): -
US (Lowa)
Europe: London, Finland
Setting up an RPC node
Step 1: Choose a blockchain network
The blockchain network you are participating in is Vanarchain.
Ensure you understand the network's architecture, consensus algorithm, and RPC’s roles.
Familiarize yourself with the network's documentation, technical specifications, and community resources.
Step 2: Set up the environment
Install a Linux-based operating system Ubuntu 22.04 with a compatible architecture (x86_64).
Configure the network settings, DNS, and firewall rules to allow port 30311 tcp/udp incoming connections.
Install go - version should 1.20.14
Step 3: Install dependencies and source code
Install the required dependencies, such as:
git (for cloning the blockchain's repository)
make (for building the blockchain's binary)
gcc (for compiling the blockchain's code)
Clone the blockchain's repository using git clone:
git clone https://github.com/VanarChain/vanarchain-blockchain.git
This is the URL of the GitHub repository. It points to a specific directory within the repository.
Change into the cloned repository directory:
cd vanarchain-blockchain
cd: This is a command that changes the current directory to a new location.
vanarchain-blockchain: This is the name of the repository, which is also the directory name.
“git checkout v1.1.1”: Latest tag Sep 2024. You can see the the available versions at https://github.com/VanarChain/vanarchain-blockchain/tags and you should use the latest available version.
Run the make command to build the blockchain's binary:
make all
Copies the geth file from the build directory to the parent directory. Copies the bootnode file from the build directory to the parent directory. Changes the current directory to the parent directory.
cp ./build/bin/geth /usr/bin/geth
cp ./build/bin/geth /usr/bin/geth: This is a command that copies a file from one location to another. It is executed as follows:
cp: This is the command that stands for "copy".
./build/bin/geth: This is the source file to be copied. The ./ before build indicates that the directory is relative to the current directory.
/usr/bin/geth: This is the destination directory and filename where the file will be copied to. /usr/bin is a standard directory on Unix-like systems where executable programs are typically stored. geth is the name of the file to which the geth file will be copied.
So, this command copies the geth file from the build directory to the parent directory.
Step 4: Join the network
Connect to the network by establishing connections with other nodes (peers) and broadcasting your node's presence.
Validate transactions and blocks as a validator, following the network's consensus algorithm.
RPC node creation commands
To create a new account on the Vanar network using the Geth command-line tool, follow these steps:
Create a new directory for your node
Create a new directory to store the blockchain data and other files:
mkdir /node
Running a new RPC node
To run a node on the Vanar network using the Geth command-line tool write the following code.
|
/usr/bin/geth: The executable name is geth, and the path is /usr/bin/, which is the default location for executable files on Unix-like systems.
--vanar: This option tells Geth to start in "Vanar" mode, which is a specific configuration for the Vanar node.
--datadir /node/: This option sets the data directory for the node to /node/. This is where the node will store its blockchain data, including the blockchain itself, transactions, and contract storage.
--syncmode 'full': This option tells the node to start a full sync from the genesis block. This means the node will download the entire blockchain from the genesis block to the current tip.
--port 30311: This option sets the listening port for the node to 30311. This is the port that other nodes will use to connect to this node.
--txpool.rejournal 5m: This option sets the journal interval for the transaction pool to 5 minutes. When the node processes 5 minutes of transactions, it will restart the transaction pool to ensure that all transactions are processed.
--txpool.globalslots 10240: This option sets the global slots for the transaction pool to 10240. This determines the maximum number of transactions that can be stored in the transaction pool.
--http: This option enables the HTTP API for the node.
--http.port 8545: This option sets the port for the HTTP API to 8545.
--http.addr '0.0.0.0': This option sets the IP address for the HTTP API to 0.0.0.0, which means the API will listen on all available network interfaces.
--http.api 'eth,net,web3,txpool': This option specifies the API endpoints that will be available through the HTTP API. In this case, it's eth, net, web3, and txpool.
--ws: This option enables the WebSocket API for the node.
--ws.port 8546: This option sets the port for the WebSocket API to 8546.
--ws.addr '0.0.0.0': This option sets the IP address for the WebSocket API to 0.0.0.0, which means the API will listen on all available network interfaces.
--ws.api 'eth,net,web3,txpool': This option specifies the API endpoints that will be available through the WebSocket API. In this case, it's eth, net, web3, and txpool.
--http.vhosts "*": This option sets the vhosts for the HTTP API to *, which means the API will listen on all available domains.
--http.corsdomain "*": This option sets the CORS domains for the HTTP API to *, which means the API will allow requests from any domain.
--ws.origins "*": This option sets the origins for the WebSocket API to *, which means the API will allow connections from any origin.
RPC node as a service
We recommend using RPC as a service to avoid disconnection of the Vanar chain.
Create log directory
Create the log directory using the following command: -
|
mkdir: This is the command used to create new directories. The name stands for "make directory".
/var/log/: This is a standard directory in Unix-like operating systems where log files are typically stored. It is used by various system services and applications to store their log files.
vanarchain/: This is the name of the new directory being created within /var/log/. Here, the directory will be used to store log files related to the VanarChain service.
Starting RPC service in Vanar chain
The commands given below are for managing services on a Linux system, specifically for starting a service called vanarchain.service, It is for an RPC node in a Vanar chain network.
|
sudo systemctl daemon-reload
This command reloads the systemd manager configuration. It is necessary to run this command whenever you make changes to the service unit files (e.g., modifying or creating a new service file) so that systemd can recognize and apply those changes. The sudo part of the command indicates that administrative privileges are required to perform this action.
sudo: Executes the command with superuser (root) privileges.
systemctl: The command-line utility used to interact with the systemd system and service manager.
daemon-reload: Tells systemd to reload its configuration files.
sudo systemctl start vanarchain.service
This command starts the vanarchain.service, which is the service responsible for running the VanarChain RPC node.
sudo: Executes the command with superuser (root) privileges.
systemctl: The command-line utility for managing systemd services.
start: Tells systemd to start the specified service.
vanarchain.service: The name of the service unit file that defines how to manage the VanarChain RPC node.
Unit File
|
[Unit] Section
Description: Provides a brief description of what the service is. In this case, it describes it as the vanarchain service.
After: Specifies that this service should start after the network.target, ensuring that the network is up before this service starts. This is important for services that require network connectivity.
StartLimitIntervalSec: Setting this to 0 disables the rate limit for restarting the service. This means there is no limit on how frequently the service can restart within a specific time frame.
[Service] Section
Type=simple: Indicates that the service is a simple one and that systemd should consider the service running as soon as the process specified in ExecStart is started.
Restart=always: Configures the service to always restart if it stops or crashes. This is useful for ensuring high availability.
RestartSec=1: Specifies a delay of 1 second before attempting to restart the service after it stops.
User=<your OS User>: Specifies the user under which the service should run. You need to replace <your OS User> with the actual username that should run the service. For example, you might replace it with vanarmain or another appropriate user.
ExecStart: This specifies the command to start the service. You need to fill this in with the path to the executable or script that starts the vanarchain service.
StandardOutput: Redirects the standard output (stdout) of the service to the specified log file (/var/log/vanarchain/vanarchain-err.log). The append: part means that it will append to the file rather than overwriting it.
StandardError: Redirects the standard error (stderr) of the service to the specified log file (/var/log/vanarchain/vanarchain.log). Similarly, it will append to the file.
[Install] Section
Unit Configuration: Defines dependencies and description.
Service Configuration: Specifies the service type, restart policies, user context, and logging.
Install Configuration: Sets the target environment for the service.
Verify the node
Verify that the node is running and syncing with the Vanar network.
|
tail: This Unix command is used to display the last part of a file. By default, it shows the last 10 lines of the specified file.
-f: This option stands for "follow". It tells tail to not only show the last part of the file but also to continually monitor the file for new lines and display them as they are added. This is useful for real-time monitoring.
/var/log/vanarchain/vanarchain.log: This is the file path to the log file you want to monitor. In this case, it is the log file for the vanarchain service.
Purpose
When you run the above-given command, you are essentially setting up a real-time view of the vanarchain.log file. This can be very useful for:
Monitoring Node Activity: Watching the log file allows you to see what the vanarchain node is doing in real time. This can include transactions being processed, blocks being added to the blockchain, and any errors or warnings that might occur.
Debugging and Troubleshooting: If you are experiencing issues with your vanarchain node, monitoring the log file can provide insights into what might be going wrong. You can see error messages and other diagnostic information as they happen.
Performance Monitoring: Keeping an eye on the log file can help you understand the performance of your node, such as how quickly it processes transactions or how often it syncs with other nodes.
Last updated