What is Ethereum light node?
Ethereum light node protocol is big step towards bringing the Ethereum client to small devices with limited hardware resources. Details of light client protocol can be found at GitHub.
First you need to install geth. You can follow the instruction here about geth installation.
$geth version Geth Version: 1.8.0-unstable Git Commit: 55599ee95d4151a2502465e0afc7c47bd1acba77 Architecture: amd64 Protocol Versions: [63 62] Network Id: 1 Go Version: go1.8.1 Operating System: linux GOPATH= GOROOT=/usr/lib/go-1.8
Geth can be started in "full", "fast", or "light" syncmode.
- Full Sync: It gets the block headers, the block bodies, and validates every element from genesis block.
- Fast Sync: It gets the block headers, the block bodies, it processes no transactions until current block. Then it gets a snapshot state and goes like a full synchronization.
- Light Sync: It gets only the current state. To verify elements, it needs to ask to full (archive) nodes for the corresponding tree leaves.(Source: Stackexchange)
For light node client, we start geth in light mode; pass --syncmode "light" to stratup commmand.
geth --syncmode "light" --rpc --rpccorsdomain "*" --datadir path-to-directory-to-save-blocks
It takes less than 10 minute and approx 300MB of space to sync the node.
Why is light node so fast and less space consuming?
Light node download just the header of the blocks and that too it does not download all the blocks. For all kind of processing, light node depends on full node peers.
At the time of writing this article, current block number is "5139816" and it started downloading "4948159" block onwards as you can see in log below.
INFO [02-22|21:32:59] UDP listener up net=enode://0162ef15d43d3d5f8edad80d938c1413e898edd6bdc8162976912d6bcb96f8aeba266e017dce7917785aafcfce584781ece81143988e452208a976a4a71730cb@[::]:30303 WARN [02-22|21:32:59] Light client mode is an experimental feature INFO [02-22|21:32:59] RLPx listener up self="enode://0162ef15d43d3d5f8edad80d938c1413e898edd6bdc8162976912d6bcb96f8aeba266e017dce7917785aafcfce584781ece81143988e452208a976a4a71730cb@[::]:30303?discport=0" INFO [02-22|21:32:59] IPC endpoint opened: /media/nodejs/Ethereum/fastnodeblocks/geth.ipc INFO [02-22|21:32:59] HTTP endpoint opened: http://127.0.0.1:8545 INFO [02-22|21:32:59] Mapped network port proto=udp extport=30303 intport=30303 interface="UPNP IGDv1-IP1" INFO [02-22|21:32:59] Mapped network port proto=tcp extport=30303 intport=30303 interface="UPNP IGDv1-IP1" INFO [02-22|21:36:00] Block synchronisation started INFO [02-22|21:36:04] Imported new block headers count=192 elapsed=2.653s number=**4948159** hash=2f28c7…916482 ignored=0 INFO [02-22|21:36:05] Imported new block headers count=192 elapsed=366.718ms number=4948351 hash=af7be1…954b05 ignored=0 INFO [02-22|21:36:07] Generating ethash verification cache epoch=165 percentage=72 elapsed=3.018s
It downloads block header and verifies it. As verification is a CPU intensive process, you can expect CPU utilization to go high.
Note: The light client protocol is under development. See the following links for current state of the protocol specification.
If interested, you can participate in discussion on Ethereum Light node on Gitter.
Read similar articles below: