forked from Chia-Network/pool-reference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwin_simulation.py
More file actions
45 lines (33 loc) · 1.42 KB
/
win_simulation.py
File metadata and controls
45 lines (33 loc) · 1.42 KB
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
from secrets import token_bytes
from chia.consensus.pos_quality import _expected_plot_size
from chia.consensus.pot_iterations import calculate_iterations_quality
# This is the sub slot iters that all pools must use to base the difficulty on. A difficulty of 1 (the minimum)
# targets about 100 proofs per day for one plot of size k32. There are 9216 signage points per day, 64 signage points
# per slot, the difficulty constant factor is 2**67.
ssi = (2 ** 67 / (_expected_plot_size(32)) / 9216) * 64 * 100
print(f"SSi {ssi}")
# We use 734 million as an approximation and a number that is easier to remember
ssi = 734000000
def do_simulation(days: int, diff: int, k: int, num: int):
successes = 0
for i in range(9216 * days):
for j in range(num):
s = calculate_iterations_quality(2 ** 67, token_bytes(32), k, diff, token_bytes(32)) < (ssi // 64)
if s:
successes += 1
return successes
# Difficulty 1, 1 day with 1 plot
print(do_simulation(1, 1, 32, 1))
# Difficulty 100, 10 day with 1 plot = 101GB
print(do_simulation(10, 100, 32, 1))
# Difficulty 100, 1 day with 100 plots = 10TB
print(do_simulation(1, 100, 32, 100))
# Difficulty 5000, 1 day with 10340 plots = 1PiB
print(do_simulation(1, 5000, 32, 10340))
# Test
# total_su = 0
# for _ in range(1000):
# su = do_simulation(1, 1, 32, 1)
# total_su += su
# print(total_su / 1000)
# assert abs(1 - (total_su / 1000) / 1) < 0.01