Skip to content

Commit

Permalink
doc: reflect bootnode changes
Browse files Browse the repository at this point in the history
  • Loading branch information
niklaslong committed Sep 16, 2021
1 parent d857a98 commit a9218bd
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 34 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ USAGE:
FLAGS:
-h, --help Prints help information
--is-bootnode Run the node as a bootnode (IP is hard coded in the protocol)
--is-miner Start mining blocks from this node
--no-jsonrpc Run the node without running the json rpc server
Expand Down
10 changes: 2 additions & 8 deletions network/documentation/concepts/network_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ snarkOS downloads, verifies, and stores the history of valid blocks and transact
## Peer Discovery

When a node joins the network for the first time, it needs to populate a list of active peers in the network.
In order to bootstrap peer discovery, snarkOS includes a set of optional bootnodes which provides an initial set of peers.
In order to bootstrap peer discovery, snarkOS includes a set of optional specialised beacon nodes. Once connected, these provide an initial set of peers which includes the address of a sync provider. The sync provider will supply the node with an initial sync of the chainstate.
To allow users flexibility, snarkOS provides allows users to configure the initial set of nodes in the configuration file,
or as a input via a command-line flag.

Expand All @@ -20,13 +20,7 @@ This processes starts by asking peers for more connected nodes in the network wi
followed by attempts to establish a connection with each newly discovered peer.

Upon success, snarkOS will store the new peer address to allow it to connect directly with this peer in the future,
without needing to use bootnodes to startup in the future.

#### Bootnodes

Bootnodes operate like other full nodes and serve as a public access point for all peers in the network.
Bootnodes are run by community members and bolster the network
by enabling new nodes to connect and participate in the network effortlessly.
without needing to use peer discovery nodes to startup in the future.

## Connecting to Peers

Expand Down
7 changes: 3 additions & 4 deletions network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ impl Config {
sync_provider_addresses: Vec<String>,
peer_sync_interval: Duration,
) -> Result<Self, NetworkError> {
// Convert the given bootnodes into socket addresses.

// Convert the given seeded nodes into socket addresses.
let beacons: Vec<SocketAddr> = beacon_addresses
.into_iter()
.flat_map(|addr| addr.parse().ok())
Expand Down Expand Up @@ -101,7 +100,7 @@ impl Config {
self.sync_providers.load_full()
}

/// Returns `true` if this node is a bootnode. Otherwise, returns `false`.
/// Returns `true` if this node is a sync provider node. Otherwise, returns `false`.
#[inline]
pub fn is_sync_provider(&self) -> bool {
matches!(self.node_type, NodeType::SyncProvider)
Expand All @@ -113,7 +112,7 @@ impl Config {
matches!(self.node_type, NodeType::Crawler)
}

/// Returns `true` if this node is a plain node. Otherwise, returns `false`.
/// Returns `true` if this node is a plain client node. Otherwise, returns `false`.
#[inline]
pub fn is_client(&self) -> bool {
matches!(self.node_type, NodeType::Client)
Expand Down
2 changes: 1 addition & 1 deletion network/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ impl Node {
// all of our connected peers anyways.

// The order of preference for the sync node is as follows:
// 1. Iterate (in declared order) through the sync_providers:
// 1. Iterate (in declared order) through the sync providers:
// a. Check if this node is connected to the specified sync provider in the peer book.
// b. Select the specified sync provider as the sync node if this node is connected to it.
// 2. If this node is not connected to any sync provider,
Expand Down
11 changes: 5 additions & 6 deletions network/src/peers/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ impl Node {
}
}

// Attempt to connect to a few random bootnodes if the node has no active
// connections or if it's a bootnode itself.
// Attempt to connect to a few random peer provider nodes if the node has no active
// connections or if it's a beacon itself.
if (!self.config.is_sync_provider() && self.peer_book.get_active_peer_count() == 0) || self.config.is_beacon() {
let random_beacons = self
.config
Expand Down Expand Up @@ -212,7 +212,6 @@ impl Node {
// Local address must be known by now.
let own_address = self.expect_local_addr();

// If this node is not a bootnode, attempt to satisfy the minimum number of peer connections.
let random_peers = {
trace!(
"Connecting to {} disconnected peers",
Expand All @@ -222,7 +221,7 @@ impl Node {
// Obtain the collection of disconnected peers.
let mut candidates = self.peer_book.disconnected_peers_snapshot();

// Bootnodes are connected to in a dedicated method.
// Peer discovery nodes are connected to in a dedicated method, so we exclude them here.
let beacons = self.config.beacons();
candidates.retain(|peer| peer.address != own_address && !beacons.contains(&peer.address));

Expand Down Expand Up @@ -263,7 +262,7 @@ impl Node {

/// Broadcasts a `GetPeers` message to all connected peers to request for more peers.
async fn broadcast_getpeers_requests(&self) {
// If the node is not a bootnode or a crawler, check if the request for peers is needed
// If the node is a client node, check if the request for peers is needed
// based on the number of active connections.
if self.config.is_client() {
// Fetch the number of connected and connecting peers.
Expand Down Expand Up @@ -327,7 +326,7 @@ impl Node {
.map(|peer| peer.address)
.collect();

// Bootnodes apply less strict filtering rules if the set is empty by falling back on
// Beacons apply less strict filtering rules if the set is empty by falling back on
// connected peers that may or may not be routable...
let peers = if self.config.is_beacon() && strictly_filtered_peers.is_empty() {
let filtered_peers: Vec<SocketAddr> = connected_peers
Expand Down
2 changes: 1 addition & 1 deletion network/tests/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ async fn handshake_timeout_initiator_side() {
};
let node = test_node(setup).await;

// the node should start connecting to all the configured bootnodes
// the node should start connecting to all the configured beacons.
wait_until!(3, node.peer_book.get_active_peer_count() != 0);

// but since they won't reply, it should drop them after the handshake deadline
Expand Down
2 changes: 1 addition & 1 deletion network/tests/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async fn beacon_peer_propagation() {
&& node_charlie.peer_book.get_active_peer_count() == 2
};

// Make sure B and C connect => bootnode propagates peers (without `is_routable` check in this
// Make sure B and C connect => becon propagates peers (without `is_routable` check in this
// case).
wait_until!(5, triangle_is_formed());
}
8 changes: 4 additions & 4 deletions network/tests/topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ async fn star_converges_to_mesh() {
..Default::default()
};

// A bootnode will be necessary at the center of the star for peers to get propagated.
// A beacon node will be necessary at the center of the star for peers to get propagated.
let hub_setup = TestSetup {
node_type: NodeType::Beacon,
..setup()
Expand All @@ -215,7 +215,7 @@ async fn star_converges_to_mesh() {
// Create the regular nodes.
let mut nodes = test_nodes(N - 1, setup).await;

// Insert the bootnode at the head of the list.
// Insert the beacon at the head of the list.
nodes.insert(0, test_node(hub_setup).await);

connect_nodes(&mut nodes, Topology::Star).await;
Expand All @@ -231,9 +231,9 @@ async fn star_converges_to_mesh() {
#[tokio::test(flavor = "multi_thread")]
async fn binary_star_contact() {
// Two initally separate star topologies subsequently connected by a single node connecting to
// their bootnodes.
// the peer discovery nodes at their center.

// Setup the bootnodes for each star topology.
// Setup the beacons for each star topology.
let beacon_setup = || TestSetup {
node_type: NodeType::Beacon,
consensus_setup: None,
Expand Down
5 changes: 3 additions & 2 deletions rpc/documentation/public_endpoints/getnetworkgraph.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Returns the network graph crawled by this node (if it is a bootnode).
Returns the network graph crawled by this node (if it is a crawler).

### Arguments

Expand All @@ -20,7 +20,8 @@ None
| `edges[i].source` | SocketAddr | One side of the crawled connection |
| `edges[i].target` | SocketAddr | The other side of the crawled connection |
| `vertices[i].addr` | SocketAddr | The recorded address of the crawled node |
| `vertices[i].is_bootnode` | bool | Indicates whether the node is a bootnode |
| `vertices[i].is_beacon` | bool | Indicates whether the node is a beacon |
| `vertices[i].is_sync_provider` | bool | Indicates whether the node is a sync provider |
| `vertices[i].degree_centrality` | u16 | The node's degree centrality, aka its connection count |
| `vertices[i].eigenvector_centrality` | f64 | The node's eigenvector centrality, indicates its relative importance in the network |
| `vertices[i].fiedler_value` | f64 | The node's fiedler value, can be used to partition the network graph |
Expand Down
2 changes: 1 addition & 1 deletion rpc/documentation/public_endpoints/getnodeinfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ None

| Parameter | Type | Description |
|:----------------:|:-------------:|:---------------------------------------------:|
| `is_bootnode` | bool | Flag indicating if the node is a bootnode |
| `node_type` | NodeType | Flag indicating if the node type |
| `is_miner` | bool | Flag indicating if the node is a miner |
| `is_syncing` | bool | Flag indicating if the node currently syncing |
| `launched` | timestamp | The timestamp of when the node was launched |
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/rpc_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub struct NodeInfo {
/// The configured listening address of the node.
pub listening_addr: SocketAddr,

/// Flag indicating if the node is a bootnode
/// Flag indicating if the node's type.
pub node_type: NodeType,

/// Flag indicating if the node is operating as a miner
Expand Down
2 changes: 1 addition & 1 deletion snarkos/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ impl CLI for ConfigCli {
const ABOUT: AboutType = "Run an Aleo node (include -h for more options)";
const FLAGS: &'static [FlagType] = &[
flag::NO_JSONRPC,
flag::IS_MINER,
flag::TRIM_STORAGE,
flag::VALIDATE_STORAGE,
flag::SQLITE,
Expand Down Expand Up @@ -477,7 +478,6 @@ impl CLI for ConfigCli {
"no-jsonrpc",
"export-canon-blocks",
"import-canon-blocks",
"is-bootnode",
"is-miner",
"ip",
"port",
Expand Down
5 changes: 2 additions & 3 deletions testing/src/network/topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ pub enum Topology {

/// Connects the nodes in a given `Topology`.
///
/// This function assumes the nodes have an established address but don't have their services
/// started yet, as it uses the bootnodes to establish the connections between nodes.
/// This function assumes the nodes have an established address.
///
/// When connecting in a `Star`, the first node in the `nodes` will be used as the hub.
pub async fn connect_nodes(nodes: &mut Vec<Node>, topology: Topology) {
Expand All @@ -52,7 +51,7 @@ pub async fn connect_nodes(nodes: &mut Vec<Node>, topology: Topology) {
async fn line(nodes: &mut Vec<Node>) {
let mut prev_node: Option<SocketAddr> = None;

// Start each node with the previous as a bootnode.
// Connect each node with the previous.
for node in nodes {
if let Some(addr) = prev_node {
node.connect_to_addresses(&[addr]).await;
Expand Down

0 comments on commit a9218bd

Please sign in to comment.