Skip to content

Single graphsync error causes deal to fail #156

@dirkmc

Description

@dirkmc

Background

go-fil-markets assumes that Disconnect is only fired when several retries have been attempted, so on the client side it fails the deal when the Disconnect event is fired (on the provider side it waits for the client to reconnect).

In most places in the go-data-transfer code, the Disconnect event is only fired when SendMessage fails, and SendMessage only fails after attempting to retry the message send several times.

if err := m.dataTransferNetwork.SendMessage(ctx, chst.OtherPeer(), updateRequest); err != nil {
err = fmt.Errorf("Unable to send request: %w", err)
_ = m.OnRequestDisconnected(ctx, channelID)
return err
}

However when there is an error sending data with graphsync (eg because the connection went down), go-data-transfer fires the Disconnect event:

func (t *Transport) gsNetworkErrorListener(p peer.ID, request graphsync.RequestData, err error) {
t.dataLock.Lock()
defer t.dataLock.Unlock()
chid, ok := t.graphsyncRequestMap[graphsyncKey{request.ID(), p}]
if ok {
err := t.events.OnRequestDisconnected(context.TODO(), chid)
if err != nil {
log.Error(err)
}
}
}

When go-fil-markets sees the Disconnect event it immediately fails the deal.

Currently for push channels (the local node initiated a channel to send data to the remote peer), the push channel monitor will automatically attempt to send a "restart" message when it sees a data-transfer error:

case datatransfer.Error:
// If there's an error, attempt to restart the channel
log.Debugf("%s: data transfer error, restarting", mc.chid)
go mc.restartChannel()

However when go-fil-markets receives an Error event from go-data-transfer it immediately aborts the transfer.

Proposed Solution

When there is an error sending data with graphsync, fire a new SendError event.
In the push channel monitor, listen for the SendError event and respond by restarting the push channel.

More detail on the proposed solution: #160

Metadata

Metadata

Assignees

No one assigned

    Labels

    x/igniteIssues and PRs being tracked by Team Ignite at Protocol Labs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions