Bitcoin on CPU

I learned about Bitcoin in 2013. I watched it for a while before I entered the market in 2014. I dabbled in day-trading (bad idea, just don’t if you like sleep at all…) I even wrote a Python trading bot back in the day that made some decent profits before my 24 year old self got nervous about playing with more money than I’d ever had at once and turned it off.

During the run up at the end of 2014 I sold out of my position a little before the peak. It was dumb luck, trust me I was no genius trader by any means and that’s still true. I told myself the volatility was too much for me, and it was… I lost a lot of sleep that year. But I never stopped checking up on how Bitcoin was doing and recently I’ve gotten back in the game. This year with the corona epidemic and the unprecedented amount of money being created, the multiple other currencies that have experienced hyper-inflation recently, Bitcoin’s raison d’être for existing is back in center-view.

I believe in Bitcoin and want to contribute to the network somehow. Mining is out of the question. It was out of the question even back in 2014 when ASICs started coming onto the scene. Another option is running a Bitcoin full node.

What is a full node?

To answer that question, let’s take a step back and look at how the Bitcoin protocol works. Miners collect new transactions from the network together in blocks and then hash them over and over. They’re looking for a hash that has a specific number of preceding zeroes, called the difficulty. This process is called proof of work and it’s the heart of what makes Bitcoin work. The process of finding a hash that matches the difficulty takes a lot of computing power but checking that hash is trivially easy even for a low-powered computer.

Bitcoin is trust-less at every layer so we don’t blindly trust the blocks miners give us; we verify. This is the work that full nodes do. They enforce the rules of Bitcoin always. If a miner produces a block that doesn’t follow the rules it is ignored and if it happens enough that miner is also ignored. This gives miners a financial incentive to behave. If you don’t follow the rules you don’t receive the transaction fees or the block bounty. Full nodes are a check on the [51% attack.

Full nodes also give you a voting voice in the case of a hard-fork. The software you run determines the rules followed. This happened with Bitcoin Cash in 2019. Developers attempted to alter the Bitcoin consensus rules in a way that would defy Bitcoin’s core tenant of limited supply – scarcity. Contributors running full nodes voted on which fork to follow by running one version of the full node software or the other and overwhelmingly chose BTC. You can see that in the price of both today: BTC - $9450 vs. BCH - $240.

Tutorial

I have a home server which is my lab of sorts. I use it for all kinds of things and there are various tasks it runs for me and it has enough storage for this. You don’t have to have a dedicated computer to run a full node. Lots of contributors run full nodes on Raspberry Pi’s or other single-board computers. There are only a few requirements to run a full node:

  • You are going to download the entire blockchain so you will need a sizable amount of free storage. The blockchain is 282GB as of this post. Each block is around 1MB and new blocks are mined every 10 minutes so the blockchain size grows linearly with time.

Blockchain size graph

  • Obviously you’ll need to download the blockchain in its entirety so you’ll want an unmetered internet connection. After the initial blockchain download you will download 20GB and upload 200GB per month on average.
  • You need the full node to run at least 6 hours per day. Running it all the time is better.
  • You probably don’t want this running on a high powered gaming computer unless you like paying your energy company for electricity. This is a big reason a lot of people opt for a Raspberry Pi.

Getting the full node up and running is actually very easy. There’s a GUI version you can use but I run my Linux server headless so we’ll go through the CLI version. The installation instructions found here are very good. The verification of the file integrity and the signing keys may not be obvious to novice users so I’ll go through the steps here:

  1. First off, you need to download the Linux tarball, the SHA256SUMS file and the release signing key corresponding to your version.
  2. Now verify the download files integrity with the SHA256SUMS file. Run the following command and you should see an OK corresponding to the tarball you downloaded.
~/Downloads$ sha256sum --ignore-missing -c SHA256SUMS.asc
bitcoin-0.20.0-x86_64-linux-gnu.tar.gz: OK
sha256sum: WARNING: 20 lines are improperly formatted
  1. Import the public key into your GPG keyring. I installed version 0.20.0 so in my case the signing key was laanwj-releases.asc.
~/Downloads$ gpg --import laanwj-releases.asc
gpg: key 90C8019E36C2E964: 51 signatures not checked due to missing keys
gpg: key 90C8019E36C2E964: public key "Wladimir J. van der Laan (Bitcoin Core binary release signing key) <laanwj@gmail.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1
gpg: no ultimately trusted keys found
  1. Now verify the SHA256SUMS.asc file. If you are an extra cautious person you can go a step further and ask one of the project developers to verify the fingerprint.
~/Downloads$ gpg --verify SHA256SUMS.asc
gpg: Signature made Wed 03 Jun 2020 05:59:52 AM EDT
gpg:                using RSA key 90C8019E36C2E964
gpg: Good signature from "Wladimir J. van der Laan (Bitcoin Core binary release signing key) <laanwj@gmail.com>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 01EA 5486 DE18 A882 D4C2  6845 90C8 019E 36C2 E964
  1. Now that we’ve verified the download you can follow along with the installation instructions.

Networking/Firewall

You’ll also need to open the 8333 port for your full node. The process for this is very dependent on your set up. In my case, I needed to set up port forwarding through my router as well as open the port in my iptables firewall. I have my firewall set up to DROP any incoming traffic not explicitly allowed so I simply added an INPUT rule like this:

iptables -A INPUT -p tcp --dport 8333 -j ACCEPT

Starting up

I went the init script route for starting my full node using systemd instead of a crontab. If you want to use systemd:

  1. Add this init script to your /usr/lib/systemd/system folder.

  2. Test by starting the script: systemctl start bitcoind

  3. If bitcoind started successfully you can start it at boot time: systemctl enable bitcoind

Initial Block Download

The inital block download will take a while to complete depending on your connection. I have a gigabit fiber connection and it still took the majority of 24 hours to complete. You are downloading a full copy of the blockchain from other contributors running a full node so even if you have a fast connection you will likely be limited by others upload speeds.

Conclusion

I hope this helps others get their full nodes up and running. It genuinely feels good to contribute to the network and keep Bitcoin safe. If this helped let me know on Twitter or if you did get stuck along the way, I’d be happy to help you along if I can and I’ll update this guide for others.