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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
//! TruthLinked Constants - All system-wide configuration values
use MAX_GAS_PER_TX;
// ========== NETWORK PARAMETERS ==========
/// Ingress server port (client transaction submission)
pub const INGRESS_PORT: u16 = 18080;
/// ACK server port (validator attestations)
pub const ACK_SERVER_PORT: u16 = 18081;
/// RPC server port (HTTP API)
pub const RPC_PORT: u16 = 19944;
// ========== STAKING PARAMETERS ==========
/// Number of blocks after which a committed-but-unrevealed oracle request expires (slash window)
/// At 200ms/block: 7200 blocks = ~24 min. Validators have that long to reveal after commit quorum.
pub const ORACLE_REVEAL_DEADLINE_BLOCKS: u64 = 7200;
// ========== TIME VALIDATION PARAMETERS ==========
/// Max future timestamp drift for batch headers (5 minutes)
pub const BATCH_MAX_FUTURE_DRIFT: u64 = 300;
/// Max past age for batch headers (1 hour)
pub const BATCH_MAX_PAST_AGE: u64 = 3600;
/// Max future timestamp drift for snapshots (1 minute)
pub const SNAPSHOT_MAX_FUTURE_DRIFT: u64 = 60;
/// Max past age for snapshots (30 minutes)
pub const SNAPSHOT_MAX_PAST_AGE: u64 = 1800;
// ========== ACK SERVER PARAMETERS ==========
// ========== TOKEN PARAMETERS ==========
/// Token name
pub const TOKEN_NAME: &str = "TruthLinked";
/// Token symbol
pub const TOKEN_SYMBOL: &str = "TLKD";
/// Smallest unit name
pub const TOKEN_SUBUNIT: &str = "xiom";
/// Token decimals
pub const TOKEN_DECIMALS: u8 = 9;
/// Total supply (1 billion TLKD)
pub const TOTAL_SUPPLY: u128 = 1_000_000_000_000_000_000;
/// Maximum total devnet faucet mint allowance (100 million TLKD).
pub const MAX_TESTNET_MINT: u128 = 100_000_000 * ONE_TRTH;
// ========== STORAGE PARAMETERS ==========
/// Maximum blockchain headers kept in memory (~10KB each with Dilithium sigs)
pub const MAX_HEADER_HISTORY: u64 = 2_000;
/// Maximum snapshots kept on disk
pub const MAX_SNAPSHOTS_KEPT: usize = 10;
/// executed_tx_hashes cap and keep-after-prune
pub const MAX_EXECUTED_TX_HASHES: usize = 100_000;
pub const KEEP_EXECUTED_TX_HASHES: usize = 80_000;
/// pending_batches hard cap in streaming consensus
pub const MAX_PENDING_BATCHES: usize = 64;
/// State collection caps (pruned end-of-block)
pub const MAX_AIRDROP_CLAIMS: usize = 50_000;
pub const MAX_PENDING_NAMES: usize = 1_000;
pub const MAX_TOKEN_AUTHORITY_PROPOSALS: usize = 256;
pub const MAX_URL_PROPOSALS: usize = 256;
pub const MAX_SCHEMA_PROPOSALS: usize = 256;
pub const MAX_ORACLE_RESULTS: usize = 1_000;
pub const MAX_NAME_REGISTRY: usize = 100_000;
pub const MAX_SCHEMA_REGISTRY: usize = 10_000;
/// AttestationPipeline early buffer cap
pub const MAX_EARLY_ATTESTATION_BUFFER: usize = 64;
/// SyncManager peer_heights hard cap
pub const MAX_SYNC_PEER_HEIGHTS: usize = 256;
// ========== CRYPTOGRAPHIC CONTEXTS ==========
/// Signing context for batch headers
pub const BATCH_SIGN_CONTEXT: & = b"truthlinked-batch-v1";
/// Signing context for attestations
pub const ATTESTATION_CONTEXT: & = b"truthlinked-attestation-v1";
pub const STREAM_TX_CONTEXT: & = b"truthlinked-streamed-tx-v1";
/// Signing context for snapshots
pub const SNAPSHOT_SIGN_CONTEXT: & = b"truthlinked-snapshot-v1";
// ========== VM PARAMETERS ==========
/// Maximum recursion depth in cell VM
pub const MAX_RECURSION_DEPTH: u32 = 256;
/// Maximum compute units per cell execution (same as max gas per tx)
pub const MAX_COMPUTE_UNITS: u64 = MAX_GAS_PER_TX;
/// Maximum loop iterations per loop
pub const MAX_LOOP_ITERATIONS: u64 = 10_000;
/// Maximum loop nesting depth
pub const MAX_LOOP_DEPTH: u32 = 10;
// ========== COMPUTE UNIT COSTS ==========
/// Base cost per opcode
pub const CU_BASE: u64 = 100;
/// State write operation
pub const CU_SET_FIELD: u64 = 1_000;
/// State read operation
pub const CU_GET_FIELD: u64 = 500;
/// State delete operation
pub const CU_DELETE_FIELD: u64 = 1_000;
/// Addition operation
pub const CU_ADD: u64 = 200;
/// Subtraction operation
pub const CU_SUB: u64 = 200;
/// Multiplication operation
pub const CU_MUL: u64 = 300;
/// Division operation
pub const CU_DIV: u64 = 400;
/// Comparison operations
pub const CU_COMPARE: u64 = 150;
/// If statement
pub const CU_IF: u64 = 200;
/// Loop initialization
pub const CU_LOOP: u64 = 500;
/// Stack operations
pub const CU_STACK: u64 = 50;
/// Emit log/event
pub const CU_EMIT_LOG: u64 = 1_000;
/// System context access
pub const CU_SYSTEM_CONTEXT: u64 = 50;
/// Hashing operations
pub const CU_BLAKE3: u64 = 500;
pub const CU_SHA256: u64 = 500;
// ========== DETERMINISTIC GAS METERING ==========
/// This ensures all validators compute the same gas cost regardless of Wasmer version
/// Bitwise operations
pub const CU_BITWISE: u64 = 100;
/// Bytes operations
pub const CU_BYTES: u64 = 100;
/// Storage iteration
pub const CU_STORAGE_ITER: u64 = 1_000;
/// Cell calls
pub const CU_CALL: u64 = 10_000;
pub const CU_STATIC_CALL: u64 = 5_000;
/// Dilithium signature verification (FREE - subsidized by chain)
pub const CU_DILITHIUM_VERIFY: u64 = 0;
/// Owner check
pub const CU_REQUIRE_OWNER: u64 = 100;
// staking lock parameters (blocks)
// 1 month to 4 years, based on 200ms block time.
pub const STAKED_TRTH_MIN_LOCK_BLOCKS: u64 = 30 * 432_000;
pub const STAKED_TRTH_MAX_LOCK_BLOCKS: u64 = 4 * 365 * 432_000;
// ========== EMISSION PARAMETERS ==========
/// Blocks per year at 300ms block time (365.25 days × 24h × 3600s / 0.3s)
pub const BLOCKS_PER_YEAR: u64 = 105_120_000;
/// Year-1 treasury emission in whole TLKD (multiply by ONE_TRTH for xiom)
pub const EMISSION_YEAR1_TRTH: u128 = 25_000_000;
/// Annual emission decay in basis points (2000 = 20%)
pub const EMISSION_DECAY_BPS_PER_YEAR: u64 = 2_000;
/// Emission epoch length in blocks (~1 day at 300ms/block)
pub const EMISSION_EPOCH_BLOCKS: u64 = 432_000;
// ========== FEE SPLIT PARAMETERS (basis points) ==========
/// Validators share of protocol fee revenue (60%)
pub const FEE_SPLIT_VALIDATORS_BPS: u128 = 6_000;
/// Stakers share of protocol fee revenue (20%)
pub const FEE_SPLIT_STAKERS_BPS: u128 = 2_000;
/// Burn share of protocol fee revenue (20%)
pub const FEE_SPLIT_BURN_BPS: u128 = 2_000;
// ========== SECURITY PARAMETERS ==========
/// Storage cost per byte (compute units)
pub const CU_STORAGE_PER_BYTE: u64 = 10;
/// Canonical storage key width for cell storage host ABI.
pub const STORAGE_KEY_BYTES: usize = 32;
/// Canonical storage value width for cell storage host ABI.
pub const STORAGE_VALUE_BYTES: usize = 32;
// ========== SNAPSHOT VALIDATION LIMITS ==========
/// Max signatures accepted in a snapshot payload.
pub const SNAPSHOT_MAX_SIGNATURES: usize = 1_000;
// ========== ANSI COLOR CODES ==========
pub const ANSI_RESET: &str = "\x1b[0m";
pub const ANSI_GREEN: &str = "\x1b[32m";
pub const ANSI_RED: &str = "\x1b[31m";
pub const ANSI_YELLOW: &str = "\x1b[33m";
pub const ANSI_CYAN: &str = "\x1b[36m";
pub const ANSI_BOLD: &str = "\x1b[1m";
pub const ANSI_DIM: &str = "\x1b[2m";