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
9098140d
Commit
9098140d
authored
May 03, 2019
by
UNHALE NILESH ARUN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
read me updated
parent
fd6c5dba
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
67 additions
and
13 deletions
+67
-13
Config.py
Config.py
+7
-2
Network.py
Network.py
+8
-0
OverlayNode.py
OverlayNode.py
+10
-3
Plot.py
Plot.py
+26
-0
README.md
README.md
+1
-6
Utility.py
Utility.py
+10
-1
dummy2.py
dummy2.py
+4
-0
start.sh
start.sh
+1
-1
No files found.
Config.py
View file @
9098140d
...
...
@@ -2,7 +2,7 @@ lambda_proposer = 30# wait time for priority messages to be received
tou_proposer
=
26
# proposer rolecount
ROLE_BLOCK_PROPOSER
=
'BLOCK_PROPOSER'
tou_step
=
60
# tou is expected number of users that sortition selects for committee
tou_step
=
28
# tou is expected number of users that sortition selects for committee
ROLE_COMMITEE_FOR_VOTE
=
'committee'
lambda_block
=
300
#seconds
...
...
@@ -21,8 +21,13 @@ FINALIZED_BLOCK_msg_type = "FINALIZED_BLOCK"
TENTATIVE_BLOCK_msg_type
=
"TENTATIVE_BLOCK"
NUMBER_OF_NODES_IN_NETWORK
=
10
0
NUMBER_OF_NODES_IN_NETWORK
=
5
0
MAXSTEP
=
15
FINAL_STEP
=
9999999999
'''------------------------------------------------------------------------------'''
Experiment_1_OBS
=
{}
#KEY : (subusercount,sortitionCount)
\ No newline at end of file
Network.py
View file @
9098140d
...
...
@@ -92,6 +92,14 @@ class Network():
for
node
in
self
.
nodes
.
values
():
node
.
simulate
(
time
)
if
time
==
str
(
99999
):
for
link
in
self
.
links
.
values
():
self
.
logger
.
info
(
"remaining tasks : {}"
.
format
((
link
.
link
,
link
.
todoList
)))
for
node
in
self
.
nodes
.
values
():
self
.
logger
.
info
(
"reamaining tasks : {}"
.
format
((
node
.
id
,
node
.
todoList
)))
self
.
logger
.
info
(
"reamaining tasks : {}"
.
format
(
node
.
ResumeTasks
))
pass
if
__name__
==
'__main__'
:
...
...
OverlayNode.py
View file @
9098140d
...
...
@@ -167,6 +167,7 @@ class OverlayNode(Node):
while
True
:
#increment round number
self
.
logger
.
info
(
"STARTING ROUND NUMBER : {}"
.
format
(
self
.
currentRound
))
blockForBA
=
None
...
...
@@ -234,6 +235,7 @@ class OverlayNode(Node):
else
:
# others than block proposers
# everybody is waiting for lambda_proposer+ lambda_block 33 seconds
self
.
logger
.
info
(
"GOING TO SLEEP for {}"
.
format
(
Config
.
lambda_proposer
+
Config
.
lambda_block
))
yield
"resume"
,
Config
.
lambda_proposer
+
Config
.
lambda_block
# TODO:done : drop any priority messages in queue
...
...
@@ -661,15 +663,16 @@ class OverlayNode(Node):
var_BBA_star
[
'step'
]
+=
1
self
.
printStats
()
# self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type].clear()
yield
'resume'
,
50
yield
"resume"
,
50
'''END : BBAStar case 3'''
yield
"resume"
,
1
if
var_BBA_star
[
'step'
]
==
Config
.
MAXSTEP
:
self
.
logger
.
info
(
"I AM GOING TO HANG FOREVER"
)
yield
"resume"
,
40120000
# hang forever
exit
(
0
)
#
exit(0)
''' END : BBA* ALGORITHM '''
...
...
@@ -727,7 +730,10 @@ class OverlayNode(Node):
self
.
messagesTillNow
.
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'
,
10
print
(
"stats for experiment 1 : {}"
.
format
(
Config
.
Experiment_1_OBS
))
self
.
currentRound
=
self
.
currentRound
+
1
# self.logger.info(self.uniqueReceivedMessages)
...
...
@@ -765,6 +771,7 @@ class OverlayNode(Node):
pass
self
.
ResumeTasks
[
str
(
int
(
self
.
network
.
time
)
+
10
)]
.
append
((
"nextOn"
,
self
.
startNodeLifeCycleGenerator
,))
pass
...
...
Plot.py
0 → 100644
View file @
9098140d
import
matplotlib.pyplot
as
plt
stats
=
{
49
:
[
5
,
3
],
41
:
[
14
,
12
],
23
:
[
7
,
5
],
40
:
[
5
,
4
],
19
:
[
3
,
3
],
31
:
[
7
,
6
],
28
:
[
1
,
1
],
33
:
[
7
,
5
],
38
:
[
10
,
8
],
16
:
[
2
,
2
],
48
:
[
3
,
3
],
50
:
[
4
,
2
],
12
:
[
1
,
1
],
17
:
[
3
,
1
],
42
:
[
2
,
2
],
35
:
[
1
,
1
],
45
:
[
2
,
2
],
37
:
[
7
,
6
],
36
:
[
4
,
2
],
7
:
[
1
,
1
],
29
:
[
1
,
1
],
26
:
[
4
,
3
],
32
:
[
1
,
1
],
34
:
[
1
,
1
],
39
:
[
1
,
1
],
25
:
[
5
,
3
],
46
:
[
1
,
1
],
8
:
[
1
,
1
],
30
:
[
1
,
1
]}
stats2
=
{
38
:
[
2
,
2
],
20
:
[
2
,
2
],
37
:
[
2
,
2
],
47
:
[
2
,
2
],
41
:
[
11
,
8
],
46
:
[
1
,
1
],
49
:
[
4
,
3
],
40
:
[
2
,
2
],
32
:
[
1
,
1
],
45
:
[
4
,
3
],
24
:
[
2
,
2
],
30
:
[
1
,
1
],
31
:
[
2
,
2
],
28
:
[
2
,
2
],
35
:
[
2
,
2
],
22
:
[
1
,
1
],
43
:
[
3
,
3
],
23
:
[
1
,
1
],
39
:
[
1
,
1
],
27
:
[
2
,
2
],
7
:
[
1
,
1
],
29
:
[
3
,
2
]}
stats3
=
{
41
:
[
2
,
2
],
16
:
[
2
,
2
],
48
:
[
1
,
1
],
5
:
[
1
,
1
],
21
:
[
2
,
2
],
39
:
[
1
,
1
],
47
:
[
2
,
2
],
46
:
[
1
,
1
],
38
:
[
1
,
1
],
45
:
[
1
,
1
],
42
:
[
1
,
1
],
40
:
[
1
,
1
]}
dict
=
{}
for
key
,
val
in
stats
.
items
():
# print(key)
# print(val)
dict
[
key
]
=
(
val
[
0
]
/
val
[
1
])
# print(sorted(dict))
lists
=
sorted
(
dict
.
items
())
# sorted by key, return a list of tuples
x
,
y
=
zip
(
*
lists
)
plt
.
xlabel
(
'Stake'
)
plt
.
ylabel
(
'Sub User'
)
plt
.
plot
(
x
,
y
)
plt
.
savefig
(
'stats.png'
)
plt
.
show
()
README.md
View file @
9098140d
...
...
@@ -5,11 +5,6 @@
`pip3 install -r requirements.txt`
`pip3 install python-louvain==0.5`
`sudo pip3 install networkx`
`apt-get install python3-tk`
*
Setup
...
...
@@ -19,7 +14,7 @@
*
How to run
`$
python3 Starter.py
`
`$
./start.sh
`
Utility.py
View file @
9098140d
...
...
@@ -2,7 +2,7 @@ from ecdsa import SigningKey,SECP256k1
from
ecdsa.keys
import
BadSignatureError
from
numpy.random
import
randint
import
numpy
as
np
import
Config
import
binascii
import
random
import
scipy.stats
as
stats
...
...
@@ -48,6 +48,14 @@ def verifyVRF(pk,hash,proof,seed):
return
False
return
True
def
gatherStatsExperiment1
(
w
,
j
):
temp
=
Config
.
Experiment_1_OBS
.
get
(
w
,
[
0
,
0
])
temp
[
0
]
=
temp
[
0
]
+
j
temp
[
1
]
=
temp
[
1
]
+
1
Config
.
Experiment_1_OBS
[
w
]
=
temp
def
sortition
(
sk
,
seed
,
rolecount
,
role
,
w
,
badaW
,
pk
):
'''
...
...
@@ -94,6 +102,7 @@ def sortition(sk,seed,rolecount,role,w,badaW,pk):
print
(
'
\n
'
)
print
(
'===============> The j value is >>>'
,
j
)
print
(
'
\n
'
)
gatherStatsExperiment1
(
w
,
j
)
return
(
hash
,
proof
,
j
)
...
...
dummy2.py
0 → 100644
View file @
9098140d
x
=
(
1
,
2
)
y
=
(
3
,
2
)
x
[
0
]
=
5
print
(
x
[
1
]
+
y
[
1
])
\ No newline at end of file
start.sh
View file @
9098140d
#!/usr/bin/env bash
python3 filegen.py
10
0
python3 filegen.py
5
0
rm
-rf
ASim.log
...
...
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