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

Client should stop polling provider for deal acceptance after (deal start epoch + grace period) has elapsed #503

Closed
dirkmc opened this issue Mar 5, 2021 · 1 comment · Fixed by #516
Assignees
Labels
x/ignite Issues and PRs being tracked by Team Ignite at Protocol Labs

Comments

@dirkmc
Copy link
Contributor

dirkmc commented Mar 5, 2021

Description

When making a storage deal, once the data has been successfully transferred to the provider, the client polls the provider to check on the state of the deal until the deal has been published:

// CheckForDealAcceptance is run until the deal is sealed and published by the provider, or errors
func CheckForDealAcceptance(ctx fsm.Context, environment ClientDealEnvironment, deal storagemarket.ClientDeal) error {
dealState, err := environment.GetProviderDealState(ctx.Context(), deal.ProposalCid)
if err != nil {
log.Warnf("error when querying provider deal state: %w", err) // TODO: at what point do we fail the deal?
return waitAgain(ctx, environment, true, storagemarket.StorageDealUnknown)
}
if isFailed(dealState.State) {
return ctx.Trigger(storagemarket.ClientEventDealRejected, dealState.State, dealState.Message)
}
if isAccepted(dealState.State) {
if *dealState.ProposalCid != deal.ProposalCid {
return ctx.Trigger(storagemarket.ClientEventResponseDealDidNotMatch, *dealState.ProposalCid, deal.ProposalCid)
}
return ctx.Trigger(storagemarket.ClientEventDealAccepted, dealState.PublishCid)
}
return waitAgain(ctx, environment, false, dealState.State)
}
func waitAgain(ctx fsm.Context, environment ClientDealEnvironment, pollError bool, providerState storagemarket.StorageDealStatus) error {
t := time.NewTimer(environment.PollingInterval())
go func() {
select {
case <-t.C:
_ = ctx.Trigger(storagemarket.ClientEventWaitForDealState, pollError, providerState)
case <-ctx.Context().Done():
t.Stop()
return
}
}()
return nil
}

If there is an error polling the provider, the client waits for 30 seconds then tries again.

const DefaultPollingInterval = 30 * time.Second

If there is no error but the deal hasn't been accepted yet, the client also waits for 30 seconds then tries again.

Currently there is no upper bound on the number of retries.

Proposed solution

Keep polling until the deal proposal start epoch has been reached (plus 10 epochs).
At that point, fail the deal.

Increase polling interval to 5s (at the moment it's set to 1s in lotus)

@s0nik42
Copy link

s0nik42 commented Mar 5, 2021

Hi @dirkmc , Does the maximum number of error is also going to work for offline deals ?

@aarshkshah1992 aarshkshah1992 self-assigned this Mar 25, 2021
@dirkmc dirkmc added the x/ignite Issues and PRs being tracked by Team Ignite at Protocol Labs label Mar 25, 2021
@aarshkshah1992 aarshkshah1992 changed the title Add configurable max errors waiting for deal acceptance Client should stop polling provider for deal acceptance after (deal start epoch + grace period) has elapsed Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x/ignite Issues and PRs being tracked by Team Ignite at Protocol Labs
Projects
None yet
3 participants