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

minor fix

parent b5a476fc
lambda_proposer = 30# wait time for priority messages to be received lambda_proposer = 30# wait time for priority messages to be received
tou_proposer = 20 # proposer rolecount tou_proposer = 26 # proposer rolecount
ROLE_BLOCK_PROPOSER = 'BLOCK_PROPOSER' ROLE_BLOCK_PROPOSER = 'BLOCK_PROPOSER'
tou_step = 28 # tou is expected number of users that sortition selects for committee tou_step = 60 # tou is expected number of users that sortition selects for committee
ROLE_COMMITEE_FOR_VOTE = 'committee' ROLE_COMMITEE_FOR_VOTE = 'committee'
lambda_block = 300 #seconds lambda_block = 300 #seconds
...@@ -21,7 +21,7 @@ FINALIZED_BLOCK_msg_type = "FINALIZED_BLOCK" ...@@ -21,7 +21,7 @@ FINALIZED_BLOCK_msg_type = "FINALIZED_BLOCK"
TENTATIVE_BLOCK_msg_type = "TENTATIVE_BLOCK" TENTATIVE_BLOCK_msg_type = "TENTATIVE_BLOCK"
NUMBER_OF_NODES_IN_NETWORK = 30 NUMBER_OF_NODES_IN_NETWORK = 100
MAXSTEP = 15 MAXSTEP = 15
FINAL_STEP = 9999999999 FINAL_STEP = 9999999999
......
0 29 0 57
0 13 0 62
1 5 0 58
1 28 1 23
2 6 1 65
2 23 1 10
2 18 2 84
3 20 2 58
3 19 2 90
3 10 2 99
3 4 3 22
4 21 3 56
4 9 4 72
4 24 4 62
5 26 4 38
5 25 5 52
5 11 5 57
6 11 5 42
6 17 6 10
6 8 6 90
7 22 7 21
7 28 7 45
8 25 8 76
8 22 8 71
8 18 9 32
9 18 9 97
9 24 9 46
9 28 10 59
10 25 10 79
10 16 11 83
12 15 11 81
12 14 11 23
12 21 12 27
13 22 12 75
14 27 12 59
14 17 13 66
14 26 13 44
15 18 13 41
15 29 14 99
15 20 14 65
16 17 15 16
17 20 15 71
19 20 15 95
19 24 16 40
17 95
17 74
17 34
17 29
18 39
18 52
19 96
19 82
20 81
20 90
21 26 21 26
22 23 21 91
23 29 22 26
25 27 22 92
27 29 23 97
23 44
24 27
24 94
25 80
25 77
25 46
26 48
26 30
27 83
27 80
28 40
28 44
28 98
29 78
30 74
30 48
30 50
31 52
31 55
31 49
32 91
32 93
33 47
33 51
34 37
35 85
35 61
35 48
36 98
36 93
37 57
37 51
37 55
38 73
38 67
38 81
39 40
39 94
40 59
41 48
42 85
42 68
42 78
43 53
43 98
44 65
45 80
46 88
46 56
47 74
49 82
49 68
49 53
50 89
51 93
51 68
54 99
54 63
55 96
55 87
56 71
56 91
58 83
60 78
60 97
61 63
62 68
62 98
63 74
64 70
64 88
66 87
67 90
67 99
69 89
69 81
70 86
72 93
72 73
75 82
76 77
78 84
79 97
83 85
85 86
92 94
...@@ -19,6 +19,7 @@ class Network(): ...@@ -19,6 +19,7 @@ class Network():
self.networkClockTime = 0 self.networkClockTime = 0
self.pk_weight_map = {} self.pk_weight_map = {}
self.time = 0 self.time = 0
self.BlocksHashTOBLOCK_MAP = {}
def setupNetwork(self): def setupNetwork(self):
''' '''
......
...@@ -28,3 +28,73 @@ ...@@ -28,3 +28,73 @@
27 27
28 28
29 29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
...@@ -29,7 +29,7 @@ class OverlayNode(Node): ...@@ -29,7 +29,7 @@ class OverlayNode(Node):
self.currentRole = "BLOCK_PROPOSER" self.currentRole = "BLOCK_PROPOSER"
self.currentSeed = None self.currentSeed = None
self.currentPreviousHash = None self.currentPreviousHash = None
self.seenBlocksHashTOBLOCK_MAP = {}
self.startNodeLifeCycleGenerator = self.startNodeLifeCycle() self.startNodeLifeCycleGenerator = self.startNodeLifeCycle()
# adding initial task of bootstraping node.and it only contains ba* resume tasks # adding initial task of bootstraping node.and it only contains ba* resume tasks
...@@ -225,6 +225,7 @@ class OverlayNode(Node): ...@@ -225,6 +225,7 @@ class OverlayNode(Node):
self.logger.info("broadcsting BLOCK Proposal Message : {}".format(BLOCK_PROPOSAL_MSG_to_broadcast)) self.logger.info("broadcsting BLOCK Proposal Message : {}".format(BLOCK_PROPOSAL_MSG_to_broadcast))
self.broadcast(self.network.time, BLOCK_PROPOSAL_MSG_to_broadcast) self.broadcast(self.network.time, BLOCK_PROPOSAL_MSG_to_broadcast)
blockForBA = (previousHash,BLOCK_PROPOSAL_MSG_to_broadcast[2]) blockForBA = (previousHash,BLOCK_PROPOSAL_MSG_to_broadcast[2])
self.network.BlocksHashTOBLOCK_MAP[Utility.pseudoRandomGenerator(blockForBA)] = blockForBA
self.logger.info('Proposed block : {}'.format(blockForBA)) self.logger.info('Proposed block : {}'.format(blockForBA))
else: # others than block proposers else: # others than block proposers
...@@ -244,6 +245,7 @@ class OverlayNode(Node): ...@@ -244,6 +245,7 @@ class OverlayNode(Node):
######### Performing selection of block BA* ############################ ######### Performing selection of block BA* ############################
if not (self.uniqueReceivedMessages[Config.BLOCK_PROPOSAL_MSG_type] or blockForBA) : if not (self.uniqueReceivedMessages[Config.BLOCK_PROPOSAL_MSG_type] or blockForBA) :
blockForBA = (previousHash,"Empty") blockForBA = (previousHash,"Empty")
self.network.BlocksHashTOBLOCK_MAP[Utility.pseudoRandomGenerator(blockForBA)] = blockForBA
elif not blockForBA : elif not blockForBA :
# Todo select block from highest priority node # Todo select block from highest priority node
blockForBA = (self.uniqueReceivedMessages[Config.BLOCK_PROPOSAL_MSG_type][0][1], blockForBA = (self.uniqueReceivedMessages[Config.BLOCK_PROPOSAL_MSG_type][0][1],
...@@ -713,17 +715,18 @@ class OverlayNode(Node): ...@@ -713,17 +715,18 @@ class OverlayNode(Node):
FNALIZED_BLOCK_msg = ( FNALIZED_BLOCK_msg = (
Config.FINALIZED_BLOCK_msg_type,hblockSTAR ) Config.FINALIZED_BLOCK_msg_type,hblockSTAR )
self.logger.info("FINALIZED BLOCK in round :"+str(self.currentRound)+" : {}".format(FNALIZED_BLOCK_msg)) self.logger.info("FINALIZED BLOCK in round :"+str(self.currentRound)+" : {}".format(FNALIZED_BLOCK_msg))
self.blockchain.append(str((self.currentPreviousHash,hblockSTAR))) self.blockchain.append(str(self.network.BlocksHashTOBLOCK_MAP[hblockSTAR]))
else: else:
TENTATIVE_BLOCK_msg = (Config.TENTATIVE_BLOCK_msg_type, hblockSTAR) TENTATIVE_BLOCK_msg = (Config.TENTATIVE_BLOCK_msg_type, hblockSTAR)
self.logger.info("TENTATIVE BLOCK in round :"+str(self.currentRound)+" : {}".format(TENTATIVE_BLOCK_msg)) self.logger.info("TENTATIVE BLOCK in round :"+str(self.currentRound)+" : {}".format(TENTATIVE_BLOCK_msg))
self.tentativeblockchain.append(str((self.currentPreviousHash,hblockSTAR))) self.tentativeblockchain.append(str(self.network.BlocksHashTOBLOCK_MAP[hblockSTAR]))
self.logger.info("BLOCKCHAIN : {}".format(self.blockchain)) self.logger.info("BLOCKCHAIN : {}".format(self.blockchain))
self.printStats() self.printStats()
self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type].clear() self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type].clear()
self.messagesTillNow.clear() self.messagesTillNow.clear()
# self.messageQueue.clear() self.logger.info("PROPOSED BLOCKS IN ROUND :"+str(self.currentRound)+" : {} ".format(self.network.BlocksHashTOBLOCK_MAP))
self.network.BlocksHashTOBLOCK_MAP.clear()
yield 'resume', 50 yield 'resume', 50
# self.logger.info(self.uniqueReceivedMessages) # self.logger.info(self.uniqueReceivedMessages)
...@@ -793,18 +796,19 @@ def takeSecond(elem): ...@@ -793,18 +796,19 @@ def takeSecond(elem):
if __name__ == '__main__': if __name__ == '__main__':
d = {} x = ['I am the first block', "('812a53b631914a36764fc9f8328dd019ce50f5c4b6051f670fbe0efb705efc77', 84736415767811103652304891014813354728426533548611541614918993721182826986444)", "('d31fbe19c2e713985ecdf394969c7790d19a87dcafa9c02cba0558bf12d544d4', 103122347745550455001943383981344366012988901432495847445355962900079905936198)", "('fd5a205348d15fc21b256ebd303a135857bda77a1993cf11303e45785aefb332', 47823573000215416532528435656381159431075140417141700821011381942532282748521)", "('9c868518b4d10e1a4a13046f6097f97d6df6dc1e95a661953d527a823ee6f050', 55460601694948737718196781018048019511931736228223657848800923874020053551928)", "('c2a3b56930d43645a93e865782abb0b4bac6681e693c9d50c13fd7391b4b7f25', 58707674458812810357241716928176455160340351916543706621213043845025913695452)", "('b03f15d0e7782a7f95fab6617411aa03f21cd9229e8e4f242ea4079ecd920cc2', 67573794190754323804116586417572734088575374646300010693539061879295897305162)", "('98d98b0732f5c5218a3b2ad49b5cba8c7d17c996ff4ea5689937684f2b20d79d', 69633357725200221165001650735647103204316958836713683487178046118094356870936)", "('9f4af3721891d947075907ba44c0d3587a6be51214b56be4478cbbfb54d5d88b', 66422139942822171704688570027380253905979677843036084427158008574677456200809)", "('86231ce45686fdafc82dc4159ba710e3f8b7fa31cf78dd25dcb8dfca313b4ac2', 108471944712883743347571235551646957426255157519283101098519720665762066857519)"]
key = 2 y = ['I am the first block', "('812a53b631914a36764fc9f8328dd019ce50f5c4b6051f670fbe0efb705efc77', 84736415767811103652304891014813354728426533548611541614918993721182826986444)", "('d31fbe19c2e713985ecdf394969c7790d19a87dcafa9c02cba0558bf12d544d4', 103122347745550455001943383981344366012988901432495847445355962900079905936198)", "('fd5a205348d15fc21b256ebd303a135857bda77a1993cf11303e45785aefb332', 47823573000215416532528435656381159431075140417141700821011381942532282748521)", "('9c868518b4d10e1a4a13046f6097f97d6df6dc1e95a661953d527a823ee6f050', 55460601694948737718196781018048019511931736228223657848800923874020053551928)", "('c2a3b56930d43645a93e865782abb0b4bac6681e693c9d50c13fd7391b4b7f25', 58707674458812810357241716928176455160340351916543706621213043845025913695452)", "('b03f15d0e7782a7f95fab6617411aa03f21cd9229e8e4f242ea4079ecd920cc2', 67573794190754323804116586417572734088575374646300010693539061879295897305162)", "('98d98b0732f5c5218a3b2ad49b5cba8c7d17c996ff4ea5689937684f2b20d79d', 69633357725200221165001650735647103204316958836713683487178046118094356870936)", "('9f4af3721891d947075907ba44c0d3587a6be51214b56be4478cbbfb54d5d88b', 66422139942822171704688570027380253905979677843036084427158008574677456200809)", "('86231ce45686fdafc82dc4159ba710e3f8b7fa31cf78dd25dcb8dfca313b4ac2', 108471944712883743347571235551646957426255157519283101098519720665762066857519)"]
value =5 ['I am the first block',
d[key] = d.get(key, value) "('812a53b631914a36764fc9f8328dd019ce50f5c4b6051f670fbe0efb705efc77', 84736415767811103652304891014813354728426533548611541614918993721182826986444)",
"('d31fbe19c2e713985ecdf394969c7790d19a87dcafa9c02cba0558bf12d544d4', 103122347745550455001943383981344366012988901432495847445355962900079905936198)",
##print(d[2]) "('fd5a205348d15fc21b256ebd303a135857bda77a1993cf11303e45785aefb332', 47823573000215416532528435656381159431075140417141700821011381942532282748521)",
"('9c868518b4d10e1a4a13046f6097f97d6df6dc1e95a661953d527a823ee6f050', 55460601694948737718196781018048019511931736228223657848800923874020053551928)",
v = 7 "('c2a3b56930d43645a93e865782abb0b4bac6681e693c9d50c13fd7391b4b7f25', 58707674458812810357241716928176455160340351916543706621213043845025913695452)",
d[key] = d.get(key, v) "('b03f15d0e7782a7f95fab6617411aa03f21cd9229e8e4f242ea4079ecd920cc2', 67573794190754323804116586417572734088575374646300010693539061879295897305162)",
"('98d98b0732f5c5218a3b2ad49b5cba8c7d17c996ff4ea5689937684f2b20d79d', 69633357725200221165001650735647103204316958836713683487178046118094356870936)",
##print(d[2]) "('9f4af3721891d947075907ba44c0d3587a6be51214b56be4478cbbfb54d5d88b', 66422139942822171704688570027380253905979677843036084427158008574677456200809)",
"('86231ce45686fdafc82dc4159ba710e3f8b7fa31cf78dd25dcb8dfca313b4ac2', 108471944712883743347571235551646957426255157519283101098519720665762066857519)"]
print(len(x))
......
#!/usr/bin/env bash #!/usr/bin/env bash
#python3 filegen.py 30 python3 filegen.py 100
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