forked from BlockScience/subspace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.py
193 lines (157 loc) · 6.19 KB
/
types.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
from typing import Annotated, Callable, NamedTuple, Optional, TypedDict, Union
# Time units
Blocks = Annotated[float, "blocks"] # 1 block ~ 6s. Or 1 day ~ 14400 blocks
Days = Annotated[float, "days"] # Number of days
Seconds = Annotated[float, "s"]
PerYear = Annotated[float, "1/year"] # Yearly rate
Year = Annotated[float, "year"] # Number of years
Picoseconds = Annotated[float, "ps"] # Number of Picoseconds
# Measurement units
Credits = Annotated[float, "SSC"]
CreditsPerComputeWeights = Annotated[float, "SSC/CW"]
CreditsPerDay = Annotated[float, "SSC/day"]
ComputeWeights = Annotated[float, "CW"]
Shannon = Annotated[float, "Shannon"] # 1e-18 SSC
ShannonPerComputeWeights = Annotated[float, "Shannon/CW"]
# Storage
Bytes = Annotated[int, "bytes"]
Chunk = Annotated[int, "chunk"] # As per Subnomicon: 1 chunk = 32 Bytes
RawRecord = Annotated[Chunk, "raw_record"] # As per Subnomicon: 2**15 Chunks (~1MB)
Piece = Annotated[
int, "piece"
] # As per Subnomicon: 1 piece = 1 record + commitment + witness
Record = Annotated[Piece, "record"] # As per Subnomicon: a transformed raw record.
Sector = Annotated[Piece, "sector"] # As per Subnomicon: 1000 Pieces or ~ 1 GiB
# As per Subnomicon: A collection of potential partial or full blocks.
# Can be either a fixed-size portion of the Blockchain History
# or a fixed-size portion of the Archived History
Segment = Annotated[Bytes, "segment"]
RecordedHistorySegment = Annotated[Record, "record_segment"]
ArchivedHistorySegment = Annotated[Piece, "archive_segment"]
# Taxonomy:
# Chunk < Record/Piece < Sector < Plot < History
# Misc units
Percentage = Annotated[float, "%"]
class SubspaceModelState(TypedDict):
# Time Variables
days_passed: Days
delta_days: Days
delta_blocks: Blocks
# Metrics
circulating_supply: Credits
user_supply: Credits
issued_supply: Credits
sum_of_stocks: Credits
block_utilization: Percentage
# Governance Variables
dsf_relative_disbursal_per_day: Percentage
# Stocks
reward_issuance_balance: Credits
other_issuance_balance: Credits
operators_balance: Credits
nominators_balance: Credits
holders_balance: Credits
farmers_balance: Credits
staking_pool_balance: Credits
fund_balance: Credits
burnt_balance: Credits
# Staking Pool Shares
nominator_pool_shares: float
operator_pool_shares: float
# Deterministic Variables
block_reward: Credits
blockchain_history_size: Bytes
total_space_pledged: Bytes
allocated_tokens: Credits
buffer_size: Bytes
# Stochastic Variables
average_base_fee: Optional[ShannonPerComputeWeights]
average_priority_fee: Optional[ShannonPerComputeWeights]
average_compute_weight_per_tx: ComputeWeights
average_transaction_size: Bytes
transaction_count: int
average_compute_weight_per_bundle: ComputeWeights
average_bundle_size: Bytes
bundle_count: int
# Metrics
compute_fee_volume: Credits
storage_fee_volume: Credits
rewards_to_nominators: Credits
# max_normal_weight:
# max_bundle_weight:
# target_block_fullness:
# block_weight_utilization:
# adjustment_variable:
# priority_fee_volume:
class SubspaceModelParams(TypedDict):
label: str
timestep_in_days: Days
# Mechanisms to be determined
issuance_function: Callable
slash_function: Callable[[SubspaceModelState], Credits]
# Implementation parameters
block_time_in_seconds: Seconds
archival_depth: Blocks
archival_buffer_segment_size: Bytes
header_size: Bytes
min_replication_factor: float
max_block_size: Bytes
weight_to_fee: Credits
# Economic Parameters
reward_proposer_share: Percentage
max_credit_supply: Credits
credit_supply_definition: Callable[[SubspaceModelState], Credits]
# Fees & Taxes
fund_tax_on_proposer_reward: Percentage
fund_tax_on_storage_fees: Percentage
compute_fees_to_farmers: Percentage
compute_fees_tax_to_operators: Percentage
# Slash Parameters
slash_to_fund: Percentage
slash_to_holders: Percentage
# Behavioral Parameters
operator_stake_per_ts_function: Callable[[bool], Percentage]
nominator_stake_per_ts_function: Callable[[bool], Percentage]
# operator_avg_stake_per_ts: Callable[[bool], Percentage]
# nominator_avg_stake_per_ts: Callable[[bool], Percentage]
# operator_std_stake_per_ts: Callable[[bool], Percentage]
# nominator_std_stake_per_ts: Callable[[bool], Percentage]
transfer_farmer_to_holder_per_day: Percentage
transfer_operator_to_holder_per_day: Percentage
transfer_holder_to_nominator_per_day: Percentage
transfer_holder_to_operator_per_day: Percentage
# Environmental Parameters
base_fee_function: Callable[[bool], Percentage]
# avg_base_fee: Credits
# std_base_fee: Credits
min_base_fee: Credits
priority_fee_function: Callable[[bool], Percentage]
# avg_priority_fee: Credits
# std_priority_fee: Credits
compute_weights_per_tx_function: Callable[[bool], ComputeWeights]
# avg_compute_weights_per_tx: ComputeWeights
# std_compute_weights_per_tx: ComputeWeights
min_compute_weights_per_tx: ComputeWeights
compute_weights_per_bundle_function: Callable[[bool], ComputeWeights]
# avg_compute_weights_per_bundle: ComputeWeights
# std_compute_weights_per_bundle: ComputeWeights
min_compute_weights_per_bundle: ComputeWeights
transaction_size_function: Callable[[bool], Bytes]
# avg_transaction_size: Bytes
# std_transaction_size: Bytes
min_transaction_size: Bytes
bundle_size_function: Callable[[bool], Bytes]
# avg_bundle_size: Bytes # TODO: confirm
# std_bundle_size: Bytes # TODO: confirm
min_bundle_size: Bytes # TODO: confirm
transaction_count_per_day_function: Callable[[bool], float]
# avg_transaction_count_per_day: float
bundle_count_per_day_function: Callable[[bool], float]
# avg_bundle_count_per_day: float
slash_per_day_function: Callable[[bool], float]
# avg_slash_per_day: float
new_sectors_per_day_function: Callable[[bool], float]
# avg_new_sectors_per_day: float
# std_new_sectors_per_day: float
# Logic implementation types
StochasticFunction = Callable[[SubspaceModelParams, SubspaceModelState], float]