haskell-distributed / network-transport-tcp

TCP Realisation of Network.Transport
http://haskell-distributed.github.com
BSD 3-Clause "New" or "Revised" License
30 stars 27 forks source link

Protocol versioning (feature request with potential implementation) #55

Closed avieth closed 7 years ago

avieth commented 7 years ago

A candidate implementation of protocol versioning. Here's how it works:

Versionless part of the protocol:

If B accepts the version number, then the rest of the interaction proceeds according to that version.

Currently there is only version 0x00000000. Any connection with a different version number will be rejected as unsupported, and any rejected connection attempt will abandoned because this version of nt-tcp supports only 0x00000000.

It's important to note that there's minimal performance penalty for the typical Cloud Haskell use case, where every peer runs the same version. The versionless part of the protocol is optimistic: the connecting peer assumes its peer will be able to handle its version, and extra round trips are imposed only if the peer needs a downgrade/upgrade.

Thoughts?

avieth commented 7 years ago

followed by a Word32 giving the length of remaining data (presumably version-specific handshake data).

There would have to be a sensible maximum length here.

avieth commented 7 years ago

Is there a multi-part version scheme here or not?

No decision about the versioning scheme has been made, only the size of the version identifier (32 bits).

Should we start from version 0? We're already changing it! Perhaps clearer to call the new version v1.

Doesn't matter to me. How about we do multi-part and go with 0x00000001 (or 0.0.0.1).

I'm slightly unclear if certain things are being moved around or also changed. Might be clearer if we split the patch in two: first moves things around, second changes behaviour.

Yes there's a lot of movement. I'll split it up into 2 commits.

avieth commented 7 years ago

@dcoutts 6fbb642bb567ba1b0930b676dbd779764175182f is just code movement, 2ba08264b9cb8c615e5b9993cdf4fc3d5a2c9506 is the actual versioning implementation.

avieth commented 7 years ago

Included the commit from #60 in here to make the tests pass.