Commit 677c3f5
committed
feat: wall clock timestamps, committee BFT, emission fix, duplicate node fix
Emission fix (lazy_rewards.rs, node.rs):
- Add sentinel guard in calculate_years_since_genesis: genesis_timestamp==0 returns 0
Prevents 56-year miscalculation causing 14 halvings and 3 QNC instead of 251k QNC
- Add update_genesis_timestamp() method to PhaseAwareRewardManager
- Call update_genesis_timestamp at 4 critical points: genesis creation, network sync,
P2P receive, and storage load on restart
Committee-based BFT (block.rs, node.rs):
- Add consensus_committee field Option<Vec<String>> to ConsensusData struct with serde default
- Implement select_consensus_committee() using SHA3 VRF seeded from MacroBlock N-2 randomness_beacon
- CONSENSUS_COMMITTEE_SIZE=100, COMMITTEE_THRESHOLD=120
- trigger_macroblock_consensus: subsample committee when total validators exceed threshold
- start_macroblock_consensus_listener: non-committee validators skip BFT and receive MB via sync
- Emergency macroblocks bypass committee (consensus_committee=None)
- Scales MacroBlock BFT from O(n^2) to O(1) for networks up to 1000+ validators
Wall clock timestamps (node.rs):
- Replace slot-based timestamps (genesis_ts + height * 1s) with SystemTime::now()
Old approach accumulated 20min drift per 8h, compounding to days and months over time
- MicroBlock: timestamp = max(now(), parent.timestamp + 1) guarantees strict monotonicity
- Emergency MacroBlock: timestamp = now() with defensive genesis existence guard
- Consensus MacroBlock: timestamp = now()
- Validation updated to Ethereum-style rules only: future (<=now+15s) and monotonicity (>parent.ts)
- Remove slot-based past check to ensure rolling update compatibility across mixed-version networks
- TIMESTAMP_FUTURE_TOLERANCE raised from 5s to 15s matching Ethereum standard
- Explorer will now show correct relative times for all new transactions
Duplicate node registration fix (node.rs):
- Prevent same wallet address from registering a Light or Super node more than once on-chain
Made-with: Cursor1 parent 2acc8c1 commit 677c3f5
3 files changed
Lines changed: 227 additions & 172 deletions
File tree
- core
- qnet-consensus/src
- qnet-state/src
- development/qnet-integration/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
274 | 281 | | |
275 | 282 | | |
276 | 283 | | |
277 | 284 | | |
278 | 285 | | |
279 | 286 | | |
280 | | - | |
| 287 | + | |
281 | 288 | | |
282 | 289 | | |
283 | 290 | | |
| |||
576 | 583 | | |
577 | 584 | | |
578 | 585 | | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
579 | 596 | | |
580 | 597 | | |
581 | 598 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
222 | 234 | | |
223 | 235 | | |
224 | 236 | | |
| |||
0 commit comments