Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev (backend/demo) #2

Draft
wants to merge 31 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
688df34
hbswap demo
lilione Nov 1, 2020
c82b768
account sys
lilione Nov 23, 2020
47997c6
Revert to using original Compiler structure
sbellem Dec 17, 2020
13bea50
tmp
lilione Dec 22, 2020
5f0bfa4
add threshold for inputmask generation
lilione Dec 22, 2020
98319ac
test threshold
lilione Dec 22, 2020
4ba0818
change prime number
lilione Dec 22, 2020
0d1fb59
tmp
lilione Dec 23, 2020
e9d000d
deploy to testnet
lilione Dec 23, 2020
635d614
demo in a single container
lilione Jan 13, 2021
9caba65
wip: merge / containerization
sbellem Jan 14, 2021
ae77b82
Add more trades to simulation
sbellem Jan 20, 2021
61ca9ac
reconstruct zero share
lilione Jan 20, 2021
10b645a
liquidity provider implemented
lilione Jan 21, 2021
f72b56a
demo ready
lilione Jan 22, 2021
0badb66
Merge containerization with latest demo
sbellem Jan 23, 2021
402f4f1
Package honeybadgerswap python code
sbellem Jan 29, 2021
9261093
Re-org to extract to HoneyBadgerSwap repo
sbellem Jan 30, 2021
0b1d9e5
Move mpc programs for hbswap
sbellem Feb 1, 2021
1b026b0
Update docker-compose file and compile.sh
sbellem Feb 1, 2021
1f6ccc1
Add MP-SPDZ as git submodule
sbellem Feb 1, 2021
f4d6b9d
Add MP-SPDZ as a git submodule
sbellem Feb 1, 2021
5fcb03a
Adapt code to work with MP-SPDZ git submodule
sbellem Feb 1, 2021
a02539d
Create OPS.md
sbellem Feb 17, 2021
cbfcc92
Rename path to hbswap go code
sbellem Feb 25, 2021
4f62857
Set PYTHONUNBUFFERED=1 in docker-compose.yml
sbellem Feb 25, 2021
3290fb7
Rework hbswap.Dockerfile
sbellem Feb 25, 2021
d4ce505
Cleanup of a few .go files
sbellem Feb 25, 2021
94b422f
Access output from first line in server.go
sbellem Feb 25, 2021
4b3d313
Update MP-SPDZ gitmodule branch
sbellem Feb 25, 2021
4ebd71a
Refactor docker images to speed up build phase
sbellem Feb 25, 2021
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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
poa/data
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
poa/data
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "MP-SPDZ"]
path = MP-SPDZ
url = https://github.com/initc3/MP-SPDZ.git
branch = random-shamir-prep
79 changes: 79 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Go (server) dependencies
FROM golang:buster as go-deps

# ethereum
COPY --from=sbellem/go-ethereum:cfbb969da-buster \
/go/src/golang.org/x /go/src/golang.org/x
COPY --from=sbellem/go-ethereum:cfbb969da-buster \
/go/src/github.com/ethereum /go/src/github.com/ethereum

COPY src /go/src/github.com/initc3/HoneyBadgerSwap/src
WORKDIR /go/src/github.com/initc3/HoneyBadgerSwap/src
RUN go get -d -v ./...


# main image
FROM python:3.8

ENV PYTHONUNBUFFERED 1

# MP-SPDZ
# TODO: review dependencies as some of them may not be needed.
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libboost-dev \
libboost-thread-dev \
libsodium-dev \
libssl-dev \
libtool \
m4 \
texinfo \
yasm \
&& rm -rf /var/lib/apt/lists/*
# mpir
ENV LD_LIBRARY_PATH /usr/local/lib
RUN mkdir -p /usr/local/share/info
COPY --from=initc3/mpir:55fe6a9 /usr/local/mpir/lib/libmpir*.*a /usr/local/lib/
COPY --from=initc3/mpir:55fe6a9 /usr/local/mpir/lib/libmpir.so.23.0.3 /usr/local/lib/
COPY --from=initc3/mpir:55fe6a9 /usr/local/mpir/lib/libmpirxx.so.8.4.3 /usr/local/lib/
COPY --from=initc3/mpir:55fe6a9 /usr/local/mpir/include/mpir*.h /usr/local/include/
COPY --from=initc3/mpir:55fe6a9 /usr/local/mpir/share/info/* /usr/local/share/info/
RUN set -ex \
&& cd /usr/local/lib \
&& ln -s libmpir.so.23.0.3 libmpir.so \
&& ln -s libmpir.so.23.0.3 libmpir.so.23 \
&& ln -s libmpirxx.so.8.4.3 libmpirxx.so \
&& ln -s libmpirxx.so.8.4.3 libmpirxx.so.8

ENV HBSWAP_HOME /usr/src/hbswap
WORKDIR $HBSWAP_HOME
ENV INPUTMASK_SHARES "/opt/hbswap/inputmask-shares"
ENV PREP_DIR "/opt/hbswap/preprocessing-data"
COPY --from=sbellem/mpspdz:2cf97686-randomshamirprep\
/usr/src/MP-SPDZ/random-shamir.x /usr/src/hbswap/
COPY --from=sbellem/mpspdz:2cf97686-maliciousshamirparty \
/usr/src/MP-SPDZ/malicious-shamir-party.x /usr/src/hbswap/
RUN mkdir -p $INPUTMASK_SHARES $PREP_DIR
#############################################################################

# GO (server) dependencies
ENV PATH /usr/local/go/bin:$PATH
COPY --from=golang:1.15.8-buster /usr/local/go /usr/local/go
ENV GOPATH /go
ENV PATH $GOPATH/bin:$PATH
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
COPY --from=go-deps /go/src /go/src
#############################################################################

ENV DB_PATH /opt/hbswap/db

# Python (HTTP server) dependencies for HTTP server
RUN apt-get update && apt-get install -y --no-install-recommends \
lsof \
libmpfr-dev \
libmpc-dev \
&& rm -rf /var/lib/apt/lists/*

COPY src/python /usr/src/honeybadgerswap-python
WORKDIR /usr/src/honeybadgerswap-python
RUN pip install --editable .
1 change: 1 addition & 0 deletions MP-SPDZ
Submodule MP-SPDZ added at 2cf976
154 changes: 154 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
.PHONY: help

.DEFAULT_GOAL := help

define PRINT_HELP_PYSCRIPT
import re, sys

for line in sys.stdin:
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
print("%-20s %s" % (target, help))
endef

export PRINT_HELP_PYSCRIPT

help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)

clean: clean-mpc-progs
docker-compose run --rm ethnode rm -rf /opt/hbswap/poa/data
#docker-compose run --rm mpc.nodes rm -rf Scripts/hbswap/log/*

clean-mpc-progs:
docker-compose run --rm mpc.compile rm -rf Programs/Bytecode Programs/Schedules Programs/Public-Input

clean-player-data:
docker-compose run --rm mpc.trusted.setup rm -rf Player-Data/*

#down: down-init
down:
docker-compose -f docker-compose.yml -f liquidity-provider.yml -f trader.yml down --remove-orphans

stop:
docker-compose stop ethnode mpc.nodes

rm: clean
#docker-compose rm --stop --force ethnode contract.deploy contract.deposit
docker-compose rm --stop --force -v
docker volume rm \
hbswap_public-keys \
hbswap_secrets-p0 \
hbswap_secrets-p1 \
hbswap_secrets-p2 \
hbswap_secrets-p3

init-eth:
docker-compose up -d ethnode
docker-compose up contract.deploy
docker-compose up pool.init
docker-compose up client.deposit

simulation: down mpc-keys mpc-compile
docker-compose up -d ethnode
docker-compose up deploy.contract
docker-compose up -d \
mpcnode0 \
mpcnode1 \
mpcnode2 \
mpcnode3
docker-compose -f docker-compose.yml -f liquidity-provider.yml up init.pool
docker-compose -f docker-compose.yml -f trader.yml up public.deposit
docker-compose -f docker-compose.yml -f trader.yml up secret.deposit
docker-compose -f docker-compose.yml -f trader.yml up trade-1
docker-compose -f docker-compose.yml -f trader.yml up trade-2
docker-compose -f docker-compose.yml -f trader.yml up trade-1
docker-compose -f docker-compose.yml -f trader.yml up trade-2
docker-compose -f docker-compose.yml -f trader.yml up trade-1
docker-compose -f docker-compose.yml -f trader.yml up trade-2
docker-compose -f docker-compose.yml -f trader.yml up trade-1
docker-compose -f docker-compose.yml -f trader.yml up trade-2
docker-compose -f docker-compose.yml -f trader.yml up trade-1
docker-compose -f docker-compose.yml -f trader.yml up trade-2
docker-compose -f docker-compose.yml -f trader.yml up trade-1
docker-compose -f docker-compose.yml -f trader.yml up trade-2

start-hbswap:
docker-compose up -d ethnode
docker-compose up deploy.contract
docker-compose up -d \
mpcnode0 \
mpcnode1 \
mpcnode2 \
mpcnode3
#sh scripts/follow-sim-logs-with-tmux.sh

public-deposit:
docker-compose -f docker-compose.yml -f trader.yml up public.deposit

init-secrets:
docker-compose -f docker-compose.yml -f liquidity-provider.yml up init.pool
docker-compose -f docker-compose.yml -f trader.yml up secret.deposit

trade-1:
docker-compose -f docker-compose.yml -f trader.yml up trade-1

trade-2:
docker-compose -f docker-compose.yml -f trader.yml up trade-2

up-eth:
docker-compose up -d ethnode

deploy-contract: up-eth
docker-compose -f docker-compose.yml -f eth.yml up contract.deploy

lp-init-pool:
docker-compose -f docker-compose.yml -f liquidity-provider.yml up pool.init

trader-deposit:
docker-compose -f docker-compose.yml -f trader.yml up client.deposit

mpc-keys:
docker-compose up mpc.trusted.setup

mpc-compile:
docker-compose up mpc.compile

mpc-init-pool: mpc-keys mpc-compile
docker-compose up \
mpc.init.node.0 \
mpc.init.node.1 \
mpc.init.node.2 \
mpc.init.node.3

mpc:
docker-compose up -d \
mpcnode0 \
mpcnode1 \
mpcnode2 \
mpcnode3

run-client:
docker-compose up client

#up: ## run the example
up: down rm mpc-keys mpc-compile mpc-init-pool ## run the example
docker-compose up -d ethnode
docker-compose up contract.deploy
docker-compose up contract.deposit
docker-compose up -d mpcnode0 mpcnode1 mpcnode2 mpcnode3
docker-compose up -d client
sh scripts/follow-sim-logs-with-tmux.sh

down-init:
docker-compose -f hbswap-init.yml down --remove-orphans

rm-init: clean
docker-compose -f hbswap-init.yml rm --stop --force mpc.trusted.setup mpc.compile mpcnode0 mpcnode1 mpcnode2 mpcnode3
#docker-compose -f hbswap-init.yml rm --stop --force mpc.trusted.setup mpc.compile mpc.allnodes

up-init: down-init rm-init
docker-compose -f hbswap-init.yml up mpc.trusted.setup mpc.compile
docker-compose -f hbswap-init.yml up mpcnode0 mpcnode1 mpcnode2 mpcnode3
#docker-compose -f hbswap-init.yml up mpc.allnodes
16 changes: 16 additions & 0 deletions OPS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Dev Ops

## git submodule reminders

to update to latest submodule code:

```shell
git submodule update --remote
```

to change branch:

```shell
git config -f .gitmodules submodule.MP-SPDZ.branch new-branch-name
git submodule update --remote
```
26 changes: 26 additions & 0 deletions conf/client.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# MPC network configuation

# MPC network params
n = 4
t = 1

# MPC servers
[[servers]]
id = 0
host = "mpcnode0"
http_port = 8080

[[servers]]
id = 1
host = "mpcnode1"
http_port = 8080

[[servers]]
id = 2
host = "mpcnode2"
http_port = 8080

[[servers]]
id = 3
host = "mpcnode3"
http_port = 8080
30 changes: 30 additions & 0 deletions conf/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# MPC network configuation

# MPC network params
n = 4
t = 1

# MPC servers
[[servers]]
id = 0
host = "127.0.0.1"
http_host = "127.0.0.1"
http_port = 8080

[[servers]]
id = 1
host = "127.0.0.1"
http_host = "127.0.0.1"
http_port = 8081

[[servers]]
id = 2
host = "127.0.0.1"
http_host = "127.0.0.1"
http_port = 8082

[[servers]]
id = 3
host = "127.0.0.1"
http_host = "127.0.0.1"
http_port = 8083
30 changes: 30 additions & 0 deletions conf/server.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# MPC network configuation

# MPC network params
n = 4
t = 1

# MPC servers
[[servers]]
id = 0
host = "mpcnode0"
http_port = 8080
http_host = "0.0.0.0"

[[servers]]
id = 1
host = "mpcnode1"
http_port = 8080
http_host = "0.0.0.0"

[[servers]]
id = 2
host = "mpcnode2"
http_port = 8080
http_host = "0.0.0.0"

[[servers]]
id = 3
host = "mpcnode3"
http_port = 8080
http_host = "0.0.0.0"
Loading