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

fix: allow client to set fast-retrieval #1004

Merged
merged 5 commits into from
Nov 24, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 0 additions & 29 deletions api/api_full.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package api

import (
"context"
"encoding/json"
"fmt"
"time"

Expand Down Expand Up @@ -297,34 +296,6 @@ type MethodCall struct {
Error string
}

type StartDealParams struct {
Data *storagemarket.DataRef
Wallet address.Address
Miner address.Address
EpochPrice types.BigInt
MinBlocksDuration uint64
ProviderCollateral big.Int
DealStartEpoch abi.ChainEpoch
FastRetrieval bool
VerifiedDeal bool
}

func (s *StartDealParams) UnmarshalJSON(raw []byte) (err error) {
type sdpAlias StartDealParams

sdp := sdpAlias{
FastRetrieval: true,
}

if err := json.Unmarshal(raw, &sdp); err != nil {
return err
}

*s = StartDealParams(sdp)

return nil
}

type IpldObject struct {
Cid cid.Cid
Obj interface{}
Expand Down
Binary file modified build/openrpc/boost.json.gz
Binary file not shown.
10 changes: 8 additions & 2 deletions cmd/boost/deal_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ var dealFlags = []cli.Flag{
Required: true,
},
&cli.IntFlag{
Name: "start-epoch",
Usage: "start epoch by when the deal should be proved by provider on-chain",
Name: "start-epoch",
Usage: "start epoch by when the deal should be proved by provider on-chain",
DefaultText: "current chain head + 2 days",
},
&cli.IntFlag{
Expand All @@ -77,6 +77,11 @@ var dealFlags = []cli.Flag{
Usage: "whether the deal funds should come from verified client data-cap",
Value: true,
},
&cli.BoolFlag{
Name: "fast-retrieval",
Usage: "indicates that data should be available for fast retrieval",
Value: true,
},
&cli.StringFlag{
Name: "wallet",
Usage: "wallet address to be used to initiate the deal",
Expand Down Expand Up @@ -251,6 +256,7 @@ func dealCmdAction(cctx *cli.Context, isOnline bool) error {
DealDataRoot: rootCid,
IsOffline: !isOnline,
Transfer: transfer,
FastRetrieval: cctx.Bool("fast-retrieval"),
}

log.Debugw("about to submit deal proposal", "uuid", dealUuid.String())
Expand Down
9 changes: 6 additions & 3 deletions documentation/en/api-v1-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ Response:
"CheckpointAt": "0001-01-01T00:00:00Z",
"Err": "string value",
"Retry": "auto",
"NBytesReceived": 9
"NBytesReceived": 9,
"FastRetrieval": true
}
```

Expand Down Expand Up @@ -462,7 +463,8 @@ Response:
"CheckpointAt": "0001-01-01T00:00:00Z",
"Err": "string value",
"Retry": "auto",
"NBytesReceived": 9
"NBytesReceived": 9,
"FastRetrieval": true
}
```

Expand Down Expand Up @@ -506,7 +508,8 @@ Inputs:
"ClientID": "string value",
"Params": "Ynl0ZSBhcnJheQ==",
"Size": 42
}
},
"FastRetrieval": true
}
]
```
Expand Down
2 changes: 1 addition & 1 deletion indexprovider/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (w *Wrapper) AnnounceBoostDeal(ctx context.Context, pds *types.ProviderDeal
protocols := []metadata.Protocol{
&metadata.GraphsyncFilecoinV1{
PieceCID: pds.ClientDealProposal.Proposal.PieceCID,
FastRetrieval: true,
FastRetrieval: pds.FastRetrieval,
VerifiedDeal: pds.ClientDealProposal.Proposal.VerifiedDeal,
},
}
Expand Down
6 changes: 2 additions & 4 deletions storagemarket/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ func (p *Provider) ExecuteDeal(ctx context.Context, dp *types.DealParams, client
Transfer: dp.Transfer,
IsOffline: dp.IsOffline,
Retry: smtypes.DealRetryAuto,
FastRetrieval: dp.FastRetrieval,
}
// validate the deal proposal
if err := p.validateDealProposal(ds); err != nil {
Expand Down Expand Up @@ -586,10 +587,7 @@ func (p *Provider) AddPieceToSector(ctx context.Context, deal smtypes.ProviderDe
StartEpoch: deal.ClientDealProposal.Proposal.StartEpoch,
EndEpoch: deal.ClientDealProposal.Proposal.EndEpoch,
},
// Assume that it doesn't make sense for a miner not to keep an
// unsealed copy. TODO: Check that's a valid assumption.
//KeepUnsealed: deal.FastRetrieval,
KeepUnsealed: true,
KeepUnsealed: deal.FastRetrieval,
}

// Attempt to add the piece to a sector (repeatedly if necessary)
Expand Down
3 changes: 3 additions & 0 deletions storagemarket/types/deal_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ type ProviderDealState struct {

// NBytesReceived is the number of bytes Received for this deal
NBytesReceived int64

// Keep unsealed copy of the data
FastRetrieval bool
Comment on lines +62 to +63
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add some code to make sure the FastRetrieval flag gets written to / read from the database when the ProviderDealState is written to the DB

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add that part

}

func (d *ProviderDealState) String() string {
Expand Down
1 change: 1 addition & 0 deletions storagemarket/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ type DealParams struct {
ClientDealProposal market.ClientDealProposal
DealDataRoot cid.Cid
Transfer Transfer // Transfer params will be the zero value if this is an offline deal
FastRetrieval bool
}

type DealFilterParams struct {
Expand Down