nexaroa 0.0.111__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- neuroshard/__init__.py +93 -0
- neuroshard/__main__.py +4 -0
- neuroshard/cli.py +466 -0
- neuroshard/core/__init__.py +92 -0
- neuroshard/core/consensus/verifier.py +252 -0
- neuroshard/core/crypto/__init__.py +20 -0
- neuroshard/core/crypto/ecdsa.py +392 -0
- neuroshard/core/economics/__init__.py +52 -0
- neuroshard/core/economics/constants.py +387 -0
- neuroshard/core/economics/ledger.py +2111 -0
- neuroshard/core/economics/market.py +975 -0
- neuroshard/core/economics/wallet.py +168 -0
- neuroshard/core/governance/__init__.py +74 -0
- neuroshard/core/governance/proposal.py +561 -0
- neuroshard/core/governance/registry.py +545 -0
- neuroshard/core/governance/versioning.py +332 -0
- neuroshard/core/governance/voting.py +453 -0
- neuroshard/core/model/__init__.py +30 -0
- neuroshard/core/model/dynamic.py +4186 -0
- neuroshard/core/model/llm.py +905 -0
- neuroshard/core/model/registry.py +164 -0
- neuroshard/core/model/scaler.py +387 -0
- neuroshard/core/model/tokenizer.py +568 -0
- neuroshard/core/network/__init__.py +56 -0
- neuroshard/core/network/connection_pool.py +72 -0
- neuroshard/core/network/dht.py +130 -0
- neuroshard/core/network/dht_plan.py +55 -0
- neuroshard/core/network/dht_proof_store.py +516 -0
- neuroshard/core/network/dht_protocol.py +261 -0
- neuroshard/core/network/dht_service.py +506 -0
- neuroshard/core/network/encrypted_channel.py +141 -0
- neuroshard/core/network/nat.py +201 -0
- neuroshard/core/network/nat_traversal.py +695 -0
- neuroshard/core/network/p2p.py +929 -0
- neuroshard/core/network/p2p_data.py +150 -0
- neuroshard/core/swarm/__init__.py +106 -0
- neuroshard/core/swarm/aggregation.py +729 -0
- neuroshard/core/swarm/buffers.py +643 -0
- neuroshard/core/swarm/checkpoint.py +709 -0
- neuroshard/core/swarm/compute.py +624 -0
- neuroshard/core/swarm/diloco.py +844 -0
- neuroshard/core/swarm/factory.py +1288 -0
- neuroshard/core/swarm/heartbeat.py +669 -0
- neuroshard/core/swarm/logger.py +487 -0
- neuroshard/core/swarm/router.py +658 -0
- neuroshard/core/swarm/service.py +640 -0
- neuroshard/core/training/__init__.py +29 -0
- neuroshard/core/training/checkpoint.py +600 -0
- neuroshard/core/training/distributed.py +1602 -0
- neuroshard/core/training/global_tracker.py +617 -0
- neuroshard/core/training/production.py +276 -0
- neuroshard/governance_cli.py +729 -0
- neuroshard/grpc_server.py +895 -0
- neuroshard/runner.py +3223 -0
- neuroshard/sdk/__init__.py +92 -0
- neuroshard/sdk/client.py +990 -0
- neuroshard/sdk/errors.py +101 -0
- neuroshard/sdk/types.py +282 -0
- neuroshard/tracker/__init__.py +0 -0
- neuroshard/tracker/server.py +864 -0
- neuroshard/ui/__init__.py +0 -0
- neuroshard/ui/app.py +102 -0
- neuroshard/ui/templates/index.html +1052 -0
- neuroshard/utils/__init__.py +0 -0
- neuroshard/utils/autostart.py +81 -0
- neuroshard/utils/hardware.py +121 -0
- neuroshard/utils/serialization.py +90 -0
- neuroshard/version.py +1 -0
- nexaroa-0.0.111.dist-info/METADATA +283 -0
- nexaroa-0.0.111.dist-info/RECORD +78 -0
- nexaroa-0.0.111.dist-info/WHEEL +5 -0
- nexaroa-0.0.111.dist-info/entry_points.txt +4 -0
- nexaroa-0.0.111.dist-info/licenses/LICENSE +190 -0
- nexaroa-0.0.111.dist-info/top_level.txt +2 -0
- protos/__init__.py +0 -0
- protos/neuroshard.proto +651 -0
- protos/neuroshard_pb2.py +160 -0
- protos/neuroshard_pb2_grpc.py +1298 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# neuroshard/core/economics/__init__.py
|
|
2
|
+
"""
|
|
3
|
+
Token economics components for NeuroShard.
|
|
4
|
+
|
|
5
|
+
- constants: Token economics constants
|
|
6
|
+
- ledger: NEUROLedger, PoNWProof
|
|
7
|
+
- wallet: Wallet
|
|
8
|
+
- market: InferenceMarket
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
'NEURO_DECIMALS',
|
|
13
|
+
'NEURO_TOTAL_SUPPLY',
|
|
14
|
+
'NEUROLedger',
|
|
15
|
+
'PoNWProof',
|
|
16
|
+
'ProofType',
|
|
17
|
+
'Wallet',
|
|
18
|
+
'InferenceMarket',
|
|
19
|
+
'MIN_STAKE_AMOUNT',
|
|
20
|
+
'MAX_STAKE_AMOUNT',
|
|
21
|
+
'MIN_STAKE_DURATION_DAYS',
|
|
22
|
+
'MAX_STAKE_DURATION_DAYS',
|
|
23
|
+
'calculate_stake_multiplier',
|
|
24
|
+
'is_valid_stake_amount',
|
|
25
|
+
'is_valid_stake_duration',
|
|
26
|
+
'calculate_layer_bonus',
|
|
27
|
+
'calculate_burn_amount',
|
|
28
|
+
'is_eligible_validator',
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
def __getattr__(name):
|
|
32
|
+
"""Lazy loading of submodules."""
|
|
33
|
+
if name in ('NEURO_DECIMALS', 'NEURO_TOTAL_SUPPLY', 'VALIDATOR_MIN_STAKE',
|
|
34
|
+
'VALIDATOR_MIN_MEMORY_MB', 'TRAINING_REWARD_PER_BATCH',
|
|
35
|
+
'DATA_REWARD_PER_SAMPLE', 'INFERENCE_MARKET_TARGET_RESPONSE_TIME',
|
|
36
|
+
'MIN_STAKE_AMOUNT', 'MAX_STAKE_AMOUNT',
|
|
37
|
+
'MIN_STAKE_DURATION_DAYS', 'MAX_STAKE_DURATION_DAYS',
|
|
38
|
+
'calculate_stake_multiplier', 'is_valid_stake_amount',
|
|
39
|
+
'is_valid_stake_duration', 'calculate_layer_bonus',
|
|
40
|
+
'calculate_burn_amount', 'is_eligible_validator'):
|
|
41
|
+
from neuroshard.core.economics import constants
|
|
42
|
+
return getattr(constants, name)
|
|
43
|
+
elif name in ('NEUROLedger', 'PoNWProof', 'ProofType', 'LedgerEntry', 'sign_proof'):
|
|
44
|
+
from neuroshard.core.economics import ledger
|
|
45
|
+
return getattr(ledger, name)
|
|
46
|
+
elif name == 'Wallet':
|
|
47
|
+
from neuroshard.core.economics.wallet import Wallet
|
|
48
|
+
return Wallet
|
|
49
|
+
elif name in ('InferenceMarket', 'RequestStatus'):
|
|
50
|
+
from neuroshard.core.economics import market
|
|
51
|
+
return getattr(market, name)
|
|
52
|
+
raise AttributeError(f"module 'neuroshard.core.economics' has no attribute '{name}'")
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
"""
|
|
2
|
+
NEURO Token Economics - Centralized Configuration
|
|
3
|
+
|
|
4
|
+
This module defines ALL economic constants for the NeuroShard network.
|
|
5
|
+
All values are documented and should be referenced from here, not hardcoded elsewhere.
|
|
6
|
+
|
|
7
|
+
=============================================================================
|
|
8
|
+
DESIGN PRINCIPLES
|
|
9
|
+
=============================================================================
|
|
10
|
+
|
|
11
|
+
1. TRAINING DOMINATES: Training rewards are the highest to incentivize
|
|
12
|
+
actual model improvement over passive participation.
|
|
13
|
+
|
|
14
|
+
2. WORK BEFORE STAKE: Base rewards come from actual work (compute).
|
|
15
|
+
Staking only provides a multiplier, not base rewards.
|
|
16
|
+
|
|
17
|
+
3. DIMINISHING RETURNS: Stake multipliers use logarithmic scaling to
|
|
18
|
+
prevent rich-get-richer dynamics.
|
|
19
|
+
|
|
20
|
+
4. DEFLATIONARY: 5% of all spending is burned, creating scarcity.
|
|
21
|
+
|
|
22
|
+
5. SECURITY: Multiple caps and limits prevent economic attacks.
|
|
23
|
+
|
|
24
|
+
=============================================================================
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
# =============================================================================
|
|
28
|
+
# REWARD RATES
|
|
29
|
+
# =============================================================================
|
|
30
|
+
|
|
31
|
+
# UPTIME REWARD (minimal - discourages idle farming)
|
|
32
|
+
# Goal: Minimal passive income, forces users to train for real rewards
|
|
33
|
+
UPTIME_REWARD_PER_MINUTE = 0.0001 # 0.0001 NEURO per minute
|
|
34
|
+
# ~0.14 NEURO/day idle (80% reduction)
|
|
35
|
+
|
|
36
|
+
# TRAINING REWARD (dominant - this is the core value!)
|
|
37
|
+
# Goal: Strong incentive for active training, covers electricity + profit
|
|
38
|
+
TRAINING_REWARD_PER_BATCH = 0.0005 # 0.0005 NEURO per training batch
|
|
39
|
+
# 60 batches/min = 0.03 NEURO/min = ~43 NEURO/day
|
|
40
|
+
# Training earns 300x more than idle!
|
|
41
|
+
|
|
42
|
+
# DATA SERVING REWARD (for nodes serving training shards)
|
|
43
|
+
DATA_REWARD_PER_SAMPLE = 0.00001 # 0.00001 NEURO per data sample served
|
|
44
|
+
|
|
45
|
+
# INFERENCE REWARD (PURE MARKET-BASED PRICING)
|
|
46
|
+
# Goal: Let supply/demand discover the true price
|
|
47
|
+
# No artificial caps - market determines value based on model quality via demand
|
|
48
|
+
# Quality is implicit: stupid model = no demand = low price, good model = high demand = high price
|
|
49
|
+
|
|
50
|
+
# Dynamic Market Parameters
|
|
51
|
+
INFERENCE_MARKET_PRICE_SMOOTHING = 0.8 # EMA smoothing (higher = smoother price changes)
|
|
52
|
+
INFERENCE_MARKET_CAPACITY_TIMEOUT = 60 # Seconds before stale capacity expires
|
|
53
|
+
INFERENCE_MARKET_TARGET_RESPONSE_TIME = 60 # Target seconds to serve requests
|
|
54
|
+
INFERENCE_MARKET_BASE_PRICE = 0.0001 # Starting price (bootstrap with worthless model)
|
|
55
|
+
|
|
56
|
+
# =============================================================================
|
|
57
|
+
# ROLE DISTRIBUTION (for inference rewards)
|
|
58
|
+
# =============================================================================
|
|
59
|
+
|
|
60
|
+
# Role shares for inference (must sum to 1.0)
|
|
61
|
+
DRIVER_SHARE = 0.15 # 15% - Tokenization, embedding, request routing
|
|
62
|
+
WORKER_SHARE = 0.70 # 70% - Heavy computation (split by layers)
|
|
63
|
+
VALIDATOR_SHARE = 0.15 # 15% - Output projection, loss calc, response
|
|
64
|
+
|
|
65
|
+
# Role bonuses (multipliers on base rewards)
|
|
66
|
+
DRIVER_BONUS = 1.2 # 20% bonus for being entry point
|
|
67
|
+
VALIDATOR_BONUS = 1.3 # 30% bonus for being exit point + proof validation
|
|
68
|
+
WORKER_LAYER_BONUS = 0.05 # 5% bonus per layer held (Increased to incentivize storage)
|
|
69
|
+
MAX_LAYER_BONUS = 1.0 # Cap layer bonus at 100% (Allow full nodes to earn 2x)
|
|
70
|
+
|
|
71
|
+
# Training bonus (extra incentive for training participation)
|
|
72
|
+
TRAINING_BONUS = 1.1 # 10% bonus when actively training (Lowered as base reward covers it)
|
|
73
|
+
|
|
74
|
+
# =============================================================================
|
|
75
|
+
# STAKING ECONOMICS
|
|
76
|
+
# =============================================================================
|
|
77
|
+
|
|
78
|
+
# Stake multiplier formula: 1.0 + STAKING_BASE_BONUS * log2(1 + stake / STAKING_UNIT)
|
|
79
|
+
STAKING_BASE_BONUS = 0.1 # Base 10% bonus coefficient
|
|
80
|
+
STAKING_UNIT = 1000.0 # Staking calculated per 1000 NEURO
|
|
81
|
+
STAKING_DIMINISHING = True # Use logarithmic diminishing returns
|
|
82
|
+
|
|
83
|
+
# Staking limits
|
|
84
|
+
MIN_STAKE_AMOUNT = 1.0 # Minimum stake amount (1 NEURO)
|
|
85
|
+
MAX_STAKE_AMOUNT = 10_000_000.0 # Maximum stake amount (10M NEURO)
|
|
86
|
+
MIN_STAKE_DURATION_DAYS = 1 # Minimum lock period (1 day)
|
|
87
|
+
MAX_STAKE_DURATION_DAYS = 365 # Maximum lock period (1 year)
|
|
88
|
+
|
|
89
|
+
# =============================================================================
|
|
90
|
+
# VALIDATOR REQUIREMENTS (DYNAMIC SCALING)
|
|
91
|
+
# =============================================================================
|
|
92
|
+
|
|
93
|
+
# Base validator stake - used when network is small
|
|
94
|
+
VALIDATOR_BASE_STAKE = 100.0 # Starting minimum (100 NEURO)
|
|
95
|
+
VALIDATOR_MIN_MEMORY_MB = 2000 # Minimum memory for Validator (2GB)
|
|
96
|
+
|
|
97
|
+
# Dynamic stake tiers - scales with network size for security
|
|
98
|
+
# As more validators join, stake requirement increases to maintain security
|
|
99
|
+
VALIDATOR_STAKE_TIERS = [
|
|
100
|
+
# (max_validators, required_stake)
|
|
101
|
+
(2, 0.0), # Bootstrap: 0-2 validators → FREE (network needs to start!)
|
|
102
|
+
(10, 100.0), # Early: 3-10 validators → 100 NEURO
|
|
103
|
+
(50, 250.0), # Growing: 11-50 validators → 250 NEURO
|
|
104
|
+
(200, 500.0), # Established: 51-200 validators → 500 NEURO
|
|
105
|
+
(1000, 1000.0), # Mature: 201-1000 validators → 1,000 NEURO
|
|
106
|
+
(float('inf'), 2500.0), # Large scale: 1000+ validators → 2,500 NEURO
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
# Legacy constant for backward compatibility (uses dynamic function below)
|
|
110
|
+
VALIDATOR_MIN_STAKE = VALIDATOR_BASE_STAKE
|
|
111
|
+
|
|
112
|
+
# Validation rewards
|
|
113
|
+
VALIDATION_FEE_PER_PROOF = 0.001 # 0.001 NEURO per proof validated
|
|
114
|
+
VALIDATION_CONSENSUS_THRESHOLD = 0.66 # 66% stake-weighted agreement required
|
|
115
|
+
|
|
116
|
+
# Validator selection
|
|
117
|
+
VALIDATOR_ROTATION_ENABLED = True # Enable random validator selection
|
|
118
|
+
VALIDATOR_SELECTION_RANDOMNESS = 0.3 # 30% randomness in selection
|
|
119
|
+
|
|
120
|
+
# Remote proof security (limits impact of fake stake claims)
|
|
121
|
+
REMOTE_STAKE_MULTIPLIER_CAP = 1.5 # Max multiplier for remote proofs
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def get_dynamic_validator_stake(num_validators: int) -> float:
|
|
125
|
+
"""
|
|
126
|
+
Get the required validator stake based on current network size.
|
|
127
|
+
|
|
128
|
+
Scales automatically to maintain security as network grows:
|
|
129
|
+
- Few validators: Low barrier (100 NEURO) for accessibility
|
|
130
|
+
- Many validators: Higher barrier (2500 NEURO) for security
|
|
131
|
+
|
|
132
|
+
Args:
|
|
133
|
+
num_validators: Current number of validators in the network
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
Required stake in NEURO
|
|
137
|
+
|
|
138
|
+
Examples:
|
|
139
|
+
>>> get_dynamic_validator_stake(5) # Bootstrap
|
|
140
|
+
100.0
|
|
141
|
+
>>> get_dynamic_validator_stake(30) # Growing
|
|
142
|
+
250.0
|
|
143
|
+
>>> get_dynamic_validator_stake(100) # Established
|
|
144
|
+
500.0
|
|
145
|
+
>>> get_dynamic_validator_stake(500) # Mature
|
|
146
|
+
1000.0
|
|
147
|
+
>>> get_dynamic_validator_stake(2000) # Large scale
|
|
148
|
+
2500.0
|
|
149
|
+
"""
|
|
150
|
+
for max_validators, required_stake in VALIDATOR_STAKE_TIERS:
|
|
151
|
+
if num_validators <= max_validators:
|
|
152
|
+
return required_stake
|
|
153
|
+
|
|
154
|
+
# Fallback to highest tier
|
|
155
|
+
return VALIDATOR_STAKE_TIERS[-1][1]
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def get_validator_stake_info(num_validators: int) -> dict:
|
|
159
|
+
"""
|
|
160
|
+
Get detailed validator stake information for current network state.
|
|
161
|
+
|
|
162
|
+
Returns:
|
|
163
|
+
Dict with current requirement, next tier, and progress info
|
|
164
|
+
"""
|
|
165
|
+
current_stake = get_dynamic_validator_stake(num_validators)
|
|
166
|
+
|
|
167
|
+
# Find current and next tier
|
|
168
|
+
current_tier_idx = 0
|
|
169
|
+
for i, (max_val, stake) in enumerate(VALIDATOR_STAKE_TIERS):
|
|
170
|
+
if num_validators <= max_val:
|
|
171
|
+
current_tier_idx = i
|
|
172
|
+
break
|
|
173
|
+
|
|
174
|
+
# Get next tier info
|
|
175
|
+
next_tier = None
|
|
176
|
+
validators_until_increase = None
|
|
177
|
+
if current_tier_idx < len(VALIDATOR_STAKE_TIERS) - 1:
|
|
178
|
+
current_max = VALIDATOR_STAKE_TIERS[current_tier_idx][0]
|
|
179
|
+
next_stake = VALIDATOR_STAKE_TIERS[current_tier_idx + 1][1]
|
|
180
|
+
validators_until_increase = current_max - num_validators + 1
|
|
181
|
+
next_tier = {
|
|
182
|
+
"stake": next_stake,
|
|
183
|
+
"at_validators": current_max + 1,
|
|
184
|
+
"validators_away": validators_until_increase,
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
"current_stake_required": current_stake,
|
|
189
|
+
"num_validators": num_validators,
|
|
190
|
+
"tier": current_tier_idx + 1,
|
|
191
|
+
"total_tiers": len(VALIDATOR_STAKE_TIERS),
|
|
192
|
+
"next_tier": next_tier,
|
|
193
|
+
"tiers": [
|
|
194
|
+
{"max_validators": max_v if max_v != float('inf') else "unlimited", "stake": s}
|
|
195
|
+
for max_v, s in VALIDATOR_STAKE_TIERS
|
|
196
|
+
],
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
# =============================================================================
|
|
200
|
+
# FEE BURN (Deflationary Mechanism)
|
|
201
|
+
# =============================================================================
|
|
202
|
+
|
|
203
|
+
FEE_BURN_RATE = 0.05 # 5% of spending fees are burned
|
|
204
|
+
BURN_ADDRESS = "BURN_0x0000000000000000000000000000000000000000"
|
|
205
|
+
|
|
206
|
+
# =============================================================================
|
|
207
|
+
# ANTI-CHEAT LIMITS
|
|
208
|
+
# =============================================================================
|
|
209
|
+
|
|
210
|
+
MAX_UPTIME_PER_PROOF = 120 # Max 2 minutes per proof (prevents inflation)
|
|
211
|
+
MAX_TOKENS_PER_MINUTE = 1_000_000 # Max 1M tokens/minute (modern GPUs can do this)
|
|
212
|
+
MAX_PROOFS_PER_HOUR = 120 # Max 2 proofs per minute sustained
|
|
213
|
+
PROOF_FRESHNESS_WINDOW = 300 # Proofs valid for 5 minutes
|
|
214
|
+
|
|
215
|
+
# =============================================================================
|
|
216
|
+
# SLASHING
|
|
217
|
+
# =============================================================================
|
|
218
|
+
|
|
219
|
+
SLASH_AMOUNT = 10.0 # NEURO slashed for fraud
|
|
220
|
+
WHISTLEBLOWER_REWARD_RATE = 0.5 # 50% of slash goes to reporter
|
|
221
|
+
VALIDATOR_SLASH_MULTIPLIER = 2.0 # Validators slashed 2x for bad validation
|
|
222
|
+
|
|
223
|
+
# =============================================================================
|
|
224
|
+
# SUPPLY LIMITS
|
|
225
|
+
# =============================================================================
|
|
226
|
+
|
|
227
|
+
# There is NO hard cap on total supply - NEURO is minted through PoNW
|
|
228
|
+
# However, deflationary mechanics (burn) and diminishing rewards create scarcity
|
|
229
|
+
MAX_REWARD_PER_PROOF = 100.0 # Cap on single proof reward (sanity check)
|
|
230
|
+
MAX_DAILY_MINT_PER_NODE = 10_000.0 # Cap on daily minting per node
|
|
231
|
+
|
|
232
|
+
# =============================================================================
|
|
233
|
+
# GENESIS
|
|
234
|
+
# =============================================================================
|
|
235
|
+
|
|
236
|
+
GENESIS_SUPPLY = 0.0 # Zero pre-mine - all NEURO is earned
|
|
237
|
+
GENESIS_SIGNATURE = "GENESIS_BLOCK"
|
|
238
|
+
|
|
239
|
+
# =============================================================================
|
|
240
|
+
# HELPER FUNCTIONS
|
|
241
|
+
# =============================================================================
|
|
242
|
+
|
|
243
|
+
import math
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def calculate_stake_multiplier(stake: float) -> float:
|
|
247
|
+
"""
|
|
248
|
+
Calculate stake multiplier with diminishing returns.
|
|
249
|
+
|
|
250
|
+
Formula: 1.0 + STAKING_BASE_BONUS * log2(1 + stake / STAKING_UNIT)
|
|
251
|
+
|
|
252
|
+
Examples:
|
|
253
|
+
- 0 NEURO = 1.00x
|
|
254
|
+
- 1,000 NEURO = 1.10x
|
|
255
|
+
- 2,000 NEURO = 1.16x
|
|
256
|
+
- 10,000 NEURO = 1.35x
|
|
257
|
+
- 100,000 NEURO = 1.66x
|
|
258
|
+
"""
|
|
259
|
+
if stake <= 0:
|
|
260
|
+
return 1.0
|
|
261
|
+
|
|
262
|
+
if STAKING_DIMINISHING:
|
|
263
|
+
return 1.0 + STAKING_BASE_BONUS * math.log2(1 + stake / STAKING_UNIT)
|
|
264
|
+
else:
|
|
265
|
+
# Linear (legacy)
|
|
266
|
+
return 1.0 + (STAKING_BASE_BONUS * (stake / STAKING_UNIT))
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
def calculate_layer_bonus(layers_held: int) -> float:
|
|
270
|
+
"""
|
|
271
|
+
Calculate layer bonus for workers.
|
|
272
|
+
|
|
273
|
+
Formula: min(MAX_LAYER_BONUS, layers_held * WORKER_LAYER_BONUS)
|
|
274
|
+
"""
|
|
275
|
+
return min(MAX_LAYER_BONUS, layers_held * WORKER_LAYER_BONUS)
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
def calculate_burn_amount(spend_amount: float) -> float:
|
|
279
|
+
"""Calculate the burn amount for a transaction."""
|
|
280
|
+
return spend_amount * FEE_BURN_RATE
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
def is_valid_stake_amount(amount: float) -> tuple:
|
|
284
|
+
"""
|
|
285
|
+
Validate a stake amount.
|
|
286
|
+
|
|
287
|
+
Returns: (is_valid, error_message)
|
|
288
|
+
"""
|
|
289
|
+
if amount < MIN_STAKE_AMOUNT:
|
|
290
|
+
return False, f"Minimum stake is {MIN_STAKE_AMOUNT} NEURO"
|
|
291
|
+
if amount > MAX_STAKE_AMOUNT:
|
|
292
|
+
return False, f"Maximum stake is {MAX_STAKE_AMOUNT:,.0f} NEURO"
|
|
293
|
+
return True, ""
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def is_valid_stake_duration(days: int) -> tuple:
|
|
297
|
+
"""
|
|
298
|
+
Validate a stake duration.
|
|
299
|
+
|
|
300
|
+
Returns: (is_valid, error_message)
|
|
301
|
+
"""
|
|
302
|
+
if days < MIN_STAKE_DURATION_DAYS:
|
|
303
|
+
return False, f"Minimum lock period is {MIN_STAKE_DURATION_DAYS} day(s)"
|
|
304
|
+
if days > MAX_STAKE_DURATION_DAYS:
|
|
305
|
+
return False, f"Maximum lock period is {MAX_STAKE_DURATION_DAYS} days"
|
|
306
|
+
return True, ""
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
def is_eligible_validator(
|
|
310
|
+
stake: float,
|
|
311
|
+
memory_mb: float = None,
|
|
312
|
+
num_validators: int = 0
|
|
313
|
+
) -> tuple:
|
|
314
|
+
"""
|
|
315
|
+
Check if a node is eligible to be a validator.
|
|
316
|
+
|
|
317
|
+
Uses DYNAMIC stake requirement based on network size:
|
|
318
|
+
- Few validators (1-10): 100 NEURO
|
|
319
|
+
- Growing (11-50): 250 NEURO
|
|
320
|
+
- Established (51-200): 500 NEURO
|
|
321
|
+
- Mature (201-1000): 1,000 NEURO
|
|
322
|
+
- Large scale (1000+): 2,500 NEURO
|
|
323
|
+
|
|
324
|
+
Args:
|
|
325
|
+
stake: Amount of NEURO staked
|
|
326
|
+
memory_mb: Available memory in MB
|
|
327
|
+
num_validators: Current number of validators in network (for dynamic scaling)
|
|
328
|
+
|
|
329
|
+
Returns: (is_eligible, reason)
|
|
330
|
+
"""
|
|
331
|
+
# Get dynamic stake requirement
|
|
332
|
+
required_stake = get_dynamic_validator_stake(num_validators)
|
|
333
|
+
|
|
334
|
+
if stake < required_stake:
|
|
335
|
+
return False, f"Insufficient stake: {stake:.2f} < {required_stake:.0f} NEURO (current network requires {required_stake:.0f} with {num_validators} validators)"
|
|
336
|
+
|
|
337
|
+
if memory_mb is not None and memory_mb < VALIDATOR_MIN_MEMORY_MB:
|
|
338
|
+
return False, f"Insufficient memory: {memory_mb:.0f}MB < {VALIDATOR_MIN_MEMORY_MB}MB"
|
|
339
|
+
|
|
340
|
+
return True, f"Eligible with {stake:.2f} NEURO staked (requirement: {required_stake:.0f} NEURO)"
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
# =============================================================================
|
|
344
|
+
# SUMMARY TABLE (for reference)
|
|
345
|
+
# =============================================================================
|
|
346
|
+
"""
|
|
347
|
+
╔═══════════════════════════════════════════════════════════════════════════════╗
|
|
348
|
+
║ NEURO ECONOMICS SUMMARY (v2) ║
|
|
349
|
+
╠═══════════════════════════════════════════════════════════════════════════════╣
|
|
350
|
+
║ EARNING NEURO ║
|
|
351
|
+
╠═══════════════════════════════════════════════════════════════════════════════╣
|
|
352
|
+
║ Activity │ Rate │ Daily (Active) ║
|
|
353
|
+
║───────────────────┼─────────────────────────┼──────────────────────────────────║
|
|
354
|
+
║ Training │ 0.0005 NEURO/batch │ ~43 NEURO (60 batch/min) ║
|
|
355
|
+
║ Inference │ DYNAMIC (0.01-1.0) │ Market-based (supply/demand) ║
|
|
356
|
+
║ Data Serving │ 0.00001 NEURO/sample │ Variable ║
|
|
357
|
+
║ Uptime (idle) │ 0.0001 NEURO/min │ ~0.14 NEURO ║
|
|
358
|
+
╠═══════════════════════════════════════════════════════════════════════════════╣
|
|
359
|
+
║ REALISTIC DAILY EARNINGS (with bonuses) ║
|
|
360
|
+
╠═══════════════════════════════════════════════════════════════════════════════╣
|
|
361
|
+
║ Idle node │ ~0.14 NEURO/day │ Just uptime (unprofitable) ║
|
|
362
|
+
║ Light training │ ~10-20 NEURO/day │ Few hours active (Raspberry Pi) ║
|
|
363
|
+
║ Active trainer │ ~40-60 NEURO/day │ 24/7 training (Gaming PC) ║
|
|
364
|
+
║ Power user │ ~200-350 NEURO/day │ 24/7 + GPU + staking (Server) ║
|
|
365
|
+
╠═══════════════════════════════════════════════════════════════════════════════╣
|
|
366
|
+
║ MULTIPLIERS ║
|
|
367
|
+
╠═══════════════════════════════════════════════════════════════════════════════╣
|
|
368
|
+
║ Staking │ log2(1 + stake/1000) │ 1.10x @ 1K, 1.66x @ 100K ║
|
|
369
|
+
║ Training Bonus │ +10% │ When actively training ║
|
|
370
|
+
║ Driver Bonus │ +20% │ Holding Layer 0 ║
|
|
371
|
+
║ Validator Bonus │ +30% │ Holding Last Layer + 100 stake ║
|
|
372
|
+
║ Layer Bonus │ +5% per layer │ Max 100% ║
|
|
373
|
+
╠═══════════════════════════════════════════════════════════════════════════════╣
|
|
374
|
+
║ REQUIREMENTS ║
|
|
375
|
+
╠═══════════════════════════════════════════════════════════════════════════════╣
|
|
376
|
+
║ Validator │ 100 NEURO stake │ + 2GB memory ║
|
|
377
|
+
║ Stake Min/Max │ 1 / 10,000,000 NEURO │ ║
|
|
378
|
+
║ Lock Period │ 1 - 365 days │ ║
|
|
379
|
+
╠═══════════════════════════════════════════════════════════════════════════════╣
|
|
380
|
+
║ FEES & BURNS ║
|
|
381
|
+
╠═══════════════════════════════════════════════════════════════════════════════╣
|
|
382
|
+
║ Transaction Fee │ 5% burned │ Deflationary ║
|
|
383
|
+
║ Fraud Slash │ 10 NEURO │ 50% to reporter, 50% burned ║
|
|
384
|
+
║ Validator Slash │ 20 NEURO (2x) │ 100% burned ║
|
|
385
|
+
╚═══════════════════════════════════════════════════════════════════════════════╝
|
|
386
|
+
"""
|
|
387
|
+
|