Add a config option to set gossipub direct peers (#414)

* Add support for setting gossipsub direct peers

* Use string array for direct peers config

* Handle empty nitro and consensus config

* Increase consensus write retry attempts

* Rename config option for watcher party peers file

* Handle directPeers array being passed undefined

* Upgrade package versions

---------

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
This commit is contained in:
prathamesh0
2023-09-22 13:46:20 +05:30
committed by GitHub
co-authored by Shreerang Kale
parent 48e7785367
commit 32c78a907c
19 changed files with 65 additions and 48 deletions
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@cerc-io/cli",
"version": "0.2.59",
"version": "0.2.60",
"main": "dist/index.js",
"license": "AGPL-3.0",
"scripts": {
@@ -12,13 +12,13 @@
},
"dependencies": {
"@apollo/client": "^3.7.1",
"@cerc-io/cache": "^0.2.59",
"@cerc-io/ipld-eth-client": "^0.2.59",
"@cerc-io/cache": "^0.2.60",
"@cerc-io/ipld-eth-client": "^0.2.60",
"@cerc-io/libp2p": "^0.42.2-laconic-0.1.4",
"@cerc-io/nitro-node": "^0.1.11",
"@cerc-io/peer": "^0.2.59",
"@cerc-io/rpc-eth-client": "^0.2.59",
"@cerc-io/util": "^0.2.59",
"@cerc-io/peer": "^0.2.60",
"@cerc-io/rpc-eth-client": "^0.2.60",
"@cerc-io/util": "^0.2.60",
"@ethersproject/providers": "^5.4.4",
"@graphql-tools/utils": "^9.1.1",
"@ipld/dag-cbor": "^8.0.0",
+8 -3
View File
@@ -192,6 +192,7 @@ export class ServerCmd {
maxConnections: peerConfig.maxConnections,
dialTimeout: peerConfig.dialTimeout,
pubsub: peerConfig.pubsub,
directPeers: peerConfig.directPeers,
enableDebugInfo: peerConfig.enableDebugInfo
};
await this._peer.init(peerNodeInit, peerIdObj);
@@ -204,6 +205,10 @@ export class ServerCmd {
async initConsensus (): Promise<Consensus | undefined> {
const p2pConfig = this._baseCmd.config.server.p2p;
if (!p2pConfig || !p2pConfig.consensus) {
return;
}
const { consensus: consensusConfig } = p2pConfig;
// Setup consensus engine if enabled
@@ -213,14 +218,14 @@ export class ServerCmd {
}
assert(this.peer);
const watcherPartyPeers = readParty(consensusConfig.watcherPartyFile);
const watcherPartyPeers = readParty(consensusConfig.watcherPartyPeersFile);
// Create and initialize the consensus engine
this._consensus = new Consensus({
peer: this.peer,
publicKey: consensusConfig.publicKey,
privateKey: consensusConfig.privateKey,
party: watcherPartyPeers
partyPeers: watcherPartyPeers
});
// Connect registers the required p2p protocol handlers and starts the engine
@@ -247,7 +252,7 @@ export class ServerCmd {
} = this._baseCmd.config;
// Nitro requires p2p peer to be enabled
if (!enablePeer) {
if (!enablePeer || !nitroConfig) {
return;
}