-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
50 lines (44 loc) · 1.8 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from committee import Committee
from iniva_committee import InivaCommittee
from iniva_validator import InivaValidator
from cosmos_committee import CosmosCommittee
from cosmos_validator import CosmosValidator
from validator import Validator
if __name__ == '__main__':
totalRounds = 3000000
committeeSize = 111
fanout = 10
omittedBlocks = []
#ms = [0.05, 0.10, 0.15, 0.20, 0.25, 0.30]
ms = [0.10, 0.30]
mCounts = [int(i * committeeSize) for i in ms]
print(mCounts)
rewardss = [[], [], []]
for mCount in mCounts:
users = []
for i in range(0, committeeSize - 1 - mCount):
users.append(CosmosValidator(len(users), "Correct", 1, 0))
victim = CosmosValidator(len(users), "Correct", 2, 0)
users.append(victim)
for i in range(0, mCount):
users.append(CosmosValidator(len(users), "Byzantine", 3, victim, False, True, False, False, 100))
committee = CosmosCommittee(committeeSize, users, fanout)
for i in range(0, totalRounds):
print(str(mCount) + " " + str(i))
isProduced = committee.round(i)
total = [0, 0, 0]
nums = [committeeSize -1 - mCount, 1, mCount]
for k in range(1, 4):
for j in range(0, len(users)):
if users[j].group == k:
total[k - 1] += users[j].reward
#rewards = [total[j] / sum(total) for j in range(len(total))]
#rewards = [rewards[j] / nums[j] for j in range(len(rewards))]
#temp = 1 / committeeSize
# rewards = [(x * 0.01) /temp for x in rewards]
#rewards = [(x - temp) for x in rewards]
#rewards = [rewards[j] / temp for j in range(len(rewards))]
for k in range(1, 4):
rewardss[k - 1].append(total[k - 1])
print(total)
print(rewardss)