Skip to content

Commit 42b7710

Browse files
joshuafernandesAlexandra Tranalexandratran
authored
adding in some details re the peering process (#1643)
* adding in some details re the peering process Signed-off-by: Joshua Fernandes <joshua.fernandes@consensys.net> * edit p2p discovery process and tutorials Signed-off-by: Alexandra Tran <alexandra.tran@consensys.net> * Update docs/public-networks/how-to/connect/manage-peers.md Signed-off-by: Alexandra Carrillo <12214231+alexandratran@users.noreply.github.com> --------- Signed-off-by: Joshua Fernandes <joshua.fernandes@consensys.net> Signed-off-by: Alexandra Tran <alexandra.tran@consensys.net> Signed-off-by: Alexandra Carrillo <12214231+alexandratran@users.noreply.github.com> Co-authored-by: Alexandra Tran <alexandra.tran@consensys.net> Co-authored-by: Alexandra Carrillo <12214231+alexandratran@users.noreply.github.com>
1 parent 5caba7a commit 42b7710

File tree

3 files changed

+68
-22
lines changed

3 files changed

+68
-22
lines changed

docs/public-networks/how-to/connect/manage-peers.md

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,60 @@ tags:
99

1010
# Manage peers
1111

12-
Hyperledger Besu peer-to-peer (P2P) discovery happens periodically based on the number of peers in a network and the node's [peer limit](#limit-peers).
12+
Hyperledger Besu peer-to-peer (P2P) discovery happens periodically based on the number of peers in a
13+
network and the node's [peer limit](#limit-peers).
1314

14-
The frequency of discovery isn't configurable, but you can [limit remote connections](#limit-remote-connections) in public networks and [randomly prioritize connections](../../reference/cli/options.md#random-peer-priority-enabled) in small, stable networks.
15+
The frequency of discovery isn't configurable, but you can
16+
[limit remote connections](#limit-remote-connections) in public networks and
17+
[randomly prioritize connections](../../reference/cli/options.md#random-peer-priority-enabled) in
18+
small, stable networks.
1519

1620
:::info
21+
You can use [`admin_addPeer`](../../reference/cli/options.md#admin_addpeer) to attempt a specific
22+
connection, but this isn't P2P discovery.
23+
:::
1724

18-
You can use [`admin_addPeer`](../../reference/cli/options.md#admin_addpeer) to attempt a specific connection, but this isn't P2P discovery.
25+
In private networks, we recommend
26+
[using bootnodes](../../../private-networks/how-to/configure/bootnodes.md) to initially discover peers.
1927

20-
:::
28+
## P2P discovery process
29+
30+
The P2P discovery process requires [ports to be open to UDP and TCP traffic](configure-ports.md#p2p-networking).
31+
If you have a firewall in place, keep those ports open to allow traffic in and out.
32+
If you are running a node at home on your network, ensure that your router has those ports open.
33+
34+
The `discovery` stack uses UDP to keep peer discovery lightweight and quick.
35+
It only allows a node to find peers and connect to them, without any additional overhead.
36+
Once peers have bonded, the data exchange between them is complex and needs a fully featured
37+
protocol to support error checking and retries, so the `devP2P` stack uses TCP.
38+
39+
Both stacks work in parallel: the `discovery` stack adds new peers to the network, and the `devP2P`
40+
stack enables interactions and data flow between them.
41+
In detail, the P2P discovery process is as follows:
42+
43+
1. When Besu starts up it advertises its presence and details (including the enode) using UDP before
44+
establishing a formal connection with any peer (log messages look like `Enode URL enode://....`).
45+
46+
2. Besu attempts to connect to the network's bootnodes (a set of predefined nodes used to help
47+
bootstrap discovery).
48+
49+
3. Once a connection with a bootnode is established using UDP (`ping/pong` handshake messages in the
50+
debug and trace logs), Besu requests a list of neighbors (potential peers) from the bootnode
51+
(`find node` messages in the debug and trace logs).
52+
53+
4. Besu attempts to connect to each peer using TCP, and get status information from them – such
54+
as network details, what the peer believes to be the current chain head, and its list of neighbors.
55+
From this point on any traffic to that peer is only done using TCP.
56+
57+
5. Depending on the [synchronization method](../../get-started/connect/sync-node.md), a common block
58+
(the pivot block) is selected that all connected peers (default of 5) have, and Besu syncs from
59+
that block till it gets to chain head.
60+
Log messages look like `Downloading world state from peers for pivot block .......`.
61+
62+
6. Besu repeats the same process for each peer in step 4, and any new peers that come along
63+
(regardless of client).
2164

22-
In private networks, we recommend [using bootnodes](../../../private-networks/how-to/configure/bootnodes.md) to initially discover peers.
65+
The more peers Besu is connected to, the more confident it is of having an accurate view of the network.
2366

2467
## Limit peers
2568

docs/public-networks/tutorials/besu-teku-mainnet.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,31 +53,26 @@ Run the following command or specify the options in a [configuration file](../ho
5353

5454
```bash
5555
besu \
56-
--sync-mode=SNAP \
57-
--data-storage-format=BONSAI \
58-
--rpc-http-enabled=true \
59-
--rpc-http-host="0.0.0.0" \
60-
--rpc-ws-enabled=true \
61-
--rpc-ws-host="0.0.0.0" \
62-
--host-allowlist=<IP of Besu node>,127.0.0.1,localhost \
63-
--engine-host-allowlist=<IP of Besu node>,127.0.0.1,localhost \
64-
--engine-rpc-enabled \
56+
--sync-mode=SNAP \
57+
--data-storage-format=BONSAI \
58+
--rpc-http-enabled=true \
59+
--p2p-host=<your public IP> \
60+
--host-allowlist=<your public IP>,127.0.0.1,localhost \
61+
--engine-host-allowlist=<your public IP>,127.0.0.1,localhost \
62+
--engine-rpc-enabled \
6563
--engine-jwt-secret=<path to jwtsecret.hex>
6664
```
6765

6866
Specify:
6967

7068
- The path to the `jwtsecret.hex` file generated in [step 2](#2-generate-the-shared-secret) using the [`--engine-jwt-secret`](../reference/cli/options.md#engine-jwt-secret) option.
71-
- The IP address of your Besu node using the [`--host-allowlist`](../reference/cli/options.md#host-allowlist) and [`--engine-host-allowlist`](../reference/cli/options.md#engine-host-allowlist) options.
69+
- The public IP address of your Besu node using the [`--host-allowlist`](../reference/cli/options.md#host-allowlist) and [`--engine-host-allowlist`](../reference/cli/options.md#engine-host-allowlist) options.
7270

7371
Also, in the command:
7472

7573
- [`--sync-mode`](../reference/cli/options.md#sync-mode) specifies using [snap sync](../get-started/connect/sync-node.md#snap-synchronization).
7674
- [`--data-storage-format`](../reference/cli/options.md#data-storage-format) specifies using [Bonsai Tries](../concepts/data-storage-formats.md#bonsai-tries).
7775
- [`--rpc-http-enabled`](../reference/cli/options.md#rpc-http-enabled) enables the HTTP JSON-RPC service.
78-
- [`--rpc-http-host`](../reference/cli/options.md#rpc-http-host) is set to `0.0.0.0` to allow remote RPC connections.
79-
- [`--rpc-ws-enabled`](../reference/cli/options.md#rpc-ws-enabled) enables the WebSocket JSON-RPC service.
80-
- [`--rpc-ws-host`](../reference/cli/options.md#rpc-ws-host) is set to `0.0.0.0` to allow remote RPC connections.
8176
- [`--engine-rpc-enabled`](../reference/cli/options.md#engine-rpc-enabled) enables the [Engine API](../reference/engine-api/index.md).
8277

8378
You can modify the option values and add other [command line options](../reference/cli/options.md) as needed.
@@ -96,13 +91,16 @@ teku \
9691
--ee-jwt-secret-file=<path to jwtsecret.hex> \
9792
--metrics-enabled=true \
9893
--rest-api-enabled=true \
94+
--p2p-advertised-ip=<your public IP> \
9995
--checkpoint-sync-url=<checkpoint sync URL>
10096
```
10197

10298
Specify:
10399

104100
- The path to the `jwtsecret.hex` file generated in [step 2](#2-generate-the-shared-secret) using the
105101
[`--ee-jwt-secret-file`](https://docs.teku.consensys.io/reference/cli#ee-jwt-secret-file) option.
102+
- The public IP address of your Teku node using the
103+
[`--p2p-advertised-ip`](https://docs.teku.consensys.io/reference/cli#p2p-advertised-ip) option.
106104
- The URL of a checkpoint sync endpoint using the
107105
[`--checkpoint-sync-url`](https://docs.teku.consensys.io/reference/cli#checkpoint-sync-url) option.
108106

docs/public-networks/tutorials/besu-teku-testnet.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ Run the following command or specify the options in a [configuration file](../ho
6969
besu \
7070
--network=holesky \
7171
--rpc-http-enabled=true \
72-
--rpc-http-host=0.0.0.0 \
7372
--rpc-http-cors-origins="*" \
7473
--rpc-ws-enabled=true \
75-
--rpc-ws-host=0.0.0.0 \
74+
--p2p-host=<your public IP> \
7675
--host-allowlist="*" \
7776
--engine-host-allowlist="*" \
7877
--engine-rpc-enabled \
@@ -87,10 +86,9 @@ besu \
8786
besu \
8887
--network=sepolia \
8988
--rpc-http-enabled=true \
90-
--rpc-http-host=0.0.0.0 \
9189
--rpc-http-cors-origins="*" \
9290
--rpc-ws-enabled=true \
93-
--rpc-ws-host=0.0.0.0 \
91+
--p2p-host=<your public IP> \
9492
--host-allowlist="*" \
9593
--engine-host-allowlist="*" \
9694
--engine-rpc-enabled \
@@ -124,6 +122,7 @@ teku \
124122
--ee-jwt-secret-file=<path to jwtsecret.hex> \
125123
--metrics-enabled=true \
126124
--rest-api-enabled=true \
125+
--p2p-advertised-ip=<your public IP> \
127126
--checkpoint-sync-url=<checkpoint sync URL>
128127
```
129128

@@ -138,6 +137,7 @@ teku \
138137
--ee-jwt-secret-file=<path to jwtsecret.hex> \
139138
--metrics-enabled=true \
140139
--rest-api-enabled=true \
140+
--p2p-advertised-ip=<your public IP> \
141141
--checkpoint-sync-url=<checkpoint sync URL>
142142
```
143143

@@ -149,6 +149,8 @@ Specify:
149149

150150
- The path to the `jwtsecret.hex` file generated in [step 2](#2-generate-the-shared-secret) using the
151151
[`--ee-jwt-secret-file`](https://docs.teku.consensys.io/reference/cli#ee-jwt-secret-file) option.
152+
- The public IP address of your Teku node using the
153+
[`--p2p-advertised-ip`](https://docs.teku.consensys.io/reference/cli#p2p-advertised-ip) option.
152154
- The URL of a checkpoint sync endpoint using the
153155
[`--checkpoint-sync-url`](https://docs.teku.consensys.io/reference/cli#checkpoint-sync-url) option.
154156

@@ -169,6 +171,7 @@ teku \
169171
--ee-jwt-secret-file=<path to jwtsecret.hex> \
170172
--metrics-enabled=true \
171173
--rest-api-enabled=true \
174+
--p2p-advertised-ip=<your public IP> \
172175
--checkpoint-sync-url=<checkpoint sync URL> \
173176
--validators-proposer-default-fee-recipient=<ETH address> \
174177
--validator-keys=<path to key file>:<path to password file>[,<path to key file>:<path to password file>,...]
@@ -188,6 +191,8 @@ Specify:
188191

189192
- The path to the `jwtsecret.hex` file generated in [step 2](#2-generate-the-shared-secret) using the
190193
[`--ee-jwt-secret-file`](https://docs.teku.consensys.io/reference/cli#ee-jwt-secret-file) option.
194+
- The public IP address of your Teku node using the
195+
[`--p2p-advertised-ip`](https://docs.teku.consensys.io/reference/cli#p2p-advertised-ip) option.
191196
- The URL of a checkpoint sync endpoint using the
192197
[`--checkpoint-sync-url`](https://docs.teku.consensys.io/reference/cli#checkpoint-sync-url) option.
193198
- The test Ethereum address created in [step 3](#3-generate-validator-keys) as the default fee

0 commit comments

Comments
 (0)