Skip to content

Commit

Permalink
Merge pull request #6274 from filecoin-project/feat/directdeal
Browse files Browse the repository at this point in the history
feat: direct deal
  • Loading branch information
LinZexiao authored Mar 8, 2024
2 parents dcd42af + c207c77 commit 0b9d9ed
Show file tree
Hide file tree
Showing 7 changed files with 475 additions and 0 deletions.
2 changes: 2 additions & 0 deletions venus-devtool/api-gen/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ func init() {
uuidTmp := auuid.MustParse("102334ec-35a3-4b36-be9f-02883844503a")
addExample(&uuidTmp)

addExample(market.DirectDealState(1))

// eth types
ethint := types.EthUint64(5)
addExample(ethint)
Expand Down
9 changes: 9 additions & 0 deletions venus-shared/api/market/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"time"

"github.com/google/uuid"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p/core/peer"

Expand Down Expand Up @@ -165,6 +166,8 @@ type IMarket interface {
ReleaseDeals(ctx context.Context, miner address.Address, deals []abi.DealID) error //perm:write
GetUnPackedDeals(ctx context.Context, miner address.Address, spec *market.GetDealSpec) ([]*market.DealInfoIncludePath, error) //perm:read
UpdateStorageDealStatus(ctx context.Context, dealProposalCid cid.Cid, state storagemarket.StorageDealStatus, pieceState market.PieceStatus) error //perm:write
AssignDeals(ctx context.Context, sid abi.SectorID, ssize abi.SectorSize, spec *market.GetDealSpec) ([]*market.DealInfoV2, error) //perm:write
ReleaseDirectDeals(ctx context.Context, miner address.Address, allocationIDs []types.AllocationId) error //perm:write
// market event
ResponseMarketEvent(ctx context.Context, resp *gateway.ResponseEvent) error //perm:read
ListenMarketEvent(ctx context.Context, policy *gateway.MarketRegisterPolicy) (<-chan *gateway.RequestEvent, error) //perm:read
Expand All @@ -188,5 +191,11 @@ type IMarket interface {
// todo address undefined is invalid, it is currently not possible to directly associate an order with a miner
GetRetrievalDealStatistic(ctx context.Context, miner address.Address) (*market.RetrievalDealStatistic, error) //perm:read

// ImportDirectDeal import direct deals
ImportDirectDeal(ctx context.Context, deal *market.DirectDealParams) error //perm:write
GetDirectDeal(ctx context.Context, id uuid.UUID) (*market.DirectDeal, error) //perm:read
GetDirectDealByAllocationID(ctx context.Context, id types.AllocationId) (*market.DirectDeal, error) //perm:read
ListDirectDeals(ctx context.Context, queryParams market.DirectDealQueryParams) ([]*market.DirectDeal, error) //perm:read

api.Version
}
224 changes: 224 additions & 0 deletions venus-shared/api/market/v1/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ curl http://<ip>:<port>/rpc/v1 -X POST -H "Content-Type: application/json" -H "
* [ActorUpsert](#actorupsert)
* [AddFsPieceStorage](#addfspiecestorage)
* [AddS3PieceStorage](#adds3piecestorage)
* [AssignDeals](#assigndeals)
* [AssignUnPackedDeals](#assignunpackeddeals)
* [DagstoreDestroyShard](#dagstoredestroyshard)
* [DagstoreGC](#dagstoregc)
Expand Down Expand Up @@ -48,10 +49,14 @@ curl http://<ip>:<port>/rpc/v1 -X POST -H "Content-Type: application/json" -H "
* [DealsSetPieceCidBlocklist](#dealssetpiececidblocklist)
* [DealsSetPublishMsgPeriod](#dealssetpublishmsgperiod)
* [GetDeals](#getdeals)
* [GetDirectDeal](#getdirectdeal)
* [GetDirectDealByAllocationID](#getdirectdealbyallocationid)
* [GetRetrievalDealStatistic](#getretrievaldealstatistic)
* [GetStorageDealStatistic](#getstoragedealstatistic)
* [GetUnPackedDeals](#getunpackeddeals)
* [ID](#id)
* [ImportDirectDeal](#importdirectdeal)
* [ListDirectDeals](#listdirectdeals)
* [ListPieceStorageInfos](#listpiecestorageinfos)
* [ListenMarketEvent](#listenmarketevent)
* [MarkDealsAsPacking](#markdealsaspacking)
Expand Down Expand Up @@ -96,6 +101,7 @@ curl http://<ip>:<port>/rpc/v1 -X POST -H "Content-Type: application/json" -H "
* [PiecesListCidInfos](#pieceslistcidinfos)
* [PiecesListPieces](#pieceslistpieces)
* [ReleaseDeals](#releasedeals)
* [ReleaseDirectDeals](#releasedirectdeals)
* [RemovePieceStorage](#removepiecestorage)
* [ResponseMarketEvent](#responsemarketevent)
* [SectorGetExpectedSealDuration](#sectorgetexpectedsealduration)
Expand Down Expand Up @@ -220,6 +226,56 @@ Inputs:

Response: `{}`

### AssignDeals


Perms: write

Inputs:
```json
[
{
"Miner": 1000,
"Number": 9
},
34359738368,
{
"MaxPiece": 123,
"MaxPieceSize": 42,
"MinPiece": 123,
"MinPieceSize": 42,
"MinUsedSpace": 42,
"StartEpoch": 10101,
"EndEpoch": 10101,
"SectorExpiration": 10101
}
]
```

Response:
```json
[
{
"DealID": 5432,
"PublishCid": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"AllocationID": 0,
"PieceCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"PieceSize": 1032,
"Client": "f01234",
"Provider": "f01234",
"Offset": 1032,
"Length": 1032,
"PayloadSize": 42,
"StartEpoch": 10101,
"EndEpoch": 10101
}
]
```

### AssignUnPackedDeals


Expand Down Expand Up @@ -962,6 +1018,80 @@ Response:
]
```

### GetDirectDeal


Perms: read

Inputs:
```json
[
"07070707-0707-0707-0707-070707070707"
]
```

Response:
```json
{
"ID": "07070707-0707-0707-0707-070707070707",
"PieceCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"PieceSize": 1032,
"Client": "f01234",
"Provider": "f01234",
"PayloadSize": 42,
"State": 1,
"AllocationID": 42,
"ClaimID": 42,
"SectorID": 9,
"Offset": 1032,
"Length": 1032,
"StartEpoch": 10101,
"EndEpoch": 10101,
"Message": "string value",
"CreatedAt": 42,
"UpdatedAt": 42
}
```

### GetDirectDealByAllocationID


Perms: read

Inputs:
```json
[
0
]
```

Response:
```json
{
"ID": "07070707-0707-0707-0707-070707070707",
"PieceCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"PieceSize": 1032,
"Client": "f01234",
"Provider": "f01234",
"PayloadSize": 42,
"State": 1,
"AllocationID": 42,
"ClaimID": 42,
"SectorID": 9,
"Offset": 1032,
"Length": 1032,
"StartEpoch": 10101,
"EndEpoch": 10101,
"Message": "string value",
"CreatedAt": 42,
"UpdatedAt": 42
}
```

### GetRetrievalDealStatistic
GetRetrievalDealStatistic get retrieval deal statistic information
todo address undefined is invalid, it is currently not possible to directly associate an order with a miner
Expand Down Expand Up @@ -1069,6 +1199,83 @@ Inputs: `[]`

Response: `"12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf"`

### ImportDirectDeal
ImportDirectDeal import direct deals


Perms: write

Inputs:
```json
[
{
"SkipCommP": true,
"NoCopyCarFile": true,
"SkipGenerateIndex": true,
"DealParams": [
{
"FilePath": "string value",
"PayloadSize": 42,
"DealUUID": "07070707-0707-0707-0707-070707070707",
"AllocationID": 42,
"PieceCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"Client": "f01234"
}
]
}
]
```

Response: `{}`

### ListDirectDeals


Perms: read

Inputs:
```json
[
{
"Provider": "f01234",
"Client": "f01234",
"State": 1,
"Offset": 123,
"Limit": 123,
"Asc": true
}
]
```

Response:
```json
[
{
"ID": "07070707-0707-0707-0707-070707070707",
"PieceCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"PieceSize": 1032,
"Client": "f01234",
"Provider": "f01234",
"PayloadSize": 42,
"State": 1,
"AllocationID": 42,
"ClaimID": 42,
"SectorID": 9,
"Offset": 1032,
"Length": 1032,
"StartEpoch": 10101,
"EndEpoch": 10101,
"Message": "string value",
"CreatedAt": 42,
"UpdatedAt": 42
}
]
```

### ListPieceStorageInfos


Expand Down Expand Up @@ -2430,6 +2637,23 @@ Inputs:

Response: `{}`

### ReleaseDirectDeals


Perms: write

Inputs:
```json
[
"f01234",
[
0
]
]
```

Response: `{}`

### RemovePieceStorage


Expand Down
Loading

0 comments on commit 0b9d9ed

Please sign in to comment.