-
Notifications
You must be signed in to change notification settings - Fork 33
Closed
Description
Objective
Enable the P2P module to handle incoming messages from multiple router implementations simultaneously.
Origin Document
Currently, the message handling interaction between the P2P and the router looks like this:
flowchart LR
subgraph p2p[P2P Module]
subgraph rt[RainTree Router]
nd[Nonce Deduper]
rth[[`RainTreeMessage` Handler]]
end
p2ph[[`PocketEnvelope` message Handler]]
end
rth --> nd
rth --> p2ph
classDiagram
class RainTreeMessage {
<<protobuf>>
+Level uint32
+Data []byte
+Nonce uint64
}
class PocketEnvelope {
<<protobuf>>
+Content *anypb.Any
}
RainTreeMessage --* PocketEnvelope : serialized as `Data`
class P2PModule {
-handleNetworkData([]byte) error
-handleStream(stream libp2pNetwork.Stream)
-readStream(stream libp2pNetwork.Stream)
}
class RainTreeRouter {
+HandleNetworkData func([]byte) ([]byte, error)
}
RainTreeRouter --> P2PModule
P2PModule --> RainTreeRouter
RainTreeRouter --o RainTreeMessage
RainTreeRouter --* NonceDeduper
P2PModule --o PocketEnvelope
Goals
- Support handling message from multiple routers simultaneously
- Support message deduplication across all messages (i.e. not just raintree)
- Improve separation of concerns between P2P module and router(s)
Deliverable
flowchart LR
subgraph p2p[P2P Module]
subgraph rt[RainTree Router]
rth[[`RainTreeMessage` Handler]]
end
nd[Nonce Deduper]
p2ph[[`PocketEnvelope` message Handler]]
end
p2ph --> nd
rth --> p2ph
classDiagram
class RainTreeMessage {
<<protobuf>>
+Level uint32
+Data []byte
}
class PocketEnvelope {
<<protobuf>>
+Content *anypb.Any
+Nonce uint64
}
RainTreeMessage --* PocketEnvelope : serialized as `Data`
class P2PModule {
-handleAppData([]byte) error
}
class RainTreeRouter {
-appDataHandler RouterHandler
-handleRainTreeMsg([]byte) ([]byte, error)
-handleStream(stream libp2pNetwork.Stream)
-readStream(stream libp2pNetwork.Stream)
}
RainTreeRouter --> P2PModule : `appDataHandler` == `handleAppData`
RainTreeRouter --o RainTreeMessage
P2PModule --* NonceDeduper
P2PModule --o PocketEnvelope
- Move
NonceDeduperto the P2P module - Refactor message handling logic to flow in one direction (from the router towards the application)
- Move
Nonceproto field fromRainTreeMessagetoPocketEnvelope
Non-goals / Non-deliverables
- Integrating additional routers (e.g.
BackgroundRouter)
General issue deliverables
- Update the appropriate CHANGELOG(s)
- Update any relevant local/global README(s)
- Update relevant source code tree explanations
- Add or update any relevant or supporting mermaid diagrams
Testing Methodology
- All tests:
make test_all - LocalNet: verify a
LocalNetis still functioning correctly by following the instructions at docs/development/README.md - k8s LocalNet: verify a
k8s LocalNetis still functioning correctly by following the instructions here
Creator: @bryanchriswhite
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
p2pP2P specific changesP2P specific changes
Type
Projects
Status
Done