-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Survey applicable functions in libp2p #2
Comments
Ok. I'll work on it through the next few days. |
libp2p-rsCore interfacestransportsAn interface ( swarmDefines how to send data to a external node or respond to an incoming connection (by implementing let mut swarm = Swarm::new(transport, behaviour, local_peer_id);
swarm.listen_on("/ip4/0.0.0.0/tcp/0".parse::<Multiaddr>()); application-level protocols
encryption schemesnoise protocol (DH key exchange) stream muxers
Supported asynchronous environments
Node representation
|
It seems we need to implement a peer-finding protocol on the application-level, for I couldn't find a proper module in the libp2p. |
As I wrote above, libp2p has several modules with different roles. In this comment, I introduce two high-level modules, FloodSub and Kademlia, and explain how they are and will be used throughout our project. KademliaKademlia dynamic hash table (DHT) with its own protocol is a way to store data or resources over a p2p network and retrieve them as needed. It's core idea was introduced in 2002, in this paper. Each network node that obeys the Kademlia protocol fills its DHT with other peers' addresses. It keeps almost all of its nearest peers in its DHT but smaller portion of its farthest peers. For example, a node keeps Although Kademlia protocol supports storing and retrieving hashable data, those features are none of our interest and won't be used in our project. FloodSubFloodSub is an implementation of PubSub(Publish & Subscribe model). It is named so because it's strategy to pass a message is to flood the network with the message (every node just forwards or broadcasts received messages). A message is related with one or more topics, and subscribers of a specific topic receive messages related with that topic. When a publisher creates a message, it assigns the message with several topics and broadcast it to a group of nodes called FloodSub neighbors. IntegrationsSince Kademlia doesn't support initial launch of the network and bootstrapping of a node, initial connections should be made manually for a newly joined node. This is implemented in #41, and will be merged once reviewed. FloodSub doesn't mention how to discover peers and maintain the connections between them. Kademlia will be used to provide those functions. I'll maintain the group of FloodSub neighbors as the same as the group of Kademlia These two modules emit events to notify the upper layer that they did important operations or encountered important network events. These emitted events are the major interfaces libp2p offers. They will be captured by the background task spawned by the network instance, Plan for Implementing Public InterfacesThe following is the public interfaces of an authorized network. #[async_trait]
pub trait AuthorizedNetwork {
/// Joins the network with an authorized identity.
async fn new([OMITTED]) -> Result<Self, String> where Self: Sized;
/// Broadcasts a message to the network, after signed by the key given to this instance.
async fn broadcast(&self, message: &[u8]) -> Result<BroadcastToken, String>;
/// Stops a currently broadcasting message.
async fn stop_broadcast(&self, token: BroadcastToken) -> Result<(), String>;
/// Gets the current status of a broadcasting message.
async fn get_broadcast_status(&self, token: BroadcastToken) -> Result<BroadcastStatus, String>;
/// Creates a receiver for every message broadcast to the network, except the one sent by this instance.
async fn create_recv_queue(&self) -> Result<broadcast::Receiver<Vec<u8>>, ()>;
/// Provides the estimated list of live nodes that are eligible and identified by their public keys.
async fn get_live_list(&self) -> Result<Vec<PublicKey>, ()>;
} Currently we have four unimplemented public interfaces ( broadcastI expect it to be easy to implement, since FloodSub does the job. stop_broadcastI'll add two configurable parameters; one for the time interval between broadcast messages and the other for the timeout that specifies when to stop broadcasting the same message. get_broadcast_statusThis feature can't be implemented using FloodSub functions. Instead, I'll make every node dial directly to the message sender, once it receives a message, to notify the sender that it received the message successfully. The sender will collect this information to provide broadcast status. The way to notify the sender is subject to change. get_live_listThis will be implemented based on the broadcasting logic. Every node will regularly broadcast an "alive" message with some interval and collect the "alive" messages from other nodes to maintain the live list. |
Why don't we just assume the fully connected network? I guess we won't have that many validators, so having a network structure such as Kademlia is a little overkill? |
@posgnu How many validators do you assume? Simperby is a general solution with its own consensus mechanism. I think it should be easily scalable to the maximum number of nodes assumed in the consensus specs (I guess up to several hundred ~ one thousand). Many of the nodes might delegate their voting power to others and go offline, but we should assume the worst condition. |
We need a brief overview of the functionality of the library, which should be enough to finalize the interface of networking module
The text was updated successfully, but these errors were encountered: