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

  • A British court has postponed the final sentencing of Wen Jian, a British-Chinese national involved in the country's largest Bitcoin money laundering case, until May 24.

    On May 11th, it was reported that Jian Wen, a 42-year-old British Chinese citizen, was found guilty of "participating in arranging money laundering" in the UK's largest Bitcoin money laundering case. He could be sentenced to up to 14 years in prison. Jian Wen's defense lawyer, Mark Harries, stated that due to the judge's busy schedule, the UK court has postponed Jian Wen's final sentencing, which was originally scheduled for May 10th, to May 24th.

  • Web3 startup Star Nest completes $6 million in Pre-A round of financing

    Hong Kong Web3 music startup Star Nest announced that it has completed a $6 million Pre-A round of financing, led by Chuangqi International Limited, a wholly-owned subsidiary of Hong Kong Stock Exchange-listed company Guofu Innovation. Star Nest will collaborate with Armonia Meta Chain to develop the Star Nest SpaceStar metaverse game, which includes music, role-playing, and social features.In addition, Star Nest plans to launch its NEST project in the third quarter of 2024. Nest will receive 2.1 billion NEST tokens tailored for the project, and Star Nest will use the NEST token to build a more complete music industry token economic system. The NEST token will be widely used for purchasing performance tickets, chain game cooperation, metaverse consumption, governance voting, and other activities.

  • Over $594 million worth of PYTH is staked

    According to Dune data,  there are currently 1,201,167,362 PYTH tokens in the staked state, with a total staked value exceeding $594 million. The number of PYTH stakers has reached 151,211.

  • US Department of Justice: Tornado Cash indictment has nothing to do with "free speech"

    On May 11th, the US Department of Justice explained why the motion to dismiss the criminal case against Tornado Cash founder Roman Storm was invalid. The Department of Justice reiterated that their indictment was not related to whether the Tornado Cash computer code had freedom of speech or was protected by the First Amendment of the Constitution. The defendant was not charged for publishing computer code, but for using it to facilitate profitable illegal activities.

  • USDC circulation decreased by $100 million in the past week, with a total circulation of $33 billion

    According to official data,as of May 9th, Circle has issued approximately $2 billion USDC and redeemed approximately $2 billion USDC in the past 7 days, with a decrease in circulation of approximately $100 million. The total circulation of USDC is $33 billion, with a reserve of $33.1 billion, including approximately $3.3 billion in cash and Circle Reserve Fund holding approximately $29.8 billion.

  • SEC rejects Coinbase's request for appeals court ruling on cryptocurrency rules

    The US SEC has rejected Coinbase's request to appeal to the court to review whether traditional securities rules are applicable to cryptocurrencies. In its application, Coinbase stated that it hoped the appeals court would consider whether the Howey test, which has long been used for securities evaluation, should be applied to digital assets. However, the SEC pointed out that Coinbase has not successfully demonstrated the need for such an evaluation. The SEC stated that Coinbase is attempting to create a "new legal test," but this attempt was rejected by the court. The court found that Coinbase's arguments lacked consistency and did not successfully demonstrate the existence of decisive issues. Currently, the judge responsible for hearing the SEC's case against Coinbase will make a ruling on Coinbase's intermediate appeal motion.

  • Colombian President Suspected of Accepting $500,000 in Illegal Crypto Donations

    Colombian President Gustavo Petro is suspected of accepting over $500,000 in digital token donations from a fraudulent cryptocurrency project during his 2022 election campaign. A former contractor revealed that the illegal donation occurred during a meeting in February 2022 that discussed the advantages of cryptocurrency and the possibility of working with the government. This allegation is one of the latest charges faced by President Petro during his election campaign, with the Colombian Prosecutor's Office investigating his campaign last year.

  • Fed's Kashkari: The bar for another rate hike is high, but it cannot be ruled out

    The Federal Reserve's Kashkari expressed a cautious attitude towards restrictive monetary policy; he is adopting a wait-and-see attitude towards future monetary policy; he is in a wait-and-see state to see if inflation is stagnating; the threshold for raising interest rates again is high, but this possibility cannot be ruled out; if inflation data supports it, the Fed will maintain interest rates.

  • Blockchain Asset Management announces launch of a dedicated blockchain fund for accredited investors

    Blockchain Asset Management, a cryptocurrency fund with a scale of $100 million, announced the launch of an exclusive blockchain fund for qualified investors. The specific amount of funds raised by the fund has not been disclosed yet, but it is said to have reached "eight figures", which means it is in the tens of millions of dollars. In addition, the investment threshold for the new fund is $100,000, and all investors are required to meet the approved standards (annual income exceeding $200,000, net assets exceeding $1 million).

  • The 133rd Ethereum ACDC meeting: The goal is to complete the devnet within 7-10 days

    The Ethereum developers held their 133rd ACDC conference call. First, they outlined the latest research on Ethereum protocol confirmation rules. Then, they discussed Pectra updates related to EIP-7547 and CFI states, and decided to put them on hold temporarily. They also updated the v1.5.0-alpha.1 specification. Regarding the implementation updates for devnet-0, most teams are making progress, but there are also some unexpected complexities. The goal is to complete devnet within 7-10 days.