From 96787ae6aa2684bb5c3f80973aa5e1804e212a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Tue, 3 Mar 2020 00:49:03 +0100 Subject: [PATCH] Created networking flow (markdown) --- networking-flow.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 networking-flow.md 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)