区块的Weight

Weight是区块计费的新指标

Weight的出现来源于隔离见证,以前区块链的计费源于Size,即区块大小。

公式

w e i g h t = ( t x   s i z e   w i t h   w i t n e s s   d a t a   s t r i p p e d ) 3 + ( t x   s i z e ) <= 4000 K i l o b y t e

对于非隔离见证交易区块有1M的约束,则:
1 M 3 + 1 M = 4 M

也符合上述不等式。

例子

https://btc.com/000000000000000000109439938c398e8f858c1287c60a872ea05a2ebd002ebd
已知:

Size 324,406 Bytes
Stripped Size 324,370 Bytes
Weight 1,297,516

3 × ( S t r i p p e d S i z e ) + S i z e = W e i g h t

为什么这样设计Weight

Rationale of using a single composite constraint, instead of two separate limits such as 1MB base data and 3MB witness data:

Using two separate limits would make mining and fee estimation nearly impossible. Miners would need to solve a complex non-linear optimization problem to find the set of transactions that maximize fees given both constraints, and wallets would not be able to know what to pay as it depends on which of the two conditions is most constrained by the time miners try to produce blocks with their transactions in. Another problem with such an approach is freeloading. Once a set of transactions hit the base data 1MB constraint, up to 3MB extra data could be added to the witness by just minimally increasing the fee. The marginal cost for extra witness space effectively becomes zero in that case.

更多

猜你喜欢

转载自blog.csdn.net/jason_cuijiahui/article/details/80043146
今日推荐