lschoe / mpyc

MPyC: Multiparty Computation in Python
MIT License
367 stars 76 forks source link

Setting "-I" flag in local execution mode causes mpyc to hang on start #5

Closed aaronstjohn closed 4 years ago

aaronstjohn commented 4 years ago

Running a simple program:

#mpyc_tests.py
from mpyc.runtime import mpc
from mpyc.random import randint
print(f"M: {len(mpc.parties)} t:{mpc.threshold} pid:{mpc.pid}")
secint = mpc.SecInt()
mpc.run(mpc.start()) 
b_random = randint(secint,0,10)
print(f"Random int is : {mpc.run(mpc.output(b_random))}")

Run above without '--index' or '-I' flags works as expected:

$ python mpyc_tests.py -M8 -t2
M: 8 t:3 pid:0
2019-09-25 21:48:36,739 Start MPyC runtime v0.5.10
2019-09-25 21:48:36,964 All 8 parties connected.
Random int is : 5

Run with flags, sets the pid as expected but causes program to hang

$ python mpyc_tests.py -M8 -t2 -I1
M: 8 t:3 pid:1
2019-09-25 21:50:09,798 Start MPyC runtime v0.5.10
aaronstjohn commented 4 years ago

After looking at the code, it seems like I misunderstood how to use the flag.

After starting in one terminal tab:

$ python mpyc_tests.py -M8 -t2 -I1
<<hangs waiting for the other parties to join>>

I started:

python mpyc_tests.py -M8 -t2
<<To start the other parties up>>

In a second terminal tab which produced the output I would've expected:

$ python mpyc_tests.py -M8 -t2 -I1
M: 8 t:3 pid:1
2019-09-25 22:00:03,046 Start MPyC runtime v0.5.10
2019-09-25 22:00:05,558 All 8 parties connected.
Random bit is : 6

And:

$ python mpyc_tests.py -M8 -t2
M: 8 t:3 pid:0
2019-09-25 22:00:05,355 Start MPyC runtime v0.5.10
2019-09-25 22:00:05,580 All 8 parties connected.
Random bit is : 6