-
Notifications
You must be signed in to change notification settings - Fork 59
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
Dynamic Retrieval Pricing #542
Conversation
Codecov Report
@@ Coverage Diff @@
## master #542 +/- ##
==========================================
- Coverage 65.77% 65.63% -0.14%
==========================================
Files 56 56
Lines 3634 3750 +116
==========================================
+ Hits 2390 2461 +71
- Misses 1009 1039 +30
- Partials 235 250 +15
Continue to review full report at Codecov.
|
4a61fc5
to
8bd6d00
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test coverage is really nice 👍
@@ -37,32 +37,522 @@ import ( | |||
tut "github.com/filecoin-project/go-fil-markets/shared_testutil" | |||
) | |||
|
|||
func TestDynamicPricing(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love how thorough this test is 👍 👍
expectedUnsealPrice: expectedUnsealPrice, | ||
}, | ||
|
||
{name: "When PieceCID is not provided, prefer a piece for which an unsealed sector already exists and price it accordingly", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍
Co-authored-by: raulk <[email protected]> Co-authored-by: dirkmc <[email protected]>
Co-authored-by: dirkmc <[email protected]>
@dirkmc I've fixed a bug in commit |
@aarshkshah1992 Mind updating this PR's description with an explanation of what has been done concretely in this module (as part of the linked Lotus side PR) + what's left, so that the communityi can follow? Do we need to add more test coverage here? |
Looks good, thanks Aarsh 👍 Before we merge I'd like to do some real world testing, for correctness and also to make sure that it's performant. |
// PricingInput provides input parameters required to price a retrieval deal. | ||
type PricingInput struct { | ||
// PayloadCID is the cid of the payload to retrieve. | ||
PayloadCID cid.Cid | ||
// PieceCID is the cid of the Piece from which the Payload will be retrieved. | ||
PieceCID cid.Cid | ||
// PieceSize is the size of the Piece from which the payload will be retrieved. | ||
PieceSize abi.UnpaddedPieceSize | ||
// Client is the peerID of the retrieval client. | ||
Client peer.ID | ||
// VerifiedDeal is true if there exists a verified storage deal for the PayloadCID. | ||
VerifiedDeal bool | ||
// Unsealed is true if there exists an unsealed sector from which we can retrieve the given payload. | ||
Unsealed bool | ||
// CurrentAsk is the current configured ask in the ask-store. | ||
CurrentAsk Ask | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
( I am well aware I am commenting on an old, merged PR )
@aarshkshah1992 @hannahhoward @willscott was it a deliberate decision to exclude the client-provided selector in this structure, or just an omission? Even if we do not have the tools for miners to interpret/decide on a selector-driven partial-retrieval, the structure is being exposed to 3rd party tools. It is probably prudent to provide all the information available from the get-go, instead of adding it later on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An extra nit regarding the title-comment:
If the Miner has multiple Sector files containing the required retrieval payload AND the client hasn't mandated that we retrieve the payload from a specific Piece,
A specific deal PayloadCID
(root-dag) + PieceSize
will always invariably correspond to an identical PieceCID
. That is - if a deal is stored in multiple sectors, some sealed and some unsealed, a PieceCID
can not differentiate among them: it will be identical among them all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never too late to provide useful feedback! ;-)
Re: including the selector in the pricing function input: how useful would this be? The function can't evaluate the selector against the data, and it can't really derive anything useful from it intrinsically AFAIK.
If it's to symbolise that a partial retrieval is being performed, for pricing purposes, the price-per-byte formulation of the quote already decouples the final price from the actual data being selected. We could pass a "partial retrieval = true/false" flag, but it's not possible to calculate it correctly because the selector could be selecting the entire deal.
Re: extensibility/completeness, it's non-invasive to add a JSON field in the future if we do decide we want this for some reason. But until there's a standardised, canonical text representation for selectors, I don't think it's practical to even consider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A specific deal PayloadCID (root-dag) + PieceSize will always invariably correspond to an identical PieceCID. That is - if a deal is stored in multiple sectors, some sealed and some unsealed, a PieceCID can not differentiate among them: it will be identical among them all.
If there's an unsealed copy, we always select the unsealed copy as input to the pricing function, and as the source of the retrieval.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raulk right, I was specifically questioning this part of the sentence:
the client hasn't mandated that we retrieve the payload from a specific Piece
There is no way for a client to signal "I want to retrieve from this physical piece" via the struct in question: they all have the same PieceCid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, what @aarshkshah1992 was trying to get to is that if "universal retrieval" is enabled (such that clients don't need to specify the PieceCID they want to retrieve a given PayloadCID from), and there are multiple PieceCIDs that contain that PayloadCID, we prefer the deal that's unsealed, should there be one. I don't think any of that implies that the client gets to choose the sector, or concrete physical piece within a sector.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But until there's a standardized, canonical text representation for selectors, I don't think it's practical to even consider.
The reason I brought this up is that the selector is already exposed in a standard-ish encoded-cbor representation via the RetrievalFilter
codepath: https://github.com/filecoin-project/lotus/blob/v1.11.0-rc2/markets/dealfilter/cli.go#L28-L62
I do not have a preference either way. Rather am raising the inconsistency of having two sets of external tools, one being fed the structure in this pr, the other being fed this: https://github.com/Murmuration-Labs/bitscreen/blob/master/testdata/retrieval_proposal.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pointer. Note that this isn't a filtering function, but rather a pricing function. It runs when the retrieval provider is asked for a quote. At that time, the selector is not available. So in terms of the data interface, the deal filter and the pricing function can't be symmetrical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It runs when the retrieval provider is asked for a quote. At that time, the selector is not available.
@raulk indeed you are correct: it is all commented out :cryingbear:
https://github.com/filecoin-project/go-fil-markets/blob/v1.6.0-rc1/retrievalmarket/types.go#L158-L167
Markets PR for the Dynamic Retrieval Pricing feature. Please see the corresponding Lotus PR for the motivation behind this work.
Here is an explanation of the changes made in the Markets module to support Dynamic Retrieval Pricing:
Ask Store
to blanket price all Retrieval deals, we now call the Pricing function configured by Lotus with the following parameters and use the output of the function to price a retrieval deal:Introduces/Exports a "default pricing function" that Lotus can configure Markets to use for retrieval pricing. This pricing function:
If the Miner has multiple Sector files containing the required retrieval payload AND the client hasn't mandated that we retrieve the payload from a specific Piece, we will ALWAYS read the payload from an Unsealed Sector file and also price deals accordingly.
If the client wants to retrieve the payload from a specific Piece, the above logic still applies but we will only consider Sector files that have the Piece mandated by the user.