How to Run an Ethereum Node in GCP

This seemed like a good way to use the last few months and $300 in processing credit in my free Google Cloud Platform trial account. It turned out to be easier than expected.

Creating a new project with an Ubuntu virtual machine took minutes. Since it wasn't my hardware, I wasn't too worried about carefully understanding all the sudo instructions as I copied and pasted them. In a quarter of an hour ethereum was installed with all dependencies.

I took a few minutes to install and learn about tumx, a terminal multiplexer like screen, which gave me multiple command lines in a single session and allowed the Ethereum node to continue running in the background after I logged out.

  geth --light

cranked up a brand new node, which took several minutes to download all the headers in the blockchain about 2000 at a time.

  INFO [03-13|18:20:59] Imported new block headers  count=2048 elapsed=13.339s  number=5193663 hash=bd1e50…b759ac ignored=0

As a "light" node, I wasn't doing any mining and wasn't verifying any transactions, so probably not contributing to the health of the network, just keeping an eye on it. Google debited my account $2 for CPU effort that first day.

Next I followed instructions to create a full node on the test network, Rinkeby.

How to Set up an Ethereum Dev Environment

How to get on Rinkeby Testnet in less than 10 minutes

  geth --rinkeby

This time it took about 40 minutes to download the entire blockchain. It finally reached block 1937739 which matched the number I saw at Etherscan

  INFO [03-15|18:11:41] Imported new block receipts  count=1983 elapsed=2.189s  number=1937739 hash=64badc…b72d8e size=18.89mB  ignored=0

  geth attach console

didn't work because my path did not match the default, so I had to specify some parameters:

  geth --datadir=$HOME/.ethereum/rinkeby attach ipc:$HOME/.ethereum/rinkeby/geth.ipc

This worked.

  Welcome to the Geth JavaScript console!

  instance: Geth/v1.8.2-stable-b8b9f7f4/linux-amd64/go1.9.4

  modules: admin:1.0 clique:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

So I created a new address:

  personal.newAccount("[password redacted]")

This generated a public address which I posted to Google Plus. cW, this was the cryptic message you noticed. I then copied the URL of my Google Plus post and pasted it into the Rinkeby faucet to get some free (test) ETH.

The transaction immediately went through but I was unable to see the ETH in my node.



A helpful comment somewhere made me realize I was connected to the wrong test network; the Rinkeby Testnet has network ID 4. I found some instructions to connect to network 4 and restarted geth.

  geth --networkid=4 --rinkeby

Half an hour later, the node was synced up and I could check my balance.

  geth --datadir=$HOME/.ethereum/rinkeby attach ipc:$HOME/.ethereum/rinkeby/geth.ipc

  Welcome to the Geth JavaScript console!

instance: Geth/v1.8.2-stable-b8b9f7f4/linux-amd64/go1.9.4

  coinbase: 0x351bdc61671ba2030ffe047a2cc7aab321090fe1

at block: 1938172 (Thu, 15 Mar 2018 19:37:02 UTC)

  datadir: /home/wasoxygen/.ethereum/rinkeby

  modules: admin:1.0 clique:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0



Money! (That's 3 ETH expressed in wei, the smallest unit in the rococo numbering convention. The largest, a "tether" or tera-ether, contains a trillion ETH.)

Test money, anyway. I can now write a smart contract and try it out. But I thought it would be more fun to do some mining on the production network. To make a profit requires specialized and expensive hardware, but I thought I could earn a few wei as an exercise. Cryptocurrency mining is strictly prohibited on the Google Cloud Platform free trial, with reports of violating accounts getting suspended in hours, so I would use a Mac Mini at home, which turned out to be woefully underpowered. The video card did not have enough memory for ethminer to start, and geth no longer supported CPU mining because it is too hopeless.

So I turned to Casper, the test network designed to switch from the energy-intensive proof-of-work algorithms used by most cryptocurrencies to a proof-of-stake model, in which users who hold ETH will collect transaction fees (but not rewards of free ETH) by validating transactions. With this lower barrier to entry, Byzantine fault tolerance is a challenge.

I was a few months late joining, and couldn't get past "waiting for bootstrap" errors. They say several invalid forks have been created, and I wasn't able to make more progress.

Next idea is to go back to writing and deploying a simple contract. MyCrypto has a fantastic tool for interacting with contracts.


Super exciting... I still only understand portions of what I just read, but I'm stoked that you got this up and running. So cool. I hope to see updates as you go.

posted by wasoxygen: 322 days ago