The StoragePower actor has a few roles:
OnEpochTickEnd
)Actor Type:
Exported Methods:
type State struct {
TotalRawBytePower abi.StoragePower
TotalBytesCommitted abi.StoragePower
TotalQualityAdjPower abi.StoragePower
TotalQABytesCommitted abi.StoragePower
TotalPledgeCollateral abi.TokenAmount
ThisEpochRawBytePower abi.StoragePower
ThisEpochQualityAdjPower abi.StoragePower
ThisEpochPledgeCollateral abi.TokenAmount
ThisEpochQAPowerSmoothed smoothing.FilterEstimate
MinerCount int64
MinerAboveMinPowerCount int64
CronEventQueue cid.Cid
FirstCronEpoch abi.ChainEpoch
Claims cid.Cid
ProofValidationBatch *cid.Cid
}
TotalRawBytePower
: The sum of all RawBytePower from all Miners meeting minimum power (ConsensusMinerMinPower)
TotalRawBytePower >= 0
TotalBytesCommitted
: The sum of all RawBytePower from all Miners, including those that do not meet minimum power (ConsensusMinerMinPower)
TotalBytesCommitted >= TotalRawBytePower
TotalQualityAdjPower
: The sum of all QualityAdjPower from all Miners meeting minimum power (ConsensusMinerMinPower)
TotalQualityAdjPower >= TotalRawBytePower
TotalQABytesCommitted
: The sum of all QualityAdjPower from all Miners, including those that do not meet minimum power (ConsensusMinerMinPower)
TotalQABytesCommitted >= TotalQualityAdjPower
TotalPledgeCollateral
: Current total amount of pledge collateral held across all Miners
TotalPledgeCollateral >= 0
ThisEpochRawBytePower
: Total RawBytePower of consensus-eligible Miners. Set each cron tick and remains constant until the next cron tick.
ThisEpochRawBytePower >= 0
ThisEpochQualityAdjPower
: Total QualityAdjPower of consensus-eligible Miners. Set each cron tick and remains constant until the next cron tick.
ThisEpochQualityAdjPower >= 0
ThisEpochPledgeCollateral
: Total pledge collateral held across all Miners. Set each cron tick and remains constant until the next cron tick.
ThisEpochPledgeCollateral >= 0
ThisEpochQAPowerSmoothed
: TODO
MinerCount
: The number of Miner actors created via CreateMiner
, minus the number deleted via OnConsensusFault
MinerCount >= MinerAboveMinPowerCount
MinerAboveMinPowerCount
: The number of Miner Claims with a QualityAdjPower above ConsensusMinerMinPower.
MinerAboveMinPowerCount >= 0
CronEventQueue
: A collection of CronEvents that are sent to specific Miners at specific epochs.
map[ChainEpoch]AMT[CronEvent]
CronEvent
belowFirstCronEpoch
: The epoch at which cron tick processing will start.
FirstCronEpoch >= 0
Claims
: A collection of Claims denoting the StoragePower each Miner has accrued.
map[Address]Claim
Claim
belowProofValidationBatch
: A collection of PoReps for each Miner that will be processed on the next invocation of OnEpochTickEnd
.
map[Address]AMT[SealVerifyInfo]
rt.Syscalls().BatchVerifySeals
SealVerifyInfo
below
type CronEvent struct {
MinerAddr addr.Address
CallbackPayload []byte
}
MinerAddr
: The address of the Miner whose OnDeferredCronEvent
method will be invoked.
CallbackPayload
: The parameters with which OnDeferredCronEvent
will be invoked.
A Claim tracks power accrued by a Miner across all active Sectors.
type Claim struct {
SealProofType abi.RegisteredSealProof
RawBytePower abi.StoragePower
QualityAdjPower abi.StoragePower
}
SealProofType
: The type of proof being used by the Miner
RawBytePower
: Sum of RawBytePower for a Miner's Sectors
RawBytePower >= 0
QualityAdjPower
: Sum of QualityAdjPower for a Miner's Sectors
QualityAdjPower >= 0
type SealVerifyInfo struct {
SealProof RegisteredSealProof
SectorID
DealIDs []DealID
Randomness SealRandomness
InteractiveRandomness
InteractiveSealRandomness
Proof []byte
SealedCID cid.Cid
UnsealedCID cid.Cid
}
SealProof
: The proof type used by a Miner for sealing Sectors.
SectorID
: The ID of the sector being proven. Combines the Miner's actor ID and the SectorNumber.
DealIDs
: A slice of DealIDs stored in the sector given by SectorID
Randomness
: Randomness included before PreCommit. Used to validate proof of replication.
InteractiveRandomness
: Randomness included after PreCommit. Used to validate proof of replication.
Proof
: A Proof of Replication that validates the sealing process has been performed correctly.
SealedCID
: The root hash of the Sealed Sector
UnsealedCID
: The root hash of the Unsealed Sector
func (a Actor) Constructor(rt Runtime, _ *adt.EmptyValue) *adt.EmptyValue
Initializes StoragePower actor state.
func (a Actor) CreateMiner(rt Runtime, params *CreateMinerParams) *CreateMinerReturn
Creates a new Miner actor via the Init actor.
st.Claims
, and st.MinerCount
is incremented.
type CreateMinerParams struct {
Owner addr.Address
Worker addr.Address
SealProofType abi.RegisteredSealProof
Peer abi.PeerID
Multiaddrs []abi.Multiaddrs
}
Owner
: The new Miner's Owner address
Worker
: The new Miner's Worker address
SealProofType
: The proof type used for the Miner's sector commit proofs
Peer
: The Libp2p identity used to connect with this Miner
Multiaddrs
: Slice of Libp2p multi-addresses used to establish connections with this miner
type CreateMinerReturn struct {
IDAddress addr.Address
RobustAddress addr.Address
}
IDAddress
: The new Miner's ID address
RobustAddress
: The new Miner's ACTOR address
func (a Actor) UpdateClaimedPower(rt Runtime, params *UpdateClaimedPowerParams) *adt.EmptyValue
Invoked by a Miner whenever their claimed power changes, which may result from any of the following exported methods:
This method:
st.TotalBytesCommitted
and st.TotalQABytesCommitted
are adjusted directlyst.MinerAboveMinPowerCount
is increased by 1 if the change to Miner power puts them above ConsensusMinMinerPower
st.MinerAboveMinPowerCount
is decreased by 1 if the change to Miner power puts them below ConsensusMinMinerPower
st.RawBytePower
and st.TotalQualityAdjPower
are adjusted depending on the Miner's power in relation to ConsensusMinMinerPower
UpdateClaimedPowerParams contains the amount a Miner's power has changed. Both amounts may be positive or negative, signalling an increase or decrease in Miner's power, respectively.
type UpdateClaimedPowerParams struct {
RawByteDelta abi.StoragePower
QualityAdjustedDelta abi.StoragePower
}
RawByteDelta
: The change to the Miner's RawBytePower
QualityAdjustedDelta
: The change to the Miner's QualityAdjPower
st.Claims
func (a Actor) EnrollCronEvent(rt Runtime, params *EnrollCronEventParams) *adt.EmptyValue
This method is invoked by a Miner from any of the following exported methods:
EnrollCronEvent
allows a Miner to schedule a CronEvent with the StoragePower actor, which will be processed at some future epoch as part of StoragePower.OnEpochTickEnd.
At the specified epoch (EventEpoch
), OnEpochTickEnd invokes Miner.OnDeferredCronEvent, supplying a Payload
that allows the Miner to determine how to handle the CronEvent. There are a few types of Payload
(defined in miner_actor.go
):
Miner.handleProvingDeadline
.
If an enrolled CronEvent has an EventEpoch
before st.FirstCronEpoch
, st.FirstCronEpoch
is set to EventEpoch
.
type EnrollCronEventParams struct {
EventEpoch abi.ChainEpoch
Payload []byte
}
EventEpoch
: The epoch at which the CronEvent will be processed.
EventEpoch >= 0
Payload
: The payload that will be supplied to Miner.OnDeferredCronEvent.
params.EventEpoch < 0
func (a Actor) OnEpochTickEnd(rt Runtime, _ *adt.EmptyValue) *adt.EmptyValue
OnEpochTickEnd
is a special method invoked by the Cron actor at the end of each tipset.
OnEpochTickEnd
has 3 responsibilities:
st.ProofValidationBatch
contains proofs-of-replication (PoRep) submitted by Miners, these are verified in bulk via rt.Syscalls().BatchVerifySeals
. For each Miner with successfully-proven Sectors, Miner.ConfirmSectorProofsValid is invoked and provided the successfully-proven SectorNumbers.
st.ProofValidationBatch
, st.ProofValidationBatch
is set to nil
st.CronEventQueue
for each epoch from st.FirstCronEpoch
to rt.CurrEpoch()
. Each CronEvent is processed by invoking the specified Miner's OnDeferredCronEvent method.
st.FirstCronEpoch
is set to rt.CurrEpoch() + 1
.st.ThisEpochRawBytePower
, is passed to Reward.UpdateNetworkKPI.func (a Actor) UpdatePledgeTotal(rt Runtime, pledgeDelta *abi.TokenAmount) *adt.EmptyValue
Each time a Miner's active Sectors change, their pledge total is updated and this method is invoked.
pledgeDelta
may be a positive or negative value, signifying a gain or loss respectively.
st.Claims
st.TotalPledgeCollateral
to be negativeThis method was deprecated. See this PR.
func (a Actor) SubmitPoRepForBulkVerify(rt Runtime, sealInfo *abi.SealVerifyInfo) *adt.EmptyValue
This method is invoked by Miner.ProveCommitSector. When ProveCommitting a Sector, a Miner submits a proof-of-replication (PoRep) to the StoragePower actor via SubmitPoRepForBulkVerify
.
SubmitPoRepForBulkVerify
inserts the Miner's proof in st.ProofValidationBatch
. At the end of the same epoch, StoragePower.OnEpochTickEnd will batch-verify all submitted PoReps.
st.Claims
MaxMinerProveCommitsPerEpoch
(8000) alreadyfunc (a Actor) CurrentTotalPower(rt Runtime, _ *adt.EmptyValue) *CurrentTotalPowerReturn
This method is a simple getter which returns the total power and pledge collateral recorded by the StoragePower actor during the last cron tick. This method is a simple read of these state fields:
st.ThisEpochRawBytePower
: Sum of RawBytePower for consensus-eligible Minersst.ThisEpochQualityAdjPower
: Sum of QualityAdjPower for consensus-eligible Minersst.ThisEpochPledgeCollateral
: Sum of pledge collateral across all Minersst.ThisEpochQAPowerSmoothed
: TODO