How to reduce time to sync Ethereum Geth node from few weeks to few hours?
Here is the answer!
To create your own Ethereum full node...
you need to have powerful server with a fast storage, fast internet connection and enough time to synchronize node with the network
Here is some benchmark results, regarding to the post from official Ethereum blog:
Full sync benchmark on two i3.2xlarge AWS EC2 instances ($0.624 per Hour, 8 cores, 61 GiB RAM, ephemeral volume 1.9 TiB NVMe SSD, if you stop the instance - you will lose all data)
with --cache=4096 --maxpeers=50 --syncmode=full
Using c5.xlarge instance with EBS io1 volume (Provisioned IOPS) you can spend more, than 5 weeks time and about $1325, AWS calculation is here
Here is a way to download data from the existing node and continue to sync:
Pre Requirements:
Hardware: at least 1.6 TB of free space on storage, 16GB RAM (but 8GB can work), 4 CPU cores (but 2 CPU cores can work)
Software: all we need are lftp and docker (here is the manual for Ubuntu):
sudo apt-get update -y
sudo apt-get install docker.io lftp -y
sudo usermod -aG docker $USER
sudo su - $USER
1. Download chaindata folder:
lftp -e "mirror ./chaindata ./chaindata --log=downloading.log" http://api.chaindata.club 2>&1 &
disown "%lftp"
To view downloading log (be ready to wait ~1 hour, while lftp utility indexing the remote folder):
tail -f downloading.log
2. Run Geth mounting the datadir folder:
mkdir -p full-ethereum-node/geth
mv chaindata full-ethereum-node/geth/
docker run -d --rm --name full-node-ethereum --ulimit nofile=10000:10000 -p 8545:8545 -p 30303:30303 -v $PWD/full-ethereum-node:/root/.ethereum ethereum/client-go --http --http.addr "0.0.0.0" --nousb --ipcdisable --syncmode full
To view geth log:
docker logs -f full-node-ethereum
3. To check actual state of the node:
docker run --rm -it ethereum/client-go --exec "eth.blockNumber" attach http://$(hostname -I | awk '{print $1}'):8545