Skip to content

Commit

Permalink
Add "induce_faults" to the config
Browse files Browse the repository at this point in the history
Add a config value to induce faults during reconsutrction - both
batch_reconstruct and robust_reconstruct. This would
cause the code to go to the non-optimistic path. This will be helpful
during benchmarking since this would prevent us from having to
rebuild/redeploy the code again and again.
  • Loading branch information
smkuls committed Mar 2, 2019
1 parent 4e8d479 commit c993aa8
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 44 deletions.
20 changes: 20 additions & 0 deletions conf/mpc_with_faults/local.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"N": 4,
"t": 1,
"my_id": 0,
"peers": [
"localhost:7000",
"localhost:7001",
"localhost:7002",
"localhost:7003"
],
"reconstruction": {
"induce_faults": true
},
"extra": {
"k": 8,
"run_id": "82d7c0b8040f4ca1b3ff6b9d27888fef",
"public_key": "gANjX19tYWluX18KVEJMU1B1YmxpY0tleQpxACmBcQF9cQIoWAEAAABscQNLBFgBAAAAa3EESwJYAgAAAFZLcQVDVWOtlZ1Ns2/KbccoQ0somPzJfJw+UK9tcMnh9aRGHOEDXgoKzNJ1heQ9e9ZeyMDcxgC31gbI/Pmtej3MJ8f5qdHpILC/5tb+jPKivxJ6D5BZs4dW+ABxBlgDAAAAVktzcQddcQgoQ1Ulox8fmCgO8Lh92WEZAgW9xlkmolSOh4OgMs0WHY3Is5mLpjFWALP/0ghWk5i5gR4jqyQ/lgJ5EQL0chfMgCAHsW4k8YAvRP4IEg6lu70p2qNY5KcBcQlDVToorXqzQpuGfsqHDMqGNRCOf1bnzh8scULqbDFxWT7hAIA2mers8STlP0QiuCd7GW4PT+AWYCuWQZHr3EUDBkQ3JyEslHZpx84YIacXt6dXcK5IvQFxCkNVMOrp4Q7YNNV5qsH++3jkM0hzAUHW+gWYopN1IFSmooXv3uk5xvo4m9b4zZQ9FGr39LWSZD0I92ht3mndOkHKilUGV22z4Wm1+sAU3WNdWX3tnNiNAXELQ1Ufmpi4bhSz6c+SEFBiBeC6v5ThcKTM3FExaJuHSO1wT6Xa1tBBCmKdPFFqUA6BEx6AyLMihBNkdQGk5gAAnjfK6HXox3Zikb8MwKVid56zzRdpvfwBcQxldWIu",
"private_key": "gANjX19tYWluX18KVEJMU1ByaXZhdGVLZXkKcQApgXEBfXECKFgBAAAAbHEDSwRYAQAAAGtxBEsCWAIAAABWS3EFQ1VjrZWdTbNvym3HKENLKJj8yXycPlCvbXDJ4fWkRhzhA14KCszSdYXkPXvWXsjA3MYAt9YGyPz5rXo9zCfH+anR6SCwv+bW/ozyor8Seg+QWbOHVvgAcQZYAwAAAFZLc3EHXXEIKENVJaMfH5goDvC4fdlhGQIFvcZZJqJUjoeDoDLNFh2NyLOZi6YxVgCz/9IIVpOYuYEeI6skP5YCeREC9HIXzIAgB7FuJPGAL0T+CBIOpbu9KdqjWOSnAXEJQ1U6KK16s0Kbhn7KhwzKhjUQjn9W584fLHFC6mwxcVk+4QCANpnq7PEk5T9EIrgnexluD0/gFmArlkGR69xFAwZENychLJR2acfOGCGnF7enV3CuSL0BcQpDVTDq6eEO2DTVearB/vt45DNIcwFB1voFmKKTdSBUpqKF797pOcb6OJvW+M2UPRRq9/S1kmQ9CPdobd5p3TpByopVBldts+FptfrAFN1jXVl97ZzYjQFxC0NVH5qYuG4Us+nPkhBQYgXgur+U4XCkzNxRMWibh0jtcE+l2tbQQQpinTxRalAOgRMegMizIoQTZHUBpOYAAJ43yuh16Md2YpG/DMClYnees80Xab38AXEMZVgBAAAAaXENSwBYAgAAAFNLcQ5DHEBitQwnmtBTmLgWDcrngXWZKO2uXnwOCgkAvlpxD3ViLg=="
}
}
17 changes: 17 additions & 0 deletions conf/mpc_with_faults/local.1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"N": 4,
"t": 1,
"my_id": 1,
"peers": [
"localhost:7000",
"localhost:7001",
"localhost:7002",
"localhost:7003"
],
"extra": {
"k": 8,
"run_id": "82d7c0b8040f4ca1b3ff6b9d27888fef",
"public_key": "gANjX19tYWluX18KVEJMU1B1YmxpY0tleQpxACmBcQF9cQIoWAEAAABscQNLBFgBAAAAa3EESwJYAgAAAFZLcQVDVWOtlZ1Ns2/KbccoQ0somPzJfJw+UK9tcMnh9aRGHOEDXgoKzNJ1heQ9e9ZeyMDcxgC31gbI/Pmtej3MJ8f5qdHpILC/5tb+jPKivxJ6D5BZs4dW+ABxBlgDAAAAVktzcQddcQgoQ1Ulox8fmCgO8Lh92WEZAgW9xlkmolSOh4OgMs0WHY3Is5mLpjFWALP/0ghWk5i5gR4jqyQ/lgJ5EQL0chfMgCAHsW4k8YAvRP4IEg6lu70p2qNY5KcBcQlDVToorXqzQpuGfsqHDMqGNRCOf1bnzh8scULqbDFxWT7hAIA2mers8STlP0QiuCd7GW4PT+AWYCuWQZHr3EUDBkQ3JyEslHZpx84YIacXt6dXcK5IvQFxCkNVMOrp4Q7YNNV5qsH++3jkM0hzAUHW+gWYopN1IFSmooXv3uk5xvo4m9b4zZQ9FGr39LWSZD0I92ht3mndOkHKilUGV22z4Wm1+sAU3WNdWX3tnNiNAXELQ1Ufmpi4bhSz6c+SEFBiBeC6v5ThcKTM3FExaJuHSO1wT6Xa1tBBCmKdPFFqUA6BEx6AyLMihBNkdQGk5gAAnjfK6HXox3Zikb8MwKVid56zzRdpvfwBcQxldWIu",
"private_key": "gANjX19tYWluX18KVEJMU1ByaXZhdGVLZXkKcQApgXEBfXECKFgBAAAAbHEDSwRYAQAAAGtxBEsCWAIAAABWS3EFQ1VjrZWdTbNvym3HKENLKJj8yXycPlCvbXDJ4fWkRhzhA14KCszSdYXkPXvWXsjA3MYAt9YGyPz5rXo9zCfH+anR6SCwv+bW/ozyor8Seg+QWbOHVvgAcQZYAwAAAFZLc3EHXXEIKENVJaMfH5goDvC4fdlhGQIFvcZZJqJUjoeDoDLNFh2NyLOZi6YxVgCz/9IIVpOYuYEeI6skP5YCeREC9HIXzIAgB7FuJPGAL0T+CBIOpbu9KdqjWOSnAXEJQ1U6KK16s0Kbhn7KhwzKhjUQjn9W584fLHFC6mwxcVk+4QCANpnq7PEk5T9EIrgnexluD0/gFmArlkGR69xFAwZENychLJR2acfOGCGnF7enV3CuSL0BcQpDVTDq6eEO2DTVearB/vt45DNIcwFB1voFmKKTdSBUpqKF797pOcb6OJvW+M2UPRRq9/S1kmQ9CPdobd5p3TpByopVBldts+FptfrAFN1jXVl97ZzYjQFxC0NVH5qYuG4Us+nPkhBQYgXgur+U4XCkzNxRMWibh0jtcE+l2tbQQQpinTxRalAOgRMegMizIoQTZHUBpOYAAJ43yuh16Md2YpG/DMClYnees80Xab38AXEMZVgBAAAAaXENSwFYAgAAAFNLcQ5DHF8IxDi+fpchoNuyDYCNrDKI6gOBi7g0u5dJe3NxD3ViLg=="
}
}
17 changes: 17 additions & 0 deletions conf/mpc_with_faults/local.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"N": 4,
"t": 1,
"my_id": 2,
"peers": [
"localhost:7000",
"localhost:7001",
"localhost:7002",
"localhost:7003"
],
"extra": {
"k": 8,
"run_id": "82d7c0b8040f4ca1b3ff6b9d27888fef",
"public_key": "gANjX19tYWluX18KVEJMU1B1YmxpY0tleQpxACmBcQF9cQIoWAEAAABscQNLBFgBAAAAa3EESwJYAgAAAFZLcQVDVWOtlZ1Ns2/KbccoQ0somPzJfJw+UK9tcMnh9aRGHOEDXgoKzNJ1heQ9e9ZeyMDcxgC31gbI/Pmtej3MJ8f5qdHpILC/5tb+jPKivxJ6D5BZs4dW+ABxBlgDAAAAVktzcQddcQgoQ1Ulox8fmCgO8Lh92WEZAgW9xlkmolSOh4OgMs0WHY3Is5mLpjFWALP/0ghWk5i5gR4jqyQ/lgJ5EQL0chfMgCAHsW4k8YAvRP4IEg6lu70p2qNY5KcBcQlDVToorXqzQpuGfsqHDMqGNRCOf1bnzh8scULqbDFxWT7hAIA2mers8STlP0QiuCd7GW4PT+AWYCuWQZHr3EUDBkQ3JyEslHZpx84YIacXt6dXcK5IvQFxCkNVMOrp4Q7YNNV5qsH++3jkM0hzAUHW+gWYopN1IFSmooXv3uk5xvo4m9b4zZQ9FGr39LWSZD0I92ht3mndOkHKilUGV22z4Wm1+sAU3WNdWX3tnNiNAXELQ1Ufmpi4bhSz6c+SEFBiBeC6v5ThcKTM3FExaJuHSO1wT6Xa1tBBCmKdPFFqUA6BEx6AyLMihBNkdQGk5gAAnjfK6HXox3Zikb8MwKVid56zzRdpvfwBcQxldWIu",
"private_key": "gANjX19tYWluX18KVEJMU1ByaXZhdGVLZXkKcQApgXEBfXECKFgBAAAAbHEDSwRYAQAAAGtxBEsCWAIAAABWS3EFQ1VjrZWdTbNvym3HKENLKJj8yXycPlCvbXDJ4fWkRhzhA14KCszSdYXkPXvWXsjA3MYAt9YGyPz5rXo9zCfH+anR6SCwv+bW/ozyor8Seg+QWbOHVvgAcQZYAwAAAFZLc3EHXXEIKENVJaMfH5goDvC4fdlhGQIFvcZZJqJUjoeDoDLNFh2NyLOZi6YxVgCz/9IIVpOYuYEeI6skP5YCeREC9HIXzIAgB7FuJPGAL0T+CBIOpbu9KdqjWOSnAXEJQ1U6KK16s0Kbhn7KhwzKhjUQjn9W584fLHFC6mwxcVk+4QCANpnq7PEk5T9EIrgnexluD0/gFmArlkGR69xFAwZENychLJR2acfOGCGnF7enV3CuSL0BcQpDVTDq6eEO2DTVearB/vt45DNIcwFB1voFmKKTdSBUpqKF797pOcb6OJvW+M2UPRRq9/S1kmQ9CPdobd5p3TpByopVBldts+FptfrAFN1jXVl97ZzYjQFxC0NVH5qYuG4Us+nPkhBQYgXgur+U4XCkzNxRMWibh0jtcE+l2tbQQQpinTxRalAOgRMegMizIoQTZHUBpOYAAJ43yuh16Md2YpG/DMClYnees80Xab38AXEMZVgBAAAAaXENSwJYAgAAAFNLcQ5DHH2u02VVYl3vqP9ODTYz1u94qxlUuPRbbSWSOIxxD3ViLg=="
}
}
17 changes: 17 additions & 0 deletions conf/mpc_with_faults/local.3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"N": 4,
"t": 1,
"my_id": 3,
"peers": [
"localhost:7000",
"localhost:7001",
"localhost:7002",
"localhost:7003"
],
"extra": {
"k": 8,
"run_id": "82d7c0b8040f4ca1b3ff6b9d27888fef",
"public_key": "gANjX19tYWluX18KVEJMU1B1YmxpY0tleQpxACmBcQF9cQIoWAEAAABscQNLBFgBAAAAa3EESwJYAgAAAFZLcQVDVWOtlZ1Ns2/KbccoQ0somPzJfJw+UK9tcMnh9aRGHOEDXgoKzNJ1heQ9e9ZeyMDcxgC31gbI/Pmtej3MJ8f5qdHpILC/5tb+jPKivxJ6D5BZs4dW+ABxBlgDAAAAVktzcQddcQgoQ1Ulox8fmCgO8Lh92WEZAgW9xlkmolSOh4OgMs0WHY3Is5mLpjFWALP/0ghWk5i5gR4jqyQ/lgJ5EQL0chfMgCAHsW4k8YAvRP4IEg6lu70p2qNY5KcBcQlDVToorXqzQpuGfsqHDMqGNRCOf1bnzh8scULqbDFxWT7hAIA2mers8STlP0QiuCd7GW4PT+AWYCuWQZHr3EUDBkQ3JyEslHZpx84YIacXt6dXcK5IvQFxCkNVMOrp4Q7YNNV5qsH++3jkM0hzAUHW+gWYopN1IFSmooXv3uk5xvo4m9b4zZQ9FGr39LWSZD0I92ht3mndOkHKilUGV22z4Wm1+sAU3WNdWX3tnNiNAXELQ1Ufmpi4bhSz6c+SEFBiBeC6v5ThcKTM3FExaJuHSO1wT6Xa1tBBCmKdPFFqUA6BEx6AyLMihBNkdQGk5gAAnjfK6HXox3Zikb8MwKVid56zzRdpvfwBcQxldWIu",
"private_key": "gANjX19tYWluX18KVEJMU1ByaXZhdGVLZXkKcQApgXEBfXECKFgBAAAAbHEDSwRYAQAAAGtxBEsCWAIAAABWS3EFQ1VjrZWdTbNvym3HKENLKJj8yXycPlCvbXDJ4fWkRhzhA14KCszSdYXkPXvWXsjA3MYAt9YGyPz5rXo9zCfH+anR6SCwv+bW/ozyor8Seg+QWbOHVvgAcQZYAwAAAFZLc3EHXXEIKENVJaMfH5goDvC4fdlhGQIFvcZZJqJUjoeDoDLNFh2NyLOZi6YxVgCz/9IIVpOYuYEeI6skP5YCeREC9HIXzIAgB7FuJPGAL0T+CBIOpbu9KdqjWOSnAXEJQ1U6KK16s0Kbhn7KhwzKhjUQjn9W584fLHFC6mwxcVk+4QCANpnq7PEk5T9EIrgnexluD0/gFmArlkGR69xFAwZENychLJR2acfOGCGnF7enV3CuSL0BcQpDVTDq6eEO2DTVearB/vt45DNIcwFB1voFmKKTdSBUpqKF797pOcb6OJvW+M2UPRRq9/S1kmQ9CPdobd5p3TpByopVBldts+FptfrAFN1jXVl97ZzYjQFxC0NVH5qYuG4Us+nPkhBQYgXgur+U4XCkzNxRMWibh0jtcE+l2tbQQQpinTxRalAOgRMegMizIoQTZHUBpOYAAJ43yuh16Md2YpG/DMClYnees80Xab38AXEMZVgBAAAAaXENSwNYAgAAAFNLcQ5DHA2f5ZwEFHhC+5FcojW4UlIB2nOLscvy/FqUephxD3ViLg=="
}
}
22 changes: 0 additions & 22 deletions conf/sample.ini

This file was deleted.

18 changes: 18 additions & 0 deletions conf/sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Look at config.py to understand how this config is used within HBMPC.
{
"N": 4, // Total number of parties
"t": 1, // Value of the threshold for corrupt parties
"my_id": 3, // Id of the current node
"skip_preprocessing": true, // To indicate if the preprocessing needs to be skipped, by default it is NOT skipped
// Network details of all participating parties
"peers": [
"localhost:7000",
"localhost:7001",
"localhost:7002",
"localhost:7003"
],
// Any other parameter needed by the MPC appliction
"extra": {
"k": 8
}
}
11 changes: 9 additions & 2 deletions honeybadgermpc/batch_reconstruction.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
from random import randint
from .field import GF
from .polynomial import polynomials_over, EvalPoint, fnt_decode_step1
from .robust_reconstruction import attempt_reconstruct, robust_reconstruct
Expand Down Expand Up @@ -229,8 +230,8 @@ async def batch_interpolate(data_receivers, field, point, n, t):
return None


async def batch_reconstruct(elem_batches, p, t, n, myid, send, recv, debug=False,
use_fft=False):
async def batch_reconstruct(elem_batches, p, t, n, myid, send, recv, config=None,
debug=False, use_fft=False):
"""
args:
shared_secrets: an array of points representing shared secrets S1 - SB
Expand All @@ -248,7 +249,13 @@ async def batch_reconstruct(elem_batches, p, t, n, myid, send, recv, debug=False
Reconstruction takes places in chunks of t+1 values
"""

fp = GF.get(p)

if config is not None and config.induce_faults:
logging.debug("[FAULT][BatchReconsutrction] Sending random shares.")
elem_batches = [fp(randint(0, fp.modulus-1)) for _ in range(len(elem_batches))]

poly = polynomials_over(fp)
point = EvalPoint(fp, n, use_fft=use_fft)
bench_logger = logging.LoggerAdapter(logging.getLogger("benchmark_logger"),
Expand Down
17 changes: 17 additions & 0 deletions honeybadgermpc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,23 @@ def __init__(self, ip, port):
self.port = port


class ConfigVars(object):
Reconstruction = "reconstruction"


class ReconstructionConfig(object):
def __init__(self, induce_faults):
self.induce_faults = induce_faults


class HbmpcConfig(object):
N = None
t = None
my_id = None
peers = None
skip_preprocessing = False
extras = None
reconstruction = None

@staticmethod
def load_config():
Expand Down Expand Up @@ -67,6 +77,13 @@ def load_config():
if "extra" in config:
HbmpcConfig.extras = config["extra"]

induce_faults = False
if "reconstruction" in config:
if "induce_faults" in config["reconstruction"]:
induce_faults = config["reconstruction"]["induce_faults"]

HbmpcConfig.reconstruction = ReconstructionConfig(induce_faults)

# Ensure the required values are set before this method terminates
assert HbmpcConfig.my_id is not None, "Node Id: missing"
assert HbmpcConfig.N is not None, "N: missing"
Expand Down
19 changes: 11 additions & 8 deletions honeybadgermpc/ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import socket
import logging
from .mpc import Mpc
from .config import HbmpcConfig, ConfigVars
from .program_runner import ProgramRunner
from .preprocessing import wait_for_preprocessing, preprocessing_done

Expand Down Expand Up @@ -201,13 +202,15 @@ async def close(self):


class ProcessProgramRunner(ProgramRunner):
def __init__(self, config, n, t, nodeid, mixin_ops={}):
self.config = config
def __init__(self, network_config, n, t, nodeid, config={}):
self.network_config = network_config
self.N, self.t, self.nodeid = n, t, nodeid
self.senders = Senders([asyncio.Queue() for _ in range(n)], config, nodeid)
self.listener = Listener(config[nodeid].port)
self.senders = Senders(
[asyncio.Queue() for _ in range(n)], network_config, nodeid)
self.listener = Listener(network_config[nodeid].port)
self.programs = []
self.mixin_ops = mixin_ops
self.config = config
self.config[ConfigVars.Reconstruction] = HbmpcConfig.reconstruction

def get_send_and_recv(self, sid):
listener_queue = self.listener.get_program_queue(sid)
Expand Down Expand Up @@ -244,7 +247,7 @@ def add(self, sid, program, **kwargs):
send,
recv,
program,
self.mixin_ops,
self.config,
**kwargs,
)
self.programs.append(asyncio.ensure_future(context._run()))
Expand All @@ -270,9 +273,8 @@ async def close(self):


if __name__ == "__main__":
from .mpc import test_prog1, test_prog2
from .mpc import test_prog1, test_prog2, test_batchopening
from .preprocessing import PreProcessedElements
from .config import HbmpcConfig

asyncio.set_event_loop(asyncio.new_event_loop())
loop = asyncio.get_event_loop()
Expand All @@ -294,6 +296,7 @@ async def close(self):
loop.run_until_complete(program_runner.start())
program_runner.add(1, test_prog1)
program_runner.add(2, test_prog2)
program_runner.add(3, test_batchopening)
loop.run_until_complete(program_runner.join())
loop.run_until_complete(program_runner.close())
finally:
Expand Down
35 changes: 23 additions & 12 deletions honeybadgermpc/mpc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import logging
from random import randint
from collections import defaultdict
from .polynomial import polynomials_over
from .field import GF, GFElement
Expand All @@ -11,6 +12,7 @@
from .elliptic_curve import Subgroup
from .preprocessing import PreProcessedElements
from .mixins import MixinOpName
from .config import ConfigVars


class NotEnoughShares(Exception):
Expand All @@ -23,7 +25,7 @@ class BatchReconstructionFailed(Exception):

class Mpc(object):

def __init__(self, sid, n, t, myid, pid, send, recv, prog, mixin_ops, **prog_args):
def __init__(self, sid, n, t, myid, pid, send, recv, prog, config, **prog_args):
# Parameters for robust MPC
# Note: tolerates min(t,N-t) crash faults
assert type(n) is int and type(t) is int
Expand All @@ -35,7 +37,7 @@ def __init__(self, sid, n, t, myid, pid, send, recv, prog, mixin_ops, **prog_arg
self.pid = pid
self.field = GF.get(Subgroup.BLS12_381)
self.poly = polynomials_over(self.field)
self.mixin_ops = mixin_ops
self.config = config

# send(j, o): sends object o to party j with (current sid)
# recv(): returns (j, o) from party j
Expand Down Expand Up @@ -71,8 +73,14 @@ async def open_share(self, share):
t = share.t if share.t is not None else self.t
# Broadcast share
for j in range(self.N):
value_to_share = share.v
if (ConfigVars.Reconstruction in self.config
and self.config[ConfigVars.Reconstruction].induce_faults):
logging.debug("[FAULT][RobustReconstruct] Sending random share.")
value_to_share = self.field(randint(0, self.field.modulus - 1))

# 'S' is for single shares
self.send(j, ('S', shareid, share.v))
self.send(j, ('S', shareid, value_to_share))

# Set up the buffer of received shares
share_buffer = [self._share_buffers[i][shareid] for i in range(self.N)]
Expand All @@ -92,9 +100,12 @@ def _send(j, o):
(tag, share) = o
self.send(j, (tag, shareid, share))
_recv = self._sharearray_buffers[shareid].get

opening = batch_reconstruct([s.v for s in sharearray._shares],
self.field.modulus, sharearray.t, self.N,
self.myid, _send, _recv, debug=True)
self.field.modulus, sharearray.t, self.N, self.myid,
_send, _recv,
config=self.config.get(ConfigVars.Reconstruction),
debug=True)
self._openings[shareid] = opening
return opening

Expand Down Expand Up @@ -222,8 +233,8 @@ def __rmul__(self, other): return Share(self.v * other, self.t)
def __mul__(self, other):
assert type(other) is Share
assert self.t == other.t
if MixinOpName.MultiplyShare in context.mixin_ops:
return context.mixin_ops[MixinOpName.MultiplyShare](context, self, other)
if MixinOpName.MultiplyShare in context.config:
return context.config[MixinOpName.MultiplyShare](context, self, other)
else:
raise NotImplementedError

Expand Down Expand Up @@ -301,9 +312,9 @@ def __sub__(self, other):
[(a-b) for (a, b) in zip(self._shares, other._shares)], self.t)

def __mul__(self, other):
if MixinOpName.MultiplyShareArray in context.mixin_ops:
if MixinOpName.MultiplyShareArray in context.config:
assert type(other) is ShareArray
return context.mixin_ops[MixinOpName.MultiplyShareArray](
return context.config[MixinOpName.MultiplyShareArray](
context, self, other)
else:
raise NotImplementedError
Expand All @@ -312,9 +323,9 @@ def __mul__(self, other):


class TaskProgramRunner(ProgramRunner):
def __init__(self, n, t, mixin_ops={}):
def __init__(self, n, t, config={}):
self.N, self.t, self.pid = n, t, 0
self.mixin_ops = mixin_ops
self.config = config
self.tasks = []
self.loop = asyncio.get_event_loop()

Expand All @@ -330,7 +341,7 @@ def add(self, program, **kwargs):
sends[i],
recvs[i],
program,
self.mixin_ops,
self.config,
**kwargs,
)
self.tasks.append(self.loop.create_task(context._run()))
Expand Down

0 comments on commit c993aa8

Please sign in to comment.