It's still possible to run the execution client (layer 1) alone but after the Merge in the upcoming days, we need to run the execution client and consensus client to be able to access to the Ethereum network. In this article, I will cover the
execution layer only.
The execution client listens to new transactions and executes them in the EVM (state machine) and holds the database of Ethereum network.
- See the overview of execution client in Etherenodes
- See the execution layer specification in Ethereum Repo
This article covers the node running from the source code or from the package in Ubuntu.
- Node Types
- Why should I run a node
- Create the chaindata folder
- Run the node
- Interacting with Geth
- Run the node (dev mode / contributor)
- Next Step
Little abstract before jumping in our journey with the Ethereum node.
Ethereum is a distributed decentralised network of computers. Each computer in this network is running a software that contains the history of the blockchain, the ability to validate/mine blocks and transactions.
In order to be a node in the Ethereum network, a client needs to download this software that implements the specification of the yellow paper to be able to communicate within the network.
In this article, the client I'll be choosing is Geth. It's the most popular client and backed by the Ethereum Community.
You can run a node on any computers but it's worth to consider running your Ethereum node in a dedicated hardware to minimise the performance issues.
Make sure to have a stable internet connection. Even though you can go offline, your node goes inactive until you come back and download the latest changes from other nodes automatically.
You can buy hardware from a vendor and have a plug and play node or you can build your own. The last option is cheaper and funnier.
- 8GB RAM (16GB for a validator);
- 2TB SSD for write speeds (12TB for Archive node);
- CPU with a benchmark score of 6667+
- 16GB RAM (32GB for a validator);
- Unlimited High speed internet bandwidth;
In order to run your node, you need to be aware of the node types. Each node type consumes data differently. There are 3 node type:
- Light Node
- Full Node
- Archive Node
Instead of downloading the entire blockchain, you can download a shallow copy of the data containing only the block headers. A light node relies on a full node to get more data. A light node can also verify the data and participate to the network. The drawback is that you cannot participate in a consensus, you cannot be a miner nor a validator.
The full node stores all block data not since the
Genesis. This is periodically pruned and get only the most recent 128 blocks. A full node can:
- Participate in a consensus;
- Validate blocks;
- Verify the states;
- Serve the network and provide data on request;
The drawback is that you cannot query data at block #1,000,000 because you don't have the entire history. Only the 128 last blocks.
The archive node stores the historical states since the
Genesis. Basically, if you want the query data since the first block, you can with the archive node.
If you really believe in Ethereum, and decentralised crypto currency, you should consider running a node.
You can use Ethereum privately and verify the data yourself. "Don't trust, verify" is a popular Blockchain mantra.
- Don't rely on another node
- Use an Ethereum wallet within the node and use DApps more securely and privately without leaking your address and balance to another node.
- Build your custom RPC endpoint
- Stake your ETH and earn rewards (be a validator with 32ETH)
- Allow wallets provider like
Metamaskto use your node
- Enforce the consensus rules
- Social recovery in case of massive attack
- More diverse and robust network and provide a censorship-resistant ecosystem
If you are on Windows and have
Chocolatey installed, you can run (Admin mode) these commands:
choco install git
choco install golang
choco install mingw
(If you run these commands, you'll need to close your terminal and open up a new one)
Then you can follow one of these steps in order to have Geth installed:
- Download Source code (Windows) or
- Download Source Code (Linux) or
- Download the Package (Ubuntu)
In order to download the source code, you can copy and paste these commands:
git clone firstname.lastname@example.org:ethereum/go-ethereum.git src\github.com\ethereum\go-ethereum
You can now build the project from the binaries
go get -u -v golang.org/x/net/context
go install -v ./cmd/...
If you have Linux (or MacOS), it's slightly different. You can just run this command:
go get -d github.com/ethereum/go-ethereum
If you have an existing Geth client, you can update with this command
go get -u github.com/ethereum/go-ethereum
You need to add the launchpad repository
sudo add-apt-repository -y ppa:ethereum/ethereum
Then you can download the stable version of go-ethereum
sudo apt-get update
sudo apt-get install ethereum
If you have an existing geth installation, you can get the latest version with the following commands:
sudo apt-get update
sudo apt-get install ethereum
sudo apt-get upgrade geth
In order to store the chain data, you need to create a folder somewhere in your system. I usually create the chain data at the same level of the binary (in my case)
mkdir -p ./chain/data
Now you are ready for running the node.
geth console --syncmode full --networkid 1 --gcmode full --datadir ..\chain\data\
What I'm doing here:
- geth: command line interface for the client
- console: start geth environment
- syncmode full: blockchain sync mode to full (default to snap)
- networkid 1: run the mainnet (by default it runs the mainnet)
- gcmode full: Garbage collection (full or archive)
- datadir: chaindata folder path that I have created earlier on
You can run a testnet node if you want to. You need to remove
--networkid 1 and replace by
geth --help to see the full list of commands
Once you have executed this command, you should have this output
You will see that it will be searching for peers and download the blockchain data since the genesis (7 years 2 month and 5 days in my case)
(It's running in foreground. As soon as you close the terminal or press Ctrl+C / Ctrl+D, it will shutdown the node). If you want to run a node in a foreground or using as a service in Ubuntu, there are a lot of documentation for you. This is not the purpose of this article.
You can interact with your node by attaching it to the datadir
geth attach --datadir ..\chain\data\
You can see what is the current block being downloaded and the highest block by executing this command in the interactive console
var lastPercentage = 0;
var lastBlocksToGo = 0;
var timeInterval = 10000;
var percentage = eth.syncing.currentBlock/eth.syncing.highestBlock*100;
var percentagePerTime = percentage - lastPercentage;
var blocksToGo = eth.syncing.highestBlock - eth.syncing.currentBlock;
var bps = (lastBlocksToGo - blocksToGo) / (timeInterval / 1000)
var etas = 100 / percentagePerTime * (timeInterval / 1000)
var etaM = parseInt(etas/60,10);
console.log(parseInt(percentage,10)+'% ETA: '+etaM+' minutes @ '+bps+'bps');
lastPercentage = percentage;lastBlocksToGo = blocksToGo;
The number of block will be decreasing because over the year, there are more and more transaction in a block and you will be downloading more data in a full node in the last 128 blocks.
The purpose of this article is not to help you running in dev mode. So I won't detail too much.
If you want to contribute to the Ethereum client, you can run the command geth in dev mode without putting your assets at risk. There is a
--dev flag that run
geth in dev mode. In this way you have a node with:
- Data directory with a testing genesis block
- Max peers to 0. That means that Geth won't search for peers (default to 50)
- The node won't be visible to other nodes
- Gas price is set at 0 wei
- PoA (Proof of Authority) in order to mine block on demand
- Generate Block on demand.
For example, you can run this command:
geth --dev --http --http.api eth,web3,personal,net --http.corsdomain "http://remix.ethereum.org"
(See the full help from the command
The next step is to run the consensus layer in order to be able to participate in the network after the merge.
After that, we will be covering the setup of a private node.
Here you have just an overview on how to setup an Ethereum node. There are more to cover like:
- Using Clef as ab account management for Geth that allows to sign transaction
- Create a specific user to setup the node and give privilege
- Port forwarding for your node
- Miner options from the command line (will be deprecated)
- Auto start on boot in Linux And more.
Thank you for reading and have fun in the decentralised world :)