Skip to content

[Pre2P] Refine the P2P module listening and IO behaviour #86

@Olshansk

Description

@Olshansk

Objective

Implement and test RainTree's redundancy layer on top of the Pre2P module.

Origin Document

The Pocket Network V1 P2P Specification, supported by this explanation of RainTree is partially implemented in the pre2p/raintree branch atop the Pre2P module at the time of creating this issue.

While #80 is close to being done, #85 was opened to implement the redundancy layer.

Per offline discussions within the core team, we have decided to migrate Pre2P module to be the primary P2P module but transfer all the IO learnings from P2P` atop of it. The existing implementation can be found here: milestone/v1-prototype...integration/module/p2p-simplified-over-9000.

However, there are some major missing components which need to be added per a message from @derrandz:

Listening and IO behavior in Pre2P has consequences:

1. We accept connections sequentially, and we handle them in the same way, no async handling (not suitable for our use case)
2. We read off of connections with the expectation that the sender/writer will immediately close once he's done sending/that the sender is doing fire and dump style of communication (not connection pooling logic atm)

These observations mean:

we won't be able to achieve graceful shutdown with open connections, nor accept incoming connections concurrently or achieve ACK and waiting on ACKs behavior. (and make e2e tests difficult to write)

You can say that those were the main difference between P2P (albeit the approaches are different), as p2p does the following:

1. P2P Pools connections as default behavior and allows for graceful shutdowns.
2. P2P offers functionality to fire and forget with the Write method if you don't need the "connection pool". Send will pool or use a pooled connection. (e.g: the broadcast relies on Write)

The highlighted points are crucial behaviors that the p2p module has to have to allow for handshakes, sending messages and expecting ACKs (or syncing in the future) 

Goals

Deliverables

  • Non-tangible deliverables
    • Transfer learnings from the initial P2P implementation to Pre2P
    • Identify and describe missing gaps in the Pre2P implementation when it comms IO and connection pooling in this PR
  • List out the features which need to be transferred offered (e.g. P2P pooling, async message handling) and the difficulty of adding it to Pre2P
  • Implement the list of features above
  • Update the README.md (to be added in the pre2p/raintree soon) describing the added / modified code layout of Pre2P module with the new modifications

Testing Methodology

  1. Use make test_pre2p to run existing tests
  2. Update the test suite in raintree_utils_test.go and add raintree_redundancy_layer_test.go int he same package with new tests
  3. [Optional] Use LocalNet as described in docs/development/README.md
  4. [Optional] Using Telemetry (if ready) to validate the results from (2)

Non-goals

  • Scaling LocalNet to many nodes
  • Resolving tech debt or optimizing existing code
  • Replacing P2P with Pre2P

Creator: @Olshansk
Co-Owners: @derrandz

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreCore infrastructure - protocol relatedp2pP2P specific changes

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions