diff --git a/env.md b/env.md index 7b3dfc204..7b0640d1d 100644 --- a/env.md +++ b/env.md @@ -56,6 +56,9 @@ Environmental variables are also tracked in `ENVIRONMENT_VARIABLES` within `src/ - `P2P_BOOTSTRAP_NODES` : List of bootstrap nodes. Defults to OPF nodes. Example: ["/dns4/node3.oceanprotocol.com/tcp/9000/p2p/"] - `P2P_MIN_CONNECTIONS`: The minimum number of connections below which libp2p will start to dial peers from the peer book. Setting this to 0 disables this behaviour. Default: 1 - `P2P_MAX_CONNECTIONS`: The maximum number of connections libp2p is willing to have before it starts pruning connections to reduce resource usage. Default: 300 +- `P2P_AUTODIALPEERRETRYTHRESHOLD`: When we've failed to dial a peer, do not autodial them again within this number of ms. Default: 1000 \* 120 +- `P2P_AUTODIALCONCURRENCY`: When dialling peers from the peer book to keep the number of open connections, add dials for this many peers to the dial queue at once. Default: 5 +- `P2P_MAXPEERADDRSTODIAL`: Maximum number of addresses allowed for a given peer before giving up. Default: 5 ## Additional Nodes (Test Environments) diff --git a/src/@types/OceanNode.ts b/src/@types/OceanNode.ts index f05fef319..86fd4b461 100644 --- a/src/@types/OceanNode.ts +++ b/src/@types/OceanNode.ts @@ -47,6 +47,9 @@ export interface OceanNodeP2PConfig { announcePrivateIp: boolean minConnections: number maxConnections: number + autoDialPeerRetryThreshold: number + autoDialConcurrency: number + maxPeerAddrsToDial: number } export interface OceanNodeConfig { diff --git a/src/components/P2P/index.ts b/src/components/P2P/index.ts index c8d7ea94e..8979dff9d 100644 --- a/src/components/P2P/index.ts +++ b/src/components/P2P/index.ts @@ -330,7 +330,10 @@ export class OceanP2P extends EventEmitter { maxParallelDials: config.p2pConfig.connectionsMaxParallelDials, // 150 total parallel multiaddr dials dialTimeout: config.p2pConfig.connectionsDialTimeout, // 10 second dial timeout per peer dial minConnections: config.p2pConfig.minConnections, - maxConnections: config.p2pConfig.maxConnections + maxConnections: config.p2pConfig.maxConnections, + autoDialPeerRetryThreshold: config.p2pConfig.autoDialPeerRetryThreshold, + autoDialConcurrency: config.p2pConfig.autoDialConcurrency, + maxPeerAddrsToDial: config.p2pConfig.maxPeerAddrsToDial } } if (config.p2pConfig.bootstrapNodes && config.p2pConfig.bootstrapNodes.length > 0) { @@ -340,7 +343,7 @@ export class OceanP2P extends EventEmitter { peerDiscovery: [ bootstrap({ list: config.p2pConfig.bootstrapNodes, - timeout: 1000, // in ms, + timeout: 20000, // in ms, tagName: 'bootstrap', tagValue: 50, tagTTL: 10000000000 diff --git a/src/utils/config.ts b/src/utils/config.ts index d6ebf127b..c2de1d3e9 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -483,10 +483,17 @@ async function getEnvConfig(isStartup?: boolean): Promise { announcePrivateIp: getBoolEnvValue('P2P_ANNOUNCE_PRIVATE', false), filterAnnouncedAddresses: readListFromEnvVariable( ENVIRONMENT_VARIABLES.P2P_FILTER_ANNOUNCED_ADDRESSES, - isStartup + isStartup, + ['172.15.0.0/24'] ), minConnections: getIntEnvValue(process.env.P2P_MIN_CONNECTIONS, 1), - maxConnections: getIntEnvValue(process.env.P2P_MAX_CONNECTIONS, 300) + maxConnections: getIntEnvValue(process.env.P2P_MAX_CONNECTIONS, 300), + autoDialPeerRetryThreshold: getIntEnvValue( + process.env.P2P_AUTODIALPEERRETRYTHRESHOLD, + 1000 * 120 + ), + autoDialConcurrency: getIntEnvValue(process.env.P2P_AUTODIALCONCURRENCY, 5), + maxPeerAddrsToDial: getIntEnvValue(process.env.P2P_MAXPEERADDRSTODIAL, 5) }, // Only enable provider if we have a DB_URL hasProvider: !!getEnvValue(process.env.DB_URL, ''),