-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
63 lines (47 loc) · 1.5 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
51
52
53
54
55
56
57
58
59
60
61
62
from protocol import Protocol
from committee import Committee
from deligator import Delegator
from validator import Validator
from byzantine import Byzantine
from cosmos import Cosmos
from randomselect import RandomSelect
import matplotlib.pyplot as plt
if __name__ == '__main__':
validators = []
delegators = []
for i in range(70):
validators.append(Validator(len(validators), 200))
for i in range(30):
validators.append(Byzantine(len(validators), 200, [validators[0]], False))
for i in range(1000):
delegators.append(Delegator(len(delegators), 50, 1, 0))
committeeSize = 20
rounds = 50000
reward = 1000
#setup = Cosmos()
setup = RandomSelect()
protocol = Protocol(committeeSize, validators, delegators, rounds, setup, reward)
protocol.run()
rewards = [v.totalReward for v in validators]
dcounts = [v.dcount/rounds for v in validators]
overallrewards = [v.overallRewars for v in validators]
print(dcounts)
print(rewards)
print(overallrewards)
# Generate x-axis values (0 to 99 in this case)
x = range(len(rewards))
# Create the bar plot
plt.bar(x, rewards)
# Add labels and title
plt.xlabel('Item')
plt.ylabel('Reward')
plt.title('Comparison of Rewards')
# Display the plot
plt.show()
plt.bar(x, dcounts)
# Add labels and title
plt.xlabel('Validators')
plt.ylabel('Average number of delegators per round')
plt.title('Comparison')
# Display the plot
plt.show()