刘振 上海交通大学 计算机科学与工程系 电信群楼3-509

Slides:



Advertisements
Similar presentations
高考短文改错专题 张柱平. 高考短文改错专题 一. 对短文改错的要求 高考短文改错的目的在于测试考生判断发现, 纠正语篇中 语言使用错误的能力, 以及考察考生在语篇中综合运用英 语知识的能力. 二. 高考短文改错的命题特点 高考短文改错题的形式有说明文. 短文故事. 书信等, 具有很 强的实用性.
Advertisements

高考英语阅读分析 —— 七选五. 题型解读: 试题模式: 给出一篇缺少 5 个句子的文章, 对应有七个选项,要求同学们根据文章结构、 内容,选出正确的句子,填入相应的空白处。 考查重点: 主要考查考生对文章的整体内容 和结构以及上下文逻辑意义的理解和掌握。 (考试说明) 选项特点: 主旨概括句(文章整体内容)
期末考试作文讲解 % 的同学赞成住校 30% 的学生反对住校 1. 有利于培养我们良好的学 习和生活习惯; 1. 学生住校不利于了解外 界信息; 2 可与老师及同学充分交流有 利于共同进步。 2. 和家人交流少。 在寄宿制高中,大部分学生住校,但仍有一部分学生选 择走读。你校就就此开展了一次问卷调查,主题为.
智慧老伯的一席話 原稿 : 溫 Sir 中譯 : 老柳 A man of 92 years, short, very well- presented, who takes great care in his appearance, is moving into an old people’s.
考研英语复试 口语准备 考研英语口语复试. 考研英语复试 口语准备 服装 谦虚、微笑、自信 态度积极 乐观沉稳.
SanazM Compiled By: SanazM Here Are Some Tips That May Bring You A Beautiful Life! Music: 美麗人生 Angel ( 主題曲 ) Revised By: Henry 以下是一些能帶給你一個美麗人生的秘訣 中文註解:
2014 年上学期 湖南长郡卫星远程学校 制作 13 Getting news from the Internet.
F1 VISA APPLICATION F1学生赴美留学签证申请流程.
专题八 书面表达.
完形填空技巧 CET4.
To Tell His Story To Tell His Story
雅思大作文的结构 Presented by: 总统秘书王富贵.
Welcome Welcome to my class Welcome to my class!.
专题讲座 武强中学外语组 制作:刘瑞红.
Bitcoin-NG: A Scalable Blockchain Protocol
Could you please clean your room?
Unit 4 I used to be afraid of the dark.
Module 5 Shopping 第2课时.
Population proportion and sample proportion
馬太福音 Matthew 11: 那時,耶穌說:「父啊,天地的主,我感謝你!因為你將這些事向聰明通達人就藏起來,向嬰孩就顯出來。26 父啊,是的,因為你的美意本是如此。27 一切所有的,都是我父交付我的; 25 At that time Jesus said, “I praise you,
Here Are Some Tips That May Bring You A Beautiful Life!
摘錄自~《當下的力量~The Power of Now》
初二英语写作课 课件 福建省闽清县第一中 王国豪
MICROECONOMICS Chapter16 Price Control 價格管制.
Friendship Bouquet 友谊之花 Music: Nightengale Serenade
The expression and applications of topology on spatial data
This Is English 3 双向视频文稿.
The Wise Old Man 智慧老伯的一席話 原稿: 溫Sir 中譯 : 老柳 中譯潤稿:風刀雨箭
塑膠材料的種類 塑膠在模具內的流動模式 流動性質的影響 溫度性質的影響
Oxford English Module 3 Out and about 8 Visiting museums.
客户服务 询盘惯例.
Unit Three On Price next.
Lesson 44:Popular Sayings
Supernatural Love and Unity
第十五课:在医院看病.
客户服务 售后服务.
A SMALL TRUTH TO MAKE LIFE 100%
Here Are Some Tips That May Bring You A Beautiful Life!
Here Are Some Tips That May Bring You A Beautiful Life!
Here Are Some Tips That May Bring You A Beautiful Life!
Mechanics Exercise Class Ⅰ
Guide to a successful PowerPoint design – simple is best
Chp.4 The Discount Factor
Good Karma 善業 原稿:牛Sir 配楽:懺悔經 捕頭恭製 按鍵換頁.
BORROWING SUBTRACTION WITHIN 20
The Wise Old Man 智慧老伯的一席話 原稿: 溫Sir 中譯 : 老柳
Lesson 19: A Story or a Poem?
关联词 Writing.
True friendship is like sound health;
Unit 5 First aid Warming up 《和你一样》 中国红十字会宣传曲 高二年级 缪娜.
成才之路 · 英语 人教版 · 必修1 路漫漫其修远兮 吾将上下而求索.
中考英语阅读理解 完成句子命题与备考 宝鸡市教育局教研室 任军利
Chapter 3 What Is Money?.
高考应试作文写作训练 5. 正反观点对比.
Good Karma 善因緣 This is a nice reading, but short. Enjoy! This is what The Dalai Lama has to say for All it takes is a few seconds to read and think.
The Role of Parents in the Moral Development of the Child
冀教版 九年级  Look into Science!.
计算机问题求解 – 论题1-5 - 数据与数据结构 2018年10月16日.
Remember the five simple rules to be happy 快樂的五個簡單常規
严肃游戏设计—— Lab-Adventure
Good Karma 善因緣 This is a nice reading, but short. Enjoy! This is what The Dalai Lama has to say for All it takes is a few seconds to read and think.
English article read(英文文章閱讀)
The Wise Old Man 智慧老伯的一席話 原稿: 溫Sir 中譯 : 老柳
自主练悟 ①(2017·桂林市联考)To them, life is a competition — they have to do _______ (good) than their peers to be happy. ②(2017·菏泽市模拟)People who forgive.
Hospitality English 酒店商务英语 讲师:罗云利 工商与公共管理学院.
獻上自己來榮耀神 Offering Ourselves To Glorify God
刘振 上海交通大学 计算机科学与工程系 电信群楼3-509
Ministers of the New Testament 新約的執事 2 Corinthians 3
Train Track and Children
陳情表之外     with 三仁 三樂 歐陽宜璋製於 /10/23.
Presentation transcript:

刘振 上海交通大学 计算机科学与工程系 电信群楼3-509 liuzhen@sjtu.edu.cn 区块链技术 刘振 上海交通大学 计算机科学与工程系 电信群楼3-509 liuzhen@sjtu.edu.cn

Bitcoin Consensus What data does each node store at its local storage? What does they do? fully validating nodes Complete blockchain The chain of the blockheads The transactions o the blockchain The list of UTXO (Unspent Transaction Output) To proceeds the transactions quickly Transaction Pool The node will select transactions from transaction pool and mine. lightweight nodes(Thin Clients or Simplified Payment Verification (SPV) Clients): The complete chain of the block heads They only store the pieces that they need to verify specific transactions that they care about Does not mine 完整的(共识)区块链 整条区块(头)链 区块链上的交易 还未被消费的“交易输出”列表 这个列表最好事放在内存里而非硬盘上,要用来快速判断待处理交易的有效性 交易池 收到的、待打包成块处理的交易 会从交易池收集数据、挖矿 轻量节点(轻客户端,简单付款验证,Simplified Payment Verification,SPV): 完整的区块(头)链 只存储所关心的、需要进行核验的部分交易 不挖矿

Bitcoin Consensus How does each node make sure that his local block chain is consistent with that of the major nodes in the system? Distributed Consensus Distributed Consensus Protocol There are n nodes that each have an input value. Some of these nodes are faulty or malicious. A distributed consensus protocol has the following two properties: It must terminate with all honest nodes in agreement on the value The value must have been generated by an honest node 协议能够终止,且此时所有诚实节点对数据达成一致 最终达成一致的数据必须是由诚实节点生成的

Bitcoin Consensus The target of Bitcoin consensus: Question: At any moment, all nodes in the Bitcoin Network agrees on a series of blocks, and the transactions in these blocks. Question: A new block candidate is found and broadcast, some nodes receive and accept this new block, while others did not. What is the state? If there are multiple such blocks, what is the state? It must happens, since it is a p2p network 如果不只一个处于这样状态的区块,它们处于什么状态? 一定会有这样的(多个)区块的,因为是在一个分布式网络里、网络是异步的

Bitcoin Consensus 1 …… 100 101 102 1 …… 100 101 102 1 …… 100 101 102 Tx21,Tx22,Tx23 1 …… 100 101 Tx1 Tx2 102 Tx3 Tx4 Tx31,Tx32,Tx33 1 …… 100 101 Tx1 Tx2 102 Tx3 Tx4 Tx51,Tx52,Tx53 1 …… 100 101 Tx5 Tx6 102 Tx7 Tx8

Bitcoin Consensus Bitcoin Consensus Who proposes the new block (the content of the blockchain)? The miners compete by computing hash, and broadcast the valid candidate to the Bitcoin Network Who decides whether the new block is accepted by whole bitcoin network? No discussion and negotiation, since the nodes does not trust each other Implicit consensus:each node makes its own decision on whether accept a new block Check the validity of the new block If accept, then uptae local blockchain by appending the new block to the current blockchain, and mine based on the updated blockchain If do not accept, still mine based on current blockchain Consensus result: If the majority nodes are `honest’, then all the nodes have the same local consensus blockchain. 谁决定被提出的块是否被整个网络接受?(对区块链的内容达成共识) 没有协商过程:各节点是互不信任的,不会互相协商 采用的是隐性共识:每个节点自己决定是否接受收到的块 检验块的有效性 如果接受,就把收到的该块作为最新块加到自己本地的区块链尾部来更新本地区块链,并在更新后的链的基础上再挖矿 如果不接受,则仍然以本地当前的区块链为基础继续挖矿 共识的结果: 系统中诚实节点占“大多数”的话,则所有节点本地的共识区块链是一致的。 诚实节点:遵循比特币协议的节点 大多数:并不是节点大多数、身份大多数等,而是“算力”大多数 所有节点达成共识:数据不与系统共识区块链一致的节点,其后继处理的交易、块等并不会被其他节点接受、纳入共识区块链。

Bitcoin Consensus Bitcoin Consensus Honest Nodes:honestly executes the Bitcoin protocols Majority: not the number majority, but the computation power majority All nodes achieve consensus: If a node’s data is inconsistent with the system consensus blockchain, the transactions and blocks it proposes will be rejected by other nodes, thus cannot be added into the system blockchain. 谁决定被提出的块是否被整个网络接受?(对区块链的内容达成共识) 没有协商过程:各节点是互不信任的,不会互相协商 采用的是隐性共识:每个节点自己决定是否接受收到的块 检验块的有效性 如果接受,就把收到的该块作为最新块加到自己本地的区块链尾部来更新本地区块链,并在更新后的链的基础上再挖矿 如果不接受,则仍然以本地当前的区块链为基础继续挖矿 共识的结果: 系统中诚实节点占“大多数”的话,则所有节点本地的共识区块链是一致的。 诚实节点:遵循比特币协议的节点 大多数:并不是节点大多数、身份大多数等,而是“算力”大多数 所有节点达成共识:数据不与系统共识区块链一致的节点,其后继处理的交易、块等并不会被其他节点接受、纳入共识区块链。

Bitcoin Consensus Why does a node behave honestly? 比特币共识机制 Once the proposed block is accepted by whole network, the miner will obtain the block reward and transaction fee If put invalid transaction in its block, the block may be accepted by the colluding miners, but the honest miners will not accept the block, and the reward and transaction fee can not be spent. How about all colluding miners continue mining on this ‘invalid’ block? 比特币共识机制 比特币网络节点为什么要诚实? 区块被整个网络接受后能获得区块奖励和交易费:经济刺激 如果把无效的交易放到自己提出的块中,这个块虽然可以被自己以及合谋的节点纳入各自的本地链中,但其他的诚实的节点是不会接收这个含有无效的交易的块的,诚实节点挖矿时不会在这样的“无效块”的基础上挖,其中的区块奖励自然也就花不出去了 只要合谋的节点后面继续在这个“无效块”的基础上挖就行了? 在一次竞争“提出块”的过程中,赢得竞争的概率等于算力占全系统算力的百分比。 所以,“大多数”是算力大多数,而不是节点个数 如果算力占到系统总算力的大多数,以当前情况来看,在计算资源的投入上已经很大了。如果去做恶意的、不诚实的行为,会导致比特币价格下跌甚至崩溃,那么这些投入的资源、以及已经取得的比特币的价值也就随之下跌了。会这样去做吗?

Mining ecosystem health Bitcoin Consensus The reason that Bitcoin consensus works is the financial incentive. Bitcoin’s Security Mining ecosystem health Bitcoin’s Price more computation power are invested to bitcoins, and more honest miners, more secure More secure, higher price 越多算力投比入到比特币系统中、越多诚实用户,比特币安全性越好 比特币价值越高,越吸引更多的算力投入到比特币挖矿、越多的用户诚实的执行比特币协议 比特币安全性越好,其价值越高 比特币共识机制的成功的根本原因:经济刺激 三者互相依赖 正向:正向促进 反向:任何一个环节出问题,会导致整个系统崩溃 比特币最初并不具备任何一个条件 比特币是幸运的,安全地度过了其脆弱的“婴儿期” 后来的AltCoin怎么办? Higher price, more computation power are invested to bitcoins, and more honest miners

Bitcoin Consensus PoW (Proof of Work) Implicit Consensus When the new block will cause a fork of the blockchain, before finding a valid new block, the miner receiver two blocks with the same height, Follow the first received Tx23 1 …… 100 101 Tx1 Tx2 102 Tx21 Tx22 101 Tx5 Tx6

Bitcoin Consensus PoW (Proof of Work) Implicit Consensus When the new block will cause a fork of the blockchain, before finding a valid new block, the miner receiver two blocks with the different heights, Tx23 1 …… 100 101 Tx1 Tx2 102 Tx21 Tx22 101 Tx5 Tx6 102 Tx7 Tx8

Bitcoin Consensus PoW (Proof of Work) Implicit Consensus When the new block will cause a fork of the blockchain, before finding a valid new block, the miner receiver two blocks with the different heights, Follow the longest chain Tx23 1 …… 100 101 Tx1 Tx2 102 Tx21 Tx22 101 Tx5 Tx6 102 Tx7 Tx8

Bitcoin Consensus PoW (Proof of Work) Implicit Consensus When the new block will cause a fork of the blockchain, before finding a valid new block, the miner receiver two blocks with the different heights, Follow the longest chain Tx23 1 …… 100 101 Tx1 Tx2 103 Tx21 Tx22 101 Tx5 Tx6 102 Tx7 Tx8

Bitcoin Consensus Why follow the longest chain? Each block implies corresponding computation power has been invested on the block. Longer chain implies more computation power (nodes) accepting the chain, and implies bigger probability these blocks are accepted by the consensus blockchain. And the blocks not on the longest chain will be “discarded” (not accepted by the nodes). Tx23 1 …… 100 101 Tx1 Tx2 103 Tx21 Tx22 挖到一个块是相当困难的,每一个块都证明了有相应的算力已经“投资”在该块上,“长链”意味着有更多的算力(节点)认可了该链,最终这些块被纳入最终链的可能性更大;而不与最长链在一起的,则会被“抛弃”(网络内节点不认可) 101 Tx5 Tx6 102 Tx7 Tx8

Bitcoin Consensus The blocks on chain may be discarded. So, when do the blocks achieve finality and become one part of the consensus blockchain? Transaction’s Confirm times:when the block containing the transaction is broadcast to the network, the confirmation time becomes 1. Then each time the block is directly or indirectly accepted by a new block, the confirmation times increments 1. Bitcoins thinks it is safe after 6 confirmations. 1 …… 100 101 Tx1 Tx2 102 Tx11 Tx12 103 Tx21 Tx22 104 Tx31 Tx32 105 Tx41 Tx42 已经上链的也可能因为会被丢弃,什么时候才真正的被纳入最终共识链、不会再被丢弃? Alice向Bob买书、并通过比特币支付,什么时候Bob才放心给Alice发货? 交易的多次确认:包含交易的块上链是第1次确认,在这个块后每增加一个新块,确认次数加1(每多一次确认,意味着更多的算力(节点)认可了该交易) 比特币认为6次确认后,交易就无法篡改了。(除非攻击者达到算力大多数,否则,攻击者使得相应的块被丢弃的概率可忽略不计,攻击者没有能力连追6个块制造出一条更长链) 101 Tx5 Tx6 102 Tx7 Tx8

Transactions Block Hash  validity Block chain PoW-based Consensus Signature  validity Block Hash  validity Block chain PoW-based Consensus

Bitcoin Limitations The total number of Bitcoins The community has basically agreed that it will not change. Transaction throughput This limitation comes from the hard coded limit on the size of blocks. 1M/Block, 256bytes/Transaction, 10min/Block 7 transactions per second Visa’s network handles about 2,000 transactions per second, and capable of handling 10,000 transactions per second during busy periods. Paypal, which is newer and smaller than Visa, can handle 100 transactions per second at peak times.

Bitcoin Limitations The cryptographic algorithms update The algorithms might be broken

Change the protocol How to introduce new features into the Bitcoin protocol? just release a new version of the software, and tell all nodes to upgrade? Hard Fork Soft Fork

Change the protocol Hard Fork: The change introduces new features that were previously considered invalid the new version of the software would recognize blocks as valid that the old software would reject when most nodes have upgraded, but some have not. The longest branch will contain blocks that are considered invalid by the old nodes. The old nodes will go off and work on a branch of the block chain that excludes blocks with the new feature. Until they upgrade their software, they’ll consider their (shorter) branch to be the longest valid branch. it makes the block chain split, and it makes the block chain split.

Change the protocol Soft Fork: The change adds features that make validation rules stricter. The old version would accept all of the blocks, whereas the new version would reject some. Provided that the majority of nodes switch over to the new software, these nodes will be able to enforce the new rules. There is a risk that old miners might mine invalid blocks because they include some transactions that are invalid under the new, stricter, rules. But the old nodes will at least figure out that some of their blocks are being rejected, even if they don’t understand the reason. This might prompt their operators to upgrade their software. there won’t be a hard fork; instead, there will be many small, temporary forks.

Change the protocol Hard Fork: Soft Fork: Unacceptable Soft Fork: Changing the block size from 1M to 2M is hard fork or soft fork?

Mining Pools The variance for a small miner is quite high.

Mining Pools The variance for a small miner is quite high. When small business people faced a lot of risk, they formed mutual insurance companies to lower that risk. A mining pool is exactly that — mutual insurance for Bitcoin miners. A group of miners will form a pool and all attempt to mine a block with a designated coinbase recipient. That recipient is called the pool manager.

Mining Pools No matter who actually finds the block, the pool manager will receive the rewards. The pool manager will take that revenue and distribute it to all the participants in the pool based on how much work each participant actually performed. The pool manager will also probably take some kind of cut for their service of managing the pool.

Mining Pools What does the pool manager do? What do the pool participants do?

Mining Pools How does a pool manager know how much work each member of the pool is actually performing? Mining Shares near‐valid blocks Miners can show these nearly valid blocks to prove that they are indeed working

Mining Pools How does exactly the pool manager calculates how much to pay each miner based on the shares they submit? Pay-per-share the pool manager pays a flat fee for every share above a certain difficulty for the block that the pool is working on. miners can send their shares to the pool manager right away and get paid without waiting for the pool to find a block. The pool manager essentially absorbs all of the risk. the pool manager will probably charge higher fees as compared with other models.

Mining Pools How does exactly the pool manager calculates how much to pay each miner based on the shares they submit? Proportional The amount of payment depends on whether or not the pool actually found a valid block. Every time a valid block is found the rewards from that block are distributed to the members proportional to how much work they actually did.

Mining Pools Modify the mining mechanism of Bitcoin, so that it can prevent the miners from forming a mining pool.

Summary Block Mining Bitcoin Network Bitcoin Consensus Protocol Change Merkle Tree Coinbase Transaction Mining Bitcoin Network Bitcoin Consensus Protocol Change Hard fork Software fork Mining Pool