Commit b936347
committed
fix: Critical P2P last_seen bug and reputation system improvements
CRITICAL FIX - LAST_SEEN BUG:
- Fixed root cause: update_peer_last_seen() now handles both peer ID and address
- Added support for 'genesis_node_003' format (was only accepting '161.97.86.81:8001')
- Uses dual indexing (peer_id_to_addr) for O(1) lookup
- Updates timestamp on ALL message types (blocks, txs, pings, consensus)
- Resolves '55.7 years ago' bug that caused network chaos after 12+ hours
REPUTATION SYSTEM FIXES:
- API now returns actual reputation values instead of hardcoded 90.0
- Proper conversion between P2P (0-100) and consensus (0.0-1.0) scales
- All rewards/penalties now properly applied:
* Success: +1.0 per block
* Failure: -2.0 for missed blocks
* Emergency: +5.0 for taking over
* Macroblock fail: -30.0 for failed leader
* Recovery: +1%/hour to 70% baseline
EMERGENCY FAILOVER FIX:
- Uses actual peer.id instead of generating random node_5130b3c4 format
- Proper Genesis node IDs (genesis_node_001-005) in emergency selection
LOGGING IMPROVEMENTS:
- Added [MACROBLOCK] prefix to all macroblock consensus logs
- Clear distinction between microblock and macroblock operations
- Emergency operations marked with [MACROBLOCK] EMERGENCY
PEER COUNT FIX:
- Genesis nodes now correctly report validated_peers.len() as peer count
- Resolves API showing 'connected_peers: 0' but 'validated_peers: 4'
This fixes the critical network stability issue where nodes would consider each other offline after running for 12+ hours, causing constant emergency failovers and desynchronization.1 parent 715ae27 commit b936347
4 files changed
Lines changed: 113 additions & 28 deletions
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1453 | 1453 | | |
1454 | 1454 | | |
1455 | 1455 | | |
1456 | | - | |
| 1456 | + | |
1457 | 1457 | | |
1458 | 1458 | | |
1459 | 1459 | | |
| |||
1833 | 1833 | | |
1834 | 1834 | | |
1835 | 1835 | | |
1836 | | - | |
| 1836 | + | |
1837 | 1837 | | |
1838 | 1838 | | |
1839 | 1839 | | |
1840 | 1840 | | |
1841 | 1841 | | |
1842 | 1842 | | |
1843 | | - | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
1844 | 1850 | | |
1845 | | - | |
1846 | | - | |
1847 | | - | |
1848 | | - | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
1849 | 1858 | | |
1850 | 1859 | | |
1851 | | - | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
1852 | 1866 | | |
1853 | | - | |
| 1867 | + | |
1854 | 1868 | | |
1855 | 1869 | | |
1856 | 1870 | | |
| |||
2008 | 2022 | | |
2009 | 2023 | | |
2010 | 2024 | | |
2011 | | - | |
| 2025 | + | |
2012 | 2026 | | |
2013 | 2027 | | |
2014 | 2028 | | |
| |||
2523 | 2537 | | |
2524 | 2538 | | |
2525 | 2539 | | |
2526 | | - | |
| 2540 | + | |
2527 | 2541 | | |
2528 | 2542 | | |
2529 | 2543 | | |
| |||
2557 | 2571 | | |
2558 | 2572 | | |
2559 | 2573 | | |
2560 | | - | |
2561 | | - | |
| 2574 | + | |
| 2575 | + | |
2562 | 2576 | | |
2563 | 2577 | | |
2564 | 2578 | | |
| |||
4253 | 4267 | | |
4254 | 4268 | | |
4255 | 4269 | | |
4256 | | - | |
4257 | | - | |
| 4270 | + | |
| 4271 | + | |
| 4272 | + | |
| 4273 | + | |
| 4274 | + | |
| 4275 | + | |
4258 | 4276 | | |
4259 | 4277 | | |
4260 | 4278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
| 387 | + | |
| 388 | + | |
392 | 389 | | |
393 | 390 | | |
394 | 391 | | |
395 | 392 | | |
396 | 393 | | |
397 | 394 | | |
398 | | - | |
399 | | - | |
400 | | - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
401 | 398 | | |
402 | 399 | | |
403 | 400 | | |
| |||
423 | 420 | | |
424 | 421 | | |
425 | 422 | | |
426 | | - | |
427 | | - | |
428 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
429 | 426 | | |
430 | 427 | | |
431 | 428 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
709 | 709 | | |
710 | 710 | | |
711 | 711 | | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
712 | 761 | | |
713 | 762 | | |
714 | 763 | | |
| |||
2512 | 2561 | | |
2513 | 2562 | | |
2514 | 2563 | | |
| 2564 | + | |
| 2565 | + | |
| 2566 | + | |
| 2567 | + | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
2515 | 2574 | | |
2516 | 2575 | | |
2517 | 2576 | | |
| |||
4347 | 4406 | | |
4348 | 4407 | | |
4349 | 4408 | | |
| 4409 | + | |
| 4410 | + | |
| 4411 | + | |
4350 | 4412 | | |
4351 | 4413 | | |
4352 | 4414 | | |
| |||
4424 | 4486 | | |
4425 | 4487 | | |
4426 | 4488 | | |
| 4489 | + | |
| 4490 | + | |
4427 | 4491 | | |
4428 | 4492 | | |
4429 | 4493 | | |
| |||
4435 | 4499 | | |
4436 | 4500 | | |
4437 | 4501 | | |
| 4502 | + | |
| 4503 | + | |
4438 | 4504 | | |
4439 | 4505 | | |
4440 | 4506 | | |
4441 | 4507 | | |
4442 | 4508 | | |
| 4509 | + | |
| 4510 | + | |
4443 | 4511 | | |
4444 | 4512 | | |
4445 | 4513 | | |
4446 | 4514 | | |
4447 | 4515 | | |
4448 | 4516 | | |
4449 | | - | |
| 4517 | + | |
4450 | 4518 | | |
4451 | 4519 | | |
4452 | 4520 | | |
4453 | 4521 | | |
4454 | 4522 | | |
4455 | 4523 | | |
4456 | 4524 | | |
| 4525 | + | |
| 4526 | + | |
4457 | 4527 | | |
4458 | 4528 | | |
4459 | 4529 | | |
4460 | 4530 | | |
4461 | 4531 | | |
4462 | 4532 | | |
4463 | | - | |
| 4533 | + | |
4464 | 4534 | | |
4465 | 4535 | | |
4466 | 4536 | | |
| |||
0 commit comments