Proof of Work - Sudoku on a planetary scale!
In this post, I'd like to talk about one of the most critical aspects of cryptocurrencies: The Consensus Algorithm. I will do so by using Bitcoin to exemplify the implementation of the consensus algorithm called Proof of Work. In some sense, Proof of Work isn't a new concept and can be found throughout history. Each of the seven wonders of the world but also a lot of other impressive constructions can be considered Proof of Work. If someone passes by, it is immediately apparent, that these constructs cannot be built cheaply. They require an incredible amount of resources, knowledge, but also an established form of society, economy, and governance for them to be created. Each of them is a testament of proof of work of a great civilization able to build something outstanding. It is not possible to recreate it without a considerable amount of work. Not even with the tools, technology, and resources we have today.
Proof of work: Something that cannot be built cheaply
Image Source: Pexels.com
Introduction
Before jumping right into the thick of things, I want to provide a short overview of what a consensus algorithm is and which role it plays in the context of the whole ecosystem of cryptocurrencies. One of the significant advantages of a cryptocurrency like Bitcoin, compared to the traditional system of money, is its decentralized nature and the fact, that transactions are neutral to the sender, the recipient, and the amount transferred. Meaning that there’s no distinction. Anyone can join and propagate transactions or participate in mining. From the perspective of the bitcoin network, every transaction is equal and is processed if the fees are paid and the transaction is valid.
The Consensus algorithm
Each time a bunch of transactions is processed into a new block, it is added to the public ledger, increasing its block height by one. Considering that we don’t trust anyone that propagates transactions or mines bocks, we need a mechanism that decides whether or not any given version of the public ledger is valid. Furthermore, the mechanism needs to detect and resolve possible conflicts. Now that we understand the job of a consensus algorithm, you might expect some super complicated procedure of how the conflicts are resolved. Surprisingly, the consensus algorithm of Bitcoin is quite simple and can be described in four words: The longest chain wins. If there are two conflicting versions of the Bitcoin blockchain, the one with the most blocks (the most extended chain) is declared to be the truth. You might ask:
- How such a simple condition could resolve all conflicts?
- How can the security of the network be maintained?
- Why isn't everyone just spamming longer chains for them to be accepted as the new truth?
This is where another crucial component of Bitcoin's consensus algorithm enters the playground: Proof of Work. The Blockchain guarantees that a new block and its transactions need to be consistent with everything from the past. Proof of Work ensures a block can't just be created without work being done.
"The characteristic that gives bitcoin its tamper-proof capability is not "the blockchain"; it's proof of work." Andreas Antonopoulos - The Internet of Money Vol. 2
Proof of Work
I found that many people think that mining is solely used to create new Bitcoins. In reality, it's quite the opposite and mining primarily serves the purpose of securing the network and processing transactions. The creation of Bitcoins used as block rewards is a mere side-effect of this process. The Block reward used to incentivize miners is halved every 210'000 blocks and will reach 0 at block 6'930'000. Expectations are that this block will be mined in the year 2040, after which transaction fees remain the only incentive for miners to process transactions into a block.
Bitcoin controlled supply timeline estimation
Image Source: The Bitcoin Wiki
Sudoku on a planetary scale!
Now that we know that Proof of Work primarily serves the purpose of processing transactions and securing the network while doing so, it's time to have a closer look at how this is done.
Mining a block must include work
In an earlier post, I described the difference between tamper-evident and tamper-proof and how the latter requires proof of work.
One of the most important aspects is to realize that if there's no work involved in creating a block, the network is not secured and immutability is not achieved. The blockchain by itself is only tamper-evident. This enables participants to notice changes and inconsistencies but doesn't hinder anyone to implement them. In combination with the consensus rule of "the longest chain wins", tamper-evident isn't enough and would end in a disaster.
So... what is the answer to this?
As you might know, each block divides into a block header and a list of transactions processed in that block. Besides some other attributes, the block header contains the hash (Merkle tree root) of all transactions as well as the hash of the previous block. With that, each participant can independently verify that the chain and all its transactions are valid and have not been tampered with.
The Bitcoin Blockchain, re-illustrated by @sblue. Based on Mastering Bitcoin by Andreas Antonopoulos, Figure 9.1 P.201
The Bitcoin Sudoku
Let's have a look at how the process of hashing and Proof of Work compares to a game of Sudoku. One aspect of Sudoku we probably all agree on is that it needs time to solve. More importantly, we can also agree on the fact that verification is done in a fraction of the time needed to solve it. The last important aspect of a Sudoku is that its complexity - estimated time required to solve it - can be mathematically determined. These three aspects make it a perfect analogy to the consensus algorithm implemented by Bitcoin.
Tamper-evident
Let's imagine, that instead of hashes, each block is confirmed with a game of Sudoku. The numbers given at the start are based on the content of the block header. The numbers that need to be filled represent the nonce. Hashing alone would mean, that the Sudoku which is solved is super easy. It's as if you had a Sudoku where all the numbers but one are given, it wouldn't take a lot of time/work to complete it.
The Bitcoin Blockchain. Hashing imagined as a game of Sudoku. Illustration by @sblue. Hashing alone is like solving a super simple Sudoku, it doesn't require much work.
Since it doesn't require work to solve a simple Sudoku, it can only provide tamper-evidence. Every participant can autonomously verify the whole blockchain and immediately takes notice of any change. The blockchain itself is tamper-evident but not tamper-proof because there's no real work required to apply changes to old blocks and recompute all "Sudokus" along the way.
"As long as there is no proof-of-work behind it, the cost of rewriting a ledger like that is zero." Andreas Antonopoulos - The Internet of Money Vol. 2
The Bitcoin Blockchain. Hashing imagined as a game of Sudoku. Illustration by @sblue. Although no work is required to solve a simple Sudoku, the chain can be verified, making the blockchain tamper-evident.
Tamper-proof
To make it impossible to change old blocks, the Sudoku needs to become harder. With Proof of Work, Bitcoin introduces a certain requirement to the hash of a block: It has to start with a certain amount of zeroes. The resulting hash of a block is altered by modifying the nonce value in the block header. It's still like solving a Sudoku, only that this time, the Soduku became much more difficult. With a Sudoku as hard as this, a block isn't just created within seconds, it requires significant computational power. In other words, there's mathematical proof that the creation of this block required real work, thus calling it Proof of Work.
The Bitcoin Blockchain. Hashing imagined as a game of Sudoku. Illustration by @sblue. Instead of solving a simple Sudoku, you're now required to solve a much harder Sudoku. The complexity is mathematically determined and strives for a solution time of 10 minutes considering all competing Sudoku players. In reality, the requirement for a hash consists of a certain amount of leading zeros. The nonce value is used to influence the resulting hash of the block header. The amount of time it takes to find such a hash strives for a solution time (time between blocks) of 10 minutes.
The amount of work needed correlates with the current amount of hashing power available in the Bitcoin network. The difficulty of the hash ("Sudoku") always strives towards a value that results in a 10-minute timespan to find an appropriate hash, considering the total hashing power currently available. The difficulty is adjusted every 2016 blocks, to sustain a block time of 10 minutes and compensate the circumstance of changing hashing power.
A monument of immutability
Immutability is when something cannot be changed. Maybe the internet can be considered as one of the first concepts achieving a considerable level of immutability. Because once something is published on the internet, it stays there forever. Attempts to remove specific content, mostly end in spreading it even further. Bitcoin implementing Proof of Work takes the concept of immutability one step further, by hardening the information utilizing computational power.
"Bitcoin's proof-of-work is a planetary scale, thermodynamically guaranteed, self-evident system of immutability" - Andreas Antonopoulos, The Internet of Money Vol. 2
The unbelievable amount of computational power utilized to solve each "Sudoku" along the way, makes it impossible to change any transaction in the past. Each new block secures every preceding block even further. Due to the amount of provable work required to create a valid hash ("solve the sudoku"), it only takes six successive blocks (6 confirmations) for a block to be considered impossible to change. Six confirmations to become truly immutable. Now imagine what it would take to replace one of the very first blocks. Besides the computational power, the fact that the difficulty adjusts every 2016 blocks adds the component of time. It would be a constant battle of increasing hashing power at the right time to sustain a block time lower than 10 minutes. It is the only way a manipulated chain could eventually surpass the original one and be accepted as the new truth. Never in human history, have we ever achieved this form of immutability, making bitcoins public ledger a real monument of immutability. It cannot be changed and it doesn't decay. Even if we consider technological progress and the ever increasing computational power, the blockchain of Bitcoin can't be rebuilt cheaply. Bitcoin's public ledger is truly immutable, based on the concept of Proof of Work and backed by a pool of unimaginable computational resources. With each block, that monument grows further and sets a new standard, redefining the term immutability.
"Now history is written by the expenditure of real-world energy, and there is no cheap way to forge that history." Andreas Antonopoulos - The Internet of Money Vol. 2
Conclusion
Proof of Work/Mining is far more than just the creation of some Bitcoins and primarily serves the purpose of securing the network. By doing so, people around the world created an incredibly impressive monument of immutability represented by the blockchain of Bitcoin. And it is growing bigger and stronger each day. To me, the result of this collaboration of thousands of miners to achieve true immutability is one of the most impressive aspects of Bitcoin and Cryptocurrencies. Bitcoin's example of immutability achieved through Proof of Work is unprecedented in scale amongst all cryptocurrencies. However, the principles described in this post can be applied to any cryptocurrency implementing Proof of Work as their consensus algorithm. Although there's the legitimate discussion of whether or not the power consumption is justified, I think the sheer existence of such a monument of immutability deserves acknowledgment and respect. Time will tell, how other consensus algorithms will perform once exposed to an adoption similar to Bitcoin. I'm excited to follow the progress of all the different ideas but consider Proof of Work the most proven and robust approach to reach consensus and immutability in existence.
I hope I was able to give you an insight into the fascinating aspects of Proof of Work & Immutability and appreciate any feedback, question or input in the comments below.
Thanks for reading and have a great day!
@sblue
Sources & Additional Information
- Bitcoin Whitepaper
- Bitcoin.org - Open source P2P money
- Bitcoin Wiki
- Controlled supply - Bitcoin Wiki
- GitHub - bitcoin/bitcoin: Bitcoin Core integration/staging tree
- Bitcoin Block Explorer - Blockchain
- Andreas M. Antonopoulos – The open blockchain expert
- Andreas M. Antonopoulos (@aantonop) | Twitter
- Books – Andreas M. Antonopoulos
- Bitcoin - Wikipedia
- Blockchain - Wikipedia
- Merkle tree - Wikipedia
- OpenSky Sudoku Generator
- Free stock photos · Pexels
- WTF is Money? And why Bitcoin is more than just a currency. — Steemit
- What is Bitcoin? - When Money becomes a content type! — Steemit
- What is Git / Github? - The 3 minute journey through Bitcoins GitHub history — Steemit
Congratulations! This post has been chosen as one of the daily Whistle Stops for The STEEM Engine!
You can see your post's place along the track here: The Daily Whistle Stops, Issue # 87 (3/28/18)
The STEEM Engine is an initiative dedicated to promoting meaningful engagement across Steemit. Find out more about us and join us today!
Thank you very much! It is an honour to be one of the daily Whistle Stops. I'm grateful to be part of this amazing community! I appreciate the help and encouragement this community provides to its members. Keep up the good work! Thanks again and have a great day!
finally got a chance to read this hehehehehe its past its payout - so i will give you an upvote that isn't worth anything unfortunately.... but also a tip :)
@tipu send tip
the use of sudoku REALLY helped!!! I did try to understand your other post about the 51% attack... and that one was more difficult to understand LOL
because if it's immutable... then how is it vulnerable?
I'll keep trying to learn more from you hehehehe
(i hope my tip jar is still full so I can actually give you a tip!!! LOL)
Hey @dreemsteem! Thanks for your reply and also thanks for the tip! I didn't know there is a tip bot! 👍I'm happy that you liked my post. In general, you're right: Immutability and vulnerability are contradictory. What I described in my 51% Attack post is the theoretical possibility of an attack. Mostly to change the current blocks / immediate future, which allows the attacker to double spend coins. My post also showed how/why this is a rather theoretical attack, especially if we consider today's situation. The reward of such an attack is just too small in regards to the huge risk/investment that needs to be taken. So why bother to execute a highly risky and expensive attack when one could make a fortune being honest. Things get even trickier if one would want to change the past. I hope my explanation helped a bit! 🙂
Have a great day!
Yes it did!!! Thanks :)
I appreciate you taking the time to keep teaching me! Hehhehe
Glad to hear that! 👍I'm always happy to help if I can and if people are interested 😊.
I'm curious.....do you find that you're gifted in teaching people who are newbies? I'm asking you and one other person because I have an idea forming :)
That's an interesting question and difficult to answer. Self-assessments are always tricky and hardly objective. But I have been told that I can explain complex technical topics in an understandable manner. Also, I was tutoring programming classes for BSc students, did employee training and was involved in digital mentoring programs. I think I can objectively say that I have some skills in teaching/explaining technological topics and I'm steadily working on improving them. Writing posts on Steemit is one part of my efforts to improve my skills in this area.
very good!!!! more discussion in DM on discord! hehehehe
I already knew some of it but not nearly as detailed as you wrote it.
I admit I am more in favor of the proof of stake or the limited proof of work (IOTA) but overall we have to give credit to the first technologies that helped popularize the whole concept. What do you think will happen in the future when mining Bitcoin will not be as profitable as now? Will the miners keep the infrastructure?
Hey @alexdory!
Thank you very much for your reply. I'm happy to read that the post contained some details that were new to you. I'm not against Proof of Stake or other consensus algorithms and follow some projects that choose to implement alternatives. I only had a brief look at IOTA and found their vision very interesting. Unfortunately, it seems that they're currently facing a lot of challenges. It remains on my watchlist, and I hope the team of IOTA can overcome the obstacles. I recently took my stand about IOTA in a comment related to an IOTA video. If your interest, feel free to check it out:
The last two questions are excellent but also very tricky to answer. I guess at the end, only time will tell. However, let me try to answer them:
In general, I consider both of your questions to be of economical nature. Economical in a sense that they follow rules of economics. For example, Bitcoin goes very well with the economic principle of game theory. In regards to your questions: I'd argue that the effort always strives towards the reward. In other words, if the price of Bitcoin rises, the gap between effort and reward gets more significant, which leads to more miners entering the playground. More miners elevate the hash rate and shorten the reward per miner. Since no one wants to lose money, people will stop joining, when the gap between effort and reward gets too small (risk of losing money becomes too high). If the price falls, miners will leave the playground because it isn't profitable anymore. It's a constant balancing of Bitcoin price, hash rate, and difficulty. Mining will always be profitable for a certain amount of miners providing a certain amount of hash rate. It is only when the hash rate rises above what the Bitcoin price can deliver in reward, that mining becomes unprofitable. It will become unprofitable for inefficient setups first (maybe you paid to much for your miner, have high housing costs(rent, cooling, power etc.). Eventually, the most inefficient participants will drop out, the efficient ones stay, and the game continues. If the price of Bitcoin rises again, more miners (probably also inefficient setups) will join the playground, and the game starts from the beginning. This isn't explicitly related to Proof of Work, but rather a general phenomenon of economics. Therefore it could be applied to PoS, DPoS, limited PoW etc. as well. It applies to everything: If the effort you put into something is smaller than the reward, you're good to go. The more people join, the more efficient you need to become since the effort strives towards the reward. I plan to have a closer look at the economic / game theory related aspects of Bitcoin (Cryptocurrencies in general). But I still need to run some numbers and do some research, so stay tuned. ;)
My conclusion: I think it will always be profitable for the most efficient participants since inefficient ones will leave first. Profitability is relative to price, difficulty and hash rate, as well as depending on the efficiency of your setup.
I bet they do. But probably only the most efficient ones. Today's stats on blockchain.info show that approximately 1.3% is earned from fees. Which means that there's still an approximate reward of 150'000.- $/Day, even without the block reward. Of course, that number strongly depends on the numbers of transactions as well as the Bitcoin price. Probably the total hash rate would drop a lot without the block reward. But it would remain profitable for the most efficient miners, so why shouldn't they keep the infrastructure.
Cheers - @sblue
this deserves a 100% upvote
I like the sudoku analogy, It makes things easier to explain to a novice. I will definately use this the next time someone wants to know how this "bitcoin thing" works
Hey @felander! I'm happy to hear that you liked my post. Thank you very much for your kind words and also for the 100% upvote, much appreciated! Have a great day!
For future viewers: price of bitcoin at the moment of posting is 8625.70USD
Congratulations @sblue! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Award for the number of upvotes received
Click on any badge to view your own Board of Honor on SteemitBoard.
To support your work, I also upvoted your post!
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP
Hi @sblue! You have received 0.1 SBD tip from @dreemsteem!