sharing the bugs

parent e9c5f051
lambda_proposer = 3 # wait time for priority messages to be received
lambda_proposer = 30# wait time for priority messages to be received
tou_proposer = 20 # proposer rolecount
ROLE_BLOCK_PROPOSER = 'BLOCK_PROPOSER'
tou_step = 3 # tou is expected number of users that sortition selects for committee
ROLE_COMMITEE_FOR_VOTE = 'committee'
lambda_block = 30 #seconds
lambda_step = 3
lambda_block = 300 #seconds
lambda_step = 30
BLOCK_PROPOSAL_MSG_type = 'BLOCK_PROPOSAL_MSGs'
......@@ -15,3 +15,5 @@ COMMITTEE_VOTE_MSG_type = "COMMITTEE_VOTE"
TIMEOUT = "TIMEOUT"
T = 2/3 # T isa a fraction of expected committee size that defines BA*`s voting thershold
NUMBER_OF_NODES_IN_NETWORK = 50
0 20
0 34
0 35
0 42
0 48
1 7
1 18
1 23
1 34
2 15
2 26
3 7
3 18
3 27
3 29
3 34
3 41
3 46
4 9
4 17
4 25
4 38
4 45
4 49
5 21
5 30
5 34
5 47
6 7
6 9
6 47
7 16
7 19
8 14
8 22
8 25
9 16
9 31
9 41
9 44
10 36
10 39
11 13
11 17
11 34
11 39
11 43
12 15
12 17
12 21
12 30
12 35
13 14
13 15
14 17
0 21
0 39
1 32
1 29
2 34
2 44
3 16
3 25
3 42
3 35
4 18
4 37
4 43
4 30
5 37
5 11
5 23
6 41
6 46
7 14
7 47
7 28
8 15
8 44
8 35
9 27
9 46
9 13
9 49
10 27
10 48
10 35
11 29
11 23
12 22
12 42
13 26
13 33
14 24
14 36
14 48
15 19
15 26
15 32
15 37
15 38
14 27
14 39
15 40
16 25
16 36
16 46
17 25
17 29
17 47
18 25
18 47
19 23
19 24
19 33
19 37
20 21
20 28
20 32
20 36
20 44
20 48
23 27
23 39
23 40
25 32
25 40
25 42
25 49
27 43
27 47
28 33
28 43
29 44
30 47
30 48
31 35
31 41
32 34
32 38
32 40
32 41
32 43
33 44
34 37
34 41
34 46
37 39
16 22
16 40
16 42
17 23
17 45
18 48
19 27
19 31
20 46
20 45
20 38
21 24
21 37
21 30
23 42
25 29
26 41
28 34
29 49
30 31
30 38
31 36
31 34
32 35
32 39
33 47
36 43
37 38
39 47
40 47
41 46
41 47
41 49
43 46
43 47
44 48
47 48
......@@ -8,7 +8,7 @@ import random
from numpy.random import randint
logger = logging.getLogger(__name__)
import numpy as np
import Config
class Network():
......@@ -31,7 +31,7 @@ class Network():
:return:
'''
w = randint(1, 51, 4) # 51 is excluded - range (1,50)
w = randint(1, 51, Config.NUMBER_OF_NODES_IN_NETWORK) # 51 is excluded - range (1,50)
self.badaW = np.sum(w)
i = 0
with open('Nodes1.dat', 'r') as f:
......
......@@ -101,7 +101,7 @@ class Node(SystemEntity):
# generate tasks for todolist based on messges
for message in list(self.messageQueue): #this creates adupliacte list and iterate over it while making changes to original queue
self.processMessage(message[0],list(message[1])) # message : (time,(payload))
self.logger.info("received : "+str(message))
# self.logger.info("received : "+str(message))
self.dequeMessage()
# check if main ba* has to be resumed or not
......
......@@ -58,7 +58,9 @@ class OverlayNode(Node):
role= (Config.ROLE_COMMITEE_FOR_VOTE, round, step)
# Todo something is wrong here not getting correct votes back
votes = Utility.verifySort(pk, sorthash, proof, seed, tou, role, self.network.pk_weight_map.get(pk), self.network.badaW)
print("why votes be zero")
if votes :
self.logger.info("THese are valid committee votes with votes : ",votes)
print("why votes be zero :",role)
print(votes,"\t",value,"\t",sorthash)
return votes,value,sorthash
pass
......@@ -193,7 +195,8 @@ class OverlayNode(Node):
''' COmmitte vote reduction step 1'''
reduct_step_1 = 1
reduct_seed = (previousHash, self.currentRound, reduct_step_1)
# reduct_seed = (previousHash, self.currentRound, reduct_step_1)
reduct_seed = self.currentSeed
reduct_role_1 = (Config.ROLE_COMMITEE_FOR_VOTE,self.currentRound,reduct_step_1)
reduct_sorthash, reduct_proof, reduct_j = Utility.sortition(self.sk, reduct_seed, Config.tou_step, reduct_role_1,
self.weight, self.network.badaW, self.pk)
......@@ -241,98 +244,99 @@ class OverlayNode(Node):
######## END : count votes for hblock1 ###########
''' END : COmmitte vote reduction step 1'''
''' Start : COmmitte vote reduction step 2 '''
empty_hash = Utility.pseudoRandomGenerator((previousHash, "Empty"))
# which block to vote empty or hblock1
reduct_step2_block_to_vote = None
if hblock1 == Config.TIMEOUT :
reduct_step2_block_to_vote = empty_hash
pass
else:
reduct_step2_block_to_vote = hblock1
pass
''' COmmitte vote reduction step2 : reduct_step2_block_to_vote'''
variables_reduct_step_2 = {}
variables_reduct_step_2['step'] = 2
variables_reduct_step_2['seed'] = (previousHash, self.currentRound, variables_reduct_step_2['step'])
variables_reduct_step_2['role'] = (
Config.ROLE_COMMITEE_FOR_VOTE, self.currentRound, variables_reduct_step_2['step'])
variables_reduct_step_2['sorthash'], variables_reduct_step_2['proof'], variables_reduct_step_2[
'j'] = Utility.sortition(self.sk, variables_reduct_step_2['seed'],
Config.tou_step,
variables_reduct_step_2['role'],
self.weight, self.network.badaW,
self.pk)
# print("Reduction algo " + self.id," : ",reduct_j)
if variables_reduct_step_2['j'] > 0:
self.logger.info("selection for VOTING COMMITEE with J =" + str(variables_reduct_step_2['j']))
variables_reduct_step_2['payload'] = (
self.currentRound, variables_reduct_step_2['step'], variables_reduct_step_2['sorthash'],
variables_reduct_step_2['proof'], previousHash, reduct_step2_block_to_vote)
variables_reduct_step_2['committeeVoteMsg'] = (Config.COMMITTEE_VOTE_MSG_type,
(self.pk, variables_reduct_step_2['payload'],
self.sk.sign(bytes(
str(variables_reduct_step_2['payload']).encode(
'UTF8')))))
self.broadcast(self.network.time, variables_reduct_step_2['committeeVoteMsg'])
self.logger.info("Broadcasting commitee messgae" + str(variables_reduct_step_2['committeeVoteMsg']))
# yield "resume", Config.lambda_block + Config.lambda_step
''' COmmitte vote reduction step2 : reduct_step2_block_to_vote'''
######## count votes for hblock1 ###########
CountVotes_step2 = {}
CountVotes_step2['countVote_round'] = self.currentRound
CountVotes_step2['countVote_step'] = 1
# Config.T
# Config.tou_step
CountVotes_step2['countVote_lmbda'] = Config.lambda_block + Config.lambda_step
CountVotes_step2['start'] = int(self.network.time)
CountVotes_step2['counts'] = {}
CountVotes_step2['voters'] = []
CountVotes_step2['hblock2'] = None
while True:
if not self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type]:
if int(self.network.time) > CountVotes_step2['start'] + CountVotes_step2[
'countVote_lmbda']:
print(self.id + "Timing out")
CountVotes_step2['hblock2'] = Config.TIMEOUT
break
pass
else:
CountVotes_step2['temp_return'] = self.partOfCountVotes(
CountVotes_step2['countVote_round'], CountVotes_step2['countVote_step'],
CountVotes_step2['start'], CountVotes_step2['counts'],
CountVotes_step2['voters'], Config.T, Config.tou_step)
print("CountVotes_step2",CountVotes_step2['temp_return'])
if CountVotes_step2['temp_return']:
CountVotes_step2['hblock2'] = CountVotes_step2['temp_return']
break
yield "resume", 1 # this is to allow other nodes to be simulated and not get this node into infinite waiting on single node
self.logger.info(
"returning from first count values with return value : " + str(CountVotes_step2['hblock2']))
print("CountVotes_step2",CountVotes_step2['hblock2'])
######## END : count votes for hblock1 ###########
var_BBA_star = {}
if CountVotes_step2['hblock2'] == Config.TIMEOUT:
var_BBA_star['block_hash']= empty_hash
else:
var_BBA_star['block_hash'] = CountVotes_step2['hblock2']
print("I am culprit " ,var_BBA_star['hblock2'])
''' END : COmmitte vote reduction step 2 '''
#
# ''' Start : COmmitte vote reduction step 2 '''
# empty_hash = Utility.pseudoRandomGenerator((previousHash, "Empty"))
#
# # which block to vote empty or hblock1
# reduct_step2_block_to_vote = None
# if hblock1 == Config.TIMEOUT :
# reduct_step2_block_to_vote = empty_hash
# pass
# else:
# reduct_step2_block_to_vote = hblock1
# pass
#
# ''' COmmitte vote reduction step2 : reduct_step2_block_to_vote'''
#
# variables_reduct_step_2 = {}
#
# variables_reduct_step_2['step'] = 2
# # variables_reduct_step_2['seed'] = (previousHash, self.currentRound, variables_reduct_step_2['step'])
# variables_reduct_step_2['seed'] = self.currentSeed
# variables_reduct_step_2['role'] = (
# Config.ROLE_COMMITEE_FOR_VOTE, self.currentRound, variables_reduct_step_2['step'])
# variables_reduct_step_2['sorthash'], variables_reduct_step_2['proof'], variables_reduct_step_2[
# 'j'] = Utility.sortition(self.sk, variables_reduct_step_2['seed'],
# Config.tou_step,
# variables_reduct_step_2['role'],
# self.weight, self.network.badaW,
# self.pk)
# # print("Reduction algo " + self.id," : ",reduct_j)
#
# if variables_reduct_step_2['j'] > 0:
# self.logger.info("selection for VOTING COMMITEE with J =" + str(variables_reduct_step_2['j']))
# variables_reduct_step_2['payload'] = (
# self.currentRound, variables_reduct_step_2['step'], variables_reduct_step_2['sorthash'],
# variables_reduct_step_2['proof'], previousHash, reduct_step2_block_to_vote)
# variables_reduct_step_2['committeeVoteMsg'] = (Config.COMMITTEE_VOTE_MSG_type,
# (self.pk, variables_reduct_step_2['payload'],
# self.sk.sign(bytes(
# str(variables_reduct_step_2['payload']).encode(
# 'UTF8')))))
# self.broadcast(self.network.time, variables_reduct_step_2['committeeVoteMsg'])
# self.logger.info("Broadcasting commitee messgae" + str(variables_reduct_step_2['committeeVoteMsg']))
#
# # yield "resume", Config.lambda_block + Config.lambda_step
#
# ''' COmmitte vote reduction step2 : reduct_step2_block_to_vote'''
#
# ######## count votes for hblock1 ###########
# CountVotes_step2 = {}
# CountVotes_step2['countVote_round'] = self.currentRound
# CountVotes_step2['countVote_step'] = 2
# # Config.T
# # Config.tou_step
# CountVotes_step2['countVote_lmbda'] = Config.lambda_block + Config.lambda_step
#
# CountVotes_step2['start'] = int(self.network.time)
# CountVotes_step2['counts'] = {}
# CountVotes_step2['voters'] = []
# CountVotes_step2['hblock2'] = None
# while True:
# if not self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type]:
# if int(self.network.time) > CountVotes_step2['start'] + CountVotes_step2[
# 'countVote_lmbda']:
# print(self.id + "Timing out")
# CountVotes_step2['hblock2'] = Config.TIMEOUT
# break
# pass
# else:
# CountVotes_step2['temp_return'] = self.partOfCountVotes(
# CountVotes_step2['countVote_round'], CountVotes_step2['countVote_step'],
# CountVotes_step2['start'], CountVotes_step2['counts'],
# CountVotes_step2['voters'], Config.T, Config.tou_step)
# print("CountVotes_step2",CountVotes_step2['temp_return'])
# if CountVotes_step2['temp_return']:
# CountVotes_step2['hblock2'] = CountVotes_step2['temp_return']
# break
# yield "resume", 1 # this is to allow other nodes to be simulated and not get this node into infinite waiting on single node
# self.logger.info(
# "returning from first count values with return value : " + str(CountVotes_step2['hblock2']))
# print("CountVotes_step2",CountVotes_step2['hblock2'])
#
# ######## END : count votes for hblock1 ###########
#
# var_BBA_star = {}
#
# if CountVotes_step2['hblock2'] == Config.TIMEOUT:
# var_BBA_star['block_hash']= empty_hash
# else:
# var_BBA_star['block_hash'] = CountVotes_step2['hblock2']
#
#
# print("I am culprit " ,var_BBA_star['hblock2'])
# ''' END : COmmitte vote reduction step 2 '''
yield "resume", 9
# self.logger.info(self.uniqueReceivedMessages)
......
......@@ -133,6 +133,9 @@ def verifySort(pk,hash,proof,seed,rolecount,role,w,badaW):
break
j = j+1
if j :
print("Verification success : J :",j,role)
return j
# def computeRange():
......
......@@ -3,7 +3,7 @@ from numpy.random import randint
import sys
import networkx as nx
from networkx.algorithms import community
import numpy
'''
Generates a file of nodes
'''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment