Cointime

Download App
iOS & Android

How To Configure Ethereum Node?

Validated Project

In a previous blog, we discussed the concept of nodes in the blockchain. In this blog, I will guide you through configuring an Ethereum node.

Ethereum Node

A node in Ethereum consists of two components: execution client and consensus client.

The execution client (Execution Engine, previously called Eth1 client) listens to new transactions broadcasted in the network, executes them in EVM, and holds the latest state and database of all Ethereum data. Geth, Nethermind, Hyperledger Besu and Erigon are currently available execution clients.

The consensus client (Beacon Node / CL client, previously called Eth2 client) implements the proof-of-stake consensus algorithm, which enables the network to achieve agreement based on validated data from the execution client. Lighthouse, Lodestar, Nimbus, Prysm and Teku are some of the available consensus clients.

Prior to the merge Ethereum nodes consisted of only the execution layer which took care of Proof of Work consensus also. The merge finalized the transition of consensus from proof of work(PoW) to proof of stake(PoS). The PoS consensus-related tasks were managed by the consensus client, and deprecated the PoW functionality in the execution client.

In this short tutorial, I will demonstrate how to configure an Ethereum client in Ubuntu 20.04.4. We will use Hyperledger Besu as the execution client and Lighthouse as the consensus client. You may use any combination of execution and consensus clients.

Installation

Java Installation

Since besu is based on Java, ensure you have Java installed. If not, update and install Java using the below commands.

sudo apt update
sudo apt install openjdk-17-jdk

Ensure that Java has been installed successfully by doing a version check.

java --version

Besu Installation

Download the latest version of binaries from https://github.com/hyperledger/besu/releases. Here I am using Hyperledger Besu 23.1.2.

wget https://hyperledger.jfrog.io/hyperledger/besu-binaries/besu/23.1.2/besu-23.1.2.zip

The above command will download the compressed folder. Once the download is complete, unzip the contents into a new folder named besu.

If you do not have unzip command, install using apt install unzip

unzip besu-23.1.2.zip -d besu

Switch to the besu folder and list the files to confirm the installation.

cd besu
ls

Switch to the besu subfolder and confirm the besu version using the command.

./bin/besu --version

To change the command from ./bin/besu to besu, we should provide the full path of besu’s bin directory in the environment file. First, use the below command to display the full path of besu (present working directory) and copy it.

pwd

Next, open the environment file using the command

sudo nano /etc/environment

and append the copied path(including the bin folder) at the end of the current data.

Note: Editing the environment variable can also be done by the command:

echo ‘export PATH=$PATH:/root/besu-23.1.2/bin’ >> ~/.bashrc

Now restart the system.

Can’t wait till your system restarts? Just give the command

source /etc/environment in the terminal, it will refresh the system environment only for the open terminal.

Confirm the changes are complete by checking the version.

Install Lighthouse

Download the latest version from this link, extract the contents, or use the commands below.

wget https://github.com/sigp/lighthouse/releases/download/v4.0.1/lighthouse-v4.0.1-x86_64-unknown-linux-gnu.tar.gz
tar -xvf lighthouse-v4.0.1-x86_64-unknown-linux-gnu.tar.gz 

To change the command from ./lighthouse to lighthouse, edit the environment file as described previously.

JWT Token Generation

The execution and consensus clients authenticate each other using a 32-byte hexadecimal value called JSON Web Token (JWT secret). Before configuring the clients, let’s create the token.

You may also create it using any generator like seanwasere generator. Some clients have an inbuilt facility for token generation. You can also create a random number yourself.

I am using OpenSSL, a toolkit for cryptographic functions, to generate the token. It will be available by default in most Linux versions. If you do not have OpenSSL, please check this link for installation guidelines: https://www.openssl.org/source/.

openssl rand -hex 32 | tr -d "\n" > jwtsecret.hex

The secret code will be available in the file jwtsecret.hex.

Starting the execution client

To start the execution client, we need to specify some configuration attributes. For this, create a config.toml and copy the below content.

network="MAINNET"
data-path="./data"
rpc-http-enabled=true
rpc-http-host="0.0.0.0"
rpc-http-cors-origins=["*"]
rpc-ws-enabled=true
rpc-ws-host="0.0.0.0"
host-allowlist=["*"]
engine-host-allowlist=["*"]
engine-rpc-enabled=true
engine-jwt-secret="./jwtsecret.hex"

The configuration specifies the path to store synced data, enables HTTP and web socket communications from external sources and allows engine API services (intercommunication between execution and consensus layers).

Use the below command to start besu.

Make sure that you are in the folder containing config.toml.

besu --Xlauncher

From the terminal information, note the Engine port (8551). Next, we can configure the consensus client to connect with this execution client.

Starting the consensus client

Open a new terminal in the same location and use the below command.

lighthouse bn 
  --network mainnet 
  --execution-endpoint http://localhost:8551 
  --execution-jwt ./jwtsecret.hex 
  --checkpoint-sync-url https://sync-mainnet.beaconcha.in/  
  --disable-deposit-contract-sync 
  --http 
  --purge-db

It will instruct the lighthouse to try to connect with the present execution client, running at port number 8551. The checkpoint sync endpoints are available here. You may use any endpoints for syncing. The deposit contract syncing is disabled since we are not participating in staking. If the consensus client is stopped and restarted, there can be some errors with checkpoint syncing; the purge-db flag is used to deal with this situation.

According to the network, the time taken for syncing will be different. You can use the testnets goerli or sepolia, where the sync times are shorter. To switch to test networks, update the network parameter and checkpoint-sync-endpoints.

Within a short time, Besu and Lighthouse can connect. The clients will try to sync with the other peers in the network. The updates will be visible in the terminal.

Output Terminal of Besu
Output Terminal of Teku

Can you identify the sync mode which we are using? Running a full node can be heavy since the hardware/software requirements to manage it effectively can only be met with effort.

There are various methods to interact with the running node. Application Programming Interfaces (APIs) define methods to query a node. This will be covered in the next blog. Stay tuned.

References

[1] https://lighthouse-book.sigmaprime.io/intro.html

[2] https://besu.hyperledger.org/en/stable/

[3] https://ethereum.org/en/developers/docs/nodes-and-clients/#why-should-i-run-an-ethereum-node

(By Sumi Maria Abraham, Research & Development Engineer, Kerala Blockchain Academy)

Read more: https://kbaiiitmk.medium.com/how-to-configure-ethereum-node-152436897536

Comments

All Comments

Recommended for you

  • OpenTrade announces $4 million seed extension round led by AlbionVC

    OpenTrade has announced the completion of a $4 million seed extension financing round to build RWA-supported loan and stablecoin yield products. This round of financing was led by AlbionVC, with participation from a16z Crypto and CMCC Global. OpenTrade plans to use the funds to expand its operations and enhance its product capabilities.

  • BNB Chain Ecosystem Re-staking Infrastructure Kernel Receives Investment from Binance Labs

    BNB Chain's ecological re-staking infrastructure Kernel has announced that it has received investment from Binance Labs. As of now, its total financing amount has reached 10 million US dollars, with main investors including: SCB Limited, Laser Digital, Bankless Ventures, Hypersphere, Draper Dragon, DACM, CYPHER, ArkStream Capital, HTX Ventures, Avid VC, GSR, Cluster Capital, Longhash Ventures, Via BTC, Side Door Ventures, NOIA, and DWF Labs. It is reported that Kernel's mainnet is about to be launched. Kelp provides users with support for Ethereum liquidity re-staking services based on rsETH, while Gain provides DeFi, CeDeFi, and RWA income products. KERNEL tokens are designed to unify the governance and incentive mechanisms of Kelp, Kernel, and Gain, while providing rewards for early supporters of ecosystem development.

  • Morgan Stanley: The U.S. dollar will peak before the end of the year and enter a "bear market pattern" in 2025

    Morgan Stanley predicts that the strong US dollar will peak before the end of the year and then enter a "bearish market trend", slowly declining until 2025. The bank believes that due to the Bank of Japan's rate hikes and gradual easing actions by the Reserve Bank of Australia, the potential for the yen and Australian dollar to rise next year is the greatest.

  • Equation News calls out Binance for "insider trading": You are destroying the sentiment of the trading market

    On November 25th, Formula News reported that to those insider traders who participated in the listing of Binance perpetual contracts, please slow down when selling your chips next time. The WHY and CHEEMS crashes you caused resulted in a 100% negative return for everyone involved in the trade, and you are destroying the emotions of the trade. Earlier today, Binance announced the listing of 1000WHYUSDT and 1000CHEEMSUSDT perpetual contracts, which caused a short-term crash in WHY and CHEEMS and sparked intense discussion within the community.

  • Are we finally ready for a gas limit increase?

    There has been growing discussion around the possibility of increasing Ethereum’s gas throughput, either by raising the gas limit or reducing slot time. The key argument in favor of this is that the hardware requirements for running a validator have steadily decreased over the past four years.

  • Cointime August 17th News Express

    1.VanEck and 21Shares Solana ETF Form 19b-4 Suspected to be Removed from CBOE Website

  • Ethereum network gas fee falls back below 1 gwei

    According to Etherscan data, the current Ethereum network gas fee has fallen below 1 gwei, currently at 0.937 gwei.

  • Cointime August 10th News Express

    1. The U.S. Internal Revenue Service has released a new draft of the crypto tax form, which no longer requires filling in wallet addresses and transaction IDs

  • Ethereum ACDC #139: Pectra's Devnet 2 upgrade is under debugging, and the release date of Devnet 3 is still to be determined

    Christine Kim, Vice President of Galaxy Research, summarized the main content of the 139th ACDC conference call. The debugging of Pectra's upgraded Devnet 2 is currently underway, and the release date of Devnet 3 is yet to be determined. Developers will hold weekly testing update meetings starting from Monday to better coordinate the release of Pectra's Devnet. The decision to include EIP-7688 in Pectra's upgrade has been postponed again.

  • Ethereum network gas fee drops to 1 gwei

    According to Ether­scan data, the current gas fee on the Ethereum network has dropped to 1 gwei.