Categories
Uncategorized

Proof of work

Before Jackson was born (~6 months ago), I was in marathon running shape. That’s because during the past 12 years, I’ve trained for and run a marathon each and every year.

In 2012, at the peak of my training, I ran a personal best time of 3 hours 14 minutes (7:30 min / mile) at the Philadelphia marathon. While not world class by any stretch…for me, it was (and still is) a big accomplishment.

When it comes to running a marathon, there is no way to fake it. You’ve either put in the work to train, or you haven’t. To run a 7:30 minute / mile pace over 26.2 miles, I had to commit 6+ months. Each week, there were multiple runs, alternating from speed workouts, +10 mile long runs on weekends, and even hill repeats.

I like to refer to this as the “proof of work” I put in to prepare.

Going into marathon race day, because I knew I had put in the work, I felt confident about what I could do on the course.  And throughout the race, I reminded myself of all those training sessions while furiously turning over my legs, mile after mile.

I know you are wondering, “what does training for a marathon have to do with bitcoin”?

Proof of work, of course!

Recently, there has been a lot of FUD (fear, uncertainty, doubt) about the energy used / wasted by the Bitcoin network. And it boils down to the underlying proof of work involved.

I’ll just get it out of the way – proof of work, and the energy used in the process, is a feature, not a bug. Yes, energy is used. But it is not wasted. It serves a very important function – to protect the monetary value (~$700 billion USD as of this writing) that is stored on the network. 

Let me explain.

To do so, I need to first start with an example using PayPal so I can compare / contrast against how the Bitcoin network operates. This will help connect the dots why proof of work is needed at all. 

PayPal(centralized)

At the very highest level, PayPal is a centralized service whereas the Bitcoin network is decentralized.

That means when I try to send a friend $100 USD on PayPal, PayPal is solely responsible to check that I have the funds available, that the country my friend lives in isn’t on a sanction list, that both of our accounts are in good standing, along with potentially hundreds of other criteria before allowing the transaction to go through.

Put another way, PayPal, as a centralized service, acts as the single source of truth for all transactions that get processed on their network. That means if PayPal allows the transaction to go through, then my friend knows he is now be able to use that $100 USD. 

Now, let’s contrast this against how the Bitcoin network operates.

Bitcoin (decentralized)

As mentioned above, the Bitcoin network is decentralized. Zooming out, this is critically important for security, especially when ~$700 billion is at stake. That’s because the concept of a honeypot is removed as an attack vector. What that really means is that it is much (much) harder to hack or attack.

While this is good for security, decentralization also has drawbacks. One glaring conundrum is knowing what transactions should be processed vs. rejected without a middleman involved (ie. PayPal). 

This is where bitcoin miners (and proof of work) come in.

The role of miners in the Bitcoin network

(above) a bitcoin mining operation in action

Miners (who are scattered all around the world and competing against each other around the clock) are responsible for taking new valid transactions (that still need to be settled), bundling them together into a new block, and adding that new block to the blockchain. As a reward for doing this task over and over again, they earn newly minted bitcoin.

This is important because once a transaction makes it into a block and is then added to the blockchain, the transaction cannot be reversed. This is how the source of truth is established for who owns bitcoin and how much they own as of right now.

Extending the example above, instead of PayPal, I could instead use the Bitcoin network to send money to a friend. Assuming I had 1 bitcoin (~$33k USD as of this writing) and sent it to a friend, behind the scenes, the transaction would get picked up by a miner, added to a block, and appended to the blockchain. When that happens, my friend would now own the bitcoin.

Still following along? Now, let’s drill in one layer deeper into the actual proof of work that miners are required to perform in order to earn bitcoin rewards.

Proof of work(performed by miners) 

Since the Bitcoin network is decentralized, no permission is required to start mining. Put another way, you can literally start mining today. However, since anyone can participate, it means that any miner could attempt to add invalid transactions in a new block (whether out of negligence, malice, or otherwise).

If this were to happen, it would corrupt the entire blockchain ledger and screw up tracking of how much bitcoin each of us own. It’s not hyperbole to say that if this were to happen, bitcoin would be worthless. Immediately.

But it hasn’t happened. And it won’t, because the Bitcoin network has a mechanism to prevent and disincentivize it. And, as you guessed, it’s called proof of work!

As a miner, to create a new block (with new transactions that need to be settled) and add it to the blockchain, the last required step is to solve a difficult math problem. By design, the only way to solve this problem is through brute force. That means each computer in a mining operation is purpose built to quickly try and find the answer by guessing over and over again.

Only when a miner successfully finds the answer (and assuming they are the first one to do so for a block before all other miners), and then have their answer verified by full nodes (other participants on the Bitcoin network), does the new block get added to the blockchain. Finally, at this point in time, the miner earns newly minted bitcoin.

Roughly every 10 minutes, a new block is created. And as soon as that happens, the whole process resets and all miners compete trying to put together the next block in the blockchain.

Using the“roll-a-ball” carnival game to better explain proof of work

I know at this point, when I was learning about miners and proof of work, it was confusing. However, once I realized that there were similarities to a carnival game that I used to play as a kid, it started to make much more sense.

At the carnival, there is a game called “roll-a-ball” (link to YouTube clip to see it in action). The objective is to get your horse from one side of the board. If you are the first one to do so, you win a prize.

Here is how it works:

  • to play, each participant pays the game operator a token (something equivalent to $1-5 in the USA)
  • once the race starts, each player rolls a ball down their lane (which can land in one of many different holes at the end of the lane, corresponding to a different distance their horse will move across the board)
  • the person to roll the right combination of balls will cross the finish line first
  • there is one winner each round, and they receive a stuffed animal (or something related) as a reward
  • Once someone wins, the whole board resets and the horse race starts over again

Now, let’s connect this to miners and proof of work:

  • miners are like the participants in the “roll-a-ball” game
  • proof of work is like the act of continuously rolling the ball during the game in order to move your horse across the board (ie. have to brute force keep rolling over and over again)
  • there are many miners competing, just like there are multiple players at the same time for the carnival game
  • In order to join, miners have to buy in (ie. it requires specialized computers and related electricity costs to run those computers), just like players in the “roll-a-ball” game have to pay a token to the game operator in order to play
  • similar to roll-a-ball game, the first miner to solve the problem will earn a reward, but none of the other players earn a reward
  • as soon as a new block is created, the whole process resets, just like it does once a horse crosses the finish line in the “roll-a-ball” game

With this connection established, let’s discuss why proof of work even matters.

Back to proof of work

The essence of proof of work is that miners must do work (ie. putting together a block which includes brute force finding the answer to a computationally intense math problem) in order to earn a reward. And the work costs money in the real world.

When a miner successfully puts together a new block, they get rewarded with newly minted bitcoin. But for each block, there is only one winner. That means every other miner around the world will have incurred an electricity bill running their equipment, but not receive any reward.

This well designed check-and-balance ensures that each miner behaves (ie. only attempts to add valid transactions into a block so they can compete to earn the reward). If they were to try and add any invalid transactions, their work would not pass validation by full nodes (other participants in the Bitcoin network), resulting in that block getting tossed out. Put another way, these miners would literally be throwing out money but yet never adding new blocks to the blockchain.

(and remember, while all of this is going on, as a by-product of each miner selfishly trying to earn bitcoin rewards, what they are actually doing is settling valid transactions and recording it to the ledger)

Conclusion

Now that I’ve put in the energy to learn about proof of work, I am confident I can ignore the FUD (fear, uncertainty, doubt). And actually, I now sleep better at night knowing that my bitcoin are secure because of proof of work!

Thanks for coming by!

Let's stay in touch 👋

In an easy-to-understand way, I help fellow parents see how bitcoin leads to early retirement

As a parent, I respect your time and promise to never send you any spam!