对比特比共识机制的一些看法(my opinions on the consensus mechanism of Bitcoin )

Posted by 土猪 on March 5, 2019

一直在学习区块链的共识机制,比特币是一个很好的切入点。从创世区块开始,随着一个个节点的加入,每个节点软件自带创世区块的内容,它们或者通过专门的节点DNS文件,或者自动去连接周围的同伴,以加载被遗漏的区块。由某个节点发出的交易,广播出去被其它节点接受,验证,工作量证明的计算,谁先算出一个值,跟这个区块在一起哈希后满足小于某个数值,谁就有资格获取“铸币”交易的奖励,把这个区块广播出去,别的节点就不会继续计算下去。每个区块头都包含了这个区块所有交易的默克尔树的根哈希,确保整个区块的完整性可以被别的节点验证。

Bitcoin is a good entry point for learning the consensus mechanism of the blockchain. Starting from the genesis block, with the addition of each node, the node softwares are trying to connecting to peer nodes either through a dedicated node DNS file, or randomly connect to the surrounding peers to load the missing blocks. A transaction will be issued by a certain node, broadcasted and accepted by other nodes. Then the block will be verified and put into local pool by the nodes. After accumulating enough blocks, the nodes will compete to do work proof by picking up each random value, together with this block, if the hash satisfies less than a certain value, e.g. 00000EF. The first node who gets this value is eligible to obtain a reward for the producing of a block. It will broadcast this block, while other nodes will stop calculating. Each block header contains the root hash of the Merkel tree for all transactions in this block, ensuring that the integrity of the entire block can be verified by other nodes.

区块之间也是环环相扣,每个区块头都包含前一个区块头哈希值,越深的区块,越无法更改它的内容,因为你改了一个东西,整个区块的哈希就变了,那么下一个指向它的区块头的值也要变,这个一变,它的哈希也变,这样,你得把想改变的那个区块开始,接下来整个一个长链条全部变掉。你的改变,需要全网的节点去验证,这个是不可能通过的。除非你有足够算力,就是计算速度足够快,搞一个分叉出来,在其它节点还没反应过来的时候,连续搞6个区块来确认这个改变,那么别人看到你这个链长,就会认可你这个分叉。

Blocks are also interlocked. Each block header has a the hash value of the previous block. The deeper the block, the more it cannot be changed, because if you changed one block. The hash of the block changes, so the value of the next block header pointing to it also changes. Thus all subsequent blocks should be changed. In addition, your change requires the nodes of the entire network to verify, this is impossible. Unless you have enough calculation power, the calculation speed is fast enough, make a fork out, and when the other nodes have not reacted. You continue to make 6 blocks to confirm the change, then others see your chain is long enough, then they will make a consensus on your fork.

比特币的安全性和方便程度也是相当高,每个交易的输出的UTXO包含了锁定脚本,你必须用输入的私钥哈希,和公钥的解锁脚本去解开才可以使用。收钱账户不一定非要是一个公钥哈希,还可以是一个脚本哈希,这样,接受者可以按自己要求处理收到的钱,比如,发送到几个不同的地址。

Bitcoin is also very convenient and safe to use. The UTXO of each transaction’s output contains a lock script. You must use the input private key hash and the public key unlock script to unlock it. The destination does not have to be a public key hash, it can also be a script hash, so that the recipient can process the received money at his own will, for example, to dispatch to several different addresses.

比特币的区块链是一种非常纯粹的去中心化网络,但是我个人觉得它还是存在着一些需要改进的缺陷。比如,比特币没有account balance的概念,需要钱包软件去计算出UTXO,因为一个UTXO的输入连着另一个UTXO的输出,随着区块链越来越长,我觉得这个计算时间可能会越来越长,用户体验不会好。虽然节点也可以通过保存UTXO池来解决这个问题,但是这取决于钱包软件怎么做。

Bitcoin’s blockchain is a very pure decentralized network, but I personally feel that there are still some flaws that need to be improved. For example, Bitcoin does not have the concept of account balance. It requires wallet software to calculate UTXO. Because one UTXO input is connected to another UTXO output. As the blockchain grows longer, I think this calculation time may increase. Thus the users will experience longer lag. Although the node can also solve this problem by saving the UTXO pool, it depends on how the wallet software implement.

比特币的POW去中心化太彻底了,它模仿了动物世界的弱肉强食,谁算力大,谁说话算数,虽说如果谁有那么大算力,破坏比特币系统,从博弈角度说,不如去维护它。但是这个世界,类似希特勒的疯子也是常见。随着量子计算机的发明,如果谁把这个拿来蓄意搞破坏,也不是不可能的。他可以搞一个长长的分叉,让这个分叉变成主链。

目前挖矿那么难,还是因为比特币价格高企,人们有这个驱动力去前赴后继地验证和打包区块,如果有朝一日,人们失去了这个动力,这个松散的网络就会导致整体算力下降,因为工作量证明解决区块冲突的方法是谁长听谁的,导致破坏更加容易。最让人受不了的,就是平均10分钟的区块间隔,实在太让人受不了了,但是缩减间隔,就会导致同时出现区块被挖的可能性更大。要不,为什么以太坊总想着要过度到POS去呢?

Bitcoin’s POW decentralization is too thorough. It mimics the animal world’s strengths dominate,. Although it is said that people who possess enough power would like to enhance bitcoin rather than destroy it for the sake of their own interest. There are still many Hitlers in the world. With the invention of quantum computers, it is not impossible for anyone to deliberately destroy bitcoin network. He can make a long fork and let this fork become the main chain.

At present, mining is so difficult, or because of the high price of bitcoin, people have the driving force to go forward and verify and produce the block. If one day, people lose this motivation, this loose network will lead to the decline of overall computing power because of work. The proof of the way to resolve block conflicts is whoever listens to them and makes the damage easier. The most unbearable thing is that the average interval of 10 minutes is long, but reducing the interval will lead to the possibility that the block will be forked. Otherwise, why Ethereum always thinks about switching to POS?

我觉得POW,POS都不是理想的共识机制,我还是觉得EOS的DPOS是非常符合民主社会去中心化的机制。由股东来主导,在我看来,是不合适的,这会导致有钱人说了算,跟POW的算力说了算本质相同。矿工实际也是区块链的管理者,他们应该被选举出来,类似一个公司或者国家,管理层由股东或者人民选举出来,代表了股东或者人民的利益,如果他们做得不好,随时可以被选下来。这样一个网络,会由一帮有责任感和利益的节点来主导,也不需要竞争去计算些无聊的东西而花费电力,而是把钱花在刀刃上,提高机器性能,提高用户体验的舒适度,理论上也不会有恶意分叉产生,我记得是0.5秒一个区块,每个矿工节点做6次,然后轮到下一个矿工。DPOS的危险在于几个矿工联合起来干坏事。

I think POW and POS are not ideal consensus mechanisms. I still think that EOS’ DPOS is very similar to the decentralization mechanism of democratic society. Being dominated by shareholders is, in my opinion, inappropriate, which will lead the rich to have the final say, and POW is essentially the same. The miners are actually the managers of the blockchain. They should be elected. Similar to a company or country, the managers are elected by the shareholders. If they are not doing well, they can be voted out at any time. Such a network will be dominated by a group of responsible and profitable nodes, and there is no need to compete to calculate some boring things and lavish electricity. Block producers can spend money on the right things, e.g. improving machine performance and improving user experience. In theory, there will be no malicious forks. I remember that it was a block of 0.5 seconds, each block producer repeats 6 times, and then it turns over to the next block producer. The danger of DPOS is that several miners are united to do bad things.

总之,没有理想的共识机制,区块链发展才刚开始,一切都在摸索之中。

In short, there is no ideal consensus mechanism, blockchain development has just begun, and everything is in the process of exploration.

更多区块链文章:


支付宝打赏

您的打赏是对我最大的鼓励!