You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -33,15 +34,15 @@ Peers communicate by enqueuing messages between one another. Each peer on either
33
34
34
35
```mermaid
35
36
sequenceDiagram
36
-
actor Alice
37
-
actor Bob
37
+
actor Morty
38
+
actor Rick
38
39
loop
39
-
Alice->>Bob: Write outbound messages
40
-
Bob->>Alice: Read incoming messages
40
+
Morty->>Rick: Write outbound messages
41
+
Rick->>Morty: Read incoming messages
41
42
end
42
43
loop
43
-
Bob->>Alice: Write outbound messages
44
-
Alice->>Bob: Read incoming messages
44
+
Rick->>Morty: Write outbound messages
45
+
Morty->>Rick: Read incoming messages
45
46
end
46
47
```
47
48
@@ -55,50 +56,50 @@ A peer will then read the full message and attempt to parse it into either a net
55
56
56
57
Upon connection to a new peer, a handshake is performed between the node attempting to establish the outbound connection to the peer and the peer receiving the inbound connection.
57
58
58
-
When attempting to establish the connection, the first message that the node sends is a `Handshake` message describing the compatibility of the nodes. If the `Handshake` message is successfully received and the peer decides that it wants a connection with this node, it replies with a `PeerList` message that contains metadata about other peers that allows a node to connect to them. See [Peerlist Gossip](#peerlist-gossip).
59
+
When attempting to establish the connection, the first message that the node sends is a `Handshake` message describing the configuration of the node. If the `Handshake` message is successfully received and the peer decides that it will allow a connection with this node, it replies with a `PeerList` message that contains metadata about other peers that allows a node to connect to them. See [PeerList Gossip](#peerlist-gossip).
59
60
60
61
As an example, nodes that are attempting to connect with an incompatible version of AvalancheGo or a significantly skewed local clock are rejected.
61
62
62
63
```mermaid
63
64
sequenceDiagram
64
-
actor Alice
65
-
actor Bob
66
-
Note over Alice,Bob: Connection Created
65
+
actor Morty
66
+
actor Rick
67
+
Note over Morty,Rick: Connection Created
67
68
par
68
-
Alice->>Bob: AvalancheGo v1.0.0
69
+
Morty->>Rick: AvalancheGo v1.0.0
69
70
and
70
-
Bob->>Alice: AvalancheGo v1.11.4
71
+
Rick->>Morty: AvalancheGo v1.11.4
71
72
end
72
-
Note right of Bob: v1.0.0 is incompatible with v1.11.4.
73
-
Note left of Alice: v1.11.4 could be compatible with v1.0.0!
73
+
Note right of Rick: v1.0.0 is incompatible with v1.11.4.
74
+
Note left of Morty: v1.11.4 could be compatible with v1.0.0!
74
75
par
75
-
Bob-->>Alice: Disconnect
76
+
Rick-->>Morty: Disconnect
76
77
and
77
-
Alice-XBob: Peerlist
78
+
Morty-XRick: Peerlist
78
79
end
79
-
Note over Alice,Bob: Handshake Failed
80
+
Note over Morty,Rick: Handshake Failed
80
81
```
81
82
82
83
Nodes that mutually desire the connection will both respond with `PeerList` messages and complete the handshake.
83
84
84
85
```mermaid
85
86
sequenceDiagram
86
-
actor Alice
87
-
actor Bob
88
-
Note over Alice,Bob: Connection Created
87
+
actor Morty
88
+
actor Rick
89
+
Note over Morty,Rick: Connection Created
89
90
par
90
-
Alice->>Bob: AvalancheGo v1.11.0
91
+
Morty->>Rick: AvalancheGo v1.11.0
91
92
and
92
-
Bob->>Alice: AvalancheGo v1.11.4
93
+
Rick->>Morty: AvalancheGo v1.11.4
93
94
end
94
-
Note right of Bob: v1.11.0 is compatible with v1.11.4!
95
-
Note left of Alice: v1.11.4 could be compatible with v1.11.0!
95
+
Note right of Rick: v1.11.0 is compatible with v1.11.4!
96
+
Note left of Morty: v1.11.4 could be compatible with v1.11.0!
@@ -127,10 +128,12 @@ It is expected for Avalanche nodes to allow inbound connections. If a validator
127
128
128
129
Avalanche nodes that have identified the `IP:Port` pair of a node they want to connect to will initiate outbound connections to this `IP:Port` pair. If the connection is not able to complete the [Peer Handshake](#peer-handshake), the connection will be re-attempted with an [Exponential Backoff](https://en.wikipedia.org/wiki/Exponential_backoff).
129
130
130
-
A node should initiate outbound connections to an `IP:Port` pair that is believed to belong to a node that is not connected and meets at least one of the following conditions:
131
-
- The node is in the initial bootstrapper set.
132
-
- The node is in the default bootstrapper set.
133
-
- The node in the current Primary Network validator set.
131
+
A node should initiate outbound connections to an `IP:Port` pair that is believed to belong to another node that is not connected and meets at least one of the following conditions:
132
+
- The peer is in the initial bootstrapper set.
133
+
- The peer is in the default bootstrapper set.
134
+
- The peer is a Primary Network validator.
135
+
- The peer is a validator of a tracked Subnet.
136
+
- The peer is a validator of a Subnet and the local node is a Primary Network validator.
134
137
135
138
#### IP Authentication
136
139
@@ -148,7 +151,16 @@ Once connected to an initial set of peers, a node can use these connections to d
148
151
149
152
Peers are discovered by receiving [`PeerList`](#peerlist) messages during the [Peer Handshake](#peer-handshake). These messages quickly provide a node with knowledge of peers in the network. However, they offer no guarantee that the node will connect to and maintain connections with every peer in the network.
150
153
151
-
To provide an eventual guarantee that all peers learn of one another, nodes periodically send a [`GetPeerList`](#getpeerlist) message to a randomly selected validator with the node's current [Bloom Filter](#bloom-filter) and `Salt`.
154
+
To provide an eventual guarantee that all peers learn of one another, nodes periodically send a [`GetPeerList`](#getpeerlist) message to a randomly selected Primary Network validator with the node's current [Bloom Filter](#bloom-filter) and `Salt`.
155
+
156
+
#### Gossipable Peers
157
+
158
+
The peers that a node may include into a [`GetPeerList`](#getpeerlist) message are considered `gossipable`.
159
+
160
+
161
+
#### Trackable Peers
162
+
163
+
The peers that a node would attempt to connect to if included in a [`PeerList`](#peerlist) message are considered `trackable`.
152
164
153
165
#### Bloom Filter
154
166
@@ -171,32 +183,42 @@ A `GetPeerList` message contains the Bloom Filter of the currently known peers a
171
183
`PeerList` messages are expected to contain `IP:Port` pairs that satisfy all of the following constraints:
172
184
- The Bloom Filter sent when requesting the `PeerList` message does not contain the node claiming the `IP:Port` pair.
173
185
- The node claiming the `IP:Port` pair is currently connected.
174
-
- The `IP:Port` pair the node shared during the `Handshake` message is the node's most recently known `IP:Port` pair.
175
-
- The node claiming the `IP:Port` pair is either in the default bootstrapper set or is a current Primary Network validator.
186
+
- The node claiming the `IP:Port` pair is either in the default bootstrapper set, is a current Primary Network validator, is a validator of a tracked Subnet, or is a validator of a Subnet and the peer is a Primary Network validator.
176
187
177
-
#### Example PeerList Gossip
188
+
#### Avoiding Persistent Network Traffic
178
189
179
-
The following diagram shows an example of `Alice` repeatedly learning about new peers from `Bob`.
190
+
To avoid persistent network traffic, it must eventually hold that the set of [`gossipable peers`](#gossipable-peers) is a subset of the [`trackable peers`](#trackable-peers) for all nodes in the network.
191
+
192
+
For example, say there are 3 nodes: `Rick`, `Morty`, and `Summer`.
193
+
194
+
First we consider the case that `Rick` and `Morty` consider `Summer`[`gossipable`](#gossipable-peers) and [`trackable`](#trackable-peers), respectively.
195
+
```mermaid
196
+
sequenceDiagram
197
+
actor Morty
198
+
actor Rick
199
+
Note left of Morty: Not currently tracking Summer
200
+
Morty->>Rick: GetPeerList
201
+
Note right of Rick: Summer isn't in the bloom filter
202
+
Rick->>Morty: PeerList - Contains Summer
203
+
Note left of Morty: Track Summer and add to bloom filter
204
+
Morty->>Rick: GetPeerList
205
+
Note right of Rick: Summer is in the bloom filter
206
+
Rick->>Morty: PeerList - Empty
207
+
```
208
+
This case is ideal, as `Rick` only notifies `Morty` about `Summer` once, and never uses bandwidth for their connection again.
180
209
210
+
Now we consider the case that `Rick` considers `Summer`[`gossipable`](#gossipable-peers), but `Morty` does not consider `Summer`[`trackable`](#trackable-peers).
181
211
```mermaid
182
212
sequenceDiagram
183
-
actor Alice
184
-
actor Bob
185
-
Note left of Alice: Initialize Bloom Filter
186
-
Note left of Alice: Bloom: [0, 0, 0]
187
-
Alice->>Bob: GetPeerList [0, 0, 0]
188
-
Note right of Bob: Any peers can be sent.
189
-
Bob->>Alice: PeerList - Peer-1
190
-
Note left of Alice: Bloom: [1, 0, 0]
191
-
Alice->>Bob: GetPeerList [1, 0, 0]
192
-
Note right of Bob: Either Peer-2 or Peer-3 can be sent.
193
-
Bob->>Alice: PeerList - Peer-3
194
-
Note left of Alice: Bloom: [1, 0, 1]
195
-
Alice->>Bob: GetPeerList [1, 0, 1]
196
-
Note right of Bob: Only Peer-2 can be sent.
197
-
Bob->>Alice: PeerList - Peer-2
198
-
Note left of Alice: Bloom: [1, 1, 1]
199
-
Alice->>Bob: GetPeerList [1, 1, 1]
200
-
Note right of Bob: There are no more peers left to send!
201
-
Bob->>Alice: PeerList - Empty
213
+
actor Morty
214
+
actor Rick
215
+
Note left of Morty: Not currently tracking Summer
216
+
Morty->>Rick: GetPeerList
217
+
Note right of Rick: Summer isn't in the bloom filter
218
+
Rick->>Morty: PeerList - Contains Summer
219
+
Note left of Morty: Ignore Summer
220
+
Morty->>Rick: GetPeerList
221
+
Note right of Rick: Summer isn't in the bloom filter
222
+
Rick->>Morty: PeerList - Contains Summer
202
223
```
224
+
This case is suboptimal, because `Rick` told `Morty` about `Summer` multiple times. If this case were to happen consistently, `Rick` may waste a significant amount of bandwidth trying to teach `Morty` about `Summer`.
0 commit comments