Читать книгу Introduction to Blockchain Technology - Tiana Laurence - Страница 30

Оглавление

3 The structure of the network: consensus algorithm

A consensus algorithm is a code that governs how a blockchain operates. It sets the rules that all participants must follow to process transactions. Consensus algorithms create a network structure and process that allows a group of independent systems to agree on a single version of the truth. Consensus algorithms are not unique to blockchain technology, but they are the foundation of all blockchains. They are the set of rules that govern how each blockchain functions.

It is essential to understand the different common blockchain network structures and the consensus algorithms that dictate their structure. Understanding these structures will empower you to make informed design decisions when building applications and processing transactions.

In this section, you will uncover many of the most significant consensus rules that govern how blockchains work. You will discover how these algorithms impact the functionality and, by extension, the best use you can obtain from blockchains that utilize this type of consensus algorithm.

3.1 Proof of Work

Proof of Work (PoW) was proposed by Satoshi Nakamoto and is still used by Bitcoin, Ethereum, Litecoin, Dogecoin and many other public blockchains. It is a competitive consensus algorithm where each mining node on the blockchain is competing to secure blocks. It allows anyone to participate at any level in the creation and maintenance of the system but is very competitive. Nodes that hope to be competitive and be rewarded with cryptocurrency will need to operate specialized equipment. The algorithm is, by design, energy intensive and expensive. The expense and difficulty of obtaining bitcoins was an intentional part of the token economics. Much like mining gold, it is not cheap nor easy to mine, and the difficulty and scarcity of bitcoins is thought to drive part of the value of the asset.

The Proof of Work algorithm functions by having some of the participants of the Bitcoin blockchain, called miners, solve a complex computational problem. The miner who solves the problem first adds a new block of transactions to Bitcoin’s blockchain. The miner is then given a “block reward” with bitcoins. Currently, miners receive 12.5 bitcoins for finishing first. The number of bitcoins rewarded to miners decreases over time.

The number of miners competing for bitcoins changes frequently because each miner is participating willingly and freely. The Proof of Work algorithm will adjust the difficulty of the problem the miners are solving in order to maintain a more consistent time between blocks and to ensure the security of the transactions that are being secured in each block.

It is not uncommon for more than one miner to solve a block problem concurrently. When this happens, miners pick one of the wining blocks to continue building their chain. The longest chain wins. It is recommended that you wait for at least six blocks before confirming a transaction. You do this to ensure that enough blocks have been secured on top of the block your transaction was placed within.

The Bitcoin blockchain is protected from corruption as long as 51% or more of the blocks being created by miners are legitimate. The miners are economically incentivized only to produce valid blocks.

PoW tends to be used for peer-to-peer transaction between parties that are not connected. It can be expensive to scale applications that are built within PoW blockchains (Decentralized application, DApp) as they can be expensive and cumbersome to operate.


Figure 15 Proof of Work.

Pros:

■ It has been tested since 2009 and still works great;

■ It is slower and safer - you know your transaction will not be rolled back;

■ It is trustless - no one can block your transaction from processing.

Cons:

■ It’s slow - you have to wait for your transaction to be confirmed;

■ It’s costly - transaction costs can go up with the number of users;

■ It’s susceptible to centralization over time - those with the most recourses can pool together their efforts in mining.

3.2 Proof of Stake (PoS)

Proof of Stake (PoS) is a competitive consensus algorithm. It was created as an alternative to the Proof of Work (PoW) because blockchains had difficulty meeting the transaction speed demands.

PoS nodes do not mine cryptocurrency. Users can put some of their cryptocurrency, from a blockchain, in a retainer. This retainer allows the user to “stake” that they will process transactions honestly and by the rules of the consensus system. If the user fails to do so, they will forfeit their cryptocurrency. It is becoming popular in public blockchain networks as it is a low-cost alternative that supports greater decentralization.

Proof of Stake allows anyone to participate at any level in the creation and maintenance of the network. The one catch is that a node operator must have the minimum amount of cryptocurrency needed to stake. If they do, they can process transactions for the network. The node’s probability of securing the next block and being rewarded for doing so is equivalent to the percentage of cryptocurrency they stake.

In the event that there are two or more competing blocks (known as a fork) in the Proof of Stake algorithm, you can stake your cryptocurrency on both blocks without consequence. This is called the “nothing-at-stake” problem. It is important to note that in a Proof of Work system it is not economically viable to mine on both chains. But in PoS, there is little cost involved in working on several chains and an economic incentive to do so. There are open questions regarding what rules would be applied across PoS environments when situations arise where a staker is nefarious from start. See figure 16.

Pros:

■ It is energy efficient and does not burn electricity when mining;

■ It can be more expensive to attack than PoW - hackers need to purchase a large percentage of the native cryptocurrency;

■ It scales easily to handle transaction load and size.

Cons:

■ Rewards are weighted to those who stake their cryptocurrency the longest. The longer a miner stakes, the greater the reward. The network structure allows wealthy stakers to control more of the network and this may cause centralization and censorship.

PoS is used by Ethereum, Peercoin and Nxt.

Figure 16 Proof of Stake.

3.3 Delegated Proof of Stake

The competition to be a validator happens outside of consensus. Those with better websites and social media accounts, at this point, are selected. Delegated Proof of Stake (DPoS) is a collaborative effort, and nodes that are validating transactions are rewarded equally in this consensus system.

As a stakeholder you elect “witnesses” who will validate transactions and create blocks for the network. EOS, one of the most popular DPoS blockchains, only has 21 witnesses.

Each of the EOS witnesses are paid fees for producing blocks, and the fee is set by the stakeholders.

The witness nodes produce blocks one at a time in a round-robin fashion, or by random selection. Witnesses can’t publish consecutive blocks or execute double-spending attacks where they allow cryptocurrency to be sent twice or more from the same address without updating the ownership. This would be the equivalent to writing checks from an empty bank account that you don’t own. The person you wrote the check to believes they have been paid, but once the check is processed by the bank, it is rejected, and they learn that they have been defrauded.

Introduction to Blockchain Technology

Подняться наверх