diff --git a/networking-flow.md b/networking-flow.md new file mode 100644 index 0000000..7bf2d8d --- /dev/null +++ b/networking-flow.md @@ -0,0 +1,31 @@ +This is a collection of notes following networking related code in a beacon_node instance using the Nim libp2p implementation on Linux. + +beacon_chain/beacon_node.nim: + +- BeaconNode.start() waitsFor node.connectToNetwork() +- BeaconNode.connectToNetwork() awaits node.network.connectToNetwork(node.bootstrapNodes, node.bootstrapEnrs) + +beacon_chain/eth2_network.nim: + +- Eth2Node.connectToNetwork(seq[ENode], seq[enr.Record]) + - for each bootstrap ENR, calls Eth2Node.addKnownPeer() + - awaits Eth2Node.start() + +beacon_chain/libp2p_backend.nim: + +- Eth2Node.start() + - calls Eth2DiscoveryProtocol.open() + - calls Eth2DiscoveryProtocol.start() + - awaits Switch.start() and stores the resulting seq[Future[void]] in Eth2Node.libp2pTransportLoops; nothing further is done with those futures + - tracesAsyncErrors Eth2Node.runDiscoveryLoop() + +vendor/nim-libp2p/libp2p/switch.nim: + +- Switch.start() + - for each Switch.transports and each Switch.peerInfo awaits Transport.listen(MultiAddress, inner `handle` closure) + - returns a seq of these futures + +- Switch.start.handle(Connection) + - awaits Switch.upgradeIncoming(Connection) + - awaits Connection.close() + - awaits Switch.cleanupConn(Connection)