垃圾收集
2 个回答
- 投票数
-
- 2019-01-30
每个Tezos节点都维护分类帐当前状态的表示.该状态包括诸如每个合同的存储,不同地址的余额等之类的内容.区块链的目标是允许分散的参与者网络就该状态达成共识.
由于链可以进行重组,因此有时有时节点需要时退几步并计算出不同的状态.为了有效地做到这一点,他们需要能够快速记住几个街区之前的状态.
在当前实现中,节点会记住它经历的每个状态.这是除了记住所有的块!
垃圾回收意味着丢弃节点不再需要的过去状态,并占用宝贵的磁盘空间.通过设计,该协议不允许进行超过5个周期的重组,因此可以安全地丢弃所有早于该周期的状态.但是,由于不太可能进行大规模重组,因此可以更积极地丢弃州.
在实践中,一种好的方法是将一些最近的状态存储为一口井,并存储一些稀疏的旧状态.如果进行长时间的重组,则该节点将在重组点之前选择其知道的任何状态,并重建到该点为止的状态.
仅保留过去5个周期时,所占用的磁盘空间至少小10倍.
Each Tezos node maintains a representation of the current state of the ledger. That state includes things like the storage of each contract, the balance of different addresses, etc. The goal of the blockchain is to allow a decentralized network of participants to reach consensus on what that state is.
Since the chain can have reorganizations, it's sometimes necessary for the nodes to go back in time by a few blocks and compute a different state. In order to do so efficiently, they need to be able to quickly remember what the state was as off a few blocks ago.
In the current implementation, the node remembers every single state it ever went through. This is in addition to remember all the blocks!
Garbage collection means discarding past states which are no longer needed by the node and take up valuable disk space. By design, the protocol does not allow reorganizations longer than 5 cycles, therefore it is safe to discard all states older than that. However, states can be discarded more aggressively since large reorganizations are very unlikely.
In practice, a good approach is to store a few recent states as a well and a few, sparse, old ones. If a long reorganization happens, the node will pick whichever state it knows about prior to the reorganization point and reconstruct the state up to that point.
When only the past 5 cycles are kept, the disk space occupied is at least 10 times smaller.
-
我听说有Tezos区块链垃圾收集计划.这到底是什么意思?这些"垃圾"需要收集什么,为什么它们首先存在?垃圾收集是仅用于非完整节点还是所有节点?我们将从垃圾回收中节省多少空间?