Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
algorand
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nilak
algorand
Commits
ee00ede0
Commit
ee00ede0
authored
May 01, 2019
by
THAKARE AKSHAY HARIBHAU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sharing the bugs
parent
e9c5f051
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
180 additions
and
212 deletions
+180
-212
Config.py
Config.py
+5
-3
Links1.dat
Links1.dat
+70
-111
Network.py
Network.py
+2
-2
Node.py
Node.py
+1
-1
OverlayNode.py
OverlayNode.py
+98
-94
Utility.py
Utility.py
+3
-0
filegen.py
filegen.py
+1
-1
No files found.
Config.py
View file @
ee00ede0
lambda_proposer
=
3
# wait time for priority messages to be received
lambda_proposer
=
3
0
# wait time for priority messages to be received
tou_proposer
=
20
# proposer rolecount
tou_proposer
=
20
# proposer rolecount
ROLE_BLOCK_PROPOSER
=
'BLOCK_PROPOSER'
ROLE_BLOCK_PROPOSER
=
'BLOCK_PROPOSER'
tou_step
=
3
# tou is expected number of users that sortition selects for committee
tou_step
=
3
# tou is expected number of users that sortition selects for committee
ROLE_COMMITEE_FOR_VOTE
=
'committee'
ROLE_COMMITEE_FOR_VOTE
=
'committee'
lambda_block
=
30
#seconds
lambda_block
=
30
0
#seconds
lambda_step
=
3
lambda_step
=
3
0
BLOCK_PROPOSAL_MSG_type
=
'BLOCK_PROPOSAL_MSGs'
BLOCK_PROPOSAL_MSG_type
=
'BLOCK_PROPOSAL_MSGs'
...
@@ -15,3 +15,5 @@ COMMITTEE_VOTE_MSG_type = "COMMITTEE_VOTE"
...
@@ -15,3 +15,5 @@ COMMITTEE_VOTE_MSG_type = "COMMITTEE_VOTE"
TIMEOUT
=
"TIMEOUT"
TIMEOUT
=
"TIMEOUT"
T
=
2
/
3
# T isa a fraction of expected committee size that defines BA*`s voting thershold
T
=
2
/
3
# T isa a fraction of expected committee size that defines BA*`s voting thershold
NUMBER_OF_NODES_IN_NETWORK
=
50
Links1.dat
View file @
ee00ede0
0 20
0 21
0 34
0 39
0 35
1 32
0 42
1 29
0 48
2 34
1 7
2 44
1 18
3 16
1 23
3 25
1 34
3 42
2 15
3 35
2 26
4 18
3 7
4 37
3 18
4 43
3 27
4 30
3 29
5 37
3 34
5 11
3 41
5 23
3 46
6 41
4 9
6 46
4 17
7 14
4 25
7 47
4 38
7 28
4 45
8 15
4 49
8 44
5 21
8 35
5 30
9 27
5 34
9 46
5 47
9 13
6 7
9 49
6 9
10 27
6 47
10 48
7 16
10 35
7 19
11 29
8 14
11 23
8 22
12 22
8 25
12 42
9 16
13 26
9 31
13 33
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
14 24
14 24
14 36
14 27
14 48
14 39
15 19
15 26
15 32
15 37
15 38
15 40
15 40
16 25
16 22
16 36
16 40
16 46
16 42
17 25
17 23
17 29
17 45
17 47
18 48
18 25
19 27
18 47
19 31
19 23
20 46
19 24
20 45
19 33
20 38
19 37
21 24
20 21
21 37
20 28
21 30
20 32
23 42
20 36
25 29
20 44
26 41
20 48
28 34
23 27
29 49
23 39
30 31
23 40
30 38
25 32
31 36
25 40
31 34
25 42
32 35
25 49
32 39
27 43
33 47
27 47
36 43
28 33
37 38
28 43
39 47
29 44
40 47
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
41 46
41 46
41 47
41 49
41 49
43 46
43 47
44 48
47 48
Network.py
View file @
ee00ede0
...
@@ -8,7 +8,7 @@ import random
...
@@ -8,7 +8,7 @@ import random
from
numpy.random
import
randint
from
numpy.random
import
randint
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
import
numpy
as
np
import
numpy
as
np
import
Config
class
Network
():
class
Network
():
...
@@ -31,7 +31,7 @@ class Network():
...
@@ -31,7 +31,7 @@ class Network():
:return:
: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
)
self
.
badaW
=
np
.
sum
(
w
)
i
=
0
i
=
0
with
open
(
'Nodes1.dat'
,
'r'
)
as
f
:
with
open
(
'Nodes1.dat'
,
'r'
)
as
f
:
...
...
Node.py
View file @
ee00ede0
...
@@ -101,7 +101,7 @@ class Node(SystemEntity):
...
@@ -101,7 +101,7 @@ class Node(SystemEntity):
# generate tasks for todolist based on messges
# 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
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
.
processMessage
(
message
[
0
],
list
(
message
[
1
]))
# message : (time,(payload))
self
.
logger
.
info
(
"received : "
+
str
(
message
))
#
self.logger.info("received : "+str(message))
self
.
dequeMessage
()
self
.
dequeMessage
()
# check if main ba* has to be resumed or not
# check if main ba* has to be resumed or not
...
...
OverlayNode.py
View file @
ee00ede0
...
@@ -58,7 +58,9 @@ class OverlayNode(Node):
...
@@ -58,7 +58,9 @@ class OverlayNode(Node):
role
=
(
Config
.
ROLE_COMMITEE_FOR_VOTE
,
round
,
step
)
role
=
(
Config
.
ROLE_COMMITEE_FOR_VOTE
,
round
,
step
)
# Todo something is wrong here not getting correct votes back
# 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
)
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
)
print
(
votes
,
"
\t
"
,
value
,
"
\t
"
,
sorthash
)
return
votes
,
value
,
sorthash
return
votes
,
value
,
sorthash
pass
pass
...
@@ -193,7 +195,8 @@ class OverlayNode(Node):
...
@@ -193,7 +195,8 @@ class OverlayNode(Node):
''' COmmitte vote reduction step 1'''
''' COmmitte vote reduction step 1'''
reduct_step_1
=
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_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
,
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
)
self
.
weight
,
self
.
network
.
badaW
,
self
.
pk
)
...
@@ -241,98 +244,99 @@ class OverlayNode(Node):
...
@@ -241,98 +244,99 @@ class OverlayNode(Node):
######## END : count votes for hblock1 ###########
######## END : count votes for hblock1 ###########
''' END : COmmitte vote reduction step 1'''
''' END : COmmitte vote reduction step 1'''
#
''' Start : COmmitte vote reduction step 2 '''
# ''' Start : COmmitte vote reduction step 2 '''
empty_hash
=
Utility
.
pseudoRandomGenerator
((
previousHash
,
"Empty"
))
# empty_hash = Utility.pseudoRandomGenerator((previousHash, "Empty"))
#
# which block to vote empty or hblock1
# # which block to vote empty or hblock1
reduct_step2_block_to_vote
=
None
# reduct_step2_block_to_vote = None
if
hblock1
==
Config
.
TIMEOUT
:
# if hblock1 == Config.TIMEOUT :
reduct_step2_block_to_vote
=
empty_hash
# reduct_step2_block_to_vote = empty_hash
pass
# pass
else
:
# else:
reduct_step2_block_to_vote
=
hblock1
# reduct_step2_block_to_vote = hblock1
pass
# pass
#
''' COmmitte vote reduction step2 : reduct_step2_block_to_vote'''
# ''' COmmitte vote reduction step2 : reduct_step2_block_to_vote'''
#
variables_reduct_step_2
=
{}
# variables_reduct_step_2 = {}
#
variables_reduct_step_2
[
'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'] = (previousHash, self.currentRound, variables_reduct_step_2['step'])
variables_reduct_step_2
[
'role'
]
=
(
# variables_reduct_step_2['seed'] = self.currentSeed
Config
.
ROLE_COMMITEE_FOR_VOTE
,
self
.
currentRound
,
variables_reduct_step_2
[
'step'
])
# variables_reduct_step_2['role'] = (
variables_reduct_step_2
[
'sorthash'
],
variables_reduct_step_2
[
'proof'
],
variables_reduct_step_2
[
# Config.ROLE_COMMITEE_FOR_VOTE, self.currentRound, variables_reduct_step_2['step'])
'j'
]
=
Utility
.
sortition
(
self
.
sk
,
variables_reduct_step_2
[
'seed'
],
# variables_reduct_step_2['sorthash'], variables_reduct_step_2['proof'], variables_reduct_step_2[
Config
.
tou_step
,
# 'j'] = Utility.sortition(self.sk, variables_reduct_step_2['seed'],
variables_reduct_step_2
[
'role'
],
# Config.tou_step,
self
.
weight
,
self
.
network
.
badaW
,
# variables_reduct_step_2['role'],
self
.
pk
)
# self.weight, self.network.badaW,
# print("Reduction algo " + self.id," : ",reduct_j)
# 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'
]))
# if variables_reduct_step_2['j'] > 0:
variables_reduct_step_2
[
'payload'
]
=
(
# self.logger.info("selection for VOTING COMMITEE with J =" + str(variables_reduct_step_2['j']))
self
.
currentRound
,
variables_reduct_step_2
[
'step'
],
variables_reduct_step_2
[
'sorthash'
],
# variables_reduct_step_2['payload'] = (
variables_reduct_step_2
[
'proof'
],
previousHash
,
reduct_step2_block_to_vote
)
# self.currentRound, variables_reduct_step_2['step'], variables_reduct_step_2['sorthash'],
variables_reduct_step_2
[
'committeeVoteMsg'
]
=
(
Config
.
COMMITTEE_VOTE_MSG_type
,
# variables_reduct_step_2['proof'], previousHash, reduct_step2_block_to_vote)
(
self
.
pk
,
variables_reduct_step_2
[
'payload'
],
# variables_reduct_step_2['committeeVoteMsg'] = (Config.COMMITTEE_VOTE_MSG_type,
self
.
sk
.
sign
(
bytes
(
# (self.pk, variables_reduct_step_2['payload'],
str
(
variables_reduct_step_2
[
'payload'
])
.
encode
(
# self.sk.sign(bytes(
'UTF8'
)))))
# str(variables_reduct_step_2['payload']).encode(
self
.
broadcast
(
self
.
network
.
time
,
variables_reduct_step_2
[
'committeeVoteMsg'
])
# 'UTF8')))))
self
.
logger
.
info
(
"Broadcasting commitee messgae"
+
str
(
variables_reduct_step_2
[
'committeeVoteMsg'
]))
# 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
#
# # yield "resume", Config.lambda_block + Config.lambda_step
''' COmmitte vote reduction step2 : reduct_step2_block_to_vote'''
#
# ''' COmmitte vote reduction step2 : reduct_step2_block_to_vote'''
######## count votes for hblock1 ###########
#
CountVotes_step2
=
{}
# ######## count votes for hblock1 ###########
CountVotes_step2
[
'countVote_round'
]
=
self
.
currentRound
# CountVotes_step2 = {}
CountVotes_step2
[
'countVote_step'
]
=
1
# CountVotes_step2['countVote_round'] = self.currentRound
# Config.T
# CountVotes_step2['countVote_step'] = 2
# Config.tou_step
# # Config.T
CountVotes_step2
[
'countVote_lmbda'
]
=
Config
.
lambda_block
+
Config
.
lambda_step
# # 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['start'] = int(self.network.time)
CountVotes_step2
[
'voters'
]
=
[]
# CountVotes_step2['counts'] = {}
CountVotes_step2
[
'hblock2'
]
=
None
# CountVotes_step2['voters'] = []
while
True
:
# CountVotes_step2['hblock2'] = None
if
not
self
.
uniqueReceivedMessages
[
Config
.
COMMITTEE_VOTE_MSG_type
]:
# while True:
if
int
(
self
.
network
.
time
)
>
CountVotes_step2
[
'start'
]
+
CountVotes_step2
[
# if not self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type]:
'countVote_lmbda'
]:
# if int(self.network.time) > CountVotes_step2['start'] + CountVotes_step2[
print
(
self
.
id
+
"Timing out"
)
# 'countVote_lmbda']:
CountVotes_step2
[
'hblock2'
]
=
Config
.
TIMEOUT
# print(self.id + "Timing out")
break
# CountVotes_step2['hblock2'] = Config.TIMEOUT
pass
# break
else
:
# pass
CountVotes_step2
[
'temp_return'
]
=
self
.
partOfCountVotes
(
# else:
CountVotes_step2
[
'countVote_round'
],
CountVotes_step2
[
'countVote_step'
],
# CountVotes_step2['temp_return'] = self.partOfCountVotes(
CountVotes_step2
[
'start'
],
CountVotes_step2
[
'counts'
],
# CountVotes_step2['countVote_round'], CountVotes_step2['countVote_step'],
CountVotes_step2
[
'voters'
],
Config
.
T
,
Config
.
tou_step
)
# CountVotes_step2['start'], CountVotes_step2['counts'],
print
(
"CountVotes_step2"
,
CountVotes_step2
[
'temp_return'
])
# CountVotes_step2['voters'], Config.T, Config.tou_step)
if
CountVotes_step2
[
'temp_return'
]:
# print("CountVotes_step2",CountVotes_step2['temp_return'])
CountVotes_step2
[
'hblock2'
]
=
CountVotes_step2
[
'temp_return'
]
# if CountVotes_step2['temp_return']:
break
# CountVotes_step2['hblock2'] = CountVotes_step2['temp_return']
yield
"resume"
,
1
# this is to allow other nodes to be simulated and not get this node into infinite waiting on single node
# break
self
.
logger
.
info
(
# yield "resume", 1 # this is to allow other nodes to be simulated and not get this node into infinite waiting on single node
"returning from first count values with return value : "
+
str
(
CountVotes_step2
[
'hblock2'
]))
# self.logger.info(
print
(
"CountVotes_step2"
,
CountVotes_step2
[
'hblock2'
])
# "returning from first count values with return value : " + str(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 = {}
if
CountVotes_step2
[
'hblock2'
]
==
Config
.
TIMEOUT
:
#
var_BBA_star
[
'block_hash'
]
=
empty_hash
# if CountVotes_step2['hblock2'] == Config.TIMEOUT:
else
:
# var_BBA_star['block_hash']= empty_hash
var_BBA_star
[
'block_hash'
]
=
CountVotes_step2
[
'hblock2'
]
# else:
# var_BBA_star['block_hash'] = CountVotes_step2['hblock2']
#
print
(
"I am culprit "
,
var_BBA_star
[
'hblock2'
])
#
''' END : COmmitte vote reduction step 2 '''
# print("I am culprit " ,var_BBA_star['hblock2'])
# ''' END : COmmitte vote reduction step 2 '''
yield
"resume"
,
9
yield
"resume"
,
9
# self.logger.info(self.uniqueReceivedMessages)
# self.logger.info(self.uniqueReceivedMessages)
...
...
Utility.py
View file @
ee00ede0
...
@@ -133,6 +133,9 @@ def verifySort(pk,hash,proof,seed,rolecount,role,w,badaW):
...
@@ -133,6 +133,9 @@ def verifySort(pk,hash,proof,seed,rolecount,role,w,badaW):
break
break
j
=
j
+
1
j
=
j
+
1
if
j
:
print
(
"Verification success : J :"
,
j
,
role
)
return
j
return
j
# def computeRange():
# def computeRange():
...
...
filegen.py
View file @
ee00ede0
...
@@ -3,7 +3,7 @@ from numpy.random import randint
...
@@ -3,7 +3,7 @@ from numpy.random import randint
import
sys
import
sys
import
networkx
as
nx
import
networkx
as
nx
from
networkx.algorithms
import
community
from
networkx.algorithms
import
community
import
numpy
'''
'''
Generates a file of nodes
Generates a file of nodes
'''
'''
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment