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

Allow custom decisioning for a provider to decide retrieval deals. #269

Merged
merged 6 commits into from
Jun 9, 2020

Conversation

shannonwells
Copy link
Contributor

@shannonwells shannonwells commented Jun 5, 2020

Closes #268

  • Add a variadic func param to retrievalmarket's NewProvider func a la storagemarket
  • Add a configuration option generator func, DealDeciderOpt to generate a DeciderOpt func with the provided DealDecider func.
  • Deal acceptance is split up, inserting a "DealAwaitingAcceptance" state between "DealStatusNew" and "DealStatusAccepted"
  • New and updated tests for same.
  • Add or update integration test

@codecov-commenter
Copy link

codecov-commenter commented Jun 5, 2020

Codecov Report

Merging #269 into master will increase coverage by 0.77%.
The diff coverage is 90.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #269      +/-   ##
==========================================
+ Coverage   64.44%   65.20%   +0.77%     
==========================================
  Files          40       40              
  Lines        2289     2362      +73     
==========================================
+ Hits         1475     1540      +65     
- Misses        694      698       +4     
- Partials      120      124       +4     
Impacted Files Coverage Δ
...etrievalmarket/impl/providerstates/provider_fsm.go 85.72% <ø> (ø)
retrievalmarket/types.go 44.12% <ø> (ø)
retrievalmarket/impl/provider.go 71.60% <87.10%> (+0.69%) ⬆️
...ievalmarket/impl/providerstates/provider_states.go 73.41% <100.00%> (+2.82%) ⬆️
piecestore/piecestore.go 82.76% <0.00%> (+2.76%) ⬆️
retrievalmarket/impl/blockio/traverser.go 72.23% <0.00%> (+3.34%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2cd5ecc...867afdc. Read the comment docs.

// Stop stops handling incoming requests
func (p *provider) Stop() error {
func (p *Provider) Stop() error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this had to be exported similarly to storagemarket, so a decider func is possible

@shannonwells shannonwells changed the title Feat/add config opts #268 Allow custom decisioning for a provider to decide retrieval deals. Jun 5, 2020
@@ -189,6 +193,16 @@ func TestClientCanMakeDealWithProvider(t *testing.T) {
paramsV1: true,
selector: partialSelector,
unsealing: false},
{name: "succeeds when using a custom decider function",
decider: func(ctx context.Context, state retrievalmarket.ProviderDealState) (bool, string, error) {
Copy link
Contributor Author

@shannonwells shannonwells Jun 8, 2020

Choose a reason for hiding this comment

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

This quick and dirty integration test case is to minimize rebase conflicts for me, and will be properly set up in the PR for retrieval restart. See TODO comment below.

@@ -36,21 +38,33 @@ func ReceiveDeal(ctx fsm.Context, environment ProviderDealEnvironment, deal rm.P
}

// check that the deal parameters match our required parameters (or reject)
err = environment.CheckDealParams(dealProposal.PricePerByte, dealProposal.PaymentInterval, dealProposal.PaymentIntervalIncrease)
err = environment.CheckDealParams(dealProposal.PricePerByte,
Copy link
Contributor Author

@shannonwells shannonwells Jun 8, 2020

Choose a reason for hiding this comment

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

I was conflicted here between moving all decisioning to DecideOnDeal and leaving just the param check here. I decided an up front parameter check is okay here before the "meat" of decisioning happens, but I can be convinced otherwise.

@@ -119,22 +120,6 @@ func TestReceiveDeal(t *testing.T) {
require.NotEmpty(t, dealState.Message)
})

t.Run("response write error", func(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

write responses are moved down to the decisioning function; this test is moved there as well.

@@ -341,109 +326,113 @@ func TestProcessPayment(t *testing.T) {
})
}

type readBlockResponse struct {
Copy link
Contributor Author

@shannonwells shannonwells Jun 8, 2020

Choose a reason for hiding this comment

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

this and below ere exported to their own spot so they can be reused in related tests

@shannonwells shannonwells marked this pull request as ready for review June 8, 2020 18:29
Copy link
Collaborator

@hannahhoward hannahhoward left a comment

Choose a reason for hiding this comment

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

LGTM though I would like to understand why you made the Provider struct public.

type RetrievalProviderOption func(p *Provider)
type DealDecider func(ctx context.Context, state retrievalmarket.ProviderDealState) (bool, string, error)

type Provider struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did you decide to make this a public struct? I just want to make sure it's neccessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's similar to StorageMarket -- if you make it private you can't operate on (p Provider) to set a config option. StorageProviderOption and RetrievalProviderOption both take a (Storage|Retrieval)Provider.

@shannonwells shannonwells merged commit 095f786 into master Jun 9, 2020
@shannonwells shannonwells deleted the feat/add-config-opts-#268 branch June 9, 2020 00:17
@dirkmc dirkmc mentioned this pull request Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow custom decider function for retrieval deals
3 participants