Documentation ¶
Index ¶
- Constants
- Variables
- func CollateralPenaltyForDealActivationMissed(providerCollateral abi.TokenAmount) abi.TokenAmount
- func DealClientCollateralBounds(_ abi.PaddedPieceSize, _ abi.ChainEpoch) (min abi.TokenAmount, max abi.TokenAmount)
- func DealDurationBounds(_ abi.PaddedPieceSize) (min abi.ChainEpoch, max abi.ChainEpoch)
- func DealPricePerEpochBounds(_ abi.PaddedPieceSize, _ abi.ChainEpoch) (min abi.TokenAmount, max abi.TokenAmount)
- func DealProviderCollateralBounds(pieceSize abi.PaddedPieceSize, verified bool, ...) (min, max abi.TokenAmount)
- func DealWeight(proposal *DealProposal) abi.DealWeight
- func GenRandNextEpoch(startEpoch abi.ChainEpoch, dealID abi.DealID) abi.ChainEpoch
- func StoreEmptySetMultimap(s adt.Store, bitwidth int) (cid.Cid, error)
- func ValidateDealsForActivation(st *State, store adt.Store, dealIDs []abi.DealID, minerAddr addr.Address, ...) (big.Int, big.Int, uint64, error)
- type ActivateDealsParams
- type Actor
- func (a Actor) ActivateDeals(rt Runtime, params *ActivateDealsParams) *abi.EmptyValue
- func (a Actor) AddBalance(rt Runtime, providerOrClientAddress *addr.Address) *abi.EmptyValue
- func (a Actor) Code() cid.Cid
- func (a Actor) ComputeDataCommitment(rt Runtime, params *ComputeDataCommitmentParams) *ComputeDataCommitmentReturn
- func (a Actor) Constructor(rt Runtime, _ *abi.EmptyValue) *abi.EmptyValue
- func (a Actor) CronTick(rt Runtime, _ *abi.EmptyValue) *abi.EmptyValue
- func (a Actor) Exports() []interface{}
- func (a Actor) IsSingleton() bool
- func (a Actor) OnMinerSectorsTerminate(rt Runtime, params *OnMinerSectorsTerminateParams) *abi.EmptyValue
- func (a Actor) PublishStorageDeals(rt Runtime, params *PublishStorageDealsParams) *PublishStorageDealsReturn
- func (a Actor) State() cbor.Er
- func (a Actor) VerifyDealsForActivation(rt Runtime, params *VerifyDealsForActivationParams) *VerifyDealsForActivationReturn
- func (a Actor) WithdrawBalance(rt Runtime, params *WithdrawBalanceParams) *abi.TokenAmount
- type BalanceLockingReason
- type ClientDealProposal
- type ComputeDataCommitmentParams
- type ComputeDataCommitmentReturn
- type DealArray
- type DealMetaArray
- type DealProposal
- type DealState
- type DealSummary
- type MarketStateMutationPermission
- type OnMinerSectorsTerminateParams
- type PublishStorageDealsParams
- type PublishStorageDealsReturn
- type Runtime
- type SectorDataSpec
- type SectorDeals
- type SectorWeights
- type SetMultimap
- func (mm *SetMultimap) ForEach(epoch abi.ChainEpoch, fn func(id abi.DealID) error) error
- func (mm *SetMultimap) Put(epoch abi.ChainEpoch, v abi.DealID) error
- func (mm *SetMultimap) PutMany(epoch abi.ChainEpoch, vs []abi.DealID) error
- func (mm *SetMultimap) RemoveAll(key abi.ChainEpoch) error
- func (mm *SetMultimap) Root() (cid.Cid, error)
- type State
- type StateSummary
- type VerifyDealsForActivationParams
- type VerifyDealsForActivationReturn
- type WithdrawBalanceParams
Constants ¶
const DealMaxLabelSize = 256
DealMaxLabelSize is the maximum size of a deal label.
const DealUpdatesInterval = builtin.EpochsInDay // PARAM_SPEC
The number of epochs between payment and other state processing for deals.
const ProposalsAmtBitwidth = 5
Bitwidth of AMTs determined empirically from mutation patterns and projections of mainnet data.
const StatesAmtBitwidth = 6
Variables ¶
var DealMaxDuration = abi.ChainEpoch(540 * builtin.EpochsInDay) // PARAM_SPEC
Maximum deal duration
var DealMinDuration = abi.ChainEpoch(180 * builtin.EpochsInDay) // PARAM_SPEC
Minimum deal duration.
var PieceCIDPrefix = market0.PieceCIDPrefix
var PieceCIDPrefix = cid.Prefix{ Version: 1, Codec: cid.FilCommitmentUnsealed, MhType: mh.SHA2_256_TRUNC254_PADDED, MhLength: 32, }
var ProviderCollateralSupplyTarget = builtin.BigFrac{ Numerator: big.NewInt(1), Denominator: big.NewInt(100), }
The percentage of normalized cirulating supply that must be covered by provider collateral in a deal
Functions ¶
func CollateralPenaltyForDealActivationMissed ¶
func CollateralPenaltyForDealActivationMissed(providerCollateral abi.TokenAmount) abi.TokenAmount
Penalty to provider deal collateral if the deadline expires before sector commitment.
func DealClientCollateralBounds ¶
func DealClientCollateralBounds(_ abi.PaddedPieceSize, _ abi.ChainEpoch) (min abi.TokenAmount, max abi.TokenAmount)
func DealDurationBounds ¶
func DealDurationBounds(_ abi.PaddedPieceSize) (min abi.ChainEpoch, max abi.ChainEpoch)
Bounds (inclusive) on deal duration
func DealPricePerEpochBounds ¶
func DealPricePerEpochBounds(_ abi.PaddedPieceSize, _ abi.ChainEpoch) (min abi.TokenAmount, max abi.TokenAmount)
func DealProviderCollateralBounds ¶
func DealProviderCollateralBounds(pieceSize abi.PaddedPieceSize, verified bool, networkRawPower, networkQAPower, baselinePower abi.StoragePower, networkCirculatingSupply abi.TokenAmount) (min, max abi.TokenAmount)
func DealWeight ¶
func DealWeight(proposal *DealProposal) abi.DealWeight
Computes the weight for a deal proposal, which is a function of its size and duration.
func GenRandNextEpoch ¶
func GenRandNextEpoch(startEpoch abi.ChainEpoch, dealID abi.DealID) abi.ChainEpoch
func StoreEmptySetMultimap ¶
Writes a new empty map to the store and returns its CID.
func ValidateDealsForActivation ¶
func ValidateDealsForActivation( st *State, store adt.Store, dealIDs []abi.DealID, minerAddr addr.Address, sectorExpiry, currEpoch abi.ChainEpoch, ) (big.Int, big.Int, uint64, error)
Validates a collection of deal dealProposals for activation, and returns their combined weight, split into regular deal weight and verified deal weight.
Types ¶
type ActivateDealsParams ¶
type ActivateDealsParams = market0.ActivateDealsParams
type ActivateDealsParams struct { DealIDs []abi.DealID SectorExpiry abi.ChainEpoch }
type Actor ¶
type Actor struct{}
func (Actor) ActivateDeals ¶
func (a Actor) ActivateDeals(rt Runtime, params *ActivateDealsParams) *abi.EmptyValue
Verify that a given set of storage deals is valid for a sector currently being ProveCommitted, update the market's internal state accordingly.
func (Actor) AddBalance ¶
Deposits the received value into the balance held in escrow.
func (Actor) ComputeDataCommitment ¶
func (a Actor) ComputeDataCommitment(rt Runtime, params *ComputeDataCommitmentParams) *ComputeDataCommitmentReturn
func (Actor) Constructor ¶
func (a Actor) Constructor(rt Runtime, _ *abi.EmptyValue) *abi.EmptyValue
func (Actor) CronTick ¶
func (a Actor) CronTick(rt Runtime, _ *abi.EmptyValue) *abi.EmptyValue
func (Actor) IsSingleton ¶
func (Actor) OnMinerSectorsTerminate ¶
func (a Actor) OnMinerSectorsTerminate(rt Runtime, params *OnMinerSectorsTerminateParams) *abi.EmptyValue
Terminate a set of deals in response to their containing sector being terminated. Slash provider collateral, refund client collateral, and refund partial unpaid escrow amount to client.
func (Actor) PublishStorageDeals ¶
func (a Actor) PublishStorageDeals(rt Runtime, params *PublishStorageDealsParams) *PublishStorageDealsReturn
Publish a new set of storage deals (not yet included in a sector).
func (Actor) VerifyDealsForActivation ¶
func (a Actor) VerifyDealsForActivation(rt Runtime, params *VerifyDealsForActivationParams) *VerifyDealsForActivationReturn
Computes the weight of deals proposed for inclusion in a number of sectors. Deal weight is defined as the sum, over all deals in the set, of the product of deal size and duration.
This method performs some light validation on the way in order to fail early if deals can be determined to be invalid for the proposed sector properties. Full deal validation is deferred to deal activation since it depends on the activation epoch.
func (Actor) WithdrawBalance ¶
func (a Actor) WithdrawBalance(rt Runtime, params *WithdrawBalanceParams) *abi.TokenAmount
Attempt to withdraw the specified amount from the balance held in escrow. If less than the specified amount is available, yields the entire available balance. Returns the amount withdrawn.
type BalanceLockingReason ¶
type BalanceLockingReason int
BalanceLockingReason is the reason behind locking an amount.
const ( ClientCollateral BalanceLockingReason = iota ClientStorageFee ProviderCollateral )
type ClientDealProposal ¶
type ClientDealProposal = market0.ClientDealProposal
ClientDealProposal is a DealProposal signed by a client
type ClientDealProposal struct { Proposal DealProposal ClientSignature crypto.Signature }
type ComputeDataCommitmentParams ¶
type ComputeDataCommitmentParams struct {
Inputs []*SectorDataSpec
}
func (*ComputeDataCommitmentParams) MarshalCBOR ¶
func (t *ComputeDataCommitmentParams) MarshalCBOR(w io.Writer) error
func (*ComputeDataCommitmentParams) UnmarshalCBOR ¶
func (t *ComputeDataCommitmentParams) UnmarshalCBOR(r io.Reader) error
type ComputeDataCommitmentReturn ¶
func (*ComputeDataCommitmentReturn) MarshalCBOR ¶
func (t *ComputeDataCommitmentReturn) MarshalCBOR(w io.Writer) error
func (*ComputeDataCommitmentReturn) UnmarshalCBOR ¶
func (t *ComputeDataCommitmentReturn) UnmarshalCBOR(r io.Reader) error
type DealArray ¶
type DealArray struct {
*Array
}
A specialization of a array to deals. It is an error to query for a key that doesn't exist.
func AsDealProposalArray ¶
Interprets a store as balance table with root `r`.
type DealMetaArray ¶
type DealMetaArray struct {
*Array
}
A specialization of a array to deals. It is an error to query for a key that doesn't exist.
func AsDealStateArray ¶
func AsDealStateArray(s Store, r cid.Cid) (*DealMetaArray, error)
Interprets a store as balance table with root `r`.
func (*DealMetaArray) Get ¶
Gets the deal for a key. The entry must have been previously initialized.
func (*DealMetaArray) Root ¶
func (t *DealMetaArray) Root() (cid.Cid, error)
Returns the root cid of underlying AMT.
type DealProposal ¶
type DealProposal = market0.DealProposal
Note: Deal Collateral is only released and returned to clients and miners when the storage deal stops counting towards power. In the current iteration, it will be released when the sector containing the storage deals expires, even though some storage deals can expire earlier than the sector does. Collaterals are denominated in PerEpoch to incur a cost for self dealing or minimal deals that last for a long time. Note: ClientCollateralPerEpoch may not be needed and removed pending future confirmation. There will be a Minimum value for both client and provider deal collateral.
type DealProposal struct { PieceCID cid.Cid `checked:"true"` // Checked in validateDeal, CommP PieceSize abi.PaddedPieceSize VerifiedDeal bool Client addr.Address Provider addr.Address // Label is an arbitrary client chosen label to apply to the deal // TODO: Limit the size of this: https://github.com/filecoin-project/specs-actors/issues/897 Label string // Nominal start epoch. Deal payment is linear between StartEpoch and EndEpoch, // with total amount StoragePricePerEpoch * (EndEpoch - StartEpoch). // Storage deal must appear in a sealed (proven) sector no later than StartEpoch, // otherwise it is invalid. StartEpoch abi.ChainEpoch EndEpoch abi.ChainEpoch StoragePricePerEpoch abi.TokenAmount ProviderCollateral abi.TokenAmount ClientCollateral abi.TokenAmount }
type DealState ¶
type DealState struct { SectorStartEpoch abi.ChainEpoch // -1 if not yet included in proven sector LastUpdatedEpoch abi.ChainEpoch // -1 if deal state never updated SlashEpoch abi.ChainEpoch // -1 if deal never slashed }
type DealSummary ¶
type DealSummary struct { Provider address.Address StartEpoch abi.ChainEpoch EndEpoch abi.ChainEpoch SectorStartEpoch abi.ChainEpoch LastUpdatedEpoch abi.ChainEpoch SlashEpoch abi.ChainEpoch }
type MarketStateMutationPermission ¶
type MarketStateMutationPermission int
MarketStateMutationPermission is the mutation permission on a state field
const ( // Invalid means NO permission Invalid MarketStateMutationPermission = iota // ReadOnlyPermission allows reading but not mutating the field ReadOnlyPermission // WritePermission allows mutating the field WritePermission )
type OnMinerSectorsTerminateParams ¶
type OnMinerSectorsTerminateParams = market0.OnMinerSectorsTerminateParams
type OnMinerSectorsTerminateParams struct { Epoch abi.ChainEpoch DealIDs []abi.DealID }
type PublishStorageDealsParams ¶
type PublishStorageDealsParams = market0.PublishStorageDealsParams
type PublishStorageDealsParams struct { Deals []ClientDealProposal }
type PublishStorageDealsReturn ¶
func (*PublishStorageDealsReturn) MarshalCBOR ¶
func (t *PublishStorageDealsReturn) MarshalCBOR(w io.Writer) error
func (*PublishStorageDealsReturn) UnmarshalCBOR ¶
func (t *PublishStorageDealsReturn) UnmarshalCBOR(r io.Reader) error
type SectorDataSpec ¶
type SectorDataSpec struct { DealIDs []abi.DealID SectorType abi.RegisteredSealProof }
func (*SectorDataSpec) MarshalCBOR ¶
func (t *SectorDataSpec) MarshalCBOR(w io.Writer) error
func (*SectorDataSpec) UnmarshalCBOR ¶
func (t *SectorDataSpec) UnmarshalCBOR(r io.Reader) error
type SectorDeals ¶
type SectorDeals struct { SectorExpiry abi.ChainEpoch DealIDs []abi.DealID }
func (*SectorDeals) MarshalCBOR ¶
func (t *SectorDeals) MarshalCBOR(w io.Writer) error
func (*SectorDeals) UnmarshalCBOR ¶
func (t *SectorDeals) UnmarshalCBOR(r io.Reader) error
type SectorWeights ¶
type SectorWeights struct { DealSpace uint64 // Total space in bytes of submitted deals. DealWeight abi.DealWeight // Total space*time of submitted deals. VerifiedDealWeight abi.DealWeight // Total space*time of submitted verified deals. }
func (*SectorWeights) MarshalCBOR ¶
func (t *SectorWeights) MarshalCBOR(w io.Writer) error
func (*SectorWeights) UnmarshalCBOR ¶
func (t *SectorWeights) UnmarshalCBOR(r io.Reader) error
type SetMultimap ¶
type SetMultimap struct {
// contains filtered or unexported fields
}
func AsSetMultimap ¶
Interprets a store as a HAMT-based map of HAMT-based sets with root `r`. Both inner and outer HAMTs are interpreted with branching factor 2^bitwidth.
func MakeEmptySetMultimap ¶
func MakeEmptySetMultimap(s adt.Store, bitwidth int) (*SetMultimap, error)
Creates a new map backed by an empty HAMT and flushes it to the store. Both inner and outer HAMTs have branching factor 2^bitwidth.
func (*SetMultimap) ForEach ¶
func (mm *SetMultimap) ForEach(epoch abi.ChainEpoch, fn func(id abi.DealID) error) error
Iterates all entries for a key, iteration halts if the function returns an error.
func (*SetMultimap) Put ¶
func (mm *SetMultimap) Put(epoch abi.ChainEpoch, v abi.DealID) error
func (*SetMultimap) PutMany ¶
func (mm *SetMultimap) PutMany(epoch abi.ChainEpoch, vs []abi.DealID) error
func (*SetMultimap) RemoveAll ¶
func (mm *SetMultimap) RemoveAll(key abi.ChainEpoch) error
Removes all values for a key.
type State ¶
type State struct { // Proposals are deals that have been proposed and not yet cleaned up after expiry or termination. Proposals cid.Cid // AMT[DealID]DealProposal // States contains state for deals that have been activated and not yet cleaned up after expiry or termination. // After expiration, the state exists until the proposal is cleaned up too. // Invariant: keys(States) ⊆ keys(Proposals). States cid.Cid // AMT[DealID]DealState // PendingProposals tracks dealProposals that have not yet reached their deal start date. // We track them here to ensure that miners can't publish the same deal proposal twice PendingProposals cid.Cid // Set[DealCid] // Total amount held in escrow, indexed by actor address (including both locked and unlocked amounts). EscrowTable cid.Cid // BalanceTable // Amount locked, indexed by actor address. // Note: the amounts in this table do not affect the overall amount in escrow: // only the _portion_ of the total escrow amount that is locked. LockedTable cid.Cid // BalanceTable NextID abi.DealID // Metadata cached for efficient iteration over deals. DealOpsByEpoch cid.Cid // SetMultimap, HAMT[epoch]Set LastCron abi.ChainEpoch // Total Client Collateral that is locked -> unlocked when deal is terminated TotalClientLockedCollateral abi.TokenAmount // Total Provider Collateral that is locked -> unlocked when deal is terminated TotalProviderLockedCollateral abi.TokenAmount // Total storage fee that is locked in escrow -> unlocked when payments are made TotalClientStorageFee abi.TokenAmount }
type StateSummary ¶
type StateSummary struct { Deals map[abi.DealID]*DealSummary PendingProposalCount uint64 DealStateCount uint64 LockTableCount uint64 DealOpEpochCount uint64 DealOpCount uint64 }
func CheckStateInvariants ¶
func CheckStateInvariants(st *State, store adt.Store, balance abi.TokenAmount, currEpoch abi.ChainEpoch) (*StateSummary, *builtin.MessageAccumulator)
Checks internal invariants of market state.
type VerifyDealsForActivationParams ¶
type VerifyDealsForActivationParams struct {
Sectors []SectorDeals
}
Changed since v2: - Array of sectors rather than just one - Removed SectorStart (which is unknown at call time)
func (*VerifyDealsForActivationParams) MarshalCBOR ¶
func (t *VerifyDealsForActivationParams) MarshalCBOR(w io.Writer) error
func (*VerifyDealsForActivationParams) UnmarshalCBOR ¶
func (t *VerifyDealsForActivationParams) UnmarshalCBOR(r io.Reader) error
type VerifyDealsForActivationReturn ¶
type VerifyDealsForActivationReturn struct {
Sectors []SectorWeights
}
Changed since v2: - Array of sectors weights
func (*VerifyDealsForActivationReturn) MarshalCBOR ¶
func (t *VerifyDealsForActivationReturn) MarshalCBOR(w io.Writer) error
func (*VerifyDealsForActivationReturn) UnmarshalCBOR ¶
func (t *VerifyDealsForActivationReturn) UnmarshalCBOR(r io.Reader) error
type WithdrawBalanceParams ¶
type WithdrawBalanceParams = market0.WithdrawBalanceParams
type WithdrawBalanceParams struct { ProviderOrClientAddress addr.Address Amount abi.TokenAmount }