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
Loading
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
Loading
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
Loading
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
Loading
Non-goals / Non-deliverables
Integrating additional routers (e.g. BackgroundRouter)
General issue deliverables
Testing Methodology
Creator : @bryanchriswhite
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 --> p2phclassDiagram 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 PocketEnvelopeGoals
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 --> p2phclassDiagram 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 PocketEnvelopeNonceDeduperto the P2P moduleNonceproto field fromRainTreeMessagetoPocketEnvelopeNon-goals / Non-deliverables
BackgroundRouter)General issue deliverables
Testing Methodology
make test_allLocalNetis still functioning correctly by following the instructions at docs/development/README.mdk8s LocalNetis still functioning correctly by following the instructions hereCreator: @bryanchriswhite