0.2.5 • Published 5 years ago

enigma-p2p v0.2.5

Weekly downloads
-
License
AGPL-3.0-or-later
Repository
github
Last release
5 years ago

enigma-p2p

The Enigma Worker P2P package written in Node.js based on libp2p-js

The P2P implementation of the Enigma Worker. This implementation is part of the Node stack running as a process on the OS communicating both with Core and the outside world.

BranchBuildCode Coverage
MasterBuild Statuscodecov
DevelopBuild Statuscodecov

Table of Contents

Getting Started

Prerequisites

Installing

Until this module is not in npmjs.com:

git clone this repository

If running with Docker

cd into the project directory and type:

docker build .

To run later, save the final build hash or give it a name.

To run the node inside a container from the project directory type:

 docker run -v "$PWD":/usr/src/app -ti --net="host" <image-build-id> /bin/bash

Installing globally with nvm

  1. install nvm
  2. install some node version : $nvm install 10.16
  3. type npm install -g enigma-p2p
  4. to run global type : enigma-p2p-test <flags>

Incase of missing modules such as connect and tempdir install them in the same way.

npm install -g <missing module name>

Running the Node

Currently the node is started based on a command line interface. The node can be start from a single configuration file:

some/path/enigma-p2p/configs/template1.js

For usage example of single-config see unit-test.

Or with default configuration and CLI flags.

First:

cd ./src/cli

For help and list of flags:

$node cli_app.js -h

For the run-time commands the node can do:

While already running type help to see a list of all the available commands.

Example:

  1. launch a Bootstrap node:
node cli_app.js -i B1 -b B1 -p B1 --core 127.0.0.1:1543 --proxy 3346 --random-db --mock-core
  1. launch a regular worker node that will connect to the bootstrap:
node cli_app.js -b B1 --core 127.0.0.1:6000 --random-db --mock-core
  1. launch ANOTHER regular worker node that will connect to the bootstrap:
node cli_app.js -b B1 --core 127.0.0.1:6001 --random-db --mock-core

In this example:

--core <ip>:<port> enigma-core uri. In this example we will be using a core simulation.

--mock-core <ip>:<port> launch a core simulation.

--proxy <port> will start up the JSONrpc server as well.

--random-db is a must to generate a temporary database for the task management during testing.

-b flag for the bootstrap node, B1 is hard-coded for testing.

-i load specific node id from a hardcoded path.

-p run on a specific port since the bootstrap node is the first node everyone will connect to.

Running the tests

Tests are based on Mocha and can invoked by typing:

$npm test

JSON RPC API

The api for interacting with a proxy node.

Usage example:

  1. Start a bootstrap node which is also a Proxy
node cli_app.js -i B1 -b B1 -p B1 --core 127.0.0.1:1543 --proxy 3346 --random-db 
  1. start a regular worker that is NOT a proxy
node cli_app.js -b B1 --core 127.0.0.1:6000 --random-db
  1. IMPORTANT: assuming the worker from #2 is the selected one type selfSubscribe in the CLI so that the worker will subscribe to its own sign key. The key will be printed to std, copy it:

   [Wed Mar 27 2019 17:41:06 GMT+0200 (Israel Standard Time)] DEBUG subscribed to [0xd71c1bccb4b238cea332201bab1cd0fa70bec080] self signKey
  1. user wanting to call getWorkerEncryptionKey with curl see example and use the key from step 3 as the workerAddress parameter.

Built With

Developers

If you wish to learn more about the project and contribute make sure to checkout:

  1. On boarding guide
  2. In depth design

Authors

License

The Enigma Worker P2P is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.