Using a decentralized prediction market with a light client

Using ethereum the way it should be used right now can be frustrating. Relying on a centralized service provider like Infura to connect to the decentralized web is like taking one step forward and two steps backwards in the means of relying on 3rd parties for our interactions between each other in web3.

I’m extremely thankful that we have infura though as Status wouldn’t exist in its current form today without it; also they are aiming to decentralize their infrastructure which will be amazing.

Not all hope is lost though, it’s extremely simple to be your own light node with a little bit of digging. Something Status has set as their north star since day one, thankfully work on ULC (Ultra Light Clients) and further light node incentivization experiments will lead to easy to connect light clients in mobile devices on Status by default and more coming soon™. That day isn’t here yet but I can envision a future where instead of 4 steps there’s only 1 through Status or other clients on Ethereum.

I set out on a mission this weekend to break past the challenges that even light clients are currently having to see how possible it would be to run a Geth light-client on my own laptop and interact with the decentralized web in an appropriate manner. I specifically wanted to run Augur without the need to connect to infura because that’s the whole point right? Right!

*How hard could it be? :) *

Enter VIPNode.org, a needed hero in the broken state of LES2. Light clients are essentially not stable right now because there are not enough full nodes to service the need, and some other problems outlined in this great summary.

But how easy is it? Will it even work? I’m not a developer - am I smart enough to press the right set of keys to get my decentralized web fix?

The answer to all of those questions comes next.

The website instructions make it super simple to follow along with a little persistence. I’m also running MacOS for anyone that has any critiquing to add as I may have not done everything perfect.

I first made sure my already installed Geth client was up to date (i’m using Brew to update my already installed geth client on MacOS; you can follow specific instructions for your machine for an initial install here https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum)

$brew upgrade geth

Great success; i’ve now got a shiny new copy of Geth but guess what, I don’t want to run a pruned node because 80 GB of my hard-drive can be reserved for other fun things than the decentralized web, this is supposed to be easy and painless after all, right?

Step 1:
Get my Enode from my fresh Geth client; simple enough there are even instructions provided
(this requires booting up Geth first which i’ll get into in a moment).
I run a simple command in my terminal to first bootup Geth to find my bootnode

>open terminal

$geth

Great now Geth is up and running away (with no configurations you will still need to follow some first step instructions to create a new keypair, etc. https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options)

Now I need the Javascript console up so I can find out what Geth is up to, especially printing out that Enode I need for telling VIPNode I want a light client spot reserved for me.

New terminal tab > $geth attach

>admin.nodeInfo.enode

Perfect! My Enode information is printed out on a string for me.

I can now close my Geth terminal because we want a light client and not a full node.

Step 2: Copy-pasta time!

After filling in the information EG:(Enode://0x000) and connecting to MetaMask with my handy Brave browser by default; I pay my friend Andrey at least $15 in ETH because this is a service I’m really thankful for (even though you can pay as little as you’d like) - light clients get me rather excited about the future of web3.

Clicky click

Execute smart contract

Cool! Now what?

Oh - looks like there's one more step before I get into running my real light client and trying to connect to a DApp locally with no third party provider but p2p from my own node. (how it’s supposed to be done).

Step 3:
Set your /geth/static-nodes.json to:

`[

 enode://yourstringhere

 ]`

So now I need to find out where my Geth client lives (hint: it’s here)

$cd ~/Library/Ethereum/geth/

Looking around tells me there’s no static-nodes.json by default, so let me create one so I can put in this static node JSON file!

$touch static-nodes.json

🆒 now we’re cooking with bacon grease! An empty JSON file I can open up and paste in the above Enode information.

I use my favorite file editing software and add in the string and save it.

Step 4: Light clients n all that jazz

If everything went smooth (and I’m hoping by this point it did), we should be ready to run this puppy. Geth should have a saved spot from the VIPNode smart contract for your special access to that sweetness that is a light client.

After digging around a bit I decide to run these flags on Geth and see if my light client starts syncing.

$geth --unlock 0 --rpc --ws --rpccorsdomain “http://localhost:8080” --wsorigins=”*” --syncmode=”light”

I’ve heard some conflicts about the --wsorigins=”*” flag. Much better to narrow it down to what exactly you want to open, so please make sure to keep this in mind, I opened them all just to make sure Augur was responding to my light client :)

You can check out what all the flags do here https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options, but for my experimentations this command served me well. DYOR on best infosec practices and be careful if you don’t know what you’re doing.

Okay now it’s time to see if we’re syncing a node locally.

WOW! Within a matter of MINUTES; I’m already synced to the latest block; my Javascript console proves it.

> New terminal tab

$geth attach

>eth.blockNumber 6102139

Cool - so let’s get Augur loaded up with a local client and really experiment with web3 in its current form.

Open up Augur and change your connection method to local.

This part takes a little bit of patience (at least it did for me in the era of everything instant); but if you’ve got everything running, your database should sync with your local node in a matter of a few moments.

It should look something like this:

After opening Augur I’m simply blown away by the fact that I’m now:

1. Connected to the EVM world computer
2. Able to participate in a global prediction market in a decentralized environment and locally
3. Using less storage space than a flash drive to sync with a light client.

Running a Geth node on a Raspberry Pi seems like my next venture that hopefully will evolve into other experiments with Ethereum nodes.

Light clients are an inspiring thing, and I’m excited to see the work that the fine folks from Geth, Status, parity and other client developers come up with as Ethereum 2.0 gets closer, and as the original vision of web3 progresses into a reality.

Special thanks to Dustin Brody for helping me when I was stuck with some websocket issues on a Geth flag, Ceri for grammatical fixes and Jacek for the extra set of dev eyes.