market

package
v0.9.12 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: Apache-2.0, MIT Imports: 27 Imported by: 35

Documentation

Index

Constants

View Source
const DealUpdatesInterval = builtin.EpochsInDay

DealUpdatesInterval is the number of blocks between payouts for deals

Variables

View Source
var PieceCIDPrefix = cid.Prefix{
	Version:  1,
	Codec:    cid.FilCommitmentUnsealed,
	MhType:   mh.SHA2_256_TRUNC254_PADDED,
	MhLength: 32,
}
View Source
var ProvCollateralPercentSupplyDenom = big.NewInt(100)

ProvCollateralPercentSupplyDenom is the denominator of the percentage of normalized cirulating supply that must be covered by provider collateral

View Source
var ProvCollateralPercentSupplyNumV0 = big.NewInt(5)

ProvCollateralPercentSupplyNum is the numerator of the percentage of normalized cirulating supply that must be covered by provider collateral

View Source
var ProvCollateralPercentSupplyNumV1 = big.NewInt(1)

Functions

func DealClientCollateralBounds added in v0.8.2

func DealClientCollateralBounds(pieceSize abi.PaddedPieceSize, duration abi.ChainEpoch) (min abi.TokenAmount, max abi.TokenAmount)

func DealProviderCollateralBounds added in v0.8.2

func DealProviderCollateralBounds(pieceSize abi.PaddedPieceSize, verified bool, networkRawPower, networkQAPower, baselinePower abi.StoragePower,
	networkCirculatingSupply abi.TokenAmount, networkVersion network.Version) (min, max abi.TokenAmount)

func DealWeight added in v0.7.0

func DealWeight(proposal *DealProposal) abi.DealWeight

Computes the weight for a deal proposal, which is a function of its size and duration.

func ValidateDealsForActivation added in v0.7.0

func ValidateDealsForActivation(st *State, store adt.Store, dealIDs []abi.DealID, minerAddr addr.Address,
	sectorExpiry, currEpoch abi.ChainEpoch) (big.Int, big.Int, 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 added in v0.7.0

type ActivateDealsParams struct {
	DealIDs      []abi.DealID
	SectorExpiry abi.ChainEpoch
}

func (*ActivateDealsParams) MarshalCBOR added in v0.7.0

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

func (*ActivateDealsParams) UnmarshalCBOR added in v0.7.0

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

type Actor

type Actor struct{}

func (Actor) ActivateDeals added in v0.7.0

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

func (a Actor) AddBalance(rt Runtime, providerOrClientAddress *addr.Address) *abi.EmptyValue

Deposits the received value into the balance held in escrow.

func (Actor) Code added in v0.9.12

func (a Actor) Code() cid.Cid

func (Actor) ComputeDataCommitment

func (a Actor) ComputeDataCommitment(rt Runtime, params *ComputeDataCommitmentParams) *cbg.CborCid

func (Actor) Constructor

func (a Actor) Constructor(rt Runtime, _ *abi.EmptyValue) *abi.EmptyValue

func (Actor) CronTick added in v0.5.1

func (a Actor) CronTick(rt Runtime, _ *abi.EmptyValue) *abi.EmptyValue

func (Actor) Exports

func (a Actor) Exports() []interface{}

func (Actor) IsSingleton added in v0.9.12

func (a Actor) IsSingleton() bool

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) State added in v0.9.12

func (a Actor) State() cbor.Er

func (Actor) VerifyDealsForActivation added in v0.7.0

func (A Actor) VerifyDealsForActivation(rt Runtime, params *VerifyDealsForActivationParams) *VerifyDealsForActivationReturn

Verify that a given set of storage deals is valid for a sector currently being PreCommitted and return DealWeight of the set of storage deals given. The weight is defined as the sum, over all deals in the set, of the product of deal size and duration.

func (Actor) WithdrawBalance

func (a Actor) WithdrawBalance(rt Runtime, params *WithdrawBalanceParams) *abi.EmptyValue

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.

type BalanceLockingReason added in v0.7.2

type BalanceLockingReason int

BalanceLockingReason is the reason behind locking an amount.

const (
	ClientCollateral BalanceLockingReason = iota
	ClientStorageFee
	ProviderCollateral
)

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 {
	DealIDs    []abi.DealID
	SectorType abi.RegisteredSealProof
}

func (*ComputeDataCommitmentParams) MarshalCBOR

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

func (*ComputeDataCommitmentParams) UnmarshalCBOR

func (t *ComputeDataCommitmentParams) 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

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

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

func (*DealArray) Delete

func (t *DealArray) Delete(key uint64) 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 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) Delete

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

func (*DealMetaArray) Get

func (t *DealMetaArray) Get(id abi.DealID) (*DealState, bool, error)

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.

func (*DealMetaArray) Set

func (t *DealMetaArray) Set(k abi.DealID, value *DealState) 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 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
}

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 added in v0.7.2

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

func (*DealState) MarshalCBOR

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

func (*DealState) UnmarshalCBOR

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

type MarketStateMutationPermission added in v0.8.0

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

func (*PublishStorageDealsReturn) MarshalCBOR

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

func (*PublishStorageDealsReturn) UnmarshalCBOR

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

type Runtime

type Runtime = runtime.Runtime

type SetMultimap

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

func AsSetMultimap

func AsSetMultimap(s adt.Store, r cid.Cid) (*SetMultimap, error)

Interprets a store as a HAMT-based map of HAMT-based sets with root `r`.

func MakeEmptySetMultimap

func MakeEmptySetMultimap(s adt.Store) *SetMultimap

Creates a new map backed by an empty HAMT and flushes it to the store.

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 added in v0.5.1

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.

func (*SetMultimap) Root

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

Returns the root cid of the underlying HAMT.

type State

type State struct {
	Proposals cid.Cid // AMT[DealID]DealProposal
	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 // HAMT[DealCid]DealProposal

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

func ConstructState

func ConstructState(emptyArrayCid, emptyMapCid, emptyMSetCid cid.Cid) *State

func (*State) MarshalCBOR

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

func (*State) UnmarshalCBOR

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

type VerifyDealsForActivationParams added in v0.7.0

type VerifyDealsForActivationParams struct {
	DealIDs      []abi.DealID
	SectorExpiry abi.ChainEpoch
	SectorStart  abi.ChainEpoch
}

func (*VerifyDealsForActivationParams) MarshalCBOR added in v0.7.0

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

func (*VerifyDealsForActivationParams) UnmarshalCBOR added in v0.7.0

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

type VerifyDealsForActivationReturn added in v0.7.0

type VerifyDealsForActivationReturn struct {
	DealWeight         abi.DealWeight
	VerifiedDealWeight abi.DealWeight
}

func (*VerifyDealsForActivationReturn) MarshalCBOR added in v0.7.0

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

func (*VerifyDealsForActivationReturn) UnmarshalCBOR added in v0.7.0

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