-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
p2p: add configuration for direct peers (#4769)
see rendered readme for p2p module https://github.com/spacemeshos/go-spacemesh/blob/7066febb821b82f035ab0d539ba95dfad4e8b347/p2p/README.md
- Loading branch information
Showing
5 changed files
with
156 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
P2P | ||
=== | ||
|
||
### Direct connections | ||
|
||
If you are running multiple nodes in the local network and exposing all of them | ||
is not convenient there is an option to setup network manually, by making | ||
couple of nodes publicly available and the rest connected to them directly. | ||
|
||
### Get network id | ||
- get it with grpcurl | ||
|
||
> grpcurl -plaintext 127.0.0.1:9092 spacemesh.v1.DebugService.NetworkInfo | ||
```json | ||
{ | ||
"id": "12D3KooWRfy4Sj4rDHDuBaYw3Mg5d2puwiCyqBCWMziFquaGQ5g8" | ||
} | ||
``` | ||
|
||
- get it from stored data | ||
|
||
> cat ~/spacemesh/p2p/p2p.key | ||
```json | ||
{"Key":"CAESQAQN38GXvr+L+G+/JWoimpqPBK7I6INe+PKYA+hRJg0I65Q3IPK49Ii9dcnC3+UqB+jMEL16sqDfUubxTs62rZU=","ID":"12D3KooWRfy4Sj4rDHDuBaYw3Mg5d2puwiCyqBCWMziFquaGQ5g8"} | ||
``` | ||
|
||
### Configuration for public node | ||
|
||
Public node should have higher peer limits to help with network connectivity | ||
and a list of botnodes. Direct connections should be reciprocal, otherwise | ||
public node may prune your private node if overloaded. | ||
|
||
Setup more than one public node, and perform rolling upgrades or restart | ||
for them if needed. | ||
|
||
```json | ||
{ | ||
"p2p": { | ||
"min-peers": 30, | ||
"low-peers": 60, | ||
"high-peers": 100, | ||
"p2p-disable-legacy-discovery": true, | ||
"direct": [ | ||
"/ip4/0.0.0.0/tcp/6000/p2p/12D3KooWRkBh6QayKLb1pDRJGMHE94Lix4ZBVh2BJJeX6mghk8VH" | ||
], | ||
"bootnodes": [ | ||
"/dns4/mainnet-bootnode-10.spacemesh.network/tcp/5000/p2p/12D3KooWHK5m83sNj2eNMJMGAngcS9gBja27ho83t79Q2CD4iRjQ", | ||
"/dns4/mainnet-bootnode-11.spacemesh.network/tcp/5000/p2p/12D3KooWFrCDS8tc29nxJEYf4sKFXhXw7wMSdhQP4S7tsbfh6ngn" | ||
] | ||
} | ||
} | ||
``` | ||
|
||
### Configuration for private node | ||
|
||
Set min-peers to the number of peers in the config and disable-dht. | ||
low-peers and high-peers should not be lower than min-peers. | ||
|
||
```json | ||
{ | ||
"p2p": { | ||
"listen": "/ip4/0.0.0.0/tcp/6000", | ||
"min-peers": 1, | ||
"low-peers": 10, | ||
"high-peers": 20, | ||
"p2p-disable-legacy-discovery": true, | ||
"disable-dht": true, | ||
"bootnodes": [], | ||
"direct": [ | ||
"/ip4/0.0.0.0/tcp/7513/p2p/12D3KooWRfy4Sj4rDHDuBaYw3Mg5d2puwiCyqBCWMziFquaGQ5g8" | ||
] | ||
} | ||
} | ||
``` | ||
|
||
#### Expected result | ||
|
||
Public node will maintain many open connections | ||
|
||
> ss -npO4 | rg spacemesh | rg 7513 | rg ESTAB | wc -l | ||
> 52 | ||
Private will connect only to the specified public node: | ||
|
||
> ss -npO4 | rg spacemesh | rg 6000 | ||
``` | ||
tcp ESTAB 0 0 127.0.0.1:7513 127.0.0.1:6000 users:(("go-spacemesh",pid=39165,fd=11)) | ||
tcp ESTAB 0 0 127.0.0.1:6000 127.0.0.1:7513 users:(("go-spacemesh",pid=39202,fd=47)) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters