Running an Ethereum node from source under Ubuntu 16 LTS

This howto is made to show you how to run an Ethereum node. To run an Ethereum node we need the

geth

program to start and wait for the network synchronization – our Ethereum node will receive all the blockchains of the network!
After a successful Ethereum network synchronization we can send and receive coins securely ourselves! No other online service offers us secure sending and receiving of transcations and creation of wallet, the only way a crypto user could be absolutely sure the private key is seen only from him and is generated on his server is to become part of the Ethereum network and create your wallet with “geth” manually by the user himself.
And also be warned DO NOT use insecure sources when:

  1. installing Ubuntu, install it from a cd/dvd/usb downloaded from the official Ubuntu site here.
  2. installing all the needed dependencies from official sources only, not recommended the PPA reposigories, neither!
  3. install yourself the “geth” program, which will create an Ethereum node and after network synchronization could be used to create an Ethereum node.

Three simple rules could almost eliminate leaking your private key to hackers, which in blockchain world means losing your money…
And before start the installation a performance advice do not attempt to run an Ethereum node in a hard disk –

USE SSD

If you use a hard disk even in RAID configuration it could take several days for network synchronization and probably your machine will be useless during the synchronization.

So here are the steps to create from a scratch an Ethereum node:

STEP 1) Install Ubuntu 16 – our howto will be available soon here.

STEP 2) Building from source an Ethereum node

Check out our howto“Building from source an Ethereum node under Ubuntu 16 LTS”.

STEP 3) Start the Ethereum node

if you have followed the howto in STEP 2) you probably have “geth” installed in “~/go-ethereum/build/bin”, so first running it with:

ubuntu@srv.local:~/go-ethereum/build/bin$ ./geth --rpc --fast --cache=8144 &> ./geth.log

STEP 3) Wait for the blockchain network synchronization

When you run “geth” it will check the current state of the network and the current state of your Ethereum node, so no matter it is started for the first time or not a network synchronization is needed, your node need to be synchronized with the Ethereum network to be used for all kind of actions in the network (create a wallet, transfer funds and more).
Here is the output of just started Ethereum node:

INFO [02-27|19:14:02] Maximum peer count                       ETH=25 LES=0 total=25
INFO [02-27|19:14:02] Starting peer-to-peer node               instance=Geth/v1.8.2-unstable-b574b577/linux-amd64/go1.9.4
INFO [02-27|19:14:02] Allocated cache and file handles         database=/home/ubuntu/.ethereum/geth/chaindata cache=6108 handles=512
INFO [02-27|19:14:02] Writing default main-net genesis block 
INFO [02-27|19:14:03] Persisted trie from memory database      nodes=12356 size=2.34mB time=49.406185ms gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [02-27|19:14:03] Initialised chain configuration          config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: <nil> Engine: ethash}"
INFO [02-27|19:14:03] Disk storage enabled for ethash caches   dir=/home/ubuntu/.ethereum/geth/ethash count=3
INFO [02-27|19:14:03] Disk storage enabled for ethash DAGs     dir=/home/ubuntu/.ethash               count=2
INFO [02-27|19:14:03] Initialising Ethereum protocol           versions="[63 62]" network=1
INFO [02-27|19:14:03] Loaded most recent local header          number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [02-27|19:14:03] Loaded most recent local full block      number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [02-27|19:14:03] Loaded most recent local fast block      number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [02-27|19:14:03] Regenerated local transaction journal    transactions=0 accounts=0
INFO [02-27|19:14:03] Starting P2P networking 
INFO [02-27|19:14:05] UDP listener up                          self=enode://4ee1f43cc597fa829a04ec97dee38ad4f2c61f39f0f0e5ebd46e095c660cc95aab71eef55b0db9fd64d0afaeb589a8d9cb3eb86fdc07e32183648bc89dbd4aca@[::]:30303
INFO [02-27|19:14:05] RLPx listener up                         self=enode://4ee1f43cc597fa829a04ec97dee38ad4f2c61f39f0f0e5ebd46e095c660cc95aab71eef55b0db9fd64d0afaeb589a8d9cb3eb86fdc07e32183648bc89dbd4aca@[::]:30303
INFO [02-27|19:14:05] HTTP endpoint opened                     url=http://127.0.0.1:8545 cors= vhosts=localhost
INFO [02-27|19:14:05] IPC endpoint opened                      url=/home/ubuntu/.ethereum/geth.ipc
INFO [02-27|19:14:45] Block synchronisation started 
WARN [02-27|19:14:53] Synchronisation failed, retrying         err="block download canceled (requested)"
WARN [02-27|19:14:56] Node data write error                    err="state node 6aa064…378280 failed with all peers (1 tries, 1 peers)"
WARN [02-27|19:14:56] Synchronisation failed, retrying         err="state node 6aa064…378280 failed with all peers (1 tries, 1 peers)"
WARN [02-27|19:15:07] Node data write error                    err="state node 6aa064…378280 failed with all peers (3 tries, 3 peers)"
WARN [02-27|19:15:07] Synchronisation failed, retrying         err="state node 6aa064…378280 failed with all peers (3 tries, 3 peers)"
INFO [02-27|19:15:20] Imported new block headers               count=192 elapsed=1.115s number=192 hash=723899…123390 ignored=0
INFO [02-27|19:15:20] Imported new block receipts              count=2   elapsed=80.248µs number=2   hash=b495a1…4698c9 size=8.00B  ignored=0
INFO [02-27|19:15:20] Imported new block headers               count=192 elapsed=19.822ms number=384 hash=d3d5d5…c79cf3 ignored=0
INFO [02-27|19:15:21] Imported new block receipts              count=4   elapsed=117.07µs number=6   hash=1f1aed…6b326e size=1.10kB ignored=0
INFO [02-27|19:15:22] Imported new block headers               count=2048 elapsed=146.493ms number=2432 hash=78a9e6…079de3 ignored=0

As you can see the node connects to another nodes and receives blockchains and saves them to its local database. At present (late February 2017) a fully synchronized Ethereum node takes 59 Gigabytes of space, but this number will changed when you run your node.

STEP 3) Check the progress of the Ethereum network synchronization

The progress of Ethereum node synchronization could be checked with the “geth” program. Execute in the console:

ubuntu@srv.local:~/go-ethereum/build/bin$ ./geth --exec "web3.eth.syncing" attach
{
  currentBlock: 388,
  highestBlock: 5159514,
  knownStates: 0,
  pulledStates: 0,
  startingBlock: 0
}
ubuntu@srv.local:~/go-ethereum/build/bin$ ./geth --exec "web3.eth.syncing" attach
{
  currentBlock: 401,
  highestBlock: 5159514,
  knownStates: 0,
  pulledStates: 0,
  startingBlock: 0
}

As you can see we are at the very beginning here, we’ve received 401 of total 5159514 in the network.

After around 2 hours we are at 4882892 of total 5166333 in the network.

ubuntu@srv.local:~/go-ethereum/build/bin$ ./geth --exec "web3.eth.syncing" attach
{
  currentBlock: 4882892,
  highestBlock: 5166333,
  knownStates: 4806466,
  pulledStates: 4800942,
  startingBlock: 0
}

It is normal the highest block to increment, because the network is used intensively.
STEP 4) Successful full synchronization – how to check and to be sure
When you are almost then like in the last section of the STEP 3) you’ll begin to see lines in the geth output like:

INFO [02-28|01:46:28] Imported new block headers               count=0    elapsed=1.281ms   number=5168639 hash=433308…1a710e ignored=71

and when you execute geth with “web3.eth.syncing”:

ubuntu@srv.local:~/go-ethereum/build/bin$ ./geth --exec "web3.eth.syncing" attach
false

The node will keep on receiving new blocks, so synchronization is triggered again, syncing the received blocks and stops again. So when transferring funds or creating a wallet or any other action there will be triggered a synchronization and then execution of the action. There is a callback for when sync starts and stops. If you cannot see multiple times “false” after the last synchronization check with geth, but your are almost at the highest block, no need to worry everything is OK, you node is almost fully synchronized and can be used.

At present with SSD and 32G RAM on a intel i7 processor and a fast Internet connection 100Mbps the full synchronization took about 8 hours.

Building from source an Ethereum node under Ubuntu 16 LTS

The program, which makes an Ethereum node in your computer, is called

geth

. “geth” is written using the GO language and the latest version depends on GO version 1.7+. Ubuntu 16 LTS has GO language package version 1.6 so to build it from source we need first to install a proper version of GO Language.

STEP 1) Install a proper version of GO Language 1.7+

In our tutorial you will install 1.9 using this howto: “Install GO language in Ubuntu 16 LTS from the official site package”

STEP 2) Update your system and install dependencies

sudo apt-get update -y
sudo apt-get install -y build-essential libgmp3-dev git

STEP 3) Get the “geth” code and compile it

git clone https://github.com/ethereum/go-ethereum
cd go-ethereum
make geth

STEP 4) Check is everything is OK, installed geth version 1.8.2-unstable

srv@local:~/go-ethereum$ cd ./build/bin
srv@local:~/go-ethereum/build/bin$ ./geth version
Geth
Version: 1.8.2-unstable
Git Commit: b574b5776695eb30e034fd8c7a468b3f03d4c6b9
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.9.4
Operating System: linux
GOPATH=
GOROOT=/usr/local/go

* Next tutorial is getting the node up and running here!

* Troubleshooting

  • if you get
    ~/go-ethereum$ make geth
    build/env.sh go run build/ci.go install ./cmd/geth
    build/env.sh: 30: exec: go: not found
    Makefile:15: recipe for target 'geth' failed
    make: *** [geth] Error 127
    

    You did not install properly go, check our manual here: “Install GO language in Ubuntu 16 LTS from the official site package”. Check whether you source /etc/profile in your current ssh/console/login session, check if you exported the PATH, your PATH must include “your_goinstallation_path/bin”, it’s like “/usr/local/go”.

  • if you get
    ~/go-ethereum$ make geth
    build/env.sh go run build/ci.go install ./cmd/geth
    ci.go:190: You have Go version go1.6.2
    ci.go:191: go-ethereum requires at least Go version 1.7 and cannot
    ci.go:192: be compiled with an earlier version. Please upgrade your Go installation.
    exit status 1
    Makefile:15: recipe for target 'geth' failed
    make: *** [geth] Error 1
    

    The installation just uses the default installed GO language of your system, which is 1.6 and is not supported by the “geth” Ethereum program. There are two options:

When we talk for crypto currency the best source is always the GIT version (probably the best one is the stable tag, but it is safe to use the unstable, too), it is most secure source you could get. Do not download from 3rd party sites or unofficial repositories, you could lose your money.

* Here is the building output

srv@local:~/go-ethereum$ make geth
build/env.sh go run build/ci.go install ./cmd/geth
>>> /usr/local/go/bin/go install -ldflags -X main.gitCommit=b574b5776695eb30e034fd8c7a468b3f03d4c6b9 -v ./cmd/geth
github.com/ethereum/go-ethereum/crypto/sha3
github.com/ethereum/go-ethereum/common/math
github.com/ethereum/go-ethereum/rlp
github.com/ethereum/go-ethereum/vendor/github.com/go-stack/stack
github.com/ethereum/go-ethereum/common/hexutil
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/util
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/comparer
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/storage
github.com/ethereum/go-ethereum/crypto/secp256k1
github.com/ethereum/go-ethereum/vendor/github.com/golang/snappy
github.com/ethereum/go-ethereum/log
github.com/ethereum/go-ethereum/vendor/gopkg.in/karalabe/cookiejar.v2/collections/prque
github.com/ethereum/go-ethereum/common
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/cache
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/filter
github.com/ethereum/go-ethereum/vendor/github.com/aristanetworks/goarista/monotime
github.com/ethereum/go-ethereum/common/mclock
github.com/ethereum/go-ethereum/event
github.com/ethereum/go-ethereum/crypto/randentropy
github.com/ethereum/go-ethereum/vendor/github.com/pborman/uuid
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/opt
github.com/ethereum/go-ethereum/vendor/golang.org/x/sys/unix
github.com/ethereum/go-ethereum/vendor/golang.org/x/crypto/pbkdf2
github.com/ethereum/go-ethereum/params
github.com/ethereum/go-ethereum/vendor/golang.org/x/crypto/scrypt
github.com/ethereum/go-ethereum/vendor/gopkg.in/fatih/set.v0
github.com/ethereum/go-ethereum/cmd/internal/browser
github.com/ethereum/go-ethereum/metrics
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/errors
github.com/ethereum/go-ethereum/common/fdlimit
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/iterator
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/journal
github.com/ethereum/go-ethereum/vendor/github.com/hashicorp/golang-lru/simplelru
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/context
github.com/ethereum/go-ethereum/vendor/github.com/hashicorp/golang-lru
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/websocket
github.com/ethereum/go-ethereum/vendor/github.com/edsrzf/mmap-go
github.com/ethereum/go-ethereum/common/bitutil
github.com/ethereum/go-ethereum/vendor/github.com/rs/xhandler
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/memdb
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/table
github.com/ethereum/go-ethereum/crypto/bn256
github.com/ethereum/go-ethereum/vendor/github.com/rs/cors
github.com/ethereum/go-ethereum/vendor/golang.org/x/crypto/ripemd160
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/httpu
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/scpd
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/soap
github.com/ethereum/go-ethereum/rpc
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/ssdp
github.com/ethereum/go-ethereum/vendor/github.com/rjeczalik/notify
github.com/ethereum/go-ethereum/vendor/github.com/elastic/gosigar
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/html/atom
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/html
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/internal/identifier
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/transform
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/internal/utf8internal
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/internal/tag
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/language
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/runes
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/internal
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/charmap
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/japanese
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/korean
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/simplifiedchinese
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/traditionalchinese
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/unicode
github.com/ethereum/go-ethereum/ethdb
github.com/ethereum/go-ethereum/vendor/github.com/jackpal/go-nat-pmp
github.com/ethereum/go-ethereum/p2p/netutil
github.com/ethereum/go-ethereum/eth/tracers/internal/tracers
github.com/ethereum/go-ethereum/vendor/gopkg.in/olebedev/go-duktape.v3
github.com/ethereum/go-ethereum/vendor/github.com/golang/protobuf/proto
github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid
github.com/ethereum/go-ethereum/log/term
github.com/ethereum/go-ethereum/metrics/exp
github.com/ethereum/go-ethereum/vendor/github.com/mattn/go-colorable
github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave/cli.v1
github.com/ethereum/go-ethereum/vendor/github.com/prometheus/prometheus/util/flock
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/htmlindex
github.com/ethereum/go-ethereum/les/flowcontrol
github.com/ethereum/go-ethereum/vendor/golang.org/x/sync/syncmap
github.com/ethereum/go-ethereum/internal/jsre/deps
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/html/charset
github.com/ethereum/go-ethereum/vendor/github.com/mattn/go-isatty
github.com/ethereum/go-ethereum/vendor/github.com/fatih/color
github.com/ethereum/go-ethereum/vendor/gopkg.in/sourcemap.v1/base64vlq
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp
github.com/ethereum/go-ethereum/vendor/gopkg.in/sourcemap.v1
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/token
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/dbg
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/file
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/dcps/internetgateway1
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/dcps/internetgateway2
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/ast
github.com/ethereum/go-ethereum/internal/debug
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/parser
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/registry
github.com/ethereum/go-ethereum/internal/web3ext
github.com/ethereum/go-ethereum/vendor/github.com/peterh/liner
github.com/ethereum/go-ethereum/vendor/github.com/maruel/panicparse/stack
github.com/ethereum/go-ethereum/vendor/github.com/golang/protobuf/protoc-gen-go/descriptor
github.com/ethereum/go-ethereum/p2p/nat
github.com/ethereum/go-ethereum/vendor/github.com/mattn/go-runewidth
github.com/ethereum/go-ethereum/vendor/github.com/mitchellh/go-wordwrap
github.com/ethereum/go-ethereum/vendor/github.com/naoina/go-stringutil
github.com/ethereum/go-ethereum/vendor/github.com/naoina/toml/ast
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto
github.com/ethereum/go-ethereum/accounts/usbwallet/internal/trezor
github.com/ethereum/go-ethereum/vendor/github.com/nsf/termbox-go
github.com/ethereum/go-ethereum/vendor/github.com/naoina/toml
github.com/ethereum/go-ethereum/vendor/github.com/gizak/termui
# github.com/ethereum/go-ethereum/vendor/gopkg.in/olebedev/go-duktape.v3
In file included from vendor/gopkg.in/olebedev/go-duktape.v3/api.go:7:0:
vendor/gopkg.in/olebedev/go-duktape.v3/api.go: In function ‘_duk_error’:
vendor/gopkg.in/olebedev/go-duktape.v3/duktape.h:510:127: warning: right-hand operand of comma expression has no effect [-Wunused-value]
  (duk_error_raw((ctx), (duk_errcode_t) (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)
                                                                                                                               ^
vendor/gopkg.in/olebedev/go-duktape.v3/api.go:153:2: note: in expansion of macro ‘duk_error’
  duk_error(ctx, err_code, "%s", str);
  ^
github.com/ethereum/go-ethereum/internal/jsre
github.com/ethereum/go-ethereum/crypto
github.com/ethereum/go-ethereum/trie
github.com/ethereum/go-ethereum/crypto/ecies
github.com/ethereum/go-ethereum/p2p/discover
github.com/ethereum/go-ethereum/p2p/discv5
github.com/ethereum/go-ethereum/core/types
github.com/ethereum/go-ethereum/p2p
github.com/ethereum/go-ethereum
github.com/ethereum/go-ethereum/core/state
github.com/ethereum/go-ethereum/core/bloombits
github.com/ethereum/go-ethereum/core/vm
github.com/ethereum/go-ethereum/accounts
github.com/ethereum/go-ethereum/ethclient
github.com/ethereum/go-ethereum/accounts/keystore
github.com/ethereum/go-ethereum/accounts/usbwallet
github.com/ethereum/go-ethereum/consensus
github.com/ethereum/go-ethereum/consensus/misc
github.com/ethereum/go-ethereum/dashboard
github.com/ethereum/go-ethereum/whisper/whisperv5
github.com/ethereum/go-ethereum/consensus/clique
github.com/ethereum/go-ethereum/consensus/ethash
github.com/ethereum/go-ethereum/eth/fetcher
github.com/ethereum/go-ethereum/node
github.com/ethereum/go-ethereum/console
github.com/ethereum/go-ethereum/core
github.com/ethereum/go-ethereum/eth/downloader
github.com/ethereum/go-ethereum/eth/filters
github.com/ethereum/go-ethereum/light
github.com/ethereum/go-ethereum/internal/ethapi
github.com/ethereum/go-ethereum/miner
github.com/ethereum/go-ethereum/eth/gasprice
github.com/ethereum/go-ethereum/eth/tracers
github.com/ethereum/go-ethereum/eth
github.com/ethereum/go-ethereum/les
github.com/ethereum/go-ethereum/ethstats
github.com/ethereum/go-ethereum/cmd/utils
github.com/ethereum/go-ethereum/cmd/geth
Done building.
Run "/home/ubuntu/go-ethereum/build/bin/geth" to launch geth.
srv@local:~/go-ethereum$