-
Notifications
You must be signed in to change notification settings - Fork 6
/
structure.py
222 lines (211 loc) · 7.02 KB
/
structure.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
from subspace_model.logic import *
from typing import Callable
from copy import deepcopy
import logging
logger = logging.getLogger("subspace-digital-twin")
# Non processed blocks
_SUBSPACE_MODEL_BLOCKS: list[dict] = [
{
"label": "Time Tracking",
"ignore": False,
"desc": "Updates the time in the system",
"policies": {"evolve_time": p_evolve_time},
"variables": {
"delta_days": replace_suf,
"days_passed": add_suf,
"delta_blocks": replace_suf,
"blocks_passed": add_suf,
},
},
{
"label": "Reference Subsidy",
"ignore": False,
"policies": {},
"variables": {
"reference_subsidy": s_reference_subsidy,
},
},
{
"label": "Environmental Processes",
"ignore": False,
"policies": {"block_utilization": p_block_utilization},
"variables": {
"average_priority_fee": s_average_priority_fee,
"average_compute_weight_per_tx": s_average_compute_weight_per_tx,
"transaction_count": replace_suf,
"average_transaction_size": replace_suf,
"average_compute_weight_per_bundle": s_average_compute_weight_per_bundle,
"bundle_count": s_bundle_count,
"block_utilization": replace_suf
},
},
{
"label": "Archival Process",
"policies": {"archival": p_archive},
"variables": {
"blockchain_history_size": add_suf,
"buffer_size": add_suf,
},
},
{
"label": "Sector Onboarding",
"policies": {"sector_onboarding": p_pledge_sectors},
"variables": {
"total_space_pledged": add_suf,
},
},
{
"label": "Issuance Rewards",
"ignore": False,
"policies": {
"issuance_reward": p_reward,
},
"variables": {
"reward_issuance_balance": add_suf,
"farmers_balance": add_suf,
"block_reward": replace_suf,
"reward_to_voters": replace_suf,
"reward_to_proposer": replace_suf,
},
},
{
"label": "Storage Fees",
"ignore": False,
"policies": {"storage_fees": p_storage_fees},
"variables": {
# Fee Calculation
"free_space": replace_suf,
"storage_fee_in_credits_per_bytes": replace_suf,
"extrinsic_length_in_bytes": replace_suf,
"storage_fee_volume": replace_suf,
},
},
{
"label": "Compute Fees",
"ignore": False,
"policies": {"compute_fees": p_compute_fees},
"variables": {
# Compute fee calculations
"target_block_delta": replace_suf,
"targeted_adjustment_parameter": replace_suf,
"compute_fee_multiplier": replace_suf,
"tx_compute_weight": replace_suf,
"compute_fee_volume": replace_suf,
"priority_fee_volume": replace_suf,
# Fees and rewards distribution
"farmers_balance": add_suf,
"nominators_balance": add_suf,
"operators_balance": add_suf
},
},
{
"label": "Direct Allocations",
"ignore": False,
"policies": {"unvest": p_unvest},
"variables": {
"other_issuance_balance": add_suf,
"farmers_balance": add_suf,
"allocated_tokens": replace_suf,
"allocated_tokens_investors": replace_suf,
"allocated_tokens_founders": replace_suf,
"allocated_tokens_team": replace_suf,
"allocated_tokens_advisors": replace_suf,
"allocated_tokens_vendors": replace_suf,
"allocated_tokens_ambassadors": replace_suf,
},
},
{
"label": "Slash",
"ignore": False,
"policies": {"slash": p_slash},
"variables": {
"staking_pool_balance": add_suf,
"operator_pool_shares": add_suf,
"burnt_balance": add_suf,
},
},
{
"label": "Staking / Unstaking",
"ignore": False,
"policies": {
"staking": p_staking,
},
"variables": {
"operators_balance": add_suf,
"nominators_balance": add_suf,
"staking_pool_balance": add_suf,
"operator_pool_shares": add_suf,
"nominator_pool_shares": add_suf,
},
},
{
"label": "Transfers",
"ignore": False,
"policies": {"transfers": p_transfers},
"variables": {
"operators_balance": add_suf,
"nominators_balance": add_suf,
"farmers_balance": add_suf,
},
},
{
"label": "Metrics",
"policies": {},
"variables": {
"circulating_supply": lambda _1, _2, _3, state, _5: (
"circulating_supply",
circulating_supply(state),
),
"user_supply": lambda _1, _2, _3, state, _5: (
"user_supply",
user_supply(state),
),
"earned_supply": lambda _1, _2, _3, state, _5: (
"user_supply",
earned_supply(state),
),
"issued_supply": lambda _1, _2, _3, state, _5: (
"issued_supply",
issued_supply(state),
),
"earned_minus_burned_supply": lambda _1, _2, _3, state, _5: (
"user_supply",
earned_minus_burned_supply(state),
),
"total_supply": lambda _1, _2, _3, state, _5: (
"total_supply",
total_supply(state),
),
"sum_of_stocks": lambda _1, _2, _3, state, _5: (
"sum_of_stocks",
sum_of_stocks(state),
),
"storage_fee_per_rewards": lambda _1, _2, _3, state, _5: (
"storage_fee_per_rewards",
storage_fee_per_rewards(state),
),
"community_owned_supply": lambda params, _2, _3, state, _5: (
"community_owned_supply",
community_owned_supply(state, params),
),
"cumm_rewards": s_cumm_generic("block_reward", "cumm_rewards", nan_value=0.0),
"cumm_storage_fees_to_farmers": s_cumm_generic("storage_fee_volume", "cumm_storage_fees_to_farmers"),
"cumm_compute_fees_to_farmers": s_cumm_compute_fee_to_farmers
},
},
]
# Post Processing
blocks: list[dict] = []
for block in [b for b in _SUBSPACE_MODEL_BLOCKS if b.get("ignore", False) != True]:
_block = deepcopy(block)
for variable, suf in block.get("variables", {}).items():
if suf == add_suf:
_block["variables"][variable] = add_suf(variable)
elif suf == replace_suf:
_block["variables"][variable] = replace_suf(variable)
else:
pass
blocks.append(_block)
SUBSPACE_MODEL_BLOCKS = deepcopy(blocks)
logger.debug("SUBSPACE_MODEL_BLOCKS: \n%s", [
b["label"] for b in SUBSPACE_MODEL_BLOCKS])