Blockchain & Cryptocurrency #7: Distributed consensus by rosargia

View this thread on steempeak.com
· @rosargia ·
$9.08
Blockchain & Cryptocurrency #7: Distributed consensus
We are a group composed by some Informatics and Mathematics who like to share their IT, Math and Cryptographic knowledge with people. It is possible to find our complete courses on http://learningspot.altervista.org website. Since we think that Steemit is a great opportunity to share knowledge, we are proposing our most interesting lessons here, too.

==================================================

Until now we have talked in a generic manner about centralization and decentralization. Let's now talk about Bitcoin decentralization. The key work of this topic is distributed consensus.
<h2>How to build a distributed e-cash system</h2>
The key challenge that is necessary to solve to build a distributed e-cash system is the distributed consensus. This is a class of protocols studied for decades in the computer science literature. Intuitively, you can think of it as our goal to decentralize ScroogeCoin, which is the hypothetical currency that we saw in the first week.
<h3>Reliability in distributed systems</h3>
Imagine the backend systems for companies like Google or Facebook. These companies have thousands, or even millions of servers, which form a massive distributive database. This database records all the actions on the system, such as users' comments, likes, posts and so on.

When a new information comes in, the server needs to make sure that that comment either gets recorded in all copies of the database, or none of them. If the action gets recorded in none of the databases, it's okay: it's enough to notify the problem to the user. On the other hand, if some of the copies of the database saved it and others didn't, then there will be a lot of troubles: the database will be inconsistent.

So this is the key problem that motivated the traditional research on distributed consensus.
<h3>Distributed consensus applications</h3>
Suppose that we have a distributed consensus protocol and we were able to use it to build a massive distributed key-value store, that maps arbitrary keys or names to arbitrary values. Then we could use it for many applications, for example:
<ul>
 	<li>distributed domain name system: a mapping between human understandable domain names to IP addresses</li>
 	<li>public key directory: a mapping between user email addresses to their public keys</li>
 	<li>stock trades: the distributed database would keep track of who's transferred goods of which stock to whom</li>
</ul>
Now that Bitcoin has solved the distributed consensus problem, we can go ahead and try to use it for all these related problems. In fact, there are many <strong>Altcoins</strong>: systems built on Bitcoin-like principles to achieve slightly different goals. Sometimes they are currency systems, sometimes not.
<h3>Technical definition</h3>
Imagine that there is a fixed number $$n$$ of nodes or processes and each of them has some input value. Then a consensus protocol run on them has two requirements:
<ol>
 	<li>the protocol should terminate and all correct nodes should decide on consensus value. We say correct nodes because some of them could be faulty or even malicious.</li>
 	<li>the output value cannot be arbitrary, but must match with one of the input values proposed by at least one of the correct nodes.</li>
</ol>
<h3>Bitcoin transaction</h3>
Bitcoin is a peer-to-peer system. So, when Alice wants to pay Bob, she's going to broadcast the transaction to all of the Bitcoin nodes belonging to the peer-to-peer network.
<a href="http://learningspot.altervista.org/distributed-consensus/bitcoin_transaction/" rel="attachment wp-att-268"><img class="wp-image-268 aligncenter" src="http://learningspot.altervista.org/wp-content/uploads/2016/12/bitcoin_transaction.png" alt="bitcoin_transaction" width="577" height="138" /></a>
The transaction is going to have:
<ul>
 	<li>Alice's signature used by other nodes to check the provenience</li>
 	<li>Bob's public key, which also accesses the address at which he wants to receive bitcoins</li>
 	<li>a hash of the previous transaction. This is a way for Alice to link this transaction to her receipt of this coin from someone else previously</li>
</ul>
Alice is going to broadcast the transaction to all of the Bitcoin peer-to-peer nodes. It is not necessary that Bob listens the network to receive the funds. The bitcoins will be his, whether or not he's running a node on the network.

The network nodes wants to reach consensus on which transactions were broadcasted, and the order in which these transactions happened.
<h3>How distributed consensus could work in Bitcoin</h3>
At any given time:
<ul>
 	<li>All the nodes in the peer-to-peer network would have a sequence of transactions blocks that they've reached consensus on. In fact, for optimization purposes the transactions are organized into blocks and linked together to form a blockchain.</li>
 	<li>Each node would have a set of outstanding transactions that it has heard about. The consensus has not happened to them, yet. So each node might have a slightly different version of these outstanding transactions.</li>
</ul>
Now suppose that there are three nodes in the system, each of whom has an input: the set of outstanding transactions that it heard about. They execute together some consensus protocol, when it succeeds, it is possible to select any valid block and add it to the blockchain, even if it's a block proposed by only one node.

<a href="http://learningspot.altervista.org/distributed-consensus/distributed_consensus/" rel="attachment wp-att-267"><img class="wp-image-267 aligncenter" src="http://learningspot.altervista.org/wp-content/uploads/2016/12/distributed_consensus-960x410.png" alt="distributed_consensus" width="577" height="246" /></a>
<h3>Problems with this kind of system</h3>
Taking the traditional theory of distributive consensus and applying that to cryptocurrency, we end up with a system similar to the one described above. This has some similarities wth how Bitcoin works, but it's not exactly the same. In fact, this systems has some hard technical problems, for example:
<ul>
 	<li>Nodes might crash or might be malicious</li>
 	<li>The network is highly imperfect: it's a peer-to-peer system and not all pairs of nodes are connected to each other</li>
 	<li>There could be faults in the network because of poor Internet connectivity</li>
 	<li>There will be a lot of latency in the system, because everything happens over the Internet and there's no single data center. One particular consequence of this high latency, is that there is no notion of <strong>global time</strong>. This means that not all nodes can agree to a common ordering of events, simply based on observing timestamps.</li>
</ul>
<h5>Constraints in distributed algorithm</h5>
Especially the last problem, puts serious constraints on what sorts of algorithms can run into a consensus protocol. A lot of the literature on distributed consensus is somewhat pessimistic. And many impossibility results have been proved, such as:
<ul>
 	<li>Byzantine generals problem: under some conditions, which include the nodes acting in a deterministic manner, consensus is impossible, even with a single faulty process.</li>
 	<li>Paxos problem: under certain conditions, even if rare ones, the protocol can get stuck and fail to make any progress</li>
</ul>
However Bitcoin violates a lot of the assumptions of the previous impossibilities problems. Because of that, consensus in Bitcoin, ironically, works better in practice than in theory:
<ul>
 	<li>Bitcoin introduces the idea of incentives. Because Bitcoin is a currency, it is possible to use it to give incentives to the participants for acting honestly.</li>
 	<li>it embraces the notion of randomness: consensus happens over a long period of time, about an hour in the practical system. As time goes on, the probability that a transaction is valid goes up higher and higher. And the probability that you're wrong in making an assumption about a transaction goes down exponentially.</li>
</ul>
That's why Bitcoin is able to get around these traditional impossibility results on distributed consensus protocols.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
post_id23,302,876
authorrosargia
permlinkblockchain-and-cryptocurrency-7-distributed-consensus
categoryblockchain-crypto
json_metadata"{"app": "steemit/0.1", "format": "markdown", "links": ["http://learningspot.altervista.org", "http://learningspot.altervista.org/distributed-consensus/bitcoin_transaction/", "http://learningspot.altervista.org/distributed-consensus/distributed_consensus/"], "image": ["http://learningspot.altervista.org/wp-content/uploads/2016/12/bitcoin_transaction.png"], "tags": ["blockchain-crypto", "blockchain", "cryptocurrency", "bitcoin", "technology"]}"
created2018-01-03 12:59:06
last_update2018-01-03 12:59:06
depth0
children6
net_rshares784,912,082,397
last_payout2018-01-10 12:59:06
cashout_time1969-12-31 23:59:59
total_payout_value7.004 SBD
curator_payout_value2.078 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length8,114
author_reputation56,090,445,431
root_title"Blockchain & Cryptocurrency #7: Distributed consensus"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (35)
@rosargia ·
@OriginalWorks
@steem-untalented
properties (22)
post_id23,302,984
authorrosargia
permlinkre-rosargia-blockchain-and-cryptocurrency-7-distributed-consensus-20180103t125945251z
categoryblockchain-crypto
json_metadata"{"app": "steemit/0.1", "users": ["originalworks", "steem-untalented"], "tags": ["blockchain-crypto"]}"
created2018-01-03 12:59:45
last_update2018-01-03 12:59:45
depth1
children1
net_rshares0
last_payout2018-01-10 12:59:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length32
author_reputation56,090,445,431
root_title"Blockchain & Cryptocurrency #7: Distributed consensus"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@originalworks2 ·
The @OriginalWorks bot has determined this post by @rosargia to be original material and upvoted it! 
<center>![ezgif.com-resize.gif](https://steemitimages.com/DQmaBi37A5oTnQ9NBLH8YU4jpvhhmFauyvgg3YRrEJwskM9/ezgif.com-resize.gif)</center> 

To call @OriginalWorks, simply reply to any post with @originalworks or !originalworks in your message!
properties (22)
post_id23,303,230
authororiginalworks2
permlinkre-re-rosargia-blockchain-and-cryptocurrency-7-distributed-consensus-20180103t125945251z-20180103t130120
categoryblockchain-crypto
json_metadata"{"app": "pysteem/0.5.4"}"
created2018-01-03 13:01:21
last_update2018-01-03 13:01:21
depth2
children0
net_rshares0
last_payout2018-01-10 13:01:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length344
author_reputation18,716,395,863
root_title"Blockchain & Cryptocurrency #7: Distributed consensus"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@minnowsupport ·
<p>Congratulations!  This post has been upvoted from the communal account, @minnowsupport, by jrswab from the Minnow Support Project.  It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews/crimsonclad, and netuoso.  The goal is to help Steemit grow by supporting Minnows and creating a social network.  Please find us in the <a href="https://discord.gg/HYj4yvw">Peace, Abundance, and Liberty Network (PALnet) Discord Channel</a>.  It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.</p>

<p>If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=102530.639667%20VESTS">50SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=205303.639667%20VESTS">100SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=514303.639667%20VESTS">250SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=1025303.639667%20VESTS">500SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=2053030.639667%20VESTS">1000SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=10253030.639667%20VESTS">5000SP</a>.  <strong>Be sure to leave at least 50SP undelegated on your account.</strong></p>
properties (22)
post_id23,319,301
authorminnowsupport
permlinkre-rosargia-blockchain-and-cryptocurrency-7-distributed-consensus-20180103t143213108z
categoryblockchain-crypto
json_metadata"{"app": "cosgrove/0.0.2", "tags": ["blockchain-crypto"]}"
created2018-01-03 14:32:12
last_update2018-01-03 14:32:12
depth1
children0
net_rshares0
last_payout2018-01-10 14:32:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length1,744
author_reputation104,981,098,086,561
root_title"Blockchain & Cryptocurrency #7: Distributed consensus"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@minnowhelper ·
<p>This post has received a 0.77 % upvote from https://steemitimages.com/DQmcZYv2276nr6zEDDTZY1iLcgaBiNqumAnYtmvxNtr5zrW/minnow_klein.png thanks to: @rosargia. <br>For more information, <a href="http://www.minnowhelper.com/index.php">click here!!!</a>!<br>
<b>Send minimum 0.010 SBD to bid for votes.</b>
<br>
The Minnowhelper team is still looking for investors (Minimum 10 SP), if you are interested in this, read the conditions of how to invest <a href="http://www.minnowhelper.com/delegate.php">click here!!!</a><br>
ROI Calculator for Investors <a href="http://www.minnowhelper.com/delegatecalc.php">click here!!!</a></p>
properties (22)
post_id23,324,108
authorminnowhelper
permlinkre-rosargia-blockchain-and-cryptocurrency-7-distributed-consensus-20180103t145540400z
categoryblockchain-crypto
json_metadata"{"app": "drotto/0.0.2d", "tags": ["blockchain-crypto"]}"
created2018-01-03 14:57:12
last_update2018-01-03 14:57:12
depth1
children0
net_rshares0
last_payout2018-01-10 14:57:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length627
author_reputation1,659,586,907,437
root_title"Blockchain & Cryptocurrency #7: Distributed consensus"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@steemdunk ·
steemdunk-upvote-1514996186589
<div class="pull-right">
  <img src="https://steemitimages.com/DQmTtkrMW5Nsq8Lm3pL4pzVWQAEtqNoZZ6FhzAVmsXYEfZz/steemdunk-avatar-256x264-transparent.png">
</div>

Hello, you received a boost courtesy of @steemdunk! Steem Dunk is an automated curation platform that is easy and free for use by everyone. Need a boost? [Click me](https://steemdunk.xyz)

Upvote this comment to support the bot and increase your future rewards!
👍  
properties (23)
post_id23,337,976
authorsteemdunk
permlinksteemdunk-upvote-1514996186589
categoryblockchain-crypto
json_metadata{}
created2018-01-03 16:16:27
last_update2018-01-03 16:16:27
depth1
children0
net_rshares1,036,443,768
last_payout2018-01-10 16:16:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length424
author_reputation1,829,035,868,014
root_title"Blockchain & Cryptocurrency #7: Distributed consensus"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (1)
@fun2learn ·
Upvoted for you! Keep sharing what is good to steemit members!
properties (22)
post_id23,389,500
authorfun2learn
permlinkre-rosargia-blockchain-and-cryptocurrency-7-distributed-consensus-20180103t212719311z
categoryblockchain-crypto
json_metadata"{"app": "steemit/0.1", "tags": ["blockchain-crypto"]}"
created2018-01-03 21:27:21
last_update2018-01-03 21:27:21
depth1
children0
net_rshares0
last_payout2018-01-10 21:27:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length62
author_reputation109,928,704,812,170
root_title"Blockchain & Cryptocurrency #7: Distributed consensus"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000