Sitemap
Chris Cassano

Chris Cassano

Tech Lead @ Expand.App

Setting up a full Ethereum node with RPC and debug support (geth)

3 min readDec 18, 2018
Press enter or click to view image in full size

Getting geth running isn’t that tricky, but making sure it’s a full node with debug support takes a specific set of arguments that aren’t commonly used when most people set up a node.

A full node will be an entire copy of the blockchain and state trie and will take a long time to sync (a week or more) but provides you with the ability to debug any transaction using truffle or remix. This debug api is not available on Infura, so I had to set up my own node.

Start with a fresh Ubuntu 18.04 instance. Run the commands below:

sudo apt-get updatesudo add-apt-repository -y ppa:ethereum/ethereumsudo apt-get updatesudo apt-get install ethereum

Next, open /lib/systemd/system/geth.service in a text editor and paste in the below. Make sure to change the WorkingDirectory line to point to your home directory, and change the User line to be your main username. On AWS your username might be “ubuntu” but on GCP it is my personal username (“chris”).

Get Chris Cassano’s stories in your inbox

Join Medium for free to get updates from this writer.

You may also add the flag “ — testnet” to the geth command on the ExecStart line if you wish to start a Ropsten testnet node. If you wish to start a mainnet node, omit this flag.

[Unit]Description=Geth NodeAfter=network-online.targetWants=network-online.target[Service]WorkingDirectory=/home/chrisUser=chrisExecStart=/usr/bin/geth --gcmode archive --syncmode full --rpc --rpcaddr 0.0.0.0 --rpcapi eth,web3,debugRestart=alwaysRestartSec=5s[Install]WantedBy=multi-user.target

Next, make sure that port 30303 is open for your instance so that geth can receive incoming connections. You should also open port 8545 for RPC calls.

Then, run the commands below to start your node.

sudo systemctl enable geth
sudo systemctl start geth

To monitor the logs for geth, use the command below:

sudo journalctl -f -u geth

If you want to try and speed up the sync by connecting to peers that are known to be good, visit this gist page and find the gist for the network you’re using (for mainnet it would be mainnet-peers-latest.txt). Then run “geth attach” to open the geth console, and paste in the admin.addPeer() commands from the gist.

Syncing a full node will take like, a really long time. I began my mainnet node sync on 2018–12–17 21:28 UTC on a GCP instance with 2 cores and 8gb of ram and a 2048GB SSD. I will update this article when the syncing completes with how long it took.

Good luck!

Update 1: GCP warned me that the geth instance was utilizing all it’s memory and asked me to upgrade it. I upgraded it to 16gb of ram. We’ll see if this is now enough RAM.

Update 2: GCP warned me again to upgrade the system. Now it has 8 vCPUs and 23gb of ram. Additionally, the ropsten node I was syncing finished. This means a full ropsten node takes about 4 days to sync as of 2018–12–20.

Update 3: The node took about 3 months to sync, and was ready around March 15th, 2019.

--

--