Understanding Blockchain, Cryptocurrency decentralized consensus mechanism & mining mechanism the easy way.

Abdalla A. Mahgoub, MSc / CISI
CodeX
Published in
12 min readDec 7, 2022

Table of Contents

1. Introduction

2. Proof of work

3. Hash algorithms

4. Proof of work in bitcoin

5. Steps of Proof of work in bitcoin

6. What will happen afterwards once new blocks are created and added to the bitcoin blockchain?

7. Environmental, Social, and Governance (ESG) debate on PoW

8. Proof of Stake in Ethereum 2

9. How proof of Stake works

10. What is Wealth mechanism in PoS

11. Steps for Proof of stake in Ethereum

12. Advantages of PoS in Ethereum as oppose of Bitcoin’s PoW

13. What are the disadvantages of PoS

14. Notable cryptocurrencies that uses proof of stake

15. Other mining consensus mechanism

16. Conclusion

17. Reference

1. Introduction

Before I talk about the specifics of proof of work mechanisms on different cryptocurrencies including bitcoin, Let’s talk about blockchain and its relation to the consensus mechanism of proof of work (PoW)

Simply blockchain is consist of blocks chained together where each block contains a list of completed transactions formed in a digital ledger. In addition to that, these blocks are duplicated and distributed across the entire network, which makes these transactions not only distributed but also immutable (hashed) and secure at scale. These transactions are recorded at scale in the network for all participants to see and verify.

So How does a transaction get into the blockchain and what is the relationship between this and proof of work ?

A new transaction will be added to the block after the transaction is authenticated, then a block is sent to every active node in the network for the transaction to be validated, this validation process is actually where validators ( in this case we call them miners) solve complex mathematical puzzles concerning transaction validation and these nodes will receive a reward for this proof of work in a form of cryptocurrency or a fraction of a cryptocurrency, then the block is added to the previous block and finally the block is updated to the entire blockchain network by the duplication process I mentioned earlier.

2. Proof of work

By now proof of work ( PoW) definition is a bit clearer, Proof of work is the original decentralized consensus mechanism in a blockchain network that requires nodes (members of the network) to put in some work to solve mathematical puzzles in a way that makes them compete with each other to solve them, in order to complete transactions on the network and get rewarded by solving them with either new coins or fraction of a coin. In specific, these rewards are simply transaction fees paid by other coin holders or for some are known as HODLs ( Hold on for dear life) referring to the risk associated with investing in cryptocurrencies.

3. Hash algorithms

Blockchain of PoW has a mining algorithm or cryptographic hash function related to the block that takes the block as an input to create an output. consequently, the miner will keep hashing blocks until the miner reaches the desired output, this process can be done millions and billions of times which in return requires superior hardware to speed the process, also it needs enough electricity and time. This is the reason why mining crypto coins can be a controversial topic with it comes to climate change.

4. Proof of work in bitcoin

Bitcoin uses the mining hash algorithm of SHA256 , in addition to that, bitcoin applies a double SHA256 process to increase the security aspects of the process. So many other cryptocurrencies adopted the bitcoin SHA256 hash function such as Bytecoin, Namecoin, Peer coin, etc.

As I mentioned earlier, a miner needs to compete and solve with another miner a mathematical puzzle in the blockchain using the PoW consensus mechanism to verify the new block and add it to the blockchain once it’s solved and agreed upon by the network (other nodes or miners). But solving the puzzle is not easy at all. The mathematical problem is nothing but guessing the nonce concatenate with a string of data, the guessing process takes millions and billions of trials and errors until the right guess is achieved and compared to the target of the block, Keep in mind all this process is hashed.

Let me explain this in a form of steps to make it easier to understand.

5. Steps of Proof of work in bitcoin

1- We will collect the executed transaction from the pool and build a complete block size.

2- Applying Hash function of SHA256 twice to the block (in our case this is the block header which includes previous block hash, Timestamp, Difficulty bits and nonce)

3- Observe the result from step 2 and compare it with the expected number of zeros generated from the hash, if there was no zeros on the beginning of the hash , try to increment the nonce by one , remember this hash is compared with the target , we will keep trying to find the zeros from countless number of attempts till we reach to leading zeros.

4- Once we find a winning block ( aka a block with a result less than target ) the miner will send it to the network to other participants to confirm this calculation. Once all these nodes agreed on the winning block that was shared by the miner, the block is added to the blockchain and the miner is rewarded by a newly bitcoin or a fraction of the bitcoin ( aka Satoshi unit)

6. What will happen afterwards once new blocks are created and added to the bitcoin blockchain?

Over time more blocks are added to the chain, therefore more nodes with better computational power join the competition ( or sometimes nodes leave the network), hence, the mathematical problem can be solved faster, and block creation in return is added faster. Moreover, the block creation time is set to 10 minutes, so usually every two weeks or precisely 2016 blocks are created, and the overall difficulty of the blockchain gets readjusted leading to an increase in difficulty and a reduction of the target value. It takes a massive computational power to calculate the nonce every time the difficulty increases.

7. Environmental, Social, and Governance (ESG) debate on PoW

Proof of Work backed technology in bitcoin has many perks which can benefit the decentralization ecosystem and introduce us to a new era of better reach and scalability, advantages of adopting PoW blockchain technology are great security, more nodes in the network the better the security, lower fees than dealing with a bank or any financial institute and the scalability of the network. On the other hand, the disadvantages of PoW can be summarized as follows, difficulty in mining as it gets harder and harder with time, also mining is expensive as it requires a lot of electricity and computational power associated with it.

The shortcoming of bitcoin in energy usage and power sparked many debates on the sustainability of using such a technology, one of the greatest world Icon Elon Musk, is one of the vigorous supporters of Bitcoin cryptocurrency, his legendary tweets have an unshakable impact on the price movement of bitcoin in the market, however recently he displayed a slight fall out of the currency since the more participant into the blockchain means more energy will be produced by miners which lead to pollution and unsustainable future.

Nevertheless, that has been addressed by him, and offered a list of solutions, one of them that he spoke with North American bitcoin miners to adopt more sustainable solutions when mining a bitcoin, for example by using planned renewable solutions for mining instead of fuel-based electricity, I have shared his tweet below, Figure-1.

Figure-1 Past tweet by Elon Musk

During Elon’s tweets, the market was swinging between negative and positive statements from him, however, in my opinion, his logic is founded purely on protecting the planet by adopting better methods to protect the environment.

8. Proof of Stake in Ethereum 2

In my opinion, the other consensus mechanism is way better than proof of work.

We can’t talk about Bitcoin blockchain technology without bringing out its greatest competitor known as “Ethereum”. Moreover, it happened to be another blockchain technology with a different consensus mechanism known as “ Proof of Stake or in short PoS”. To be precise and clear about the consensus mechanism Ethereum uses, Originally Ethereum adopted the use of proof of work from Bitcoin, but due to proof of work many problems, a new way of block validation emerged and that’s Proof of Stake (PoS).

The Ethereum massive community decided to move from PoW to PoS model, this concept is still new and we already saw its adoption into the Ethereum network as Ethereum 2.0.

9. How proof of Stake works

As opposed to proof of work consensus, miners are the ones who get rewarded for solving the mathematical puzzle (aka guessing the right hash by million of trials), well in the proof of stake the nodes that maintain the validity of transactions of PoS are called validators, they have a similar task as miners in PoW , however, the mechanism is different as the validator are chosen to do the job in a deterministic way, where this way is based on wealth mechanism.

10. What is Wealth mechanism in PoS

Following our statement above, the wealth mechanism in PoS is what you call a stake, the validator with the most staked coin in circulation the better the chances of overall probability that he/she will be selected as the block creator or known as forgers.

For example, if we end up having four validators v1,v2,v3 and v4 and each one of them staked their cryptocurrency position in Ethereum (ETH) and put in 50 ETH, 43 ETH , 32 ETH and 15 ETH stakes respectively, their chances of being selected are determined as following, 50%, 43%, 32% and 15% chance of being selected the next block creator, but this doesn’t seem fair , this is why the blockchain has a set of commands to select these validators in random.

11. Steps for Proof of stake in Ethereum

The steps for a successful block creation in Ethereum is simple compared to proof of work and it is listed as following:

1- On the blockchain network , the blockchain keeps track of all active validators (Nodes) which are on the network , these validators by definition are known as block creators or forgers.

2- Once a new block is initiated to be created , the blockchain network randomly select a validator.

3- This validator verifies the new transaction and communicate his findings with other validators and propose the new blocks to them for approval.

4- Then all current active validators vote on the new blocks , where the voting power is based on the size of stake you put in as a validator

5- Validators who stakes unidentified or malicious transactions will risk losing their stake to the network

6- once the new block is approved by all , it will be added to the chain and the validator collect his transactions fees as a reward for the creation of the block.

12. Advantages of PoS in Ethereum as oppose of Bitcoin’s PoW

- One of the most notable advantage of adopting proof of stake mechanism is that it consumes less electricity to create and secure the blockchain than proof of work.

- Issuance of crypto coins is controlled as less electricity is needed to produce these coins resulting to issuance of less coins compared to the PoW based coins , moreover its true it will discourage validators to participates in the network since the issuance of coins is less. Theoretically this negative net issuance of coins leads to a portion of transaction to be burned in the network and eventually the supply goes down over time.

- This consensus mechanism has an array of different techniques that prevents organizations and group to monopolize the network via prior block of coins, this act is known as selfish mining.

- You don’t need a super computer with elite hardware to gain entry into this consensus mechanism to solve difficulty problems and create blocks. Hence , there is a low barrier of entry for this mechanism.

- PoS allows the process of chain sharding or shard chain , sharding is an upgrade procedure of staking where you can improve the Ethereum scalability and capacity to create multi blocks at the same time, on Bitcoin based mechanism the block time to create a block is 10 minutes as we discussed earlier but on Ethereum is about 13 seconds only.

13. What are the disadvantages of PoS

- Obviously, this drawback in Ethereum is known worldwide and that is the astronomical high fees compared to the other cryptocurrencies, these fees are known as “ Gas fees” prevent or make it impossible for some ERC-20 depended project to run on any payment system on Ethereum. Gas fees are the amount of money required from validators to execute transactions on the network, where its not constant as the gas fees fluctuate depending on network demand.

- Once a coin is staked , it will be almost impossible to redeemed back for any reason ,until of course the locked staked coins reached its interest end date.

- Proof of Stake algorithm system is still new to the market and has much room to grow to reach its scalable and full potential.

- The actual reward received from proof of Stake is not as much compared to proof of work.

- Big whales ( holders of sizable coins in the network) could have a notable influence on the coin and on the consensus process.

14. Notable cryptocurrencies that uses proof of stake

Although Ethereum is considered the foundation for many ERC-20 based Tokens on most cryptography exchanges , however other cryptocurrencies adopted proof of Stake as their consensus mechanism for mining . Some of these cryptocurrencies are mentioned below :

- Cardano (ADA)

- Tezos (XTZ)

- Lisk (LSK)

- Cosmos (ATOM)

- EOS (EOS)

15. Other mining consensus mechanism

I can’t conclude this paper without mentioning other consensus mechanism that could contribute greatly to the cryptocurrency world from the ICOs to financials transaction through the network. Some of these mechanisms are mentioned below :

- Delegated Proof-of-Stake (DPoS) : This mechanism is conserved an extension of the original PoS , however the difference is that all token holders select a group of delegates to complete this task. The mechanism remains decentralized as all nodes in the blockchain are authorized to select the group of validators that confirm transactions.

- Consensus as a Service (CaaS) : On this mechanism , transaction are dealt with privately on a platform known as the blockchain daura, Essentially, this mechanism operates like a digital account book: all transactions on the network are equally visible and verifiable for all operators of the nodes. The network data is stored in a highly secure database in Switzerland .

16. Conclusion

Blockchain technology and its consensus mechanism for more seamless financial transactions will shape the financial sectors for years to come. The revolution of cryptography in finance and the fall of the banking sector is imminent, where the consensus mechanism algorithm the likes of Proof of work and stake are the center of this revolution.

Proof of work (PoW) requires a lot of energy to work efficiently, however it provides the miners with a lot of power to maintain and secure the blockchain from hackers. The best-known cryptocurrency using PoW is bitcoin. The other consensus mechanism is proof of Stake ( PoS), this mechanism is revolved around the power of voting and randomness which gives it a more fair edge to it than PoW , simply PoS gives mining power based on the number of tokens or coins held by a miner or validator.

I hope you all enjoyed reading this article, Please follow me so you won’t miss out on Fintech, Artificial intelligence,Blockchain and other related Data Science projects.

Thanks again, don’t forget to follow my account and drop me a message if you ever have any questions regarding this article.

17. References

Below is a list of references I’ve used to research some of this information.

- Elon Musk and Bitcoin miners say they want to address crypto’s sustainability problem, By Kim Lyons, [Online]. Available from : https://www.theverge.com/2021/5/24/22451900/elon-musk-bitcoin-miners-council-sustainability.

- Bitcoin Proof of Work — The Only Article You Will Ever Have to Read, by Henrique Centieiro, [Online]. Available from : https://levelup.gitconnected.com/bitcoin-proof-of-work-the-only-article-you-will-ever-have-to-read-4a1fcd76a294

- What Is Proof-of-Stake, and Why Is Ethereum Adopting It?, by Ian Bezek, [Online]. Available from : https://money.usnews.com/investing/cryptocurrency/articles/what-is-proof-of-stake-and-why-is-ethereum-adopting-it

- Block time , Investopedia , [Online]. Available from : https://www.investopedia.com/terms/b/block-time-cryptocurrency.asp

- Consensus Mechanisms in Blockchain Technology, by Aurelia Nick and Lukas Hoeing, [Online]. Available from : https://www.lexology.com/library/detail.aspx?g=e30e7d54-3c7f-4ca0-8a22-478227a9b5ec

- What is Proof of Stake? How it Differs From Proof of Work, By Jeff Benson and Matt Hussey, [Online]. Available from : https://decrypt.co/resources/proof-of-work-vs-proof-of-stake

- Bashir, Imran. Mastering Blockchain : Distributed Ledger Technology, Decentralization, and Smart Contracts Explained. Birmingham — Mumbai Packt March, 2018, pp. 50–60.

- Bikramaditya Singhal, et al. Beginning Blockchain. Berkeley, Ca Apress, 2018, pp. 280–285.

--

--

Abdalla A. Mahgoub, MSc / CISI
CodeX
Writer for

Master's in Data Science. Technology Entrepreneur ,Data Scientist, Ops Analyst (ICT),Strategic Business developer, Speaker ,Writer, Full Stack developer