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

Commit ada81f9

Browse files
authored
Merge pull request #240 from enigmampc/develop
Version 0.2.5
2 parents 748b7cb + 8dff193 commit ada81f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1491
-138453
lines changed

.drone.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
kind: pipeline
2+
name: default
3+
steps:
4+
5+
- name: integration
6+
image: enigmampc/docker-client
7+
privileged: true
8+
volumes:
9+
- name: sock
10+
path: /var/run/docker.sock
11+
commands:
12+
- git clone https://github.com/enigmampc/discovery-docker-network.git
13+
- cd discovery-docker-network && cp .env-template .env
14+
- sed -i "s/COMPOSE_PROJECT_NAME=.*/COMPOSE_PROJECT_NAME=enigma_${DRONE_BUILD_NUMBER}/" .env
15+
- export MATCHING_BRANCH_CORE="$(git ls-remote --heads https://github.com/enigmampc/enigma-core.git ${DRONE_BRANCH} | wc -l)"
16+
- export MATCHING_BRANCH_CONTRACT="$(git ls-remote --heads https://github.com/enigmampc/enigma-contract.git ${DRONE_BRANCH} | wc -l)"
17+
- export DOCKER_TAG=p2p_${DRONE_BUILD_NUMBER}
18+
- sed -i "s/DOCKER_TAG=latest/DOCKER_TAG=${DOCKER_TAG}/" .env;
19+
- |
20+
/bin/bash -c '
21+
declare -a PROJECTS=(core km contract)
22+
declare -A DOCKER_IMAGES=([core]=enigma_core_hw [km]=enigma_km_hw [contract]=enigma_contract)
23+
declare -A GIT_BRANCH_ARG=([core]=GIT_BRANCH_CORE [km]=GIT_BRANCH_CORE [contract]=GIT_BRANCH_CONTRACT)
24+
declare -A PROJECT_DIRECTORY=([core]=enigma-core [km]=enigma-core [contract]=enigma-contract)
25+
declare -A PROJECT_BRANCH_FOUND=([core]=$MATCHING_BRANCH_CORE [km]=$MATCHING_BRANCH_CORE [contract]=$MATCHING_BRANCH_CONTRACT)
26+
for project in $${PROJECTS[@]}; do
27+
DOCKER_IMAGE="enigmampc/$${DOCKER_IMAGES[$project]}"
28+
if [[ "$DRONE_BRANCH" == "master" ]]; then
29+
docker pull "$DOCKER_IMAGE:latest"
30+
docker tag "$DOCKER_IMAGE:latest" "$DOCKER_IMAGE:$DOCKER_TAG"
31+
elif [ "$${PROJECT_BRANCH_FOUND[$project]}" -eq 0 ]; then
32+
docker pull "$DOCKER_IMAGE:develop"
33+
docker tag "$DOCKER_IMAGE:develop" "$DOCKER_IMAGE:$DOCKER_TAG"
34+
else
35+
cd "$${PROJECT_DIRECTORY[$project]}"
36+
if [[ "$project" == "km" ]]; then
37+
docker build -f Dockerfile.km --build-arg GIT_BRANCH_CORE=${DRONE_BRANCH} --build-arg SGX_MODE=HW -t "$DOCKER_IMAGE:$DOCKER_TAG" --no-cache .
38+
elif [[ "$project" == "core" ]]; then
39+
docker build --build-arg GIT_BRANCH_CORE=${DRONE_BRANCH} --build-arg SGX_MODE=HW -t "$DOCKER_IMAGE:$DOCKER_TAG" --no-cache .
40+
else
41+
docker build --build-arg "$${GIT_BRANCH_ARG[$project]}=${DRONE_BRANCH}" -t "$DOCKER_IMAGE:$DOCKER_TAG" --no-cache .
42+
fi
43+
cd ..
44+
fi
45+
done'
46+
- cd enigma-p2p && docker build --build-arg GIT_BRANCH_P2P=${DRONE_BRANCH} -t enigmampc/enigma_p2p:$DOCKER_TAG --no-cache . && cd ..
47+
- export NODES=3
48+
- 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=$?
49+
- docker-compose -f docker-compose.yml -f docker-compose.hw.yml down -v --rmi all || true
50+
- if [ $RESULT -ne 0 ]; then exit 1; fi
51+
52+
- name: deploy
53+
image: enigmampc/docker-client
54+
depends_on:
55+
- integration
56+
when:
57+
branch:
58+
- develop
59+
- master
60+
privileged: true
61+
volumes:
62+
- name: sock
63+
path: /var/run/docker.sock
64+
environment:
65+
USERNAME:
66+
from_secret: username
67+
PASSWORD:
68+
from_secret: password
69+
commands:
70+
- cd discovery-docker-network/enigma-p2p
71+
- echo $PASSWORD | docker login -u $USERNAME --password-stdin
72+
- if [[ ${DRONE_BRANCH} == "master" ]]; then export DOCKER_TAG=latest; else export DOCKER_TAG=develop; fi
73+
- docker build --build-arg GIT_BRANCH_P2P=${DRONE_BRANCH} -t enigmampc/enigma_p2p:$DOCKER_TAG --no-cache .
74+
- docker push enigmampc/enigma_p2p:$DOCKER_TAG
75+
76+
volumes:
77+
- name: sock
78+
host:
79+
path: /var/run/docker.sock

.travis.yml

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
language: node_js
22

33
node_js:
4-
- "11.15"
5-
6-
env:
7-
- DOCKER_COMPOSE_VERSION=1.23.2
8-
9-
before_install:
10-
- sudo rm /usr/local/bin/docker-compose
11-
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
12-
- chmod +x docker-compose
13-
- sudo mv docker-compose /usr/local/bin
4+
- "10.16"
145

156
install:
167
- npm install -g [email protected]
@@ -21,29 +12,10 @@ script:
2112
- if [ ${TRAVIS_BRANCH} == "develop" ] || [ ${TRAVIS_BRANCH} == "master" ]; then
2213
echo $TRAVIS_BRANCH ; npm run test-tree;
2314
fi
24-
- git clone https://github.com/enigmampc/discovery-docker-network.git
25-
- if [[ $TRAVIS_BRANCH == "master" ]]; then export TAG=latest; else export TAG=develop; fi
26-
27-
- |
28-
pushd discovery-docker-network &&
29-
cp .env-template .env &&
30-
sed -i "s/SGX_MODE=HW/SGX_MODE=SW/" .env &&
31-
if [[ $TAG == "develop" ]]; then sed -i "s/DOCKER_TAG=latest/DOCKER_TAG=develop/" .env; fi &&
32-
sed -i "s/-vv/-v/" enigma-core/start_core.bash &&
33-
popd
34-
- 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
35-
- pushd discovery-docker-network && docker-compose -f docker-compose.yml -f docker-compose.test.yml up --exit-code-from client && popd
3615

3716
after_success:
3817
- npm run report-coverage
3918

4019
notifications:
4120
email:
4221
on_success: never
43-
44-
deploy:
45-
provider: script
46-
script: bash scripts/deploy.sh
47-
on:
48-
all_branches: true
49-
condition: $TRAVIS_BRANCH =~ ^master|develop$

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ The P2P implementation of the Enigma Worker. This implementation is part of the
77

88
| Branch | Build | Code Coverage |
99
|--------|-------|---------------|
10-
| 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) |
11-
| 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) |
10+
| 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) |
11+
| 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) |
1212

1313
# Table of Contents
1414

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

6262
1. install `nvm`
63-
2. install some node version : `$nvm install 11.15`
63+
2. install some node version : `$nvm install 10.16`
6464
3. type `npm install -g enigma-p2p`
6565
4. to run global type : `enigma-p2p-test <flags>`
6666

@@ -96,24 +96,26 @@ Example:
9696
1. launch a Bootstrap node:
9797

9898
```
99-
node cli_app.js -i B1 -b B1 -p B1 --core 127.0.0.1:1543 --proxy 3346 --random-db
99+
node cli_app.js -i B1 -b B1 -p B1 --core 127.0.0.1:1543 --proxy 3346 --random-db --mock-core
100100
```
101101

102102
2. launch a regular worker node that will connect to the bootstrap:
103103

104104
```
105-
node cli_app.js -b B1 --core 127.0.0.1:6000 --random-db
105+
node cli_app.js -b B1 --core 127.0.0.1:6000 --random-db --mock-core
106106
```
107107

108108
3. launch ANOTHER regular worker node that will connect to the bootstrap:
109109

110110
```
111-
node cli_app.js -b B1 --core 127.0.0.1:6001 --random-db
111+
node cli_app.js -b B1 --core 127.0.0.1:6001 --random-db --mock-core
112112
```
113113

114114
In this example:
115115

116-
`--core <ip>:<port>` enigma-core uri
116+
`--core <ip>:<port>` enigma-core uri. In this example we will be using a core simulation.
117+
118+
`--mock-core <ip>:<port>` launch a core simulation.
117119

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

@@ -126,6 +128,7 @@ In this example:
126128
`-p` run on a specific port since the bootstrap node is the first node everyone will connect to.
127129

128130

131+
129132
# Running the tests
130133

131134
Tests are based on `Mocha` and can invoked by typing:

docs/ARCHITECTURE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# enigma-p2p
22
| Branch | Build | Code Coverage |
33
|--------|-------|---------------|
4-
| 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) |
5-
| 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) |
4+
| 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) |
5+
| 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) |
66

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

docs/IPC_MESSAGES.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,26 @@ Response:
212212
}
213213
}
214214
```
215+
### `RemoveContract` message
216+
Request:
217+
```
218+
{
219+
id : <unique_request_id>,
220+
type : RemoveContract,
221+
address : ...,
222+
}
223+
```
224+
Response:
225+
```
226+
{
227+
id : <unique_request_id>,
228+
type : RemoveContract,
229+
address : ...,
230+
result : {
231+
status : 0 or err code
232+
}
233+
}
234+
```
215235
### `UpdateDeltas` message
216236
Request:
217237
```
@@ -228,11 +248,30 @@ Response:
228248
type : UpdateDeltas,
229249
result : {
230250
status: 0 or err code,
231-
errors: [{address,key,status : }, ...]
251+
errors: [{address, key, status : }, ...]
252+
}
253+
}
254+
```
255+
### `RemoveDeltas` message
256+
Request:
257+
```
258+
{
259+
id : <unique_request_id>,
260+
type : RemoveDeltas,
261+
input : [{address, from:key, to:key}, ...]
262+
}
263+
```
264+
Response:
265+
```
266+
{
267+
id : <unique_request_id>,
268+
type : RemoveDeltas,
269+
result : {
270+
status: 0 or err code,
271+
errors: [{address, key, status : }, ...]
232272
}
233273
}
234274
```
235-
236275
## Master Node Key-Exchange related
237276

238277
### `GetPTTRequest` message

docs/TASKS_LIFE_CYCLE_DOCS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ Every task is identified by its unique global id both in the system and in the n
3232
<summary>Failed</summary>
3333
<p>Indicates that the task execution failed. Always includes an error message.</p>
3434
</details>
35+
<details>
36+
<summary>Ethereum-Failure</summary>
37+
<p>Indicates that the task failed due to a failure in the Ethereum callback.</p>
38+
</details>
3539

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

4044
# Communication with the selected worker.
4145
Both for requests and status checks the communication is done via the `JsonRpc` component.
42-
The worker can respond to a status check at any time.
46+
The worker can respond to a status check at any time.

package-lock.json

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "enigma-p2p",
3-
"version": "0.2.4",
3+
"version": "0.2.5",
44
"description": "Enigma P2P library based on libp2p-js ",
55
"main": "src/index.js",
66
"bin": {
@@ -18,6 +18,10 @@
1818
},
1919
"author": "isan rivkin",
2020
"license": "AGPL-3.0-or-later",
21+
"repository": {
22+
"type": "git",
23+
"url": "https://github.com/enigmampc/enigma-p2p.git"
24+
},
2125
"dependencies": {
2226
"@nodeutils/defaults-deep": "^1.1.0",
2327
"async": "^2.6.1",

src/cli/cli_app.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class CLI {
2626
// Ethereum stuff
2727
this._initEthereum = false;
2828
this._enigmaContractAddress = null;
29+
this._enigmaContractAbiPath = null;
2930
this._ethereumWebsocketProvider = null;
3031
this._ethereumAddress = null;
3132
this._autoInit = false;
@@ -345,6 +346,10 @@ class CLI {
345346
this._initEthereum = true;
346347
this._enigmaContractAddress = address;
347348
})
349+
.option('--ethereum-contract-abi-path [value]', 'specify the Enigma contract ABI path', (path)=>{
350+
this._initEthereum = true;
351+
this._enigmaContractAbiPath = path;
352+
})
348353
.option('-E, --init-ethereum', 'init Ethereum', ()=>{
349354
this._initEthereum = true;
350355
})
@@ -394,7 +399,8 @@ class CLI {
394399
builder.setEthereumConfig({
395400
ethereumUrlProvider: this._ethereumWebsocketProvider,
396401
enigmaContractAddress: this._enigmaContractAddress,
397-
ethereumAddress: this._ethereumAddress
402+
ethereumAddress: this._ethereumAddress,
403+
ethereumContractAbiPath: this._enigmaContractAbiPath
398404
});
399405
}
400406
const nodeConfig = this._getFinalConfig();

src/client_api/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ if set to `true` will return the `output` of the task if and only if the task st
124124
- `INPROGRESS`: TaskId exists and it has been verified, in-progress
125125
- `SUCCESS`: Success
126126
- `FAILED`: Failure
127+
- `ETHEREUMFAILURE`: Task failed due to an Ethereum callback failure
127128

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

@@ -163,6 +164,7 @@ Queries the node for the potential result of a given Task identified by its `tas
163164
- `INPROGRESS`: TaskId exists and it has been verified, in-progress
164165
- `SUCCESS`: Success
165166
- `FAILED`: Failure
167+
- `ETHEREUMFAILURE`: Task failed due to an Ethereum callback failure
166168
167169
`output` - byte array representing the output of the computation.
168170
@@ -192,9 +194,12 @@ curl -H "Content-Type: application/json" -d '{"jsonrpc": "2.0","id":1,"method":"
192194
"taskId":"0x0033105ed3302282dddd38fcc8330a6448f6ae16bbcb26209d8740e8b3d28538",
193195
"status":"SUCCESS",
194196
"preCodeHash":"hash-of-the-precode-bytecode",
195-
"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",
197+
"output":[22,22,22,22,22,33,44,44,44,44,44,44,44,55,66,77,88,99],
198+
"delta":{"key":0,"data":[11,2,3,5,41,44]},
199+
"usedGas":"amount-of-gas-used",
196200
"ethereumPayload":"hex of payload",
197-
"ethereumAddress":"address of the payload","signature":"enclave-signature"
201+
"ethereumAddress":"address of the payload",
202+
"signature":"enclave-signature"
198203
}
199204
}
200205
}

0 commit comments

Comments
 (0)