Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: direct deal #6274

Merged
merged 4 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: direct deal
  • Loading branch information
simlecode committed Mar 7, 2024
commit c2cd88173c8edb5257a2a0da7e36f1b4d9b65db3
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
AssignDirectDeals(ctx context.Context, sid abi.SectorID, ssize abi.SectorSize, spec *market.GetDealSpec) ([]*market.DirectDealInfo, error) //perm:read
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
ListDirectDeals(ctx context.Context, queryParams market.DirectDealQueryParams) ([]*market.DirectDeal, error) //perm:read
GetDirectDealByAllocatinoID(ctx context.Context, id uint64) (*market.DirectDeal, error) //perm:read

api.Version
}
218 changes: 218 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)
* [AssignDirectDeals](#assigndirectdeals)
* [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)
* [GetDirectDealByAllocatinoID](#getdirectdealbyallocatinoid)
* [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,51 @@ Inputs:

Response: `{}`

### AssignDirectDeals


Perms: read

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
[
{
"AllocationID": 0,
"PieceCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"PieceSize": 1032,
"Client": "f01234",
"Provider": "f01234",
"Offset": 1032,
"Length": 1032,
"StartEpoch": 10101,
"EndEpoch": 10101
}
]
```

### AssignUnPackedDeals


Expand Down Expand Up @@ -962,6 +1013,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
}
```

### GetDirectDealByAllocatinoID


Perms: read

Inputs:
```json
[
42
]
```

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 +1194,82 @@ Inputs: `[]`

Response: `"12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf"`

### ImportDirectDeal
ImportDirectDeal import direct deals


Perms: write

Inputs:
```json
[
{
"SkipCommP": true,
"NoCopyCarFile": true,
"SkipGenerateIndex": true,
"DealParams": [
{
"FilePath": "string value",
"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 +2631,23 @@ Inputs:

Response: `{}`

### ReleaseDirectDeals


Perms: write

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

Response: `{}`

### RemovePieceStorage


Expand Down
Loading