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

Commit

Permalink
Merge pull request #240 from enigmampc/develop
Browse files Browse the repository at this point in the history
Version 0.2.5
  • Loading branch information
lacabra authored Oct 18, 2019
2 parents 748b7cb + 8dff193 commit ada81f9
Show file tree
Hide file tree
Showing 69 changed files with 1,491 additions and 138,453 deletions.
79 changes: 79 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
kind: pipeline
name: default
steps:

- name: integration
image: enigmampc/docker-client
privileged: true
volumes:
- name: sock
path: /var/run/docker.sock
commands:
- git clone https://github.com/enigmampc/discovery-docker-network.git
- cd discovery-docker-network && cp .env-template .env
- sed -i "s/COMPOSE_PROJECT_NAME=.*/COMPOSE_PROJECT_NAME=enigma_${DRONE_BUILD_NUMBER}/" .env
- export MATCHING_BRANCH_CORE="$(git ls-remote --heads https://github.com/enigmampc/enigma-core.git ${DRONE_BRANCH} | wc -l)"
- export MATCHING_BRANCH_CONTRACT="$(git ls-remote --heads https://github.com/enigmampc/enigma-contract.git ${DRONE_BRANCH} | wc -l)"
- export DOCKER_TAG=p2p_${DRONE_BUILD_NUMBER}
- sed -i "s/DOCKER_TAG=latest/DOCKER_TAG=${DOCKER_TAG}/" .env;
- |
/bin/bash -c '
declare -a PROJECTS=(core km contract)
declare -A DOCKER_IMAGES=([core]=enigma_core_hw [km]=enigma_km_hw [contract]=enigma_contract)
declare -A GIT_BRANCH_ARG=([core]=GIT_BRANCH_CORE [km]=GIT_BRANCH_CORE [contract]=GIT_BRANCH_CONTRACT)
declare -A PROJECT_DIRECTORY=([core]=enigma-core [km]=enigma-core [contract]=enigma-contract)
declare -A PROJECT_BRANCH_FOUND=([core]=$MATCHING_BRANCH_CORE [km]=$MATCHING_BRANCH_CORE [contract]=$MATCHING_BRANCH_CONTRACT)
for project in $${PROJECTS[@]}; do
DOCKER_IMAGE="enigmampc/$${DOCKER_IMAGES[$project]}"
if [[ "$DRONE_BRANCH" == "master" ]]; then
docker pull "$DOCKER_IMAGE:latest"
docker tag "$DOCKER_IMAGE:latest" "$DOCKER_IMAGE:$DOCKER_TAG"
elif [ "$${PROJECT_BRANCH_FOUND[$project]}" -eq 0 ]; then
docker pull "$DOCKER_IMAGE:develop"
docker tag "$DOCKER_IMAGE:develop" "$DOCKER_IMAGE:$DOCKER_TAG"
else
cd "$${PROJECT_DIRECTORY[$project]}"
if [[ "$project" == "km" ]]; then
docker build -f Dockerfile.km --build-arg GIT_BRANCH_CORE=${DRONE_BRANCH} --build-arg SGX_MODE=HW -t "$DOCKER_IMAGE:$DOCKER_TAG" --no-cache .
elif [[ "$project" == "core" ]]; then
docker build --build-arg GIT_BRANCH_CORE=${DRONE_BRANCH} --build-arg SGX_MODE=HW -t "$DOCKER_IMAGE:$DOCKER_TAG" --no-cache .
else
docker build --build-arg "$${GIT_BRANCH_ARG[$project]}=${DRONE_BRANCH}" -t "$DOCKER_IMAGE:$DOCKER_TAG" --no-cache .
fi
cd ..
fi
done'
- cd enigma-p2p && docker build --build-arg GIT_BRANCH_P2P=${DRONE_BRANCH} -t enigmampc/enigma_p2p:$DOCKER_TAG --no-cache . && cd ..
- export NODES=3
- docker-compose -f docker-compose.yml -f docker-compose.hw.yml -f docker-compose.test.yml up --scale core=$NODES --scale p2p=$NODES --exit-code-from client && export RESULT=$? || export RESULT=$?
- docker-compose -f docker-compose.yml -f docker-compose.hw.yml down -v --rmi all || true
- if [ $RESULT -ne 0 ]; then exit 1; fi

- name: deploy
image: enigmampc/docker-client
depends_on:
- integration
when:
branch:
- develop
- master
privileged: true
volumes:
- name: sock
path: /var/run/docker.sock
environment:
USERNAME:
from_secret: username
PASSWORD:
from_secret: password
commands:
- cd discovery-docker-network/enigma-p2p
- echo $PASSWORD | docker login -u $USERNAME --password-stdin
- if [[ ${DRONE_BRANCH} == "master" ]]; then export DOCKER_TAG=latest; else export DOCKER_TAG=develop; fi
- docker build --build-arg GIT_BRANCH_P2P=${DRONE_BRANCH} -t enigmampc/enigma_p2p:$DOCKER_TAG --no-cache .
- docker push enigmampc/enigma_p2p:$DOCKER_TAG

volumes:
- name: sock
host:
path: /var/run/docker.sock
30 changes: 1 addition & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
language: node_js

node_js:
- "11.15"

env:
- DOCKER_COMPOSE_VERSION=1.23.2

before_install:
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
- "10.16"

install:
- npm install -g [email protected]
Expand All @@ -21,29 +12,10 @@ script:
- if [ ${TRAVIS_BRANCH} == "develop" ] || [ ${TRAVIS_BRANCH} == "master" ]; then
echo $TRAVIS_BRANCH ; npm run test-tree;
fi
- git clone https://github.com/enigmampc/discovery-docker-network.git
- if [[ $TRAVIS_BRANCH == "master" ]]; then export TAG=latest; else export TAG=develop; fi

- |
pushd discovery-docker-network &&
cp .env-template .env &&
sed -i "s/SGX_MODE=HW/SGX_MODE=SW/" .env &&
if [[ $TAG == "develop" ]]; then sed -i "s/DOCKER_TAG=latest/DOCKER_TAG=develop/" .env; fi &&
sed -i "s/-vv/-v/" enigma-core/start_core.bash &&
popd
- pushd discovery-docker-network/enigma-p2p && docker build --build-arg GIT_BRANCH_P2P=$TRAVIS_BRANCH -t enigmampc/enigma_p2p:$TAG --no-cache . >/dev/null && popd
- pushd discovery-docker-network && docker-compose -f docker-compose.yml -f docker-compose.test.yml up --exit-code-from client && popd

after_success:
- npm run report-coverage

notifications:
email:
on_success: never

deploy:
provider: script
script: bash scripts/deploy.sh
on:
all_branches: true
condition: $TRAVIS_BRANCH =~ ^master|develop$
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ The P2P implementation of the Enigma Worker. This implementation is part of the

| Branch | Build | Code Coverage |
|--------|-------|---------------|
| Master |[![Build Status](https://travis-ci.com/enigmampc/enigma-p2p.svg?token=cNBBjbVVEGszuAJUokFT&branch=master)](https://travis-ci.com/enigmampc/enigma-p2p) | [![codecov](https://codecov.io/gh/enigmampc/enigma-p2p/branch/master/graph/badge.svg?token=SSyRKy7Ckg)](https://codecov.io/gh/enigmampc/enigma-p2p) |
| Develop |[![Build Status](https://travis-ci.com/enigmampc/enigma-p2p.svg?token=cNBBjbVVEGszuAJUokFT&branch=develop)](https://travis-ci.com/enigmampc/enigma-p2p) | [![codecov](https://codecov.io/gh/enigmampc/enigma-p2p/branch/develop/graph/badge.svg?token=SSyRKy7Ckg)](https://codecov.io/gh/enigmampc/enigma-p2p) |
| Master |[![Build Status](https://travis-ci.org/enigmampc/enigma-p2p.svg?branch=master)](https://travis-ci.org/enigmampc/enigma-p2p) | [![codecov](https://codecov.io/gh/enigmampc/enigma-p2p/branch/master/graph/badge.svg?token=SSyRKy7Ckg)](https://codecov.io/gh/enigmampc/enigma-p2p) |
| Develop |[![Build Status](https://travis-ci.org/enigmampc/enigma-p2p.svg?branch=develop)](https://travis-ci.org/enigmampc/enigma-p2p) | [![codecov](https://codecov.io/gh/enigmampc/enigma-p2p/branch/develop/graph/badge.svg?token=SSyRKy7Ckg)](https://codecov.io/gh/enigmampc/enigma-p2p) |

# Table of Contents

Expand Down Expand Up @@ -60,7 +60,7 @@ To run the node inside a container from the project directory type:
## Installing globally with nvm

1. install `nvm`
2. install some node version : `$nvm install 11.15`
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>`

Expand Down Expand Up @@ -96,24 +96,26 @@ 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
node cli_app.js -i B1 -b B1 -p B1 --core 127.0.0.1:1543 --proxy 3346 --random-db --mock-core
```

2. 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
node cli_app.js -b B1 --core 127.0.0.1:6000 --random-db --mock-core
```

3. 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
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
`--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.

Expand All @@ -126,6 +128,7 @@ In this example:
`-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:
Expand Down
4 changes: 2 additions & 2 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# enigma-p2p
| Branch | Build | Code Coverage |
|--------|-------|---------------|
| Master |[![Build Status](https://travis-ci.com/enigmampc/enigma-p2p.svg?token=cNBBjbVVEGszuAJUokFT&branch=master)](https://travis-ci.com/enigmampc/enigma-p2p) | [![codecov](https://codecov.io/gh/enigmampc/enigma-p2p/branch/master/graph/badge.svg?token=SSyRKy7Ckg)](https://codecov.io/gh/enigmampc/enigma-p2p) |
| Develop |[![Build Status](https://travis-ci.com/enigmampc/enigma-p2p.svg?token=cNBBjbVVEGszuAJUokFT&branch=develop)](https://travis-ci.com/enigmampc/enigma-p2p) | [![codecov](https://codecov.io/gh/enigmampc/enigma-p2p/branch/develop/graph/badge.svg?token=SSyRKy7Ckg)](https://codecov.io/gh/enigmampc/enigma-p2p) |
| Master |[![Build Status](https://travis-ci.org/enigmampc/enigma-p2p.svg?branch=master)](https://travis-ci.org/enigmampc/enigma-p2p) | [![codecov](https://codecov.io/gh/enigmampc/enigma-p2p/branch/master/graph/badge.svg?token=SSyRKy7Ckg)](https://codecov.io/gh/enigmampc/enigma-p2p) |
| Develop |[![Build Status](https://travis-ci.org/enigmampc/enigma-p2p.svg?branch=develop)](https://travis-ci.org/enigmampc/enigma-p2p) | [![codecov](https://codecov.io/gh/enigmampc/enigma-p2p/branch/develop/graph/badge.svg?token=SSyRKy7Ckg)](https://codecov.io/gh/enigmampc/enigma-p2p) |

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

Expand Down
43 changes: 41 additions & 2 deletions docs/IPC_MESSAGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,26 @@ Response:
}
}
```
### `RemoveContract` message
Request:
```
{
id : <unique_request_id>,
type : RemoveContract,
address : ...,
}
```
Response:
```
{
id : <unique_request_id>,
type : RemoveContract,
address : ...,
result : {
status : 0 or err code
}
}
```
### `UpdateDeltas` message
Request:
```
Expand All @@ -228,11 +248,30 @@ Response:
type : UpdateDeltas,
result : {
status: 0 or err code,
errors: [{address,key,status : }, ...]
errors: [{address, key, status : }, ...]
}
}
```
### `RemoveDeltas` message
Request:
```
{
id : <unique_request_id>,
type : RemoveDeltas,
input : [{address, from:key, to:key}, ...]
}
```
Response:
```
{
id : <unique_request_id>,
type : RemoveDeltas,
result : {
status: 0 or err code,
errors: [{address, key, status : }, ...]
}
}
```

## Master Node Key-Exchange related

### `GetPTTRequest` message
Expand Down
6 changes: 5 additions & 1 deletion docs/TASKS_LIFE_CYCLE_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ Every task is identified by its unique global id both in the system and in the n
<summary>Failed</summary>
<p>Indicates that the task execution failed. Always includes an error message.</p>
</details>
<details>
<summary>Ethereum-Failure</summary>
<p>Indicates that the task failed due to a failure in the Ethereum callback.</p>
</details>

# Task Result Propagation in the network
All the task results are either `Failed` or `Success`, and the result is published to a topic called `/task_status/0.1`.
This is how the nodes including the **Gateway** node of the user will be informed once the result is ready.

# Communication with the selected worker.
Both for requests and status checks the communication is done via the `JsonRpc` component.
The worker can respond to a status check at any time.
The worker can respond to a status check at any time.
13 changes: 8 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "enigma-p2p",
"version": "0.2.4",
"version": "0.2.5",
"description": "Enigma P2P library based on libp2p-js ",
"main": "src/index.js",
"bin": {
Expand All @@ -18,6 +18,10 @@
},
"author": "isan rivkin",
"license": "AGPL-3.0-or-later",
"repository": {
"type": "git",
"url": "https://github.com/enigmampc/enigma-p2p.git"
},
"dependencies": {
"@nodeutils/defaults-deep": "^1.1.0",
"async": "^2.6.1",
Expand Down
8 changes: 7 additions & 1 deletion src/cli/cli_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class CLI {
// Ethereum stuff
this._initEthereum = false;
this._enigmaContractAddress = null;
this._enigmaContractAbiPath = null;
this._ethereumWebsocketProvider = null;
this._ethereumAddress = null;
this._autoInit = false;
Expand Down Expand Up @@ -345,6 +346,10 @@ class CLI {
this._initEthereum = true;
this._enigmaContractAddress = address;
})
.option('--ethereum-contract-abi-path [value]', 'specify the Enigma contract ABI path', (path)=>{
this._initEthereum = true;
this._enigmaContractAbiPath = path;
})
.option('-E, --init-ethereum', 'init Ethereum', ()=>{
this._initEthereum = true;
})
Expand Down Expand Up @@ -394,7 +399,8 @@ class CLI {
builder.setEthereumConfig({
ethereumUrlProvider: this._ethereumWebsocketProvider,
enigmaContractAddress: this._enigmaContractAddress,
ethereumAddress: this._ethereumAddress
ethereumAddress: this._ethereumAddress,
ethereumContractAbiPath: this._enigmaContractAbiPath
});
}
const nodeConfig = this._getFinalConfig();
Expand Down
9 changes: 7 additions & 2 deletions src/client_api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ if set to `true` will return the `output` of the task if and only if the task st
- `INPROGRESS`: TaskId exists and it has been verified, in-progress
- `SUCCESS`: Success
- `FAILED`: Failure
- `ETHEREUMFAILURE`: Task failed due to an Ethereum callback failure

`output` - byte array representing the output of the computation

Expand Down Expand Up @@ -163,6 +164,7 @@ Queries the node for the potential result of a given Task identified by its `tas
- `INPROGRESS`: TaskId exists and it has been verified, in-progress
- `SUCCESS`: Success
- `FAILED`: Failure
- `ETHEREUMFAILURE`: Task failed due to an Ethereum callback failure
`output` - byte array representing the output of the computation.
Expand Down Expand Up @@ -192,9 +194,12 @@ curl -H "Content-Type: application/json" -d '{"jsonrpc": "2.0","id":1,"method":"
"taskId":"0x0033105ed3302282dddd38fcc8330a6448f6ae16bbcb26209d8740e8b3d28538",
"status":"SUCCESS",
"preCodeHash":"hash-of-the-precode-bytecode",
"output":[22,22,22,22,22,33,44,44,44,44,44,44,44,55,66,77,88,99],"delta":{"key":0,"data":[11,2,3,5,41,44]},"usedGas":"amount-of-gas-used",
"output":[22,22,22,22,22,33,44,44,44,44,44,44,44,55,66,77,88,99],
"delta":{"key":0,"data":[11,2,3,5,41,44]},
"usedGas":"amount-of-gas-used",
"ethereumPayload":"hex of payload",
"ethereumAddress":"address of the payload","signature":"enclave-signature"
"ethereumAddress":"address of the payload",
"signature":"enclave-signature"
}
}
}
Expand Down
Loading

0 comments on commit ada81f9

Please sign in to comment.