-
Notifications
You must be signed in to change notification settings - Fork 17
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
Refactor transport part 1 #324
Refactor transport part 1 #324
Conversation
Proposed path forward: get unit tests outside the transport passing, comment out transport tests for now, fix transport code in a subsequent PR. |
So: I'm asking @rvagg and maybe @dirkmc or @willscott to look at the code outside the transport layer with an unfortunate promise for the moment that the code "just works" by way of the integration tests, understanding the merge is to V2, not to master, and there will be subsequence prs before release. (though to be fair there will be additional changes made to the transport boundary for the events handlers. |
Things I am most interested in review on:
|
channels/channel_state.go
Outdated
decoder, _ := c.voucherDecoder(encoded.Type) | ||
encodable, _ := decoder.DecodeFromCbor(encoded.Voucher.Raw) | ||
vouchers = append(vouchers, encodable.(datatransfer.Voucher)) | ||
voucher := encodable.(datatransfer.Voucher) | ||
c.decodedVouchers[0] = &voucher |
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.
c.decodedVouchers[0] = &voucher | |
c.decodedVouchers[i] = &voucher |
looks like a copypasta bug?
log.Infof("sending open channel to %s to restart channel %s", requestTo, chid) | ||
if err := m.transport.OpenChannel(ctx, requestTo, chid, cidlink.Link{Cid: baseCid}, selector, channel, req); err != nil { | ||
monitoredChan := m.channelMonitor.AddChannel(chid, channel.IsPull()) | ||
log.Infof("sending push restart channel to %s for channel %s", requestTo, chid) |
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.
log.Infof("sending push restart channel to %s for channel %s", requestTo, chid) | |
log.Infof("sending restart channel to %s for channel %s", requestTo, chid) |
OK, so we're going with the slightly odd
|
27daa3b
to
ab05cba
Compare
@rvagg OK I've modified my interfaces significantly, based on your feedback. I still have a kind of "multi-command" in the form of UpdateChannel, but all the individual methods are also here. Would love your feedback. Also, the transport code should be generally easier to comprehend now. |
Codecov Report
@@ Coverage Diff @@
## v2 #324 +/- ##
=====================================
Coverage ? 54.77%
=====================================
Files ? 26
Lines ? 2817
Branches ? 0
=====================================
Hits ? 1543
Misses ? 1095
Partials ? 179 |
// we aren't able to send the message to the peer because the channel | ||
// is already in an error state, which is probably because of connection | ||
// issues, so if we cant send the message just log a warning. | ||
// Close transfport and try to send a cancel message to the remote peer. |
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.
// Close transfport and try to send a cancel message to the remote peer. | |
// Close transport and try to send a cancel message to the remote peer. |
testutil/faketransport.go
Outdated
@@ -74,22 +129,11 @@ func (ft *FakeTransport) SetEventHandler(events datatransfer.EventsHandler) erro | |||
return ft.SetEventHandlerErr | |||
} | |||
|
|||
// Shutdownc loses a this transport |
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.
// Shutdownc loses a this transport | |
// Shutdown loses a this transport |
Nice. I haven't quite gone thoroughly through the graphsync bits yet, lots of detail there. But the API is nicer and much more direct. Two questions:
|
b7c9d9e
to
1076301
Compare
@@ -399,7 +399,10 @@ func (m *manager) CloseDataTransferChannel(ctx context.Context, chid datatransfe | |||
)) | |||
defer span.End() | |||
// Close the channel on the local transport | |||
err = m.transport.CloseChannel(ctx, chid) | |||
err = m.transport.UpdateChannel(ctx, chid, datatransfer.ChannelUpdate{ | |||
Paused: chst.Status().IsResponderPaused(), |
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.
yeah, this is slightly awkward isn't it? as long as we have access to the channel status this then it's probably not the worst thing
you could make it an enum with 3 values: pause, unpause (resume?), continue - where the latter is "just keep on doing what you were doing".
1076301
to
7fa9bb2
Compare
6b581f2
to
7fa9bb2
Compare
* refactor(transport): move libp2p message layer into transport * refactor(graphsync): cleanup channel state tracking * refactor(dtchannel): extract dtchannel to package * test(impl): get remaining tests passing * refactor(transport): much simpler interface * style(lint): fix imports * refactor(transport): remote unneccesary methods * fix(rebase): fix errors after rebase
* refactor(transport): move libp2p message layer into transport * refactor(graphsync): cleanup channel state tracking * refactor(dtchannel): extract dtchannel to package * test(impl): get remaining tests passing * refactor(transport): much simpler interface * style(lint): fix imports * refactor(transport): remote unneccesary methods * fix(rebase): fix errors after rebase
* refactor(transport): move libp2p message layer into transport * refactor(graphsync): cleanup channel state tracking * refactor(dtchannel): extract dtchannel to package * test(impl): get remaining tests passing * refactor(transport): much simpler interface * style(lint): fix imports * refactor(transport): remote unneccesary methods * fix(rebase): fix errors after rebase
Goals
Well, I got to passing integration tests with the messaging layer underneath the transport. I'm not feeling done at all yet, truthfully. The question now is whether to try to get all tests passing and merge the changeset, or push for something closer to what I think makes sense before we go forward.
The biggest issue at the moment is that the "dtChannel" struct, which grew sort of like a frankenstein to begin with, is even more of a frankenstein now. I think I need to dig into refactoring this. The whole of the transport code is very messy. While I can certainly finish off the unit tests, I don't know what value we get from unit testing some very rough code.