Storage Deal Flow
Add Storage Deal and Power
StorageClient
andStorageProvider
callStorageMarketActor.AddBalance
to deposit funds into Storage Market.StorageClient
andStorageProvider
can callWithdrawBalance
before any deal is made.
StorageClient
andStorageProvider
negotiate a deal off chain.StorageClient
sends aStorageDealProposal
to aStorageProvider
.StorageProvider
verifies theStorageDeal
by checking address and signature ofStorageClient
, checking the proposal'sStartEpoch
is after the current Epoch, checkingStorageClient
did not call withdraw in the last X Epoch (WithdrawBalance
should take at least X Epoch), checking bothStorageProvider
andStorageClient
have sufficient available balances inStorageMarketActor
.
StorageProvider
signs theStorageDealProposal
by constructing an on-chain message.StorageProvider
callsPublishStorageDeals
inStorageMarketActor
to publish this on-chain message which will generate aDealID
for eachStorageDeal
and store a mapping fromDealID
toStorageDeal
. However, the deals are not active at this point.As a backup,
StorageClient
may callPublishStorageDeals
with theStorageDeal
, to activate the deal if they can obtain the signed on-chain message fromStorageProvider
.It is possible for either
StorageProvider
orStorageClient
to try to enter into two deals simultaneously with funds available only for one. Only the first deal to commit to the chain will clear, the second will fail with errorerrorcode.InsufficientFunds
.
StorageProvider
callsHandleStorageDeal
inStorageMiningSubsystem
which will then add theStorageDeal
into aSector
.
Sealing sectors
Once the miner finishes packing a
Sector
, it generates a SectorPreCommitInfo and calls PreCommitSector with a PreCommitDeposit. It must call ProveCommitSector with SectorProveCommitInfo within some bound to recover the deposit. An expired PreCommit message will result in PreCommitDeposit being burned. There are two types of sectors, Regular Sector and Committed Capacity Sector but all sectors have an explicit expiration epoch declared during PreCommit. For a Regular Sector with storage deals in it, all deals must expire before sector expiration. Miner gains power for this particular sector upon successful ProveCommit.
Receive Challenge
Miners enter the
Challenged
status when receiving a SurprisePoSt challenge from the chain. Miners will then have X Epoch as the ProvingPeriod to submit a successful PoSt before the chain checks for SurprisePoSt expiry. Miners can only get out the challenge withSubmitSurprisePoStResponse
.Miners are allowed to DeclareTemporaryFault when they are in the
Challenged
state but this will not change the list of sectors challenged asChallenged
state specifies a list of sectors to be challenged which is a snapshot of all Active sectors at the time of challenge. Miners are also allowed to call ProveCommit which will add to their ClaimedPower but their Nominal and Consensus Power are still zero whe they are in either Challenged or DetectedFault state.
Declare and Recover Faults
Declared faults are penalized to a smaller degree than DetectedFault. Miners declare failing sectors by invoking
DeclareTemporaryFaults
with a specified fault duration and associatedTemporaryFaultFee
. Miner will lose power associated with the sector when the TemporaryFault period begins.The loss of power associated with TemporaryFault will be restored when the TemporaryFault period has ended and the miner is now expected to prove over that sector. Failure to do so will result in unsuccessful ElectionPoSt or unsuccessful SurprisePoSt that leads to detected faults.
Detect Faults
CronActor
triggersStorageMinerActor._rtCheckSurprisePoStExpiry
throughStoragePowerActor
and checks if SurprisePoSt challenge has expired for a particular miner.If no PoSt is submitted by the end of the
ProvingPeriod
, miner entersDetectedFault
state, somePledgeCollateral
is slashed, and all power is lost.Miners will now have to wait for the next SurprisePoSt challenge.
If the faults persist for
MAX_CONSECUTIVE_FAULTS
then sectors are terminated and provider deal collateral is slashed.
Sector Expiration
Sector expiration is done via a scheduled Cron event
_rtCheckSectorExpiry
. Sector expires when its Expiration epoch is reached and sector expiration epoch must be greater than the expiration epoch of all its deals.
Deal Payment and slashing
Deal payment and slashing are evaluated lazily through
_updatePendingDealState
at WithdrawBalance and PublishStorageDeals events. The method is also called atOnEpochTickEnd
on StorageMarketActor as a clean up mechanism.
Last updated