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

protocols/gossipsub: Move to stable futures #22

Merged

Conversation

mxinden
Copy link

@mxinden mxinden commented Jan 2, 2020

This moves the protocols/gossipsub crate to stable futures along the lines of libp2p#1328.

Let's get #21 in first and then follow up with this pull request.

Only the last 4 commits are relevant, the remainder is from merging libp2p#1328.

@AgeManning
Copy link
Member

Sounds good.

@AgeManning
Copy link
Member

Hey max.
I've created a new branch for updating gossipsub to stable futures gossip-stable-futures. I've merged the latest master in and am looking to include your modifications.

If you have the time, could you target this PR to the gossip-stable-futures branch, if not, let me know and I'll grab your commits, add them in and finish any extra work for the update.

@mxinden mxinden changed the base branch from gossipsub to gossip-stable-futures January 15, 2020 08:48
@mxinden
Copy link
Author

mxinden commented Jan 15, 2020

@AgeManning I am currently reworking this branch, given that quite a bit changed on the base branch since I opened it. Will force-push to this branch, given that there are no reviews on this pull request. Will keep you updated.

@mxinden mxinden force-pushed the gossipsub-stable-futures branch from 2f46275 to 3229a5c Compare January 15, 2020 10:51
@mxinden mxinden force-pushed the gossipsub-stable-futures branch from 3229a5c to 542b100 Compare January 15, 2020 11:08
@mxinden
Copy link
Author

mxinden commented Jan 15, 2020

@AgeManning please take a look.

@mxinden mxinden marked this pull request as ready for review January 15, 2020 11:09
return Poll::Ready(ProtocolsHandlerEvent::Custom(message));
}
Poll::Ready(Some(Err(e))) => {
// TODO: Should we really just close here? Not even log the error?
Copy link
Author

Choose a reason for hiding this comment

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

Open TODO.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should log the error, then close. This should potentially even be logged as an Err, as we probably should destroy the connection.
I had originally written this for interoperability with go and really didn't want to terminate connections. So the current version keeps running as long as we have one active (inbound or outbound) stream with the peer. If we lose the inbound stream, we probably should close the connection. What do you think?

Copy link
Author

Choose a reason for hiding this comment

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

If we lose the inbound stream, we probably should close the connection.

Are you suggesting to set self.keep_alive to false regardless of self.outboundstream being None or Some?

Copy link
Author

Choose a reason for hiding this comment

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

So we close the connection when closing an inbound stream fails, but we don't close the connection when receiving an error on an inbound substream when polling unless it will later on fail during closing of the inbound stream. That seems a bit strange, no?

Copy link
Member

Choose a reason for hiding this comment

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

I'm saying we should handle the error cases symmetrically for inbound/outbound substreams. On errors we can return ProtocolsHandlerEvent::close() or try to close the substream and return the error if closing the substream errors.

Currently, I have it that when we close one of them, the connection remains open unless both are closed. This favours connectivity on errors (if we can successfully close after an error). Maybe this makes it more resilient and we keep this logic?

Err(_) => {
return Err(io::Error::new(
Poll::Ready(Err(_)) => {
// TODO: Why do we not at least log the error (`_`)?
Copy link
Author

Choose a reason for hiding this comment

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

@AgeManning what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think we should log the error. I think the first time I wrote this I was trying to match the go-impl so was in a hurry.

Copy link
Member

@AgeManning AgeManning left a comment

Choose a reason for hiding this comment

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

Added a few comments. Let me know your thoughts.
Lets remove the todo's and merge this in if you are happy.

Err(_) => {
return Err(io::Error::new(
Poll::Ready(Err(_)) => {
// TODO: Why do we not at least log the error (`_`)?
Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think we should log the error. I think the first time I wrote this I was trying to match the go-impl so was in a hurry.

return Poll::Ready(ProtocolsHandlerEvent::Custom(message));
}
Poll::Ready(Some(Err(e))) => {
// TODO: Should we really just close here? Not even log the error?
Copy link
Member

Choose a reason for hiding this comment

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

I think we should log the error, then close. This should potentially even be logged as an Err, as we probably should destroy the connection.
I had originally written this for interoperability with go and really didn't want to terminate connections. So the current version keeps running as long as we have one active (inbound or outbound) stream with the peer. If we lose the inbound stream, we probably should close the connection. What do you think?

protocols/gossipsub/src/handler.rs Show resolved Hide resolved
@mxinden
Copy link
Author

mxinden commented Jan 22, 2020

@AgeManning as far as I can tell all comments are addressed.

In regards to the discussion when to close a connection:

I'm saying we should handle the error cases symmetrically for inbound/outbound substreams. On errors we can return ProtocolsHandlerEvent::close() or try to close the substream and return the error if closing the substream errors.

That sounds good to me. When only closing a connection on outbound errors,we might end up with a bunch of unidirectional connections.

I would defer whatever change we want to make to another pull request, as it is out of scope of stable-futures. What do you think?

@AgeManning
Copy link
Member

Sounds good to me.

Copy link
Member

@AgeManning AgeManning left a comment

Choose a reason for hiding this comment

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

Thanks for all the help!

@AgeManning AgeManning merged commit a9e19a5 into sigp:gossip-stable-futures Jan 23, 2020
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.

2 participants