lotus - 深入理解时空证明的 golang 实现部分(PoSt)
参考文章:https://www.chainnews.com/articles/836343087401.htm
lotus 的时空证明(PoSt)在两个地方会被调用该算法:Winning PoSt 和 Window PoSt。
Winning PoSt 是矿工在出块时对已经提交的扇区进行证明,证明扇区保存的数据依然存在。
Window PoSt 是矿工在对应的周期内对已经提交的扇区进行证明,证明扇区保存的数据依然存在。
// Balance of Miner Actor should be greater than or equal to
// the sum of PreCommitDeposits and LockedFunds.
// Excess balance as computed by st.GetAvailableBalance will be
// withdrawable or usable for pre-commit deposit or pledge lock-up.
type State struct {
// Information not related to sectors.
// TODO: this should be a cid of the miner Info struct so it's not re-written when other fields change.
Info MinerInfo
PreCommitDeposits abi.TokenAmount // Total funds locked as PreCommitDeposits
LockedFunds abi.TokenAmount // Total unvested funds locked as pledge collateral
VestingFunds cid.Cid // Array, AMT[ChainEpoch]TokenAmount
// Sectors that have been pre-committed but not yet proven.
PreCommittedSectors cid.Cid // Map, HAMT[SectorNumber]SectorPreCommitOnChainInfo
// Information for all proven and not-yet-expired sectors.
Sectors cid.Cid // Array, AMT[SectorNumber]SectorOnChainInfo (sparse)
// The first epoch in this miner's current proving period. This is the first epoch in which a PoSt for a
// partition at the miner's first deadline may arrive. Alternatively, it is after the last epoch at which
// a PoSt for the previous window is valid.
// Always greater than zero, his may be greater than the current epoch for genesis miners in the first
// WPoStProvingPeriod epochs of the chain; the epochs before the first proving period starts are exempt from Window
// PoSt requirements.
// Updated at the end of every period by a power actor cron event.
ProvingPeriodStart abi.ChainEpoch
// Sector numbers prove-committed since period start, to be added to Deadlines at next proving period boundary.
NewSectors *abi.BitField
// Sector numbers indexed by expiry epoch (which are on proving period boundaries).
// Invariant: Keys(Sectors) == union(SectorExpirations.Values())
SectorExpirations cid.Cid // Array, AMT[ChainEpoch]Bitfield
// The sector numbers due for PoSt at each deadline in the current proving period, frozen at period start.
// New sectors are added and expired ones removed at proving period boundary.
// Faults are not subtracted from this in state, but on the fly.
Deadlines cid.Cid
// All currently known faulty sectors, mutated eagerly.
// These sectors are exempt from inclusion in PoSt.
Faults *abi.BitField
// Faulty sector numbers indexed by the start epoch of the proving period in which detected.
// Used to track fault durations for eventual sector termination.
// At most 14 entries, b/c sectors faulty longer expire.
// Invariant: Faults == union(FaultEpochs.Values())
FaultEpochs cid