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
//! Chain constants and parameters for Tenzro Network
//!
//! This module defines immutable constants that govern the behavior
//! of the Tenzro Network blockchain.
/// The native token symbol
pub const TOKEN_SYMBOL: &str = "TNZO";
/// The native token name
pub const TOKEN_NAME: &str = "Tenzro Network Token";
/// Number of decimal places for TNZO token
pub const TOKEN_DECIMALS: u8 = 18;
/// Total supply of TNZO tokens (1 billion with 18 decimals)
pub const TOKEN_TOTAL_SUPPLY: u128 = 1_000_000_000 * 10u128.pow;
/// Mainnet chain ID
pub const MAINNET_CHAIN_ID: u64 = 1;
/// Testnet chain ID
pub const TESTNET_CHAIN_ID: u64 = 1337;
/// Maximum block size in bytes (1 MB)
pub const MAX_BLOCK_SIZE: u64 = 1024 * 1024;
/// Target block time in milliseconds (2 seconds)
pub const BLOCK_TIME_MS: u64 = 2000;
/// Maximum transactions per block
pub const MAX_TRANSACTIONS_PER_BLOCK: u32 = 1000;
/// Minimum gas price in smallest TNZO unit
pub const MIN_GAS_PRICE: u64 = 1;
/// Maximum gas per block
pub const MAX_GAS_PER_BLOCK: u64 = 30_000_000;
/// Maximum gas per transaction
pub const MAX_GAS_PER_TRANSACTION: u64 = 10_000_000;
/// Base transaction gas cost
pub const BASE_TRANSACTION_GAS: u64 = 21_000;
/// Gas cost per byte of transaction data
pub const GAS_PER_BYTE: u64 = 68;
/// Minimum stake required to become a validator (10,000 TNZO)
pub const MIN_VALIDATOR_STAKE: u128 = 10_000 * 10u128.pow;
/// Minimum stake required for TEE providers (1,000 TNZO)
pub const MIN_TEE_PROVIDER_STAKE: u128 = 1_000 * 10u128.pow;
/// Minimum stake required for model providers (500 TNZO)
pub const MIN_MODEL_PROVIDER_STAKE: u128 = 500 * 10u128.pow;
/// Minimum stake required for storage providers (500 TNZO)
pub const MIN_STORAGE_PROVIDER_STAKE: u128 = 500 * 10u128.pow;
/// Staking reward rate (basis points per year) - 5%
pub const STAKING_REWARD_RATE_BPS: u32 = 500;
/// Transaction fee (basis points) - 0.1%
pub const TRANSACTION_FEE_BPS: u32 = 10;
/// Fee burn rate (basis points) - 50% of fees are burned
pub const FEE_BURN_RATE_BPS: u32 = 5000;
/// Inflation rate (basis points per year) - 2%
pub const INFLATION_RATE_BPS: u32 = 200;
/// Maximum validators in the active set
pub const MAX_VALIDATORS: u32 = 100;
/// Unstaking period in milliseconds (7 days)
pub const UNSTAKING_PERIOD_MS: i64 = 7 * 24 * 60 * 60 * 1000;
/// Governance proposal voting period in milliseconds (7 days)
pub const GOVERNANCE_VOTING_PERIOD_MS: i64 = 7 * 24 * 60 * 60 * 1000;
/// Governance proposal minimum threshold (10,000 TNZO)
pub const GOVERNANCE_PROPOSAL_THRESHOLD: u128 = 10_000 * 10u128.pow;
/// Governance quorum requirement (basis points) - 20%
pub const GOVERNANCE_QUORUM_BPS: u32 = 2000;
/// Governance approval threshold (basis points) - 50%
pub const GOVERNANCE_APPROVAL_THRESHOLD_BPS: u32 = 5000;
/// Maximum treasury grant amount (1,000,000 TNZO)
pub const MAX_TREASURY_GRANT: u128 = 1_000_000 * 10u128.pow;
/// Address length in bytes
pub const ADDRESS_LENGTH: usize = 32;
/// Hash length in bytes
pub const HASH_LENGTH: usize = 32;
/// Maximum memo size in bytes
pub const MAX_MEMO_SIZE: usize = 256;
/// Maximum contract code size in bytes (1 MB)
pub const MAX_CONTRACT_CODE_SIZE: usize = 1024 * 1024;
/// Maximum storage size per account (100 MB)
pub const MAX_STORAGE_SIZE_PER_ACCOUNT: u64 = 100 * 1024 * 1024;
/// Bridge minimum transfer amount (10 TNZO)
pub const BRIDGE_MIN_TRANSFER: u128 = 10 * 10u128.pow;
/// Bridge fee (basis points) - 0.5%
pub const BRIDGE_FEE_BPS: u32 = 50;
/// Bridge confirmation blocks required
pub const BRIDGE_CONFIRMATION_BLOCKS: u32 = 12;
/// Challenge period for optimistic bridges (1 day)
pub const BRIDGE_CHALLENGE_PERIOD_MS: i64 = 24 * 60 * 60 * 1000;
/// Maximum agent execution time in milliseconds (60 seconds)
pub const MAX_AGENT_EXECUTION_TIME_MS: u64 = 60_000;
/// Maximum agent memory in bytes (1 GB)
pub const MAX_AGENT_MEMORY_BYTES: u64 = 1024 * 1024 * 1024;
/// Maximum agent API calls per execution
pub const MAX_AGENT_API_CALLS: u32 = 100;
/// Maximum model context window (tokens)
pub const MAX_MODEL_CONTEXT_WINDOW: u32 = 128_000;
/// Maximum model output tokens
pub const MAX_MODEL_OUTPUT_TOKENS: u32 = 4_096;
/// Default model inference timeout in milliseconds (5 minutes)
pub const DEFAULT_INFERENCE_TIMEOUT_MS: u64 = 5 * 60 * 1000;
/// TEE attestation validity period in milliseconds (30 days)
pub const TEE_ATTESTATION_VALIDITY_MS: i64 = 30 * 24 * 60 * 60 * 1000;
/// Settlement timeout in milliseconds (1 hour)
pub const SETTLEMENT_TIMEOUT_MS: i64 = 60 * 60 * 1000;
/// Maximum peer connections
pub const MAX_PEER_CONNECTIONS: u32 = 75;
/// Peer reputation decay interval in milliseconds (1 day)
pub const PEER_REPUTATION_DECAY_INTERVAL_MS: i64 = 24 * 60 * 60 * 1000;
/// Protocol version
pub const PROTOCOL_VERSION: u32 = 1;
/// Network magic bytes for mainnet
pub const MAINNET_MAGIC: = ; // "TNZO"
/// Network magic bytes for testnet
pub const TESTNET_MAGIC: = ; // "TTZO"
/// Genesis block timestamp (placeholder - should be set to actual launch)
pub const GENESIS_TIMESTAMP: i64 = 1700000000000; // Nov 14, 2023 22:13:20 GMT
/// Blocks per epoch (for reward distribution)
pub const BLOCKS_PER_EPOCH: u64 = 43200; // Approximately 1 day at 2s block time
/// Slash percentage for double signing (basis points) - 10%
pub const DOUBLE_SIGN_SLASH_BPS: u32 = 1000;
/// Slash percentage for downtime (basis points) - 0.1%
pub const DOWNTIME_SLASH_BPS: u32 = 10;
/// Maximum downtime before slashing (blocks)
pub const MAX_DOWNTIME_BLOCKS: u64 = 720; // 24 minutes at 2s block time
// ---------------------------------------------------------------------------
// Deserialization bounds (for HIGH #69 — protect against OOM via untrusted
// vectors received over RPC, P2P, or storage formats)
// ---------------------------------------------------------------------------
/// Maximum number of transactions accepted in a single deserialized block
pub const MAX_DESERIALIZED_TX_COUNT: usize = MAX_TRANSACTIONS_PER_BLOCK as usize;
/// Maximum length of a deserialized signature byte vector
pub const MAX_SIGNATURE_BYTES: usize = 256;
/// Maximum length of a deserialized public key byte vector
pub const MAX_PUBLIC_KEY_BYTES: usize = 256;
/// Maximum number of validator entries in a deserialized validator set
pub const MAX_DESERIALIZED_VALIDATOR_COUNT: usize = MAX_VALIDATORS as usize * 4;
/// Maximum number of peers in a deserialized peer list
pub const MAX_DESERIALIZED_PEER_COUNT: usize = MAX_PEER_CONNECTIONS as usize * 4;
/// Maximum number of bytes in a single deserialized vector field of unknown content
pub const MAX_DESERIALIZED_BYTES: usize = 16 * 1024 * 1024; // 16 MB
/// Maximum length of a deserialized free-form string (URLs, names, descriptions)
pub const MAX_DESERIALIZED_STRING_LEN: usize = 64 * 1024;
// ---------------------------------------------------------------------------
// Chain ID validation
// ---------------------------------------------------------------------------
/// Minimum allowed chain ID (0 is reserved/invalid)
pub const CHAIN_ID_MIN: u64 = 1;
/// Maximum allowed chain ID — matches EIP-2294 recommendation
/// (`floor(MAX_UINT64 / 2) - 36`) to avoid overflow when combined with EIP-155.
pub const CHAIN_ID_MAX: u64 = - 36;