挖矿就是不断尝试区块块头中的nonce和extra nonce的值,使得:
$$
H(block header)≤target
$$
显然目标阈值target越小,则挖矿的难度就越大。所以调整挖矿难度就是在调整target,以调整目标空间在整个输出空间中所占的比例。
Mining is the value of nónce and extra néce in the block, which makes it more difficult to dig as the target threshold of target is apparently smaller. So
比特币中使用的哈希函数是SHA-256,产生的哈希值是256位的,所以整个输出空间是2256 ,调整目标空间所占的比例,在这个问题里直观的来看就是最后得到的哈希值前面有多少位0(这只是通俗直观来看的,也许第一个非0位是要小于4也说不定),这个0越多显然值就越小,也就是挖矿难度越大了。
The Hashi function used in Bitcoin is SHA-256, resulting in a Hashi value of 256, so the whole output space is 2256, adjusting the proportion of the target space, and in this question the intuitive view is how many zeros are in front of the last Hashi value (this is merely a general view, perhaps the first one is less than 4 or less), and the smaller the value, the harder it is to dig.
挖矿难度和目标阈值的大小成反比:
$$
difficulty=\frac{difficulty_1_target}{target}
$$
上式中常量是指挖矿难度difficulty定义为1时所对应的目标阈值target的值。挖矿难度最小就是1,所以这个常量也就是target允许的最大值。
Inversely proportional to the size of the mine difficulty and target threshold:
$$$
dificultory=\frac{difficulty_1_target}{target}$br>$
refers to the value of the target threshold value of difficulty, defined as the target value of 1 at the time of the difficulty of mining. The minimum difficulty of mining is 1, so this constant is the maximum value allowed by target.
系统中的总算力越来越强,如果挖矿难度保持不变,那么平均出块时间会越来越短,这会造成一些问题。
The overall strength of the system is increasing, and if the difficulty of mining remains constant, the average amount of time available will become shorter, which will cause some problems.
假设平均出块时间减小到了1秒钟,也就是每隔1秒左右就有一个新的区块携带一些列交易被发布到比特币网络上,而在比特币网络上这个区块传播给大多数结点可能就要几十秒。如果有两个结点几乎同时发布了区块,那么就会出现分叉:
Assuming that the average block time is reduced to one second, that is, every one second or so, a new block carrying a number of column transactions is posted on the Bitcoin network, which could spread to most nodes for dozens of seconds. If two nodes are published almost simultaneously, then a fork will appear:
这是一个二分叉的情况,如果出块时间很短,就会导致这种分叉成为常态。而且不仅仅是二分叉,可能会出现很多分叉。
It's a split fork, and a short break would make this fork normal. And not only for a split fork, there could be a lot fork for a split fork .
分叉过多对比特币系统达成共识没有好处,并且会危害比特币系统的安全性。
There is no benefit in reaching a consensus on
eg:分叉攻击:正常情况下,因为大部分结点是诚实的,有恶意的结点想要在6个确认后拿这段时间集中算力算出的新链去覆盖掉最长合法链是很难的,因为诚实结点也都在集中算力扩展最长合法链。
如果出块时间很短,就会导致分叉过多(因为相比于出块时间,可以认为网络上传输的时间变长了),这样诚实结点的算力就被分散了,这时恶意结点要进行51% attack很可能就不需要50%以上的算力了,可能百分之十几就足够了,这样大大降低了比特币系统的安全性。
eg:
If the node is short, it will lead to an excessive number of splits (because it can be considered that the time of transmission on the network is longer), so that the calculation of an honest node is dispersed, and 51% of the node is likely to need more than 50% of the weight, perhaps ten percent is sufficient to significantly reduce the security of the bitcoin system.
以太坊的出块时间就降低到了15秒,大幅降低了出块时间,所以以太坊就要设计一个新的共识协议。在这个协议中,分叉产生的不能简单丢弃掉,而是也要给予一些奖励()。
In this agreement, the fork will not be simply discarded, but will be rewarded.
总之,在不同的区块链账本系统中,不论出块时间设计成多长,都要设法让其保持稳定,而不能允许它随着系统中总算力的提高而无限减小下去。
In short, in the different block chain of accounts systems, regardless of the length of time a block is designed, efforts are made to keep it stable and not to allow it to diminish indefinitely as the system's total capacity increases.
比特币协议中规定,每隔2016个区块(大约每2个星期)要重新调整一下目标阈值target,具体的迭代更新公式是:
$$
target=target*\frac{actual\ time}{expected\ time}
$$
这里就是预期的两次调整的间隔时间,即2016乘以10分钟;而是系统中产生最近的2016个区块实际花费的时间。
The Bitcoin agreement provides for a readjustment of the target threshold Target every 2016 blocks (approximately every two weeks), with the specific iterative updating formula being:
$$$$
target=target*\frac{actual\time}Expectedbr$br>, which is the expected interval between the two adjustments, that is, 2016 times 10 minutes; and the actual time it takes to produce the most recent 2016 blocks in the system.
为了避免系统中出现某些意外情况,导致系统出现非常大的波动,每次对目标阈值target的调整最大不能超过4倍,最小不能小于$\frac{1}{4}$ ,也即上式中的$\frac{actual\ time}{expected\ time}$ 即便超过4了也按4使用,即便小于$\frac{1}{4}$ 也只按$\frac{1}{4}$ 使用。
In order to avoid certain contingencies in the system, which result in very large fluctuations in the system, the target threshold Target may not be adjusted more than four times each time, at least not less than $\frac{$4}, i.e. $\frac{actual\time} in the above-set $\fracked\time}$4 is used even if more than $4 is used, even if less than $\frac{4} is used only at $\frac{4}.
target是写在比特币系统的代码里的,代码也都是开源的,如果有结点到了该调整的时候不调整target怎么办?
It's written in the bitcoin code. It's all open-source. What if there's nodes that don't adjust it when it's time to adjust?
这也是一个大部分结点诚实的问题,如果不调整target,那么发布的区块块头里的4字节nBits域(32字节的target压缩编码后的版本)就不是正确的,诚实的结点不会接收这样的区块
It's also a question of most nodes being honest, and if you don't adjust the target, then the 4 bytes nbits domain (a 32-bit version of the target compressed code) is not correct, and the honest nodes will not receive the block.
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
发表评论