Explanation of the consensus mechanism of blockchain

16-022-supersoniccontract

Consensus mechanism is a hot topic, involving environment, scalability and security. But what are they?

What is the consensus mechanism?

In the cryptocurrency world, consensus mechanisms are protocols and algorithms that enable computer networks to work together to ensure network security.

51% of the nodes in the network must agree on the global status of the network in order to reach a consensus.

To some extent, this is just a popular saying, "This is the way we should use to ensure that we all agree with each other's views.".

What consensus have we reached?

Blockchain technology consists of verified blocks, which are then added to a chain (hence the name blockchain).

Each block contains a list of transactions that have been validated in a specific time period. This can be seen by everyone; In other words, you can go back and see every transaction on the blockchain.

The consensus mechanism is used to verify transactions added to the blockchain.

Some more advanced blockchain projects will also use the consensus mechanism to verify stored data, smart contracts, etc.

But at the basic level, the consensus mechanism is used to verify transactions.

How does the consensus mechanism work?

Well, it depends on the mode that a blockchain decides to use. There are two main types of consensus mechanisms: proof of work (PoW) and proof of equity (PoS).

What is proof of work

Proof of work is the consensus mechanism used by Bitcoin. Other cryptocurrency projects using it include Ethereum 1.0, Dogecoin, and Litecoin.

It was originally developed by Cynthia Dworke and Moni Nauer in 1992 as a way to prevent spam. Although this model was first proposed, they did not call it proof of work at that time. Instead, it is called a "pricing function".

Until 2009, Nakamoto created Bitcoin, which uses proof of work as a consensus mechanism. It is used to validate transactions and create new blocks on the blockchain.

Since then, it has developed into a consensus mechanism widely used in cryptocurrency projects.

How does proof of work work?

Nodes on the network will try to answer encryption problems that are difficult to solve but easy to verify -- nodes trying to solve problems are called miners. Once a miner has completed a puzzle, they will broadcast the puzzle to the blockchain so that other miners can verify the solution.

The answer to the password puzzle is a random number called "NONCE", which represents a number used only once. This number cannot be predicted, it can only be guessed.

This means you have to spend a lot of time looking for NONCE.

Once combined with the data in the block and through the hash function, NONCE will produce a result with a series of conditions. This is the process miners will go through to verify that the solution is correct.

When a valid NONCE is combined with a block, it creates a block hash. This will then be stored on verified blocks as proof of the miners' work. The block will then be created and added to the blockchain.

Now you have evidence that you worked hard to solve this problem. Therefore, you will get a reward in the form of cryptocurrency, called the miner's reward,.

This reward is only given to the person who finds NONCE first, regardless of how much effort other people may have put into solving this puzzle.

Energy problem of work certificate

Because of the miners' rewards, Bitcoin mining is a way to create passive income for themselves, which is why individuals and large companies invest to become miners.

The stronger your computing power and the better the device that solves the encryption problem, the more likely you are to receive money as a reward.

In other words, a supercomputer is more likely to find NONCE than a 2008 Dell computer.

This has led to the use of a large amount of energy on the Bitcoin network. It has led to a consensus mechanism for environmentalists to oppose proof of work.

Bitcoin network accounts for 0.66% of global power consumption and 0.23% of global energy consumption.

Bitcoin consumed enough electricity to power Cambridge University for 1081 years, or all the teapots in the UK for 33 years.

However, not everything is bad. The large amount of computing power consumed by Bitcoin network actually means that the network is more secure.

This is because, in order to attack the blockchain, you need to control 51% of the computing power on the network (called 51% attack). Having so much computing power may cost billions of dollars, which is not economically feasible.

What is "proof of interest"

Proof of equity is a consensus mechanism used by Solana, Cardano and Tezos.

It was first created on the Bitcoin Forum in 2011 as a substitute for proof of work to improve the shortcomings of the old consensus mechanism. In 2012, we saw the first cryptocurrency project with proof of equity - Peercoin.

Ethereum 2.0 will see the blockchain shift from proof of work to proof of equity. Try to be "more scalable, safer and more sustainable".

This method uses much less computing power than the proof of work method. And, therefore, projects that use it are considered more environmentally friendly.

How does proof of interest work?

The consensus mechanism of proof of equity is to forge blocks, rather than mining like the method of proof of work.

In the proof of work project, tokens are created as rewards for miners, but in the proof of equity project, transaction costs are used as rewards. Therefore, proof of interest projects are initiated by selling pre mined tokens, or initially by means of proof of work, and then transitioned to proof of interest.

If you want to participate in counterfeiting blocks, you must invest your tokens. The mortgage process requires you to lock your tokens in the network, which means that you cannot use them during this time.

This is because if you are a bad actor, you will be punished by taking away your mortgage token - making such behavior economically feasible.

Stakers, also known as verifiers, play a similar role as miners in work certification.

Next, a pseudo-random selection method is used to select the verifier. The three most popular methods are node wealth, coin age selection, and randomized block selection.

Let's take a closer look at each method.

node wealth

To put it simply, the more tokens you bet, the greater the chance that you will be selected to verify the next block.

If this is the only variable to choose the verifier, only the richest coin operator can ensure the security of the network; This makes the project less decentralized and more vulnerable to attacks by bad people.

coin age selection

A node will be selected according to the time when the token is mortgaged, using this formula.

Currency age=number of days mortgaged x number of currencies mortgaged

Once a node has completed forging the block, its currency age will be reset to zero. Therefore, they have to wait for some time to forge another block. This prevents wealthy nail households from leading the forging process. In turn, it makes the blockchain more decentralized.

randomized block selection

The random block selection will select the next forger by finding the node with the lowest hash value and the highest equity.

It is worth noting that each cryptocurrency project using the consensus mechanism of proof of interest uses its own set of rules and methods when selecting forgers.

Back to validating a block

When a node is finally selected, it will verify the transactions in the block. Each transaction is signed with the sender's private key.

The verifier will use this key to find the sender's public key and address. Using this information, they will verify whether the sender really has the money they want to spend and whether they have spent tokens multiple times (known as the dual consumption problem).

Next, the hash function groups the verified hash transactions into a Merkle tree. Then, the forger uses its private key to sign the block and broadcast it to the blockchain, so that other verifiers (now called certifiers) can prove that the block is valid.

Slots and eras are used to divide time. The slot is the time set for creating a block (12 seconds of Ethereum 2.0).

An era is a larger defined time period, which usually indicates when a new group of verifiers will be selected (32 slots of Ethereum 2.0, about 6 minutes and 24 seconds).

Normally, each slot will generate a block on the blockchain. However, if the forger fails to generate blocks in time, this may be empty.

Once the block is verified and added to the blockchain, the forger node will receive rewards in the form of cryptocurrency.

As mentioned earlier, this usually comes from transaction costs. If the certifier proves correctly, he will also be rewarded.

Not all equity certification projects will follow this exact method, and the system will be slightly adjusted.

Entrusted shareholding certificate

Some proof of equity items allow you to entrust your token to other verifiers instead of setting a node yourself. This lowers the entry threshold for wager rewards.

Individuals choose which verifier to entrust their tokens to based on their records and reputation. Other factors can also determine where someone entrusts their tokens, such as whether they use environment-friendly energy and whether a certain proportion of them are donated to charities.

 

Differences between Proof of Work and Proof of Stake

Well, that's a big message. Let's quickly summarize the differences of consensus mechanisms.

Proof of Work

Bitcoin uses it

Blocks are mined

Miners Solve Cryptographic Problems

Need a lot of computing power to mine

Only those who solve puzzles can get rewards

Very bad for the environment

Proof of Stake

Cardano uses it

Block is forged

Keys and signatures are used to validate transactions

Verifiers must bet their tokens to be selected to forge blocks

The verifier and the certifier will be rewarded

More environmentally friendly

Other consensus mechanisms

Although these are the two most popular consensus mechanisms, they are not the only ones. In fact, when we speak, more consensus mechanisms are being created.

The following are some examples of alternative consensus mechanisms.

Space and time proof

This consensus mechanism allows projects to store data, not just validate transactions.

Essentially, the model sets a way to put information on the hard disk, and then randomly checks whether the information is still there.

People pay for their information to be stored, and those who store data pay for storage.

Certificate of Authorization

This is a more centralized version of proof of equity.

The authority certification project does not allow anyone to be the verifier, but selects several nodes that they trust. This is to process transactions more quickly and further reduce the impact on the environment.

Unique Node List

This is the consensus mechanism used by XRP.

Similar to proof of authorization, you select several nodes that you trust. This time, nodes do not need to mortgage anything, they just need to verify the transaction.

Transactions are sent to a large number of nodes, who are required to sign valid transactions. If a transaction does not get many signatures, it is considered invalid, so it is thrown away.

The consensus mechanism is essential to ensure the security of the blockchain and make it what it is today. We started from the proof of work, which is now evolving into the proof of rights and interests, as a way to reduce our damage to the earth.

But will this be the consensus mechanism for the rest of the time? Or will we soon see another evolution?