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

nino #60

Open
wants to merge 45 commits into
base: dev
Choose a base branch
from
Open

nino #60

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d1e51ec
Don't check stanford certificate
Feb 5, 2022
f880357
Merge pull request #1 from 1337samuels/bugfix/fix_certificate_for_make
1337samuels Feb 5, 2022
35a429e
Added ImprovedHB for two nodes
tomerfri Feb 5, 2022
e17fb50
Runs our test, weird our_start.sh
1337samuels Feb 5, 2022
11c996e
Now really added our_start.sh
1337samuels Feb 5, 2022
0ce8e2e
Merge remote-tracking branch 'origin/feature/time_honeybadger_test' i…
tomerfri Feb 5, 2022
f41fe90
Use logs and test normally
1337samuels Feb 5, 2022
4054dad
Merge remote-tracking branch 'origin/feature/time_honeybadger_test' i…
tomerfri Feb 5, 2022
3272ff2
Amazing logging
1337samuels Feb 5, 2022
2baf481
Move files
1337samuels Feb 5, 2022
e5f31e1
Merge remote-tracking branch 'origin/feature/time_honeybadger_test' i…
tomerfri Feb 5, 2022
9fd838d
Correct log file name
1337samuels Feb 5, 2022
037cc6f
Remove redundant logs
1337samuels Feb 5, 2022
ab001df
Split tests
tomerfri Feb 5, 2022
9840722
Merge remote-tracking branch 'origin/feature/time_honeybadger_test' i…
tomerfri Feb 5, 2022
7cb8979
Revert print removals
1337samuels Feb 7, 2022
af7e5b9
Merge pull request #2 from 1337samuels/feature/time_honeybadger_test
1337samuels Feb 7, 2022
dc0f428
Merge branch 'dev' into improvedHB
1337samuels Feb 7, 2022
5a562e1
Initial commit, test 2 different node sizes
1337samuels Feb 7, 2022
e2f6abb
added permuted HB
tomerfri Feb 7, 2022
e525f70
Move HB logic to utils.py
1337samuels Feb 7, 2022
abcf8e2
added debug prints and removing messages from transaction_buffer
tomerfri Feb 7, 2022
bc97454
Updated params
1337samuels Feb 7, 2022
98fd39c
Finish tests
1337samuels Feb 7, 2022
4488cf2
Merge pull request #4 from 1337samuels/feature/test_different_params
1337samuels Feb 7, 2022
10d5cdd
merged params
tomerfri Feb 7, 2022
2851aea
Merge branch 'improvedHB' of https://github.com/1337samuels/HoneyBadg…
tomerfri Feb 7, 2022
5dea0d3
Merge branch 'improvedHB' into feature/permutedHB
tomerfri Feb 7, 2022
e96eb35
changed to sort lexicographically
tomerfri Feb 7, 2022
2b6fbb0
Tests run and have a meaning
1337samuels Feb 7, 2022
5e4c1a0
Store and log results properly
1337samuels Feb 7, 2022
a0df03b
Merge pull request #5 from 1337samuels/feature/permutedHB
1337samuels Feb 8, 2022
2458d25
Parametrized tests
1337samuels Feb 8, 2022
f462e38
Added analyze_results.py
1337samuels Feb 8, 2022
2770395
Change gevent use
doras100p Feb 9, 2022
4bd8221
Change gevent use
doras100p Feb 9, 2022
709c48a
Fixed hanging
doras100p Feb 9, 2022
8e7d575
Some impovements but nothing works
doras100p Feb 10, 2022
159c2b0
Update
doras100p Feb 14, 2022
76dc732
Merge pull request #7 from 1337samuels/debugStuc
1337samuels Feb 14, 2022
8363680
Merge pull request #6 from 1337samuels/feature/run_tests_seperately
1337samuels Feb 14, 2022
8c802e4
Run both tests
1337samuels Feb 14, 2022
d7d053b
All tests pass and are analyzed!
1337samuels Feb 14, 2022
b2fde9b
Merge pull request #8 from 1337samuels/feature/test_throughput
1337samuels Feb 21, 2022
ea1bf97
Merge pull request #3 from 1337samuels/improvedHB
1337samuels Feb 21, 2022
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
Prev Previous commit
Next Next commit
Move HB logic to utils.py
  • Loading branch information
1337samuels committed Feb 7, 2022
commit e525f706d4fde2513a960f60691637d4f8824311
2 changes: 1 addition & 1 deletion our_srcs/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
LOG_PATH = LOG_DIR + '/honeybadger_test_{}_{}_{}_{}_{}_{}.log'
LOGGER_NAME = 'honeybadger_test_logger'
NUM_OF_NODE_OPTIONS = [4, 6]
NUM_OF_IDENTICAL_INPUTS_OPTIONS = [0, 2, 4, 6]
NUM_OF_IDENTICAL_INPUTS_OPTIONS = [0, 2, 4]
NUM_OF_INPUTS_IN_ITERATION = 3
INPUT_SIZES = [2, 1024, 1024*1024]
DEFAULT_NUM_OF_NODES = NUM_OF_NODE_OPTIONS[-1]
Expand Down
56 changes: 56 additions & 0 deletions our_srcs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
import logging
from our_srcs.consts import *
import datetime
import random
import math

from honeybadgerbft.crypto.threshsig.boldyreva import dealer
from honeybadgerbft.crypto.threshenc import tpke
import gevent
from gevent.event import Event
from gevent.queue import Queue


def setup_logging():
if not os.path.isdir(LOG_DIR):
Expand All @@ -25,5 +34,52 @@ def setup_logging():
logger.addHandler(ch)
logger.addHandler(fi)

def setup_honeybadgers(honeybadger_class, N):
sid = 'sidA'
# Generate threshold sig keys
sPK, sSKs = dealer(N, 2, seed=None)
# Generate threshold enc keys
ePK, eSKs = tpke.dealer(N, 2)

rnd = random.Random(None)
#print 'SEED:', seed
router_seed = rnd.random()
sends, recvs = simple_router(N, seed=router_seed)

badgers = [None] * N
threads = [None] * N
for i in range(N):
badgers[i] = HB(sid, i, 1, N, 1,
sPK, sSKs[i], ePK, eSKs[i],
sends[i], recvs[i])
threads[i] = gevent.spawn(badgers[i].run)

def simple_router(N, maxdelay=0.005, seed=None):
"""Builds a set of connected channels, with random delay

:return: (receives, sends)
"""
rnd = random.Random(seed)
#if seed is not None: print 'ROUTER SEED: %f' % (seed,)

queues = [Queue() for _ in range(N)]
_threads = []

def makeSend(i):
def _send(j, o):
delay = rnd.random() * maxdelay
delay *= math.log(len(o)) * 7.5
gevent.spawn_later(delay, queues[j].put_nowait, (i,o))
return _send

def makeRecv(j):
def _recv():
(i,o) = queues[j].get()
#print 'RECV %8s [%2d -> %2d]' % (o[0], i, j)
return (i,o)
return _recv

return ([makeSend(i) for i in range(N)],
[makeRecv(j) for j in range(N)])


80 changes: 16 additions & 64 deletions test/my_test.py
Original file line number Diff line number Diff line change
@@ -1,89 +1,40 @@
import random
from collections import defaultdict
import math
from datetime import datetime
import datetime

import gevent
from gevent.event import Event
from gevent.queue import Queue
from pytest import fixture, mark, raises

import honeybadgerbft.core.honeybadger
#reload(honeybadgerbft.core.honeybadger)
from honeybadgerbft.core.honeybadger import HoneyBadgerBFT, ImprovedHoneyBadgerBFT
from honeybadgerbft.crypto.threshsig.boldyreva import dealer
from honeybadgerbft.crypto.threshenc import tpke
from honeybadgerbft.core.honeybadger import BroadcastTag
from logging import getLogger
from our_srcs.utils import setup_logging
from our_srcs.utils import *
from our_srcs.consts import *

@fixture
def recv_queues(request):
from honeybadgerbft.core.honeybadger import BroadcastReceiverQueues
number_of_nodes = getattr(request, 'N', 4)
queues = {
tag.value: [Queue() for _ in range(number_of_nodes)]
for tag in BroadcastTag if tag != BroadcastTag.TPKE
}
queues[BroadcastTag.TPKE.value] = Queue()
return BroadcastReceiverQueues(**queues)



def simple_router(N, maxdelay=0.005, seed=None):
"""Builds a set of connected channels, with random delay

:return: (receives, sends)
"""
rnd = random.Random(seed)
#if seed is not None: print 'ROUTER SEED: %f' % (seed,)

queues = [Queue() for _ in range(N)]
_threads = []

def makeSend(i):
def _send(j, o):
delay = rnd.random() * maxdelay
delay *= math.log(len(o)) * 7.5
gevent.spawn_later(delay, queues[j].put_nowait, (i,o))
return _send

def makeRecv(j):
def _recv():
(i,o) = queues[j].get()
#print 'RECV %8s [%2d -> %2d]' % (o[0], i, j)
return (i,o)
return _recv

return ([makeSend(i) for i in range(N)],
[makeRecv(j) for j in range(N)])

setup_logging()
logger = getLogger(LOGGER_NAME)

def test_main():
setup_logging()
logger = getLogger(LOGGER_NAME)
_test_num_of_nodes()
#_test_num_of_identical_inputs()
#_test_input_sizes()


def _test_num_of_nodes():
logger = getLogger(LOGGER_NAME)
logger.info("Testing Number of Nodes")
for num_of_nodes in NUM_OF_NODE_OPTIONS:
_test_honeybadgers(num_of_nodes, DEFAULT_NUM_OF_IDENTICAL_INPUTS_OPTIONS, DEFAULT_INPUT_SIZE)

def _test_honeybadgers(num_of_nodes, identical_input, input_size):
logger = getLogger(LOGGER_NAME)
logger.info(f"Test Honeybadgers with N={num_of_nodes}, id={identical_input}, size={input_size}")
for hb_tuple in HONEYBADGERS:
logger.info("Testing Honeybadger: {}".format(hb_tuple[0]))
_test_honeybadger_full(hb_tuple[1], num_of_nodes, identical_input, input_size)

### Test asynchronous common subset
def _test_honeybadger_full(HB, N, identical_inputs, input_sizes):
logger=getLogger(LOGGER_NAME)
assert N >= identical_inputs, "There can't be more identical_inputs than number of nodes"
sid = 'sidA'
# Generate threshold sig keys
sPK, sSKs = dealer(N, 2, seed=None)
Expand All @@ -103,16 +54,17 @@ def _test_honeybadger_full(HB, N, identical_inputs, input_sizes):
sends[i], recvs[i])
threads[i] = gevent.spawn(badgers[i].run)

time_at_start = datetime.now().timestamp()

for i in range(N):
#if i == 1: continue
badgers[i].submit_tx('<[HBBFT Input {}]>'.format(i))
for i in range(N):
badgers[i].submit_tx('<[HBBFT Input %d]>' % (i+10))
time_at_start = datetime.datetime.now().timestamp()

for i in range(N):
badgers[i].submit_tx('<[HBBFT Input %d]>' % (i+20))
for iter_index in range(NUM_OF_INPUTS_IN_ITERATION):
identical_hbs = random.sample(range(N), identical_inputs)
logger.debug(f"At epoch {iter_index} chose identical_inputs {identical_hbs}")
for node_index in range(N):
if node_index in identical_hbs:
badgers[node_index].submit_tx(f'<HBBFT Input Epoch {iter_index} Identical Input> ' + 'a'*input_sizes)
else:
badgers[node_index].submit_tx(f'<HBBFT Input Epoch {iter_index} Different Input {node_index} ' + 'a'*input_sizes)


logger.debug("Done submitting all inputs")

Expand All @@ -122,7 +74,7 @@ def _test_honeybadger_full(HB, N, identical_inputs, input_sizes):
# Consistency check
assert len(set(outs)) == 1

time_at_end = datetime.now().timestamp()
time_at_end = datetime.datetime.now().timestamp()
time_diff = time_at_end - time_at_start
logger.info(f"Time passed: {time_diff}")

Expand Down