libp2p / specs

Technical specifications for the libp2p networking stack
https://libp2p.io
1.58k stars 275 forks source link

Add a Stream Migration spec #406

Open MarcoPolo opened 2 years ago

MarcoPolo commented 2 years ago

Initial pass at creating a spec for https://github.com/libp2p/specs/issues/328. I'll start a PoC as well to start fleshing out some of the ideas and check my understanding.

MarcoPolo commented 2 years ago

r? @marten-seemann for the first pass, I'll tag more folks as this progresses. (also I don't think I have permissions to add reviewers to the PR).

MarcoPolo commented 2 years ago

I’m wondering if each side should use their own namespace for streams, or if they should share a namespace (e.g. by say that client/server use even/odd stream IDs). Maybe then it would be possible to migrate streams that the peer initiated (is this even desireable?).

Can we rely on the underlying stream to give us a stream ID we can use for identifying streams?

What do you mean by migrating streams that the peer initiated? If I'm migrating a stream from a connection a remote peer started to a connection I started should that matter? I'm just changing how the bytes are getting there but everything else should be the same? Maybe there's something I'm missing here.

marten-seemann commented 2 years ago

Can we rely on the underlying stream to give us a stream ID we can use for identifying streams?

Probably not. While stream IDs are unique for every, they're not across muxers. It's probably easier if we introduce a new ID here.

What do you mean by migrating streams that the peer initiated? If I'm migrating a stream from a connection a remote peer started to a connection I started should that matter? I'm just changing how the bytes are getting there but everything else should be the same?

Maybe I'm just confused by the word "initiator" here. Do we mean the initiator of the connection or the initiator of the stream?

MarcoPolo commented 2 years ago

I think this finally clicked for me yesterday. The stream migration protocol is a prefix on top of another protocol. That’s how you can send the identify this stream as id=A message. I’ll update the spec on Monday.