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: index ad removal command #1859

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ type Boost interface {
BoostDeal(ctx context.Context, dealUuid uuid.UUID) (*smtypes.ProviderDealState, error) //perm:admin
BoostDealBySignedProposalCid(ctx context.Context, proposalCid cid.Cid) (*smtypes.ProviderDealState, error) //perm:admin
BoostDummyDeal(context.Context, smtypes.DealParams) (*ProviderDealRejectionInfo, error) //perm:admin
BoostIndexerAnnounceDealRemoved(ctx context.Context, propCid cid.Cid) (cid.Cid, error) //perm:admin
BoostLegacyDealByProposalCid(ctx context.Context, propCid cid.Cid) (storagemarket.MinerDeal, error) //perm:admin
BoostDagstoreRegisterShard(ctx context.Context, key string) error //perm:admin
BoostDagstoreDestroyShard(ctx context.Context, key string) error //perm:admin
BoostDagstoreInitializeShard(ctx context.Context, key string) error //perm:admin
Expand Down
26 changes: 26 additions & 0 deletions api/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified build/openrpc/boost.json.gz
Binary file not shown.
60 changes: 60 additions & 0 deletions cmd/boostd/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

bcli "github.com/filecoin-project/boost/cli"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/google/uuid"
"github.com/ipfs/go-cid"
"github.com/urfave/cli/v2"
)
Expand All @@ -17,6 +18,7 @@ var indexProvCmd = &cli.Command{
indexProvListMultihashesCmd,
indexProvAnnounceLatest,
indexProvAnnounceLatestHttp,
indexProvAnnounceDealRemovalAd,
},
}

Expand Down Expand Up @@ -127,3 +129,61 @@ var indexProvAnnounceLatestHttp = &cli.Command{
return nil
},
}

var indexProvAnnounceDealRemovalAd = &cli.Command{
Name: "announce-remove-deal",
Usage: "Published a removal ad for given deal UUID or Proposal CID (legacy deals)",
Action: func(cctx *cli.Context) error {
ctx := lcli.ReqContext(cctx)

napi, closer, err := bcli.GetBoostAPI(cctx)
if err != nil {
return err
}
defer closer()

if cctx.Args().Len() != 1 {
return fmt.Errorf("must specify only one proposal CID / deal UUID")
}

id := cctx.Args().Get(0)

var proposalCid *cid.Cid
dealUuid, err := uuid.Parse(id)
if err != nil {
propCid, err := cid.Decode(id)
if err != nil {
return fmt.Errorf("could not parse '%s' as deal uuid or proposal cid", id)
}
proposalCid = &propCid
}

if proposalCid == nil {
deal, err := napi.BoostDeal(ctx, dealUuid)
if err != nil {
return fmt.Errorf("deal not found with UUID %s: %w", dealUuid.String(), err)
}
prop, err := deal.ClientDealProposal.Proposal.Cid()
if err != nil {
return fmt.Errorf("generating proposal cid for deal %s: %w", dealUuid.String(), err)
}
proposalCid = &prop
} else {
_, err = napi.BoostLegacyDealByProposalCid(ctx, *proposalCid)
if err != nil {
_, err := napi.BoostDealBySignedProposalCid(ctx, *proposalCid)
if err != nil {
return fmt.Errorf("no deal with proposal CID %s found in boost and legacy database", proposalCid.String())
}
}
}

cid, err := napi.BoostIndexerAnnounceDealRemoved(ctx, *proposalCid)
if err != nil {
return fmt.Errorf("failed to send removal ad: %w", err)
}
fmt.Printf("Announced the removal Ad with cid %s\n", cid)

return nil
},
}
95 changes: 95 additions & 0 deletions documentation/en/api-v1-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
* [BoostDirectDeal](#boostdirectdeal)
* [BoostDummyDeal](#boostdummydeal)
* [BoostIndexerAnnounceAllDeals](#boostindexerannouncealldeals)
* [BoostIndexerAnnounceDealRemoved](#boostindexerannouncedealremoved)
* [BoostIndexerAnnounceLatest](#boostindexerannouncelatest)
* [BoostIndexerAnnounceLatestHttp](#boostindexerannouncelatesthttp)
* [BoostIndexerListMultihashes](#boostindexerlistmultihashes)
* [BoostLegacyDealByProposalCid](#boostlegacydealbyproposalcid)
* [BoostMakeDeal](#boostmakedeal)
* [BoostOfflineDealWithData](#boostofflinedealwithdata)
* [Deals](#deals)
Expand Down Expand Up @@ -596,6 +598,27 @@ Inputs: `null`

Response: `{}`

### BoostIndexerAnnounceDealRemoved


Perms: admin

Inputs:
```json
[
{
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}
]
```

Response:
```json
{
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}
```

### BoostIndexerAnnounceLatest


Expand Down Expand Up @@ -652,6 +675,78 @@ Response:
]
```

### BoostLegacyDealByProposalCid


Perms: admin

Inputs:
```json
[
{
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}
]
```

Response:
```json
{
"Proposal": {
"PieceCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"PieceSize": 1032,
"VerifiedDeal": true,
"Client": "f01234",
"Provider": "f01234",
"Label": "",
"StartEpoch": 10101,
"EndEpoch": 10101,
"StoragePricePerEpoch": "0",
"ProviderCollateral": "0",
"ClientCollateral": "0"
},
"ClientSignature": {
"Type": 2,
"Data": "Ynl0ZSBhcnJheQ=="
},
"ProposalCid": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"AddFundsCid": null,
"PublishCid": null,
"Miner": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf",
"Client": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf",
"State": 42,
"PiecePath": ".lotusminer/fstmp123",
"MetadataPath": ".lotusminer/fstmp123",
"SlashEpoch": 10101,
"FastRetrieval": true,
"Message": "string value",
"FundsReserved": "0",
"Ref": {
"TransferType": "string value",
"Root": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"PieceCid": null,
"PieceSize": 1024,
"RawBlockSize": 42
},
"AvailableForRetrieval": true,
"DealID": 5432,
"CreationTime": "0001-01-01T00:00:00Z",
"TransferChannelId": {
"Initiator": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf",
"Responder": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf",
"ID": 3
},
"SectorNumber": 9,
"InboundCAR": "string value"
}
```

### BoostMakeDeal


Expand Down
8 changes: 8 additions & 0 deletions node/impl/boost.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ func (sm *BoostAPI) BoostIndexerAnnounceLatestHttp(ctx context.Context, announce
return sm.IndexProvider.IndexerAnnounceLatestHttp(ctx, announceUrls)
}

func (sm *BoostAPI) BoostIndexerAnnounceDealRemoved(ctx context.Context, propCid cid.Cid) (cid.Cid, error) {
return sm.IndexProvider.AnnounceBoostDealRemoved(ctx, propCid)
}

func (sm *BoostAPI) BoostLegacyDealByProposalCid(ctx context.Context, propCid cid.Cid) (gfm_storagemarket.MinerDeal, error) {
return sm.LegacyStorageProvider.GetLocalDeal(propCid)
}

func (sm *BoostAPI) BoostOfflineDealWithData(ctx context.Context, dealUuid uuid.UUID, filePath string, delAfterImport bool) (*api.ProviderDealRejectionInfo, error) {
res, err := sm.StorageProvider.ImportOfflineDealData(ctx, dealUuid, filePath, delAfterImport)
return res, err
Expand Down