Skip to content

Commit a0c3689

Browse files
Merge pull request ethereumbook#521 from chronaeon/consensus-chapter-changes
Consensus chapter changes
2 parents 4f4a2ab + 463a4d5 commit a0c3689

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

consensus.asciidoc

+41-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,48 @@
22

33
== Consensus
44

5-
When it comes to decentralized record keeping, which is how blockchain technology is often described, it becomes infeasible to rely on trust alone to ensure that factual information is added to the record books. This problem arises in decentralized networks as a result of the lack of a central entity that would typically decide what should and should not be considered as fact. It's difficult to avoid this issue when working with blockchain technology because it is this lack of a central entity that is one of the main contributors to blockchain's popularity. In order to circumvent this issue a network must have a system in place by which a consensus can be reached by the nodes in the network.
5+
When it comes to decentralized record keeping, which is one important aspect of how blockchain technology functions, it becomes infeasible to rely on trust alone to ensure that factual information is added to the record books. This problem arises in decentralized networks as a result of the lack of a central entity that would typically decide what should and should not be considered as fact. It's difficult to avoid this issue when working with blockchain technology because it is this lack of a central entity that is one of the main contributors to blockchain's popularity. In order to circumvent this issue a network must have a system in place by which a consensus can be reached by the nodes in the network.
66

7-
A consensus protocol is a system that allows network nodes to reach an agreement on what should be considered as truth. When referring to a blockchain network this protocol is used to determine which copy of the blockchain is the true copy. This is required in order to prevent malicious parties from frauding the network and to guarantee the integrity of the blockchain is maintained. There are different types of consensus protocols in use in blockchain technologies, we will focus on proof of work (*POW*) and proof of stake (*POS*).
7+
8+
=== Consensus Metrics
9+
10+
A consensus metric is a measurable datum on which a blockchain network's nodes must agree in order to establish and maintain consensus for the data contained in each block. In blockchain technology, consensus metrics are measured and approved by each network node every time a new block is to be added to the chain. As a result of the consensus metric, blockchains act as chains of truth extended from one certainly verifiable fact to the next. Because of the consensus metric, a blockchain protocol's nodes become _mini-notaries_, instantly able to tell a false copy of the blockchain from the true one and report that fact to the entire network. These measures are required in order to keep bad actors from frauding the network by submitting blocks containing false information. As a result of the consensus metric of a blockchain the integrity of the blockchain is not only established, but also maintained, over the long run. Consensus metrics take a variety of forms, but the two most important for this discussion are risk-based metrics and work-based metrics.
11+
12+
=== Hash-Based Metrics
13+
14+
Commonly known as Proof-of-Work (PoW) metrics, these metrics establish consensus because protocols that use them set computers to work on finding difficult numbers. For the sake of illustration, consider supercomputers whose only job in life is to search integer-space for prime numbers. Now consider a whole network of average computers. These computers, when put together, might be said to have the combined power of a supercomputer. The only job for this network of computers is similarly to search possible numbers for another kind of number called a SHA-256 hash. These numbers have unique properties, just like prime numbers, that make them easily identifiable when discovered.
15+
16+
When SHA-256 hashes are computed accurately they serve as an attestation that a certain amount of computing power has been used to find the number. The most recent prime number to be found is asciimath:[2^(77,232,917) − 1]. It was found by a computer just like SHA-256 hashes are found by computers. SHA-256 hashes are easier to find than new prime numbers, however, and this is where hash-based metrics derive their power.
17+
18+
Every SHA-256 hash has 64 hexadecimal characters in it. For example, here is the SHA-256 hash for the word "yank".
19+
`"yank"(SHA-256) = 45F1B9FC8FD5F760A2134289579DF920AA55830F2A23DCF50D34E16C1292D7E0`
20+
21+
Compare this to the SHA-256 hash of the three letters "yan".
22+
23+
`"yan"(SHA-256) = 281ACA1A80B52620BD717E8B14A0386B8ADA92AE859AC2C8A2AC222EFA02EDBB`
24+
25+
Compare this alternately to the SHA-256 hash of the two letters "ya".
26+
27+
`"ya"(SHA-256) = 6663103A3E47EFC879EA31FA38458BE23BE0CE0895F3D8B27B7EA19A1120B3D4`
28+
29+
Lastly, compare this to the SHA-256 hash of the single letter "y".
30+
31+
`"y"(SHA-256) = A1FCE4363854FF888CFF4B8E7875D600C2682390412A8CF79B37D0B11148B0FA`
32+
33+
=== Validation for Hash-Based Metrics
34+
35+
If you hash enough random phrases, kind of like monkeys on a typewriter, eventually you will find a hash that matches a certain pattern. In the case of the hash for "ya", note that it begins with the pattern "666". This is similar to Bitcoin, except Bitcoin requires that hashes be found matching the pattern beginning with "000". Any hash that can be created by plugging information from the previous block into the SHA-256 hashing algorithm can be used to create the next block, as long as it has the right amount of leading zeros in the number, the network will agree on it and the block reward will be yours.
36+
37+
Since more and more people wish to mine Bitcoin every day, there is more computer power going to finding SHA-256 hashes, so the Bitcoin software automatically adjusts the difficulty of the consensus metric by requiring an increased amount of leading zeros to form consensus. This guarantees that new blocks are created in roughly the same increments of time as previous blocks.
38+
39+
40+
== Risk-Based Metrics
41+
42+
Commonly known as Proof-of-Stake (PoS) metrics, these metrics establish consensus because everyone runs the same amount of risk if they fail to create correct blocks. Rather than demanding each node finds an arbitrary number to add a block, as with hash-based metrics, risk-based metrics only demand that some amount of money is at risk if the validator fails to create good blocks. The metric that all nodes agree upon here is whether or not another particular node has created a block in good faith. Rather than relying on hashing arbitrary numbers to make sure a certain amount of work has gone into creating a new block, risk-based chain nodes only need to agree that a certain amount has been staked and under what conditions that stake should be slashed.
43+
44+
Risk-based chains depend upon quick, immediate, and irreversible repercussions to any block creators that fail to create what other nodes in the network consider to be quality blocks. By enforcing risk of resources lost, the process of hash-based metrics (which also relies on people not wanting to waste resources to work) can be shortcutted and implemented in a simpler way. Although fully risk-based blockchains are a topic for current research and have yet to be implemented in Ethereum, there is good reason to believe that the model will operate sufficiently when implemented properly in software.
45+
46+
=== POW
847

948
=== POW
1049

0 commit comments

Comments
 (0)