Skip to main content

7.5 Peer Count Limits

Peers in blockchain networks are other nodes your client connects to for data synchronization and message propagation. Maintaining a healthy number of peer connections is essential for exchanging block and transaction data and attesting other node's messages. Depending on your hardware and the volatility of your connections, peer limits can be adjusted.

tip

Further details about connectivity can be found on the Peer Networks and Peer Connectivity pages of the 🧠 Theory section.

warning

It's not recommended to set network peer limits higher than 100 for homestakers, as it can have negative impacts on the network's topology while gaining little to none propagation rate or stability.

info

The following steps are performed on your 📟 node server.

1. Check Peer Connections​

To get insights into the current connections, you can check the peer connections from your local node. Every node operates two independent peer-to-peer networks: the execution and the consensus layer. Each of these networks handles communication with other nodes differently and maintains separate sets of peers. Monitoring both layers is essential to ensure healthy connectivity and network participation.

The execution endpoint allows to fetch the peer counts and lots of other client-specific intormation.

JSON RPC

JSON-RPC is a lightweight communication protocol encoded in JSON, allowing calls to be sent to a service or server. Each execution client exposes a related interface at port 8545 to retreive calls to interact with the Ethereum network though the local node.

tip

By default, the LUKSO Network Configuration allows to retrieve network data for all execution clients.

1. Install Querying Tool: Install the JSON query service for data processing from the RPC endpoint.

sudo apt install jq

2. Call Execution Endpoint: While the node is running, call the JSON RPC of the execution client.

# Retrieve Execution Peers
curl -s -X POST -H "content-type: application/json" \
--data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}' \
http://localhost:8545 | jq -r '.result' | xargs printf '%d\n'
Full Command Explanation
CommandDescription
curl -s -X POST -H <text>
--data <text> <port>
Executes -X a silent -s HTTP POST request to the given <port>, while attaching custom header -H and --data content as <text> payload.
jq -r '.result' Filters the raw -r JSON object and extracts the .result value of the data object.
xargs printf '%d\n' Converts the hexadecimal result to a human-readable decimal %d number.

The output should be something in the range from 5 to 50 peers.

37
warning

If the command couldn't be executed, have a look at the Problem Scanning page to learn how to attach execution clients.

If you have low or volatile peer counts, continue to stop the node and raise the peer count limits.

2. Stop Node Operation​

Depending on your setup method, there are different ways to stop your node before configuring the IP or raising the peer limits.

cd <lukso-working-directory>
lukso stop
info

Exchange <lukso-working-directory> with the path of the node folder.

Force Client Shutdown
sudo pkill geth

4. Raise Peer Limits​

Most clients come with conservative default peer limits, which can be increased to maintain more simultaneous connections and improved stability and data propagation. However, peer counts above 100 can negatively affect the network topology and are not recommended.

tip

You should always have more than 15 stable peers after a setup time of 4 to 6 hours. If your peer count is not raising, it indicates a misconfiguration. Check that your firewall allows all necessary client ports to receive data.

warning

Ensure your router is capable of handling higher loads and requests when raising the peer limit above the default.

Depending on your execution client, the peer limit can be adjusted with different properties.

Open the configuration file using your preferred text editor.

cd <lukso-working-directory>/configs/<network>/geth/
vim geth.toml
info

The following properties need to be exchanged:

  • <lukso-working-directory> with the path to the node folder.
  • <network> with the name of your node's network.

Change the peer limit within the settings, then save and exit the file.

Update the MaxPeers property.

# Default Value
MaxPeers = 50

# Updated Value
MaxPeers = <custom-peer-limit>
info

Exchange <custom-peer-limit> with the maximum number of active peers maintained by your node.

warning

Ensure there are no missing spaces, characters or unintended linebreaks before saving the configuration file.

5. Restart the Node​

Depending on your setup method, there are different ways to start your node after the IP address or peer limits have changed.

cd <lukso-working-directory>
lukso start --checkpoint-sync
info

Exchange <lukso-working-directory> with the path of the node folder.

After the clients were started, verify that their services are still up.

sudo lukso status