market

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2022 License: Apache-2.0, MIT Imports: 18 Imported by: 130

Documentation

Index

Constants

View Source
const DealMaxLabelSize = 256

DealMaxLabelSize is the maximum size of a deal label.

View Source
const EpochUndefined = abi.ChainEpoch(-1)
View Source
const ProposalsAmtBitwidth = 5

Bitwidth of AMTs determined empirically from mutation patterns and projections of mainnet data.

View Source
const StatesAmtBitwidth = 6

Variables

View Source
var DealMaxDuration = abi.ChainEpoch(540 * builtin.EpochsInDay) // PARAM_SPEC

Maximum deal duration

View Source
var DealMinDuration = abi.ChainEpoch(180 * builtin.EpochsInDay) // PARAM_SPEC

Minimum deal duration.

View Source
var EmptyDealLabel = DealLabel{}

Zero value of DealLabel is canonical EmptyDealLabel

View Source
var MarketDefaultAllocationTermBuffer = abi.ChainEpoch(90 * builtin.EpochsInDay)
View Source
var Methods = map[uint64]interface{}{
	1: *new(func(interface{}, *abi.EmptyValue) *abi.EmptyValue),
	2: *new(func(interface{}, *address.Address) *abi.EmptyValue),
	3: *new(func(interface{}, *WithdrawBalanceParams) *abi.TokenAmount),
	4: *new(func(interface{}, *PublishStorageDealsParams) *PublishStorageDealsReturn),
	5: *new(func(interface{}, *VerifyDealsForActivationParams) *VerifyDealsForActivationReturn),
	6: *new(func(interface{}, *ActivateDealsParams) *abi.EmptyValue),
	7: *new(func(interface{}, *OnMinerSectorsTerminateParams) *abi.EmptyValue),
	8: *new(func(interface{}, *ComputeDataCommitmentParams) *ComputeDataCommitmentReturn),
	9: *new(func(interface{}, *abi.EmptyValue) *abi.EmptyValue),
}
View Source
var PieceCIDPrefix = cid.Prefix{
	Version:  1,
	Codec:    cid.FilCommitmentUnsealed,
	MhType:   mh.SHA2_256_TRUNC254_PADDED,
	MhLength: 32,
}
View Source
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 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 StoreEmptySetMultimap

func StoreEmptySetMultimap(s adt.Store, bitwidth int) (cid.Cid, error)

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 struct {
	DealIDs      []abi.DealID
	SectorExpiry abi.ChainEpoch
}

func (*ActivateDealsParams) MarshalCBOR

func (t *ActivateDealsParams) MarshalCBOR(w io.Writer) error

func (*ActivateDealsParams) UnmarshalCBOR

func (t *ActivateDealsParams) UnmarshalCBOR(r io.Reader) error

type ActivateDealsResult

type ActivateDealsResult struct {
	NonVerifiedDealSpace big.Int
	VerifiedInfos        []VerifiedDealInfo
}

func (*ActivateDealsResult) MarshalCBOR

func (t *ActivateDealsResult) MarshalCBOR(w io.Writer) error

func (*ActivateDealsResult) UnmarshalCBOR

func (t *ActivateDealsResult) UnmarshalCBOR(r io.Reader) error

type ClientDealProposal

type ClientDealProposal struct {
	Proposal        DealProposal
	ClientSignature acrypto.Signature
}

ClientDealProposal is a DealProposal signed by a client

func (*ClientDealProposal) MarshalCBOR

func (t *ClientDealProposal) MarshalCBOR(w io.Writer) error

func (*ClientDealProposal) UnmarshalCBOR

func (t *ClientDealProposal) UnmarshalCBOR(r io.Reader) error

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

type ComputeDataCommitmentReturn struct {
	CommDs []cbg.CborCid
}

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 {
	*adt.Array
}

A specialization of a array to deals. It is an error to query for a key that doesn't exist.

func AsDealProposalArray

func AsDealProposalArray(s adt.Store, r cid.Cid) (*DealArray, error)

Interprets a store as balance table with root `r`.

func (*DealArray) Delete

func (t *DealArray) Delete(id abi.DealID) error

func (*DealArray) Get

func (t *DealArray) Get(id abi.DealID) (*DealProposal, bool, error)

Gets the deal for a key. The entry must have been previously initialized.

func (*DealArray) Root

func (t *DealArray) Root() (cid.Cid, error)

Returns the root cid of underlying AMT.

func (*DealArray) Set

func (t *DealArray) Set(k abi.DealID, value *DealProposal) error

type DealLabel

type DealLabel struct {
	// contains filtered or unexported fields
}

The DealLabel is a kinded union of string or byte slice. It serializes to a CBOR string or CBOR byte string depending on which form it takes. The zero value is serialized as an empty CBOR string (maj type 3).

func NewLabelFromBytes

func NewLabelFromBytes(b []byte) (DealLabel, error)

func NewLabelFromString

func NewLabelFromString(s string) (DealLabel, error)

func (DealLabel) Equals

func (l DealLabel) Equals(o DealLabel) bool

func (DealLabel) IsBytes

func (label DealLabel) IsBytes() bool

func (DealLabel) IsString

func (label DealLabel) IsString() bool

func (DealLabel) Length

func (label DealLabel) Length() int

func (*DealLabel) MarshalCBOR

func (label *DealLabel) MarshalCBOR(w io.Writer) error

func (DealLabel) MarshalJSON

func (label DealLabel) MarshalJSON() ([]byte, error)

func (DealLabel) ToBytes

func (label DealLabel) ToBytes() ([]byte, error)

func (DealLabel) ToString

func (label DealLabel) ToString() (string, error)

func (*DealLabel) UnmarshalCBOR

func (label *DealLabel) UnmarshalCBOR(br io.Reader) error

func (*DealLabel) UnmarshalJSON

func (label *DealLabel) UnmarshalJSON(b []byte) error

type DealProposal

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
	Label DealLabel

	// 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
}

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.

func (*DealProposal) Cid

func (p *DealProposal) Cid() (cid.Cid, error)

func (*DealProposal) ClientBalanceRequirement

func (p *DealProposal) ClientBalanceRequirement() abi.TokenAmount

func (*DealProposal) Duration

func (p *DealProposal) Duration() abi.ChainEpoch

func (*DealProposal) MarshalCBOR

func (t *DealProposal) MarshalCBOR(w io.Writer) error

func (*DealProposal) ProviderBalanceRequirement

func (p *DealProposal) ProviderBalanceRequirement() abi.TokenAmount

func (*DealProposal) TotalStorageFee

func (p *DealProposal) TotalStorageFee() abi.TokenAmount

func (*DealProposal) UnmarshalCBOR

func (t *DealProposal) UnmarshalCBOR(r io.Reader) error

type DealSpaces

type DealSpaces struct {
	DealSpace         abi.DealWeight // Total space of submitted deals.
	VerifiedDealSpace abi.DealWeight // Total space of submitted verified deals.
}

func (*DealSpaces) MarshalCBOR

func (t *DealSpaces) MarshalCBOR(w io.Writer) error

func (*DealSpaces) UnmarshalCBOR

func (t *DealSpaces) UnmarshalCBOR(r io.Reader) error

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
	VerifiedClaim    verifreg.AllocationId
}

func (*DealState) MarshalCBOR

func (t *DealState) MarshalCBOR(w io.Writer) error

func (*DealState) UnmarshalCBOR

func (t *DealState) UnmarshalCBOR(r io.Reader) error

type OnMinerSectorsTerminateParams

type OnMinerSectorsTerminateParams struct {
	Epoch   abi.ChainEpoch
	DealIDs []abi.DealID
}

func (*OnMinerSectorsTerminateParams) MarshalCBOR

func (t *OnMinerSectorsTerminateParams) MarshalCBOR(w io.Writer) error

func (*OnMinerSectorsTerminateParams) UnmarshalCBOR

func (t *OnMinerSectorsTerminateParams) UnmarshalCBOR(r io.Reader) error

type PublishStorageDealsParams

type PublishStorageDealsParams struct {
	Deals []ClientDealProposal
}

func (*PublishStorageDealsParams) MarshalCBOR

func (t *PublishStorageDealsParams) MarshalCBOR(w io.Writer) error

func (*PublishStorageDealsParams) UnmarshalCBOR

func (t *PublishStorageDealsParams) UnmarshalCBOR(r io.Reader) error

type PublishStorageDealsReturn

type PublishStorageDealsReturn struct {
	IDs        []abi.DealID
	ValidDeals bitfield.BitField
}

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 SectorDealData

type SectorDealData struct {
	CommD *cid.Cid
}

func (*SectorDealData) MarshalCBOR

func (t *SectorDealData) MarshalCBOR(w io.Writer) error

func (*SectorDealData) UnmarshalCBOR

func (t *SectorDealData) UnmarshalCBOR(r io.Reader) error

type SectorDeals

type SectorDeals struct {
	SectorType   abi.RegisteredSealProof
	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 SetMultimap

type SetMultimap struct {
	// contains filtered or unexported fields
}

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) Root

func (mm *SetMultimap) Root() (cid.Cid, error)

Returns the root cid of the underlying HAMT.

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

	// Verified registry allocation IDs for deals that are not yet activated.
	PendingDealAllocationIds cid.Cid // HAMT[DealID]AllocationID
}

func ConstructState

func ConstructState(store adt.Store) (*State, error)

func (*State) MarshalCBOR

func (t *State) MarshalCBOR(w io.Writer) error

func (*State) UnmarshalCBOR

func (t *State) UnmarshalCBOR(r io.Reader) error

type VerifiedDealInfo

type VerifiedDealInfo struct {
	Client       abi.ActorID
	AllocationId verifreg.AllocationId
	Data         cid.Cid
	Size         abi.PaddedPieceSize
}

func (*VerifiedDealInfo) MarshalCBOR

func (t *VerifiedDealInfo) MarshalCBOR(w io.Writer) error

func (*VerifiedDealInfo) UnmarshalCBOR

func (t *VerifiedDealInfo) UnmarshalCBOR(r io.Reader) error

type VerifyDealsForActivationParams

type VerifyDealsForActivationParams struct {
	Sectors []SectorDeals
}

- 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 []SectorDealData
}

- 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 struct {
	ProviderOrClientAddress addr.Address
	Amount                  abi.TokenAmount
}

func (*WithdrawBalanceParams) MarshalCBOR

func (t *WithdrawBalanceParams) MarshalCBOR(w io.Writer) error

func (*WithdrawBalanceParams) UnmarshalCBOR

func (t *WithdrawBalanceParams) UnmarshalCBOR(r io.Reader) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL