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

p2p/protocols: devp2p protocol abstraction #2959

Closed
wants to merge 2 commits into from

Conversation

zelig
Copy link
Contributor

@zelig zelig commented Aug 29, 2016

Package protocols is an extension to p2p. It offers a user friendly simple way to define
devp2p subprotocols by abstracting away code that implementations would typically use.

The package provides a standard protocol peer object of type protocols.Peer initialised from
a p2p.Peer, a p2p.MsgReadWriter (the arguments passed to p2p.Protocol#Run
and a protocols.CodeMap.

Allowing the p2p.Protocol#Run function to construct this peer allows passing it to arbitrary
service instances sitting on peer connections. These service instances can encapsulate vertical slices
of business logic without duplicating code related to protocol communication.

*    registering multiple handler callbacks for incoming messages
*    automate assigments of code indexes to messages
*    automate RLP decoding/encoding based on reflecting
*    provide the forever loop to read incoming messages
*    standardise error handling related to communication
*    TODO: automatic generation of wire protocol specification for peers

see the possibly obsolete #2254 for the peer management/connectivity related aspect)

The PR includes p2p/testing subpackage that provides a powerful framework to test
fairly complex subprotocol message exchanges in a multipeer session
The test for p2p/protocols demonstrates how to use this subpackage.

@zelig zelig self-assigned this Aug 29, 2016
@robotally
Copy link

robotally commented Aug 29, 2016

Vote Count Reviewers
👍 0
👎 0

Updated: Tue Sep 13 12:01:43 UTC 2016

@GitCop
Copy link

GitCop commented Sep 13, 2016

Thank you for your contribution! Your commits seem to not adhere to the repository coding standards

  • Commit: f29201b7660ad4d6cd1f8b3945987b77b6c95a24
    • Your commit message body contains a line that is longer than 72 characters

Please check the contribution guidelines for more details.


This message was auto-generated by https://gitcop.com

@zelig zelig added review and removed in progress labels Sep 13, 2016
@zelig
Copy link
Contributor Author

zelig commented Sep 13, 2016

@fjl I implemented pretty much everything you suggested and more

  • does not depend on errs package which can now be removed (noone uses it)
  • std protocol and Node-like service constructor eliminated
  • peerPool eliminated
  • composition-based use via the Peer#Run function
  • CopeMap-based calculation
  • added Handshake call beside Register for much nicer handling of Handshakes
  • major improvement of p2p/testing supporting mulltipeer sessions with parallel messages
  • Disconnect terminates the read loop directly in testing so easy to implement Expect or Disconnect
  • ...

@GitCop
Copy link

GitCop commented Oct 2, 2016

Thank you for your contribution! Your commits seem to not adhere to the repository coding standards

  • Commit: ed6a4c64aab842f62e02dc3dc9a6341c854a3b39
    • Your commit message body contains a line that is longer than 72 characters

Please check the contribution guidelines for more details.


This message was auto-generated by https://gitcop.com

Package protocols is an extension to p2p. It offers a user friendly simple way to define
devp2p subprotocols by abstracting away code that implementations would typically use.

The package provides a standard protocol peer object of type protocols.Peer initialised from
a p2p.Peer, a p2p.MsgReadWriter (the arguments passed to p2p.Protocol#Run
and a protocols.CodeMap.

Allowing the p2p.Protocol#Run function to construct this peer allows passing it to arbitrary
service instances sitting on peer connections. These service instances can encapsulate vertical slices
of business logic without duplicating code related to protocol communication.

*    registering multiple handler callbacks for incoming messages
*    automate assigments of code indexes to messages
*    automate RLP decoding/encoding based on reflecting
*    provide the forever loop to read incoming messages
*    standardise error handling related to communication
*    TODO: automatic generation of wire protocol specification for peers

The test demonstrates the use of protocols/testing package for testing protocols

see the possibly obsolete #2254 for the peer management/connectivity related aspect)
@GitCop
Copy link

GitCop commented Oct 2, 2016

Thank you for your contribution! Your commits seem to not adhere to the repository coding standards

  • Commit: 23973c9
    • Your commit message body contains a line that is longer than 72 characters

Please check the contribution guidelines for more details.


This message was auto-generated by https://gitcop.com

@zelig zelig closed this Nov 29, 2016
@zelig zelig deleted the std_protocol branch November 29, 2016 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants