Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Merge Feature/create network module #3465

Merged
merged 167 commits into from
Apr 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
6300bd1
Add entry for modules config
jondubois Feb 28, 2019
76e350f
Bump lisk-element version
jondubois Feb 28, 2019
7eb0ff2
Modify System component to allow passing a handler to check when the …
jondubois Feb 28, 2019
03997d0
Add support for modules field in schema
jondubois Feb 28, 2019
8cdc9c2
Make chain module responsible for publishing an updateNodeInfo event …
jondubois Feb 28, 2019
205cac2
Add network module
jondubois Feb 28, 2019
30b4f75
Connect NetworkModule to main application so that it runs alongside t…
jondubois Feb 28, 2019
2e9f207
Add system tag in front of updateNodeInfo event
jondubois Mar 1, 2019
6936cf6
Add lisk-p2p module to package.json separately
jondubois Mar 1, 2019
3cc9338
Fix config for network tests
jondubois Mar 4, 2019
8a6dfa8
ESLint cleanup
jondubois Mar 4, 2019
08f1593
Bind Network module to controller actions and events
jondubois Mar 4, 2019
352d5d6
Expose additional actions
jondubois Mar 4, 2019
6d2c799
Improve approach for getting NodeInfo
jondubois Mar 5, 2019
a3e658d
Add default ackTimeout and dsicoveryInterval to Network module options
jondubois Mar 6, 2019
43e9d1a
Use 1.0 lisk-elements version since the p2p library is imported separ…
jondubois Mar 6, 2019
d7c7480
Do not expose applyPenalty action since it is not currently supported
jondubois Mar 6, 2019
eaff5e2
Add more detail to application schema
jondubois Mar 7, 2019
81c143c
Log all events from P2P library
jondubois Mar 11, 2019
d138576
Minor cleanup of network module
jondubois Mar 11, 2019
13428e3
Merge pull request #3019 from LiskHQ/2874-create_network_module
shuse2 Mar 11, 2019
458a6a1
Merge branch 'development' into feature/create_network_module
jondubois Mar 12, 2019
cb06646
Merge branch development into feature/create_network_mdoule
ishantiw Apr 3, 2019
435429d
Allow modules to emit any events on the bus under their own namespace
jondubois Apr 1, 2019
7a7002c
Adapt network module to use application state
diego-G Apr 4, 2019
a62a26d
Expose synching methods on chain module
jondubois Apr 1, 2019
bb90658
Migrate blocks submodule to use the new network module instead of int…
jondubois Apr 1, 2019
1dd941c
Fix network module compatibility issues with v1 lisk-core network
jondubois Apr 1, 2019
b680818
Change loader to use the new network module instead of old peer system
jondubois Apr 1, 2019
73bd7e4
Fix integration test related to blocks process
jondubois Apr 1, 2019
d256395
Fix unit tests related to blocks process
jondubois Apr 1, 2019
7552813
Fix loader unit tests
jondubois Apr 1, 2019
e9528a0
Remove failing unit tests
jondubois Apr 1, 2019
7ad150e
Remove unused variable
jondubois Apr 2, 2019
b381a30
Skip network tests until we have fixed the config format
jondubois Apr 3, 2019
21df01d
Resolve QA feedback
jondubois Apr 3, 2019
7b0a67c
Remove deprecated system component
diego-G Apr 4, 2019
c703035
Cleanup to account for changes to applicationState
jondubois Apr 4, 2019
4211761
Fix lint issue
jondubois Apr 4, 2019
90f4eb9
Skip jest unit test case for which requirements are currently unclear
jondubois Apr 4, 2019
f38f193
Skip test cases for which the requirements are not yet known
jondubois Apr 4, 2019
b7d21a1
Skip network test until we have the new config format
jondubois Apr 4, 2019
9540355
Fix linting
jondubois Apr 4, 2019
3a9d826
Merge pull request #3261 from LiskHQ/3260-adapt_network_module_to_app…
shuse2 Apr 5, 2019
275d969
Merge branch 'feature/create_network_module' into 2875-loader_to_use_…
jondubois Apr 5, 2019
e14fa62
Merge pull request #3272 from LiskHQ/development
jondubois Apr 5, 2019
1a5078a
Merge pull request #3243 from LiskHQ/2875-loader_to_use_network_module
shuse2 Apr 8, 2019
ab7fd05
Extract filter functions from peer submodules and use in http_api module
ishantiw Mar 25, 2019
70eef7e
API controller to use network module for api/peers and use helper funcs
ishantiw Mar 25, 2019
a0e26d5
Update P2P.getNetworkStatus() to return consolidated list of peers
ishantiw Mar 25, 2019
997cbd6
Remove the use of lodash from network module
ishantiw Mar 26, 2019
b6a408f
Use params instead of filters that is modified from previous filter f…
ishantiw Mar 26, 2019
72df02f
Improve filter functions and make them to use arrow
ishantiw Mar 26, 2019
89e7fbe
Add module options to network module and extract peers list from conf…
ishantiw Mar 28, 2019
f8f49b6
Skip network test as its failing when using network module
ishantiw Apr 2, 2019
eb4d032
Skip GET /peers functional test which needs a different approach to test
ishantiw Apr 2, 2019
989517b
Improve variable names from snake_case to camelCase
ishantiw Apr 2, 2019
23915a4
Refactor filter peer function and use lodash only for shuffling
ishantiw Apr 3, 2019
ccd2dd0
Check for unknown parameters and return validation error if passed
ishantiw Apr 3, 2019
a534b4a
Remove duplicate import statement and unwanted space
ishantiw Apr 5, 2019
741b0e0
Move peer filter functions to network helper and add func for consoli…
ishantiw Apr 5, 2019
631f40d
Register getPeers and getPeersCountByFilter actions in network module
ishantiw Apr 5, 2019
8f05a8b
Implement missing functions for network actions
ishantiw Apr 5, 2019
62bbac8
Use new actions to get peers and peersCountByFilters
ishantiw Apr 5, 2019
ef76490
Merge pull request #3180 from LiskHQ/2879-update_api_peer_endpoints_u…
shuse2 Apr 8, 2019
c09cdd9
Change version tag for @liskhq/lisk-p2 dependency
diego-G Apr 8, 2019
7b2e3f0
Remove non used peer related actions from chain module
diego-G Apr 8, 2019
acf4d7b
Update calculateConsensus() to use network module
diego-G Apr 8, 2019
612c765
Use async calculateConsensus() when syncing
diego-G Apr 8, 2019
d89f427
Upgrade jobs_queue helper to accept async jobs
diego-G Apr 9, 2019
3899428
Convert poorConsensus() to async
diego-G Apr 9, 2019
e3bac63
Fix unit test for calculateConsensus()
diego-G Apr 9, 2019
140e4e4
Fix configuration issue on network tests
diego-G Apr 9, 2019
c25fcde
Rename poorConsensus() to isPoorConsensus()
diego-G Apr 9, 2019
fd15189
Move isPoorConsensus() to peers submodule
diego-G Apr 9, 2019
ee00f45
Configure network tests Jenkins execution with just 2 peers
diego-G Apr 10, 2019
5f053a0
Prefer use of native utils instead of Object.prototype.toString.call
diego-G Apr 10, 2019
e9dfd6f
Prefer assert checks in chain helper jobs_queue
diego-G Apr 10, 2019
531932c
Merge pull request #3290 from LiskHQ/2881-update_consensus_using_netw…
shuse2 Apr 10, 2019
9c43a95
Merge branch 'development' into feature/create_network_module
jondubois Apr 11, 2019
aedb47f
Fix merge issue; lisk namespace is now app when publishing or invokin…
jondubois Apr 11, 2019
fb6cff5
Merge pull request #3300 from LiskHQ/create_network_module-merge
shuse2 Apr 11, 2019
35a0cc6
:seedling: Update transport to use network module
shuse2 Apr 9, 2019
84f322d
:fire: Remove unused test
shuse2 Apr 10, 2019
7cb9f09
:white_check_mark: Fix transport unit test
shuse2 Apr 10, 2019
35314e7
:fire: Remove broadcast header usage
shuse2 Apr 10, 2019
6890e18
:recycle: Fix typo and remove unnecessary arg
shuse2 Apr 10, 2019
2136014
:recycle: Fix comment
shuse2 Apr 10, 2019
c1d9a03
:fire: Remove old peer system usage
shuse2 Apr 11, 2019
48d8ee5
Add chain recovery logic if matching block cannot be found
jondubois Apr 9, 2019
a1ff537
Fix poor consensus detection which broke after rebase
jondubois Apr 11, 2019
b9adb83
Merge pull request #3301 from LiskHQ/3281-chain_recovery
shuse2 Apr 11, 2019
36d836e
:fire: Remove WS usage
shuse2 Apr 11, 2019
7cdce4a
:white_check_mark: Fix unit tests
shuse2 Apr 11, 2019
4370727
Merge branch 'development' into feature/create_network_module
shuse2 Apr 12, 2019
f056e85
:recycle: Fix for merge deevelopment
shuse2 Apr 12, 2019
d3ac802
Merge branch 'merge_development_into_network_module' into 2877-update…
shuse2 Apr 12, 2019
ca2a4d3
:fire: Remove chain network
shuse2 Apr 12, 2019
f0cc44e
:fire: Remove network p2p test
shuse2 Apr 12, 2019
e7575e6
Merge pull request #3307 from LiskHQ/merge_development_into_network_m…
jondubois Apr 12, 2019
dec77ba
:recycle: Fix unit test
shuse2 Apr 12, 2019
2291daf
Convert broadcaster to an ES6 Class
diego-G Apr 10, 2019
7c07cf6
Add copyright to broadcaster unit tests
diego-G Apr 12, 2019
a671202
Fix broadcaster unit tests
diego-G Apr 12, 2019
7f1a9e8
Remove unnecessary nextRelase() from broadcaster
diego-G Apr 12, 2019
2b91374
Remove callbacks from logic broadcaster
diego-G Apr 12, 2019
9cfba40
Remove self from logic broadcaster
diego-G Apr 12, 2019
cfc261c
:bug: Fix broadcaster and peer insertion
shuse2 Apr 12, 2019
7ba22f7
Invoke network send event when broadcasting from chain module
diego-G Apr 12, 2019
ebeafd5
:bug: Fix network height endpoint
shuse2 Apr 12, 2019
ab25027
:white_check_mark: Fix functional test setup
shuse2 Apr 13, 2019
6865945
Merge branch '2878-update_broadcaster_to_use_network_module' into 287…
shuse2 Apr 13, 2019
8a93d99
:fire: Remove peer from broadcaster
shuse2 Apr 13, 2019
9c716c8
:white_check_mark: Fix unit test
shuse2 Apr 13, 2019
554119b
:recycle: Add minVersion and nethash
shuse2 Apr 13, 2019
af70d38
:fire: Fix network test setting
shuse2 Apr 13, 2019
e17912c
:bug: Fix synchroous task reference
shuse2 Apr 13, 2019
dd3ef40
:bug: Fix functional ws tests
shuse2 Apr 13, 2019
93425ea
:bug: Fix broadacaster unit test
shuse2 Apr 13, 2019
c7a5607
:white_check_mark: Increase ack timeout for test
shuse2 Apr 13, 2019
b9f7bdb
:bug: Fix functional peer test
shuse2 Apr 13, 2019
5f924a8
:recycle: Fix connected state constant
shuse2 Apr 13, 2019
1ae6232
:white_check_mark: Fix unit test
shuse2 Apr 13, 2019
a72638e
:bug: Fix not to connect to self
shuse2 Apr 13, 2019
6407dfa
:white_check_mark: Fix network test configs
shuse2 Apr 13, 2019
48d9ccc
:fire: Remove unused definition
shuse2 Apr 14, 2019
9cd9a64
Merge pull request #3312 from LiskHQ/2878-update_broadcaster_to_use_n…
shuse2 Apr 15, 2019
42ae98f
Merge pull request #3295 from LiskHQ/2877-update_transport_module
shuse2 Apr 15, 2019
ee601d5
Merge branch 'development' into feature/create_network_module
shuse2 Apr 15, 2019
26ac511
Merge branch 'development' into feature/create_network_module
shuse2 Apr 16, 2019
0ebebd6
Merge branch 'development' into feature/create_network_module
shuse2 Apr 16, 2019
55a0477
Add new disconnect code and reason for when peer tries to connect to …
jondubois Apr 16, 2019
2c165b7
Disconnect if peer tries to connect to itself
jondubois Apr 16, 2019
8ceab26
Fix outbound socket management issue
jondubois Apr 16, 2019
3bf83fb
Update integration tests to account for not connecting to self
jondubois Apr 16, 2019
b6a2934
Fix tslint issue
jondubois Apr 16, 2019
c281f6e
Handle socket disconnection as part of initial discovery phase
jondubois Apr 17, 2019
0922e5a
Fix spacing issue
jondubois Apr 17, 2019
dbcaec7
Merge pull request #3382 from LiskHQ/3364-p2p_not_connect_to_self
shuse2 Apr 17, 2019
42cf200
Only update the app state if broadcast is true (not synching)
jondubois Apr 23, 2019
95e6c1b
Merge pull request #3428 from LiskHQ/3417-connection_id_not_match
shuse2 Apr 23, 2019
5234017
Merge branch 'development' into feature/create_network_module
shuse2 Apr 23, 2019
3dd9421
:recycle: Fix config changes
shuse2 Apr 23, 2019
1f45e84
:white_check_list: Fix unit test errors
shuse2 Apr 23, 2019
024c768
Merge development
shuse2 Apr 24, 2019
e54d3cc
Merge branch 'development' into merge_development_to_feature_network_…
shuse2 Apr 24, 2019
dcac1e5
Merge pull request #3431 from LiskHQ/merge_development_to_feature_net…
shuse2 Apr 24, 2019
41321c5
Fix config for network module
jondubois Apr 25, 2019
5d869a7
Merge branch 'development' into feature/create_network_module
shuse2 Apr 26, 2019
1ebfd85
:bug: Fix merge problem
shuse2 Apr 26, 2019
69117bb
:bug: Fix broadcaster with latest development
shuse2 Apr 26, 2019
d72f2b9
:recycle: Fix config
shuse2 Apr 26, 2019
4422c43
Merge pull request #3453 from LiskHQ/merge_development_into_network_f…
shuse2 Apr 26, 2019
021aa87
Merge branch 'feature/create_network_module' into 3444-fix_network_co…
shuse2 Apr 26, 2019
dc50593
Merge branch 'development' into feature/create_network_module
shuse2 Apr 26, 2019
09a9880
Merge branch 'feature/create_network_module' into 3444-fix_network_co…
shuse2 Apr 26, 2019
79864f8
Merge pull request #3445 from LiskHQ/3444-fix_network_config
shuse2 Apr 26, 2019
68e7afa
:arrow_back: Skip network test
shuse2 Apr 26, 2019
dfa08e3
Merge branch 'development' into feature/create_network_module
shuse2 Apr 28, 2019
b915bf3
:recycle: Remove redundant code
shuse2 Apr 29, 2019
b5d06bc
Merge pull request #3458 from LiskHQ/3296-disable_network_test
shuse2 Apr 29, 2019
465ee0c
:recycle: Change event format and naming
shuse2 Apr 29, 2019
a7a21e4
Merge branch 'feature/create_network_module' of https://github.com/Li…
shuse2 Apr 29, 2019
03e25fb
Merge branch 'development' of https://github.com/LiskHQ/lisk-sdk into…
shuse2 Apr 29, 2019
316e98f
:bug: not to double listen in the bootstrap
shuse2 Apr 29, 2019
f337657
:recycle: Rename event to match the framework
shuse2 Apr 29, 2019
dca1cac
Merge branch 'development' of https://github.com/LiskHQ/lisk-sdk into…
shuse2 Apr 29, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion commander/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
"compilerOptions": {
"baseUrl": ".",
"noEmit": true,
"typeRoots": ["../../types", "../types", "../node_modules/@types", "../../node_modules/@types"]
"typeRoots": [
"../../types",
"../types",
"../node_modules/@types",
"../../node_modules/@types"
]
},
"references": [{ "path": ".." }],
"include": ["./**/*", "../../types/**/*", "../types/**/*", "../src/**/*"]
Expand Down
3 changes: 3 additions & 0 deletions elements/lisk-p2p/src/disconnect_status_codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export const INVALID_CONNECTION_QUERY_CODE = 4502;
export const INVALID_CONNECTION_QUERY_REASON =
'Peer did not provide valid query parameters as part of the WebSocket connection';

export const INVALID_CONNECTION_SELF_CODE = 4101;
export const INVALID_CONNECTION_SELF_REASON = 'Peer cannot connect to itself';

export const INCOMPATIBLE_NETWORK_CODE = 4102;
export const INCOMPATIBLE_NETWORK_REASON = 'Peer nethash did not match our own';

Expand Down
13 changes: 13 additions & 0 deletions elements/lisk-p2p/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ export class PeerInboundHandshakeError extends VError {
}
}

export class PeerOutboundConnectionError extends VError {
public statusCode?: number;

public constructor(
message: string,
statusCode?: number,
) {
super(message);
this.name = 'PeerOutboundConnectError';
this.statusCode = statusCode;
}
}

export class NotEnoughPeersError extends VError {
public constructor(message: string) {
super(message);
Expand Down
15 changes: 13 additions & 2 deletions elements/lisk-p2p/src/p2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import {
INCOMPATIBLE_PEER_UNKNOWN_REASON,
INVALID_CONNECTION_QUERY_CODE,
INVALID_CONNECTION_QUERY_REASON,
INVALID_CONNECTION_SELF_CODE,
INVALID_CONNECTION_SELF_REASON,
INVALID_CONNECTION_URL_CODE,
INVALID_CONNECTION_URL_REASON,
} from './disconnect_status_codes';
Expand Down Expand Up @@ -248,7 +250,7 @@ export class P2P extends EventEmitter {
this._bindHandlersToPeerPool(this._peerPool);

this._nodeInfo = config.nodeInfo;
this._peerPool.applyNodeInfo(this._nodeInfo);
this.applyNodeInfo(this._nodeInfo);

this._discoveryInterval = config.discoveryInterval
? config.discoveryInterval
Expand All @@ -275,7 +277,6 @@ export class P2P extends EventEmitter {
this._nodeInfo = {
...nodeInfo,
};

this._peerPool.applyNodeInfo(this._nodeInfo);
}

Expand Down Expand Up @@ -338,6 +339,16 @@ export class P2P extends EventEmitter {
}
const queryObject = url.parse(socket.request.url, true).query;

if (queryObject.nonce === this._nodeInfo.nonce) {
this._disconnectSocketDueToFailedHandshake(
socket,
INVALID_CONNECTION_SELF_CODE,
INVALID_CONNECTION_SELF_REASON,
);

return;
}

if (
typeof queryObject.wsPort !== 'string' ||
typeof queryObject.version !== 'string' ||
Expand Down
35 changes: 33 additions & 2 deletions elements/lisk-p2p/src/peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@

import { EventEmitter } from 'events';
import * as querystring from 'querystring';
import { FetchPeerStatusError, RPCResponseError } from './errors';
import {
FetchPeerStatusError,
PeerOutboundConnectionError,
RPCResponseError,
} from './errors';

import {
P2PDiscoveredPeerInfo,
Expand Down Expand Up @@ -264,7 +268,11 @@ export class Peer extends EventEmitter {
}

public set outboundSocket(scClientSocket: SCClientSocket) {
if (this._outboundSocket) {
this._unbindHandlersFromOutboundSocket(this._outboundSocket);
}
this._outboundSocket = scClientSocket;
this._bindHandlersToOutboundSocket(this._outboundSocket);
}

public updatePeerInfo(newPeerInfo: P2PDiscoveredPeerInfo): void {
Expand Down Expand Up @@ -633,6 +641,20 @@ export const connectAndRequest = async (
};

const outboundSocket = socketClusterClient.create(clientOptions);
// Bind an error handler immediately after creating the socket; otherwise errors may crash the process
// tslint:disable-next-line no-empty
outboundSocket.on('error', () => {});

// tslint:disable-next-line no-let
let disconnectStatusCode: number;
// tslint:disable-next-line no-let
let disconnectReason: string;
const closeHandler = (statusCode: number, reason: string) => {
disconnectStatusCode = statusCode;
disconnectReason = reason;
};
outboundSocket.once('close', closeHandler);

// Attaching handlers for various events that could be used future for logging or any other application
outboundSocket.emit(
REMOTE_EVENT_RPC_REQUEST,
Expand All @@ -641,8 +663,17 @@ export const connectAndRequest = async (
procedure: requestPacket.procedure,
},
(err: Error | undefined, responseData: unknown) => {
outboundSocket.off('close', closeHandler);
if (err) {
reject(err);
const isFailedConnection =
disconnectReason &&
(err.name === 'TimeoutError' ||
err.name === 'BadConnectionError');
const connectionError = new PeerOutboundConnectionError(
isFailedConnection ? disconnectReason : err.message,
disconnectStatusCode,
);
reject(connectionError);

return;
}
Expand Down
45 changes: 22 additions & 23 deletions elements/lisk-p2p/test/integration/p2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Integration tests for P2P library', () => {
height: 0,
broadhash:
'2768b267ae621a9ed3b3034e2e8a1bed40895c621bbb1bbd613d92b9d24e54b5',
nonce: 'O2wTkjqplHII5wPv',
nonce: `O2wTkjqplHII${nodePort}`,
},
});
});
Expand Down Expand Up @@ -91,6 +91,8 @@ describe('Integration tests for P2P library', () => {
},
];

const nodePort = NETWORK_START_PORT + index;

return new P2P({
blacklistedPeers: [],
seedPeers,
Expand All @@ -101,7 +103,7 @@ describe('Integration tests for P2P library', () => {
// Set a different discoveryInterval for each node; that way they don't keep trying to discover each other at the same time.
discoveryInterval: DISCOVERY_INTERVAL + index * 11,
nodeInfo: {
wsPort: NETWORK_START_PORT + index,
wsPort: nodePort,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly rename the variable to wsPort for clarity (at line 94)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And other places as well, just minor that can be considered.

nethash:
'da3ed6a45429278bac2666961289ca17ad86595d33b31037615d4b8e8f158bba',
minVersion: '1.0.1',
Expand All @@ -111,7 +113,7 @@ describe('Integration tests for P2P library', () => {
height: 0,
broadhash:
'2768b267ae621a9ed3b3034e2e8a1bed40895c621bbb1bbd613d92b9d24e54b5',
nonce: 'O2wTkjqplHII5wPv',
nonce: `O2wTkjqplHII${nodePort}`,
},
});
});
Expand Down Expand Up @@ -142,7 +144,8 @@ describe('Integration tests for P2P library', () => {
const peerPorts = connectedPeers
.map(peerInfo => peerInfo.wsPort)
.sort();
const expectedPeerPorts = ALL_NODE_PORTS;
const expectedPeerPorts = ALL_NODE_PORTS
.filter(peerPort => peerPort !== p2p.nodeInfo.wsPort);

expect(peerPorts).to.be.eql(expectedPeerPorts);
});
Expand Down Expand Up @@ -329,14 +332,16 @@ describe('Integration tests for P2P library', () => {
},
];

const nodePort = NETWORK_START_PORT + index;

return new P2P({
blacklistedPeers: [],
connectTimeout: 5000,
ackTimeout: 5000,
seedPeers,
wsEngine: 'ws',
nodeInfo: {
wsPort: NETWORK_START_PORT + index,
wsPort: nodePort,
nethash:
'da3ed6a45429278bac2666961289ca17ad86595d33b31037615d4b8e8f158bba',
version: '1.0.1',
Expand All @@ -346,7 +351,7 @@ describe('Integration tests for P2P library', () => {
height: 0,
broadhash:
'2768b267ae621a9ed3b3034e2e8a1bed40895c621bbb1bbd613d92b9d24e54b5',
nonce: 'O2wTkjqplHII5wPv',
nonce: `O2wTkjqplHII${nodePort}`,
},
});
});
Expand Down Expand Up @@ -377,18 +382,12 @@ describe('Integration tests for P2P library', () => {
.map(peerInfo => peerInfo.wsPort)
.sort();

// Right now we do not care whether the node includes itself in its own peer list.
// TODO later: Formalize the correct approach and assert it here.
const peerPortsExcludingSelf = peerPorts.filter(
wsPort => wsPort !== p2p.nodeInfo.wsPort,
);

// The current node should not be in its own peer list.
const expectedPeerPorts = ALL_NODE_PORTS.filter(port => {
return port !== p2p.nodeInfo.wsPort;
});

expect(peerPortsExcludingSelf).to.be.eql(expectedPeerPorts);
expect(peerPorts).to.be.eql(expectedPeerPorts);
});
});

Expand All @@ -408,18 +407,13 @@ describe('Integration tests for P2P library', () => {
const { triedPeers } = p2p.getNetworkStatus();

const peerPorts = triedPeers.map(peerInfo => peerInfo.wsPort).sort();
// Right now we do not care whether the node includes itself in its own peer list.
// TODO later: Formalize the correct approach and assert it here.
const peerPortsExcludingSelf = peerPorts.filter(
wsPort => wsPort !== p2p.nodeInfo.wsPort,
);

// The current node should not be in its own peer list.
const expectedPeerPorts = ALL_NODE_PORTS.filter(port => {
return port !== p2p.nodeInfo.wsPort;
});

expect(peerPortsExcludingSelf).to.be.eql(expectedPeerPorts);
expect(peerPorts).to.be.eql(expectedPeerPorts);
});
});
});
Expand Down Expand Up @@ -743,6 +737,8 @@ describe('Integration tests for P2P library', () => {
},
];

const nodePort = NETWORK_START_PORT + index;

return new P2P({
blacklistedPeers: [],
connectTimeout: 5000,
Expand All @@ -753,7 +749,7 @@ describe('Integration tests for P2P library', () => {
seedPeers,
wsEngine: 'ws',
nodeInfo: {
wsPort: NETWORK_START_PORT + index,
wsPort: nodePort,
nethash:
'da3ed6a45429278bac2666961289ca17ad86595d33b31037615d4b8e8f158bba',
version: '1.0.1',
Expand All @@ -762,7 +758,8 @@ describe('Integration tests for P2P library', () => {
height: 1000 + index,
broadhash:
'2768b267ae621a9ed3b3034e2e8a1bed40895c621bbb1bbd613d92b9d24e54b5',
nonce: 'O2wTkjqplHII5wPv',
nonce: `O2wTkjqplHII${nodePort}`,

modules: index % 2 === 0 ? ['fileTransfer'] : ['socialSite'],
},
});
Expand Down Expand Up @@ -901,6 +898,8 @@ describe('Integration tests for P2P library', () => {
},
];

const nodePort = NETWORK_START_PORT + index;

return new P2P({
blacklistedPeers: [],
seedPeers,
Expand All @@ -911,7 +910,7 @@ describe('Integration tests for P2P library', () => {
// Set a different discoveryInterval for each node; that way they don't keep trying to discover each other at the same time.
discoveryInterval: DISCOVERY_INTERVAL + index * 11,
nodeInfo: {
wsPort: NETWORK_START_PORT + index,
wsPort: nodePort,
nethash:
'da3ed6a45429278bac2666961289ca17ad86595d33b31037615d4b8e8f158bba',
version: '1.0.1',
Expand All @@ -921,7 +920,7 @@ describe('Integration tests for P2P library', () => {
height: 0,
broadhash:
'2768b267ae621a9ed3b3034e2e8a1bed40895c621bbb1bbd613d92b9d24e54b5',
nonce: 'O2wTkjqplHII5wPv',
nonce: `O2wTkjqplHII${nodePort}`,
modules: {
names: ['test', 'crypto'],
active: true,
Expand Down
1 change: 1 addition & 0 deletions framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
},
"dependencies": {
"@liskhq/lisk-cryptography": "2.1.0-alpha.0",
"@liskhq/lisk-p2p": "0.1.0-alpha.4",
"@liskhq/lisk-transaction-pool": "0.1.0-alpha.1",
"@liskhq/lisk-transactions": "2.1.0-alpha.4",
"ajv": "6.7.0",
Expand Down
4 changes: 3 additions & 1 deletion framework/src/controller/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const { createLoggerComponent } = require('../components/logger');

const ChainModule = require('../modules/chain');
const HttpAPIModule = require('../modules/http_api');
const NetworkModule = require('../modules/network');

// Private __private used because private keyword is restricted
const __private = {
Expand Down Expand Up @@ -152,6 +153,7 @@ class Application {
registeredTransactions: this.getTransactions(),
});
this.registerModule(HttpAPIModule);
this.registerModule(NetworkModule);
this.overrideModuleOptions(HttpAPIModule.alias, {
loadAsChildProcess: true,
});
Expand Down Expand Up @@ -348,7 +350,7 @@ class Application {
protocolVersion: this.config.app.protocolVersion,
nonce: this.config.app.nonce,
nethash: this.config.app.nethash,
wsPort: this.config.modules.chain.network.wsPort,
wsPort: this.config.modules.network.wsPort,
httpPort: this.config.modules.http_api.httpPort,
};

Expand Down
1 change: 0 additions & 1 deletion framework/src/controller/bus.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ class Bus extends EventEmitter2 {
if (!this.getEvents().includes(eventName)) {
throw new Error(`Event ${eventName} is not registered to bus.`);
}

shuse2 marked this conversation as resolved.
Show resolved Hide resolved
// Communicate through event emitter
this.emit(eventName, eventValue);

Expand Down
2 changes: 2 additions & 0 deletions framework/src/controller/default_configurator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const yargs = require('yargs');
const chainModule = require('../modules/chain');
const APIModule = require('../modules/http_api');
const NetworkModule = require('../modules/network');
const { config: loggerConfig } = require('../components/logger/defaults');
const { config: storageConfig } = require('../components/storage/defaults');
const { config: cacheConfig } = require('../components/cache/defaults');
Expand All @@ -13,6 +14,7 @@ configurator.registerSchema(storageConfig, 'components.storage');
configurator.registerSchema(cacheConfig, 'components.cache');
configurator.registerModule(chainModule);
configurator.registerModule(APIModule);
configurator.registerModule(NetworkModule);

yargs.command(
'usage',
Expand Down
3 changes: 0 additions & 3 deletions framework/src/modules/chain/api/index.js

This file was deleted.

Loading