Commit b5a476fc authored by UNHALE NILESH ARUN's avatar UNHALE NILESH ARUN

stable algorand - deleted link - memory leak by link messages queues emptying

parent 2b3e6ec8
...@@ -78,8 +78,9 @@ class Link(SystemEntity): ...@@ -78,8 +78,9 @@ class Link(SystemEntity):
''' '''
#todo process messages in queue #todo process messages in queue
# generate tasks for todolist based on messges # generate tasks for todolist based on messges
for message in self.messageQueue: for message in list(self.messageQueue):
self.scheduleMessageDelievery(message[0],message[1]) self.scheduleMessageDelievery(message[0],message[1])
self.dequeMessage()
# TODO : perform task from todolist which are relevant for current tick # TODO : perform task from todolist which are relevant for current tick
......
...@@ -115,7 +115,7 @@ class Node(SystemEntity): ...@@ -115,7 +115,7 @@ class Node(SystemEntity):
yield "resume",timeafter_which_to_resume yield "resume",timeafter_which_to_resume
''' '''
if ResumeOut and ResumeOut[0] == "resume": if ResumeOut and ResumeOut[0] == "resume":
self.logger.info("resume has been called") # self.logger.info("resume has been called")
self.ResumeTasks[str(int(time)+int(ResumeOut[1]))].append(("nextOn", self.startNodeLifeCycleGenerator,)) self.ResumeTasks[str(int(time)+int(ResumeOut[1]))].append(("nextOn", self.startNodeLifeCycleGenerator,))
except KeyError as ke: except KeyError as ke:
# not task pending at this time # not task pending at this time
......
...@@ -13,6 +13,9 @@ genesisBlock = ("I am the first block") ...@@ -13,6 +13,9 @@ genesisBlock = ("I am the first block")
# def __init__(self): # def __init__(self):
# self.role = # self.role =
class OverlayNode(Node): class OverlayNode(Node):
def __init__(self,id,network,weight): def __init__(self,id,network,weight):
Node.__init__(self,id,network,weight) Node.__init__(self,id,network,weight)
...@@ -34,11 +37,18 @@ class OverlayNode(Node): ...@@ -34,11 +37,18 @@ class OverlayNode(Node):
self.ResumeTasks['1'].append(("nextOn", self.startNodeLifeCycleGenerator,)) self.ResumeTasks['1'].append(("nextOn", self.startNodeLifeCycleGenerator,))
self.commands.update({}) self.commands.update({})
def printStats(self):
print('----------------------------------------------------------------------------------------------------------------')
print(Config.BLOCK_PROPOSAL_MSG_type," : counts : {}".format(len(self.uniqueReceivedMessages[Config.BLOCK_PROPOSAL_MSG_type])))
print(Config.COMMITTEE_VOTE_MSG_type," : counts : {}".format(len(self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type])))
print(Config.TENTATIVE_BLOCK_msg_type," : counts : {}".format(len(self.uniqueReceivedMessages[Config.TENTATIVE_BLOCK_msg_type])))
print(Config.FINALIZED_BLOCK_msg_type," : counts : {}".format(len(self.uniqueReceivedMessages[Config.FINALIZED_BLOCK_msg_type])))
print("MESSAGES TILL NOW :COUNT : {}".format(len(self.messagesTillNow)))
print('----------------------------------------------------------------------------------------------------------------')
# def processMessage(self,time,payload): # def processMessage(self,time,payload):
# super(OverlayNode, self).processMessage(time,payload) # super(OverlayNode, self).processMessage(time,payload)
# print("from overlay node : "+str(payload)) # ##print("from overlay node : "+str(payload))
def committeeVote(self,seed ,round,step,tou,value,fromwhere_it_is_called): def committeeVote(self,seed ,round,step,tou,value,fromwhere_it_is_called):
...@@ -73,13 +83,13 @@ class OverlayNode(Node): ...@@ -73,13 +83,13 @@ class OverlayNode(Node):
try: try:
pk.verify(sign,bytes(str(payload).encode('UTF8')) ) pk.verify(sign,bytes(str(payload).encode('UTF8')) )
except BadSignatureError as badSign: except BadSignatureError as badSign:
print("bad signature") ##print("bad signature")
return 0,None,None return 0,None,None
round, step, sorthash, proof, previousblockHash, value = payload round, step, sorthash, proof, previousblockHash, value = payload
if previousblockHash != hashlib.sha256(self.blockchain[-1].encode('utf-8')).hexdigest() : if previousblockHash != hashlib.sha256(self.blockchain[-1].encode('utf-8')).hexdigest() :
print("not in the right chain") ##print("not in the right chain")
return 0, None, None return 0, None, None
...@@ -91,33 +101,33 @@ class OverlayNode(Node): ...@@ -91,33 +101,33 @@ class OverlayNode(Node):
self.logger.info("outpusts of veifysort : {}".format(votes)) self.logger.info("outpusts of veifysort : {}".format(votes))
if votes : if votes :
self.logger.info("THese are valid committee votes with votes : "+str(votes)) self.logger.info("THese are valid committee votes with votes : "+str(votes))
print(votes,"\t",value,"\t",sorthash) ##print(votes,"\t",value,"\t",sorthash)
return votes,value,sorthash return votes,value,sorthash
pass pass
def partOfCountVotes(self,round,step,start,counts,voters,T,tou): def partOfCountVotes(self,round,step,start,counts,voters,T,tou):
msgs = self.uniqueReceivedMessages.pop(Config.COMMITTEE_VOTE_MSG_type) msgs = self.uniqueReceivedMessages.pop(Config.COMMITTEE_VOTE_MSG_type)
print("-------------msgs , ", self.id) ##print("-------------msgs , ", self.id)
print(msgs) #print(msgs)
for msg in msgs: for msg in msgs:
msg_round = msg[1][1][0] msg_round = msg[1][1][0]
msg_step = msg[1][1][1] msg_step = msg[1][1][1]
payload = msg[1][1] payload = msg[1][1]
msg_pk = msg[1][0] msg_pk = msg[1][0]
# print(round, " # ",step ) # ##print(round, " # ",step )
if msg_round== round and msg_step==step : #check if message belong to current round and current step or not if msg_round== round and msg_step==step : #check if message belong to current round and current step or not
votes,value,sorthash = self.algo_processMsg(msg,tou) votes,value,sorthash = self.algo_processMsg(msg,tou)
if msg_pk in voters or votes == 0: if msg_pk in voters or votes == 0:
print(self.id + " continuing") ##print(self.id + " continuing")
continue continue
voters.append(msg_pk) voters.append(msg_pk)
print("yup its wrong here") ##print("yup its wrong here")
counts[value] = counts.get(value, votes) counts[value] = counts.get(value, votes)
print('--------------counts-------------',self.id) ##print('--------------counts-------------',self.id)
print(counts) ##print(counts)
if counts[value] > T*tou : if counts[value] > T*tou :
print("returning value") ##print("returning value")
return value return value
pass pass
...@@ -255,13 +265,13 @@ class OverlayNode(Node): ...@@ -255,13 +265,13 @@ class OverlayNode(Node):
except Exception as e: except Exception as e:
self.logger.error(e) self.logger.error(e)
# print(blockForBA) # #print(blockForBA)
hashof_blockForBA = Utility.pseudoRandomGenerator(blockForBA) hashof_blockForBA = Utility.pseudoRandomGenerator(blockForBA)
######### END : Performing selection of block BA* ############################ ######### END : Performing selection of block BA* ############################
self.printStats()
''' START : REDUCTION ALGORITHM ''' ''' START : REDUCTION ALGORITHM '''
''' COmmitte vote reduction step 1''' ''' COmmitte vote reduction step 1'''
...@@ -282,7 +292,7 @@ class OverlayNode(Node): ...@@ -282,7 +292,7 @@ class OverlayNode(Node):
self.broadcast(self.network.time,committeeVoteMsg) self.broadcast(self.network.time,committeeVoteMsg)
self.logger.info("Broadcasting commitee messgae : {}".format(committeeVoteMsg)) self.logger.info("Broadcasting commitee messgae : {}".format(committeeVoteMsg))
# print(self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type]) # ##print(self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type])
yield "resume",Config.lambda_block+Config.lambda_step yield "resume",Config.lambda_block+Config.lambda_step
######## count votes for hblock1 ########### ######## count votes for hblock1 ###########
...@@ -300,24 +310,26 @@ class OverlayNode(Node): ...@@ -300,24 +310,26 @@ class OverlayNode(Node):
while True: while True:
if not self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type] : if not self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type] :
if int(self.network.time) > start + countVote_lmbda: if int(self.network.time) > start + countVote_lmbda:
print(self.id + "Timing out") ##print(self.id + "Timing out")
hblock1 = Config.TIMEOUT hblock1 = Config.TIMEOUT
break break
pass pass
else: else:
temp_return = self.partOfCountVotes(countVote_round,countVote_reduct_step_1,start,counts,voters,Config.T,Config.tou_step) temp_return = self.partOfCountVotes(countVote_round,countVote_reduct_step_1,start,counts,voters,Config.T,Config.tou_step)
print("temp_retiurn " ,temp_return) ##print("temp_retiurn " ,temp_return)
if temp_return : if temp_return :
hblock1 = temp_return hblock1 = temp_return
break break
yield "resume",1 # this is to allow other nodes to be simulated and not get this node into infinite waiting on single node 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 : {}".format(hblock1)) self.logger.info("returning from first count values with return value : {}".format(hblock1))
print("returning from first count values with return value",hblock1) ##print("returning from first count values with return value",hblock1)
self.logger.info("votes count reduction step 1 : {}".format(counts)) self.logger.info("votes count reduction step 1 : {}".format(counts))
######## END : count votes for hblock1 ########### ######## END : count votes for hblock1 ###########
self.printStats()
self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type].clear()
yield 'resume',50
''' END : COmmitte vote reduction step 1''' ''' END : COmmitte vote reduction step 1'''
''' Start : COmmitte vote reduction step 2 ''' ''' Start : COmmitte vote reduction step 2 '''
...@@ -351,7 +363,7 @@ class OverlayNode(Node): ...@@ -351,7 +363,7 @@ class OverlayNode(Node):
variables_reduct_step_2['role'], variables_reduct_step_2['role'],
self.weight, self.network.badaW, self.weight, self.network.badaW,
self.pk) self.pk)
# print("Reduction algo " + self.id," : ",reduct_j) # ##print("Reduction algo " + self.id," : ",reduct_j)
if variables_reduct_step_2['j'] > 0: if variables_reduct_step_2['j'] > 0:
self.logger.info("selection for VOTING COMMITEE with J =" + str(variables_reduct_step_2['j'])) self.logger.info("selection for VOTING COMMITEE with J =" + str(variables_reduct_step_2['j']))
...@@ -386,7 +398,7 @@ class OverlayNode(Node): ...@@ -386,7 +398,7 @@ class OverlayNode(Node):
if not self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type]: if not self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type]:
if int(self.network.time) > CountVotes_step2['start'] + CountVotes_step2[ if int(self.network.time) > CountVotes_step2['start'] + CountVotes_step2[
'countVote_lmbda']: 'countVote_lmbda']:
print(self.id + "Timing out") ##print(self.id + "Timing out")
CountVotes_step2['hblock2'] = Config.TIMEOUT CountVotes_step2['hblock2'] = Config.TIMEOUT
break break
pass pass
...@@ -395,31 +407,32 @@ class OverlayNode(Node): ...@@ -395,31 +407,32 @@ class OverlayNode(Node):
CountVotes_step2['countVote_round'], CountVotes_step2['countVote_step'], CountVotes_step2['countVote_round'], CountVotes_step2['countVote_step'],
CountVotes_step2['start'], CountVotes_step2['counts'], CountVotes_step2['start'], CountVotes_step2['counts'],
CountVotes_step2['voters'], Config.T, Config.tou_step) CountVotes_step2['voters'], Config.T, Config.tou_step)
print("CountVotes_step2",CountVotes_step2['temp_return']) #print("CountVotes_step2",CountVotes_step2['temp_return'])
if CountVotes_step2['temp_return']: if CountVotes_step2['temp_return']:
CountVotes_step2['hblock2'] = CountVotes_step2['temp_return'] CountVotes_step2['hblock2'] = CountVotes_step2['temp_return']
break break
yield "resume", 1 # this is to allow other nodes to be simulated and not get this node into infinite waiting on single node 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( self.logger.info(
"returning from first count values with return value : " + str(CountVotes_step2['hblock2'])) "returning from first count values with return value : " + str(CountVotes_step2['hblock2']))
print("CountVotes_step2",CountVotes_step2['hblock2']) #print("CountVotes_step2",CountVotes_step2['hblock2'])
######## END : count votes for hblock1 ########### ######## END : count votes for hblock1 ###########
var_BBA_star = {} var_BBA_star = {}
print('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++') #print('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
if CountVotes_step2['hblock2'] == Config.TIMEOUT: if CountVotes_step2['hblock2'] == Config.TIMEOUT:
var_BBA_star['block_hash']= empty_hash var_BBA_star['block_hash']= empty_hash
else: else:
var_BBA_star['block_hash'] = CountVotes_step2['hblock2'] var_BBA_star['block_hash'] = CountVotes_step2['hblock2']
print("I am culprit " ) #print("I am culprit " )
print(var_BBA_star['block_hash']) #print(var_BBA_star['block_hash'])
self.printStats()
# self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type].clear()
yield 'resume', 50
''' END : COmmitte vote reduction step 2 ''' ''' END : COmmitte vote reduction step 2 '''
yield "resume", 9
''' END : REDUCTION ALGORITHM ''' ''' END : REDUCTION ALGORITHM '''
...@@ -462,7 +475,7 @@ class OverlayNode(Node): ...@@ -462,7 +475,7 @@ class OverlayNode(Node):
if not self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type]: if not self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type]:
if int(self.network.time) > CountVotes_BBA_CASE_1['start'] + CountVotes_BBA_CASE_1[ if int(self.network.time) > CountVotes_BBA_CASE_1['start'] + CountVotes_BBA_CASE_1[
'countVote_lmbda']: 'countVote_lmbda']:
print(self.id + "Timing out") #print(self.id + "Timing out")
CountVotes_BBA_CASE_1['return_block_hash'] = Config.TIMEOUT CountVotes_BBA_CASE_1['return_block_hash'] = Config.TIMEOUT
break break
pass pass
...@@ -471,16 +484,18 @@ class OverlayNode(Node): ...@@ -471,16 +484,18 @@ class OverlayNode(Node):
CountVotes_BBA_CASE_1['countVote_round'], CountVotes_BBA_CASE_1['countVote_step'], CountVotes_BBA_CASE_1['countVote_round'], CountVotes_BBA_CASE_1['countVote_step'],
CountVotes_BBA_CASE_1['start'], CountVotes_BBA_CASE_1['counts'], CountVotes_BBA_CASE_1['start'], CountVotes_BBA_CASE_1['counts'],
CountVotes_BBA_CASE_1['voters'], Config.T, Config.tou_step) CountVotes_BBA_CASE_1['voters'], Config.T, Config.tou_step)
print("CountVotes_BBA_CASE_1", CountVotes_BBA_CASE_1['temp_return']) #print("CountVotes_BBA_CASE_1", CountVotes_BBA_CASE_1['temp_return'])
if CountVotes_BBA_CASE_1['temp_return']: if CountVotes_BBA_CASE_1['temp_return']:
CountVotes_BBA_CASE_1['return_block_hash'] = CountVotes_BBA_CASE_1['temp_return'] CountVotes_BBA_CASE_1['return_block_hash'] = CountVotes_BBA_CASE_1['temp_return']
break break
yield "resume", 1 # this is to allow other nodes to be simulated and not get this node into infinite waiting on single node 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("CountVotes_BBA_CASE_1 o/p : {}".format( CountVotes_BBA_CASE_1['return_block_hash'])) self.logger.info("CountVotes_BBA_CASE_1 o/p : {}".format( CountVotes_BBA_CASE_1['return_block_hash']))
print("CountVotes_BBA_CASE_1", CountVotes_BBA_CASE_1['return_block_hash']) #print("CountVotes_BBA_CASE_1", CountVotes_BBA_CASE_1['return_block_hash'])
var_BBA_star['r'] = CountVotes_BBA_CASE_1['return_block_hash'] var_BBA_star['r'] = CountVotes_BBA_CASE_1['return_block_hash']
self.printStats()
# self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type].clear()
yield 'resume', 50
######## END : count votes for CountVotes_BBA_CASE_1 ########### ######## END : count votes for CountVotes_BBA_CASE_1 ###########
if var_BBA_star['r'] == Config.TIMEOUT : if var_BBA_star['r'] == Config.TIMEOUT :
...@@ -508,8 +523,7 @@ class OverlayNode(Node): ...@@ -508,8 +523,7 @@ class OverlayNode(Node):
pass pass
var_BBA_star['step'] += 1 var_BBA_star['step'] += 1
self.printStats()
''' START : BBAstar_case 2''' ''' START : BBAstar_case 2'''
''' COmmitte vote BBA_CASE_2 : BBA_CASE_2''' ''' COmmitte vote BBA_CASE_2 : BBA_CASE_2'''
...@@ -538,7 +552,7 @@ class OverlayNode(Node): ...@@ -538,7 +552,7 @@ class OverlayNode(Node):
if not self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type]: if not self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type]:
if int(self.network.time) > CountVotes_BBA_CASE_2['start'] + CountVotes_BBA_CASE_2[ if int(self.network.time) > CountVotes_BBA_CASE_2['start'] + CountVotes_BBA_CASE_2[
'countVote_lmbda']: 'countVote_lmbda']:
print(self.id + "Timing out") #print(self.id + "Timing out")
CountVotes_BBA_CASE_2['return_block_hash'] = Config.TIMEOUT CountVotes_BBA_CASE_2['return_block_hash'] = Config.TIMEOUT
break break
pass pass
...@@ -547,13 +561,13 @@ class OverlayNode(Node): ...@@ -547,13 +561,13 @@ class OverlayNode(Node):
CountVotes_BBA_CASE_2['countVote_round'], CountVotes_BBA_CASE_2['countVote_step'], CountVotes_BBA_CASE_2['countVote_round'], CountVotes_BBA_CASE_2['countVote_step'],
CountVotes_BBA_CASE_2['start'], CountVotes_BBA_CASE_2['counts'], CountVotes_BBA_CASE_2['start'], CountVotes_BBA_CASE_2['counts'],
CountVotes_BBA_CASE_2['voters'], Config.T, Config.tou_step) CountVotes_BBA_CASE_2['voters'], Config.T, Config.tou_step)
print("CountVotes_BBA_CASE_2", CountVotes_BBA_CASE_2['temp_return']) #print("CountVotes_BBA_CASE_2", CountVotes_BBA_CASE_2['temp_return'])
if CountVotes_BBA_CASE_2['temp_return']: if CountVotes_BBA_CASE_2['temp_return']:
CountVotes_BBA_CASE_2['return_block_hash'] = CountVotes_BBA_CASE_2['temp_return'] CountVotes_BBA_CASE_2['return_block_hash'] = CountVotes_BBA_CASE_2['temp_return']
break break
yield "resume", 1 # this is to allow other nodes to be simulated and not get this node into infinite waiting on single node 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("CountVotes_BBA_CASE_2 o/p : {}".format(CountVotes_BBA_CASE_2['return_block_hash'])) self.logger.info("CountVotes_BBA_CASE_2 o/p : {}".format(CountVotes_BBA_CASE_2['return_block_hash']))
print("CountVotes_BBA_CASE_2", CountVotes_BBA_CASE_2['return_block_hash']) #print("CountVotes_BBA_CASE_2", CountVotes_BBA_CASE_2['return_block_hash'])
var_BBA_star['r'] = CountVotes_BBA_CASE_2['return_block_hash'] var_BBA_star['r'] = CountVotes_BBA_CASE_2['return_block_hash']
...@@ -575,7 +589,9 @@ class OverlayNode(Node): ...@@ -575,7 +589,9 @@ class OverlayNode(Node):
pass pass
var_BBA_star['step'] += 1 var_BBA_star['step'] += 1
self.printStats()
# self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type].clear()
yield 'resume', 50
''' END : BBAstar_case 2''' ''' END : BBAstar_case 2'''
'''START : BBAStar case 3''' '''START : BBAStar case 3'''
...@@ -605,7 +621,7 @@ class OverlayNode(Node): ...@@ -605,7 +621,7 @@ class OverlayNode(Node):
if not self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type]: if not self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type]:
if int(self.network.time) > CountVotes_BBA_CASE_3['start'] + CountVotes_BBA_CASE_3[ if int(self.network.time) > CountVotes_BBA_CASE_3['start'] + CountVotes_BBA_CASE_3[
'countVote_lmbda']: 'countVote_lmbda']:
print(self.id + "Timing out") #print(self.id + "Timing out")
CountVotes_BBA_CASE_3['return_block_hash'] = Config.TIMEOUT CountVotes_BBA_CASE_3['return_block_hash'] = Config.TIMEOUT
break break
pass pass
...@@ -614,13 +630,13 @@ class OverlayNode(Node): ...@@ -614,13 +630,13 @@ class OverlayNode(Node):
CountVotes_BBA_CASE_3['countVote_round'], CountVotes_BBA_CASE_3['countVote_step'], CountVotes_BBA_CASE_3['countVote_round'], CountVotes_BBA_CASE_3['countVote_step'],
CountVotes_BBA_CASE_3['start'], CountVotes_BBA_CASE_3['counts'], CountVotes_BBA_CASE_3['start'], CountVotes_BBA_CASE_3['counts'],
CountVotes_BBA_CASE_3['voters'], Config.T, Config.tou_step) CountVotes_BBA_CASE_3['voters'], Config.T, Config.tou_step)
print("CountVotes_BBA_CASE_3", CountVotes_BBA_CASE_3['temp_return']) #print("CountVotes_BBA_CASE_3", CountVotes_BBA_CASE_3['temp_return'])
if CountVotes_BBA_CASE_3['temp_return']: if CountVotes_BBA_CASE_3['temp_return']:
CountVotes_BBA_CASE_3['return_block_hash'] = CountVotes_BBA_CASE_3['temp_return'] CountVotes_BBA_CASE_3['return_block_hash'] = CountVotes_BBA_CASE_3['temp_return']
break break
yield "resume", 1 # this is to allow other nodes to be simulated and not get this node into infinite waiting on single node 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("CountVotes_BBA_CASE_3 o/p : {}".format(CountVotes_BBA_CASE_3['return_block_hash'])) self.logger.info("CountVotes_BBA_CASE_3 o/p : {}".format(CountVotes_BBA_CASE_3['return_block_hash']))
print("CountVotes_BBA_CASE_3", CountVotes_BBA_CASE_3['return_block_hash']) #print("CountVotes_BBA_CASE_3", CountVotes_BBA_CASE_3['return_block_hash'])
var_BBA_star['r'] = CountVotes_BBA_CASE_3['return_block_hash'] var_BBA_star['r'] = CountVotes_BBA_CASE_3['return_block_hash']
...@@ -641,7 +657,9 @@ class OverlayNode(Node): ...@@ -641,7 +657,9 @@ class OverlayNode(Node):
pass pass
var_BBA_star['step'] += 1 var_BBA_star['step'] += 1
self.printStats()
# self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type].clear()
yield 'resume', 50
'''END : BBAStar case 3''' '''END : BBAStar case 3'''
...@@ -649,6 +667,7 @@ class OverlayNode(Node): ...@@ -649,6 +667,7 @@ class OverlayNode(Node):
if var_BBA_star['step'] == Config.MAXSTEP : if var_BBA_star['step'] == Config.MAXSTEP :
yield "resume", 40120000 # hang forever yield "resume", 40120000 # hang forever
exit(0)
''' END : BBA* ALGORITHM ''' ''' END : BBA* ALGORITHM '''
...@@ -670,7 +689,7 @@ class OverlayNode(Node): ...@@ -670,7 +689,7 @@ class OverlayNode(Node):
if not self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type]: if not self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type]:
if int(self.network.time) > CountVotes_FINAL['start'] + CountVotes_FINAL[ if int(self.network.time) > CountVotes_FINAL['start'] + CountVotes_FINAL[
'countVote_lmbda']: 'countVote_lmbda']:
print(self.id + "Timing out") ##print(self.id + "Timing out")
CountVotes_FINAL['return_block_hash'] = Config.TIMEOUT CountVotes_FINAL['return_block_hash'] = Config.TIMEOUT
break break
pass pass
...@@ -679,13 +698,13 @@ class OverlayNode(Node): ...@@ -679,13 +698,13 @@ class OverlayNode(Node):
CountVotes_FINAL['countVote_round'], CountVotes_FINAL['countVote_step'], CountVotes_FINAL['countVote_round'], CountVotes_FINAL['countVote_step'],
CountVotes_FINAL['start'], CountVotes_FINAL['counts'], CountVotes_FINAL['start'], CountVotes_FINAL['counts'],
CountVotes_FINAL['voters'], Config.T_FINAL, Config.tou_FINAL) CountVotes_FINAL['voters'], Config.T_FINAL, Config.tou_FINAL)
print("CountVotes_FINAL", CountVotes_FINAL['temp_return']) ##print("CountVotes_FINAL", CountVotes_FINAL['temp_return'])
if CountVotes_FINAL['temp_return']: if CountVotes_FINAL['temp_return']:
CountVotes_FINAL['return_block_hash'] = CountVotes_FINAL['temp_return'] CountVotes_FINAL['return_block_hash'] = CountVotes_FINAL['temp_return']
break break
yield "resume", 1 # this is to allow other nodes to be simulated and not get this node into infinite waiting on single node 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("CountVotes_FINAL o/p : {}".format(CountVotes_FINAL['return_block_hash'])) self.logger.info("CountVotes_FINAL o/p : {}".format(CountVotes_FINAL['return_block_hash']))
print("CountVotes_FINAL", CountVotes_FINAL['return_block_hash']) ##print("CountVotes_FINAL", CountVotes_FINAL['return_block_hash'])
######## END : count votes for CountVotes_FINAL ########### ######## END : count votes for CountVotes_FINAL ###########
...@@ -701,9 +720,13 @@ class OverlayNode(Node): ...@@ -701,9 +720,13 @@ class OverlayNode(Node):
self.tentativeblockchain.append(str((self.currentPreviousHash,hblockSTAR))) self.tentativeblockchain.append(str((self.currentPreviousHash,hblockSTAR)))
self.logger.info("BLOCKCHAIN : {}".format(self.blockchain)) self.logger.info("BLOCKCHAIN : {}".format(self.blockchain))
self.printStats()
self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type].clear()
self.messagesTillNow.clear()
# self.messageQueue.clear()
yield 'resume', 50
# self.logger.info(self.uniqueReceivedMessages) # self.logger.info(self.uniqueReceivedMessages)
yield "resume", 40
...@@ -775,12 +798,12 @@ if __name__ == '__main__': ...@@ -775,12 +798,12 @@ if __name__ == '__main__':
value =5 value =5
d[key] = d.get(key, value) d[key] = d.get(key, value)
print(d[2]) ##print(d[2])
v = 7 v = 7
d[key] = d.get(key, v) d[key] = d.get(key, v)
print(d[2]) ##print(d[2])
......
...@@ -140,8 +140,8 @@ def verifySort(pk,hash,proof,seed,rolecount,role,w,badaW): ...@@ -140,8 +140,8 @@ def verifySort(pk,hash,proof,seed,rolecount,role,w,badaW):
break break
j = j+1 j = j+1
if j : # if j :
print("Verification success : J :",j,role) # print("Verification success : J :",j,role)
return j return j
......
#!/usr/bin/env bash #!/usr/bin/env bash
python3 filegen.py 30 #python3 filegen.py 30
rm -rf ASim.log rm -rf ASim.log
......
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