|
27 | 27 | from typing import Dict, List, Optional, Tuple, Any |
28 | 28 | from dataclasses import dataclass |
29 | 29 |
|
| 30 | +# Canonical genesis timestamp — must match rip_200_round_robin_1cpu1vote.py |
| 31 | +GENESIS_TIMESTAMP = 1764706927 # Production chain launch (Dec 2, 2025) |
| 32 | +BLOCK_TIME = 600 |
| 33 | + |
30 | 34 | logging.basicConfig( |
31 | 35 | level=logging.INFO, |
32 | 36 | format='%(asctime)s [ANTI-DOUBLE-MINING] %(levelname)s: %(message)s' |
@@ -289,8 +293,8 @@ def get_epoch_miner_groups( |
289 | 293 | """ |
290 | 294 | epoch_start_slot = epoch * 144 |
291 | 295 | epoch_end_slot = epoch_start_slot + 143 |
292 | | - epoch_start_ts = 1728000000 + (epoch_start_slot * 600) # GENESIS_TIMESTAMP |
293 | | - epoch_end_ts = 1728000000 + (epoch_end_slot * 600) |
| 296 | + epoch_start_ts = GENESIS_TIMESTAMP + (epoch_start_slot * BLOCK_TIME) |
| 297 | + epoch_end_ts = GENESIS_TIMESTAMP + (epoch_end_slot * BLOCK_TIME) |
294 | 298 |
|
295 | 299 | cursor = conn.cursor() |
296 | 300 |
|
@@ -370,9 +374,9 @@ def calculate_anti_double_mining_rewards( |
370 | 374 |
|
371 | 375 | epoch_start_slot = epoch * 144 |
372 | 376 | epoch_end_slot = epoch_start_slot + 143 |
373 | | - epoch_start_ts = 1728000000 + (epoch_start_slot * 600) |
374 | | - epoch_end_ts = 1728000000 + (epoch_end_slot * 600) |
375 | | - |
| 377 | + epoch_start_ts = GENESIS_TIMESTAMP + (epoch_start_slot * BLOCK_TIME) |
| 378 | + epoch_end_ts = GENESIS_TIMESTAMP + (epoch_end_slot * BLOCK_TIME) |
| 379 | + |
376 | 380 | with sqlite3.connect(db_path) as conn: |
377 | 381 | conn.execute("BEGIN") |
378 | 382 |
|
@@ -651,8 +655,8 @@ def _calculate_anti_double_mining_rewards_conn( |
651 | 655 |
|
652 | 656 | epoch_start_slot = epoch * 144 |
653 | 657 | epoch_end_slot = epoch_start_slot + 143 |
654 | | - epoch_start_ts = 1728000000 + (epoch_start_slot * 600) |
655 | | - epoch_end_ts = 1728000000 + (epoch_end_slot * 600) |
| 658 | + epoch_start_ts = GENESIS_TIMESTAMP + (epoch_start_slot * BLOCK_TIME) |
| 659 | + epoch_end_ts = GENESIS_TIMESTAMP + (epoch_end_slot * BLOCK_TIME) |
656 | 660 |
|
657 | 661 | # Detect duplicate identities |
658 | 662 | duplicates = detect_duplicate_identities(conn, epoch, epoch_start_ts, epoch_end_ts) |
@@ -836,7 +840,7 @@ def setup_test_scenario(db_path: str): |
836 | 840 | # Insert test data |
837 | 841 | current_ts = int(time.time()) |
838 | 842 | epoch = 0 |
839 | | - epoch_start_ts = 1728000000 + (epoch * 144 * 600) |
| 843 | + epoch_start_ts = GENESIS_TIMESTAMP + (epoch * 144 * BLOCK_TIME) |
840 | 844 |
|
841 | 845 | # Machine A: Same fingerprint, 3 different miner IDs |
842 | 846 | fingerprint_a = json.dumps({ |
@@ -924,8 +928,8 @@ def setup_test_scenario(db_path: str): |
924 | 928 | setup_test_scenario(test_db) |
925 | 929 |
|
926 | 930 | print("\n=== Testing Anti-Double-Mining Detection ===\n") |
927 | | - |
928 | | - current_slot = (int(time.time()) - 1728000000) // 600 |
| 931 | + |
| 932 | + current_slot = (int(time.time()) - GENESIS_TIMESTAMP) // BLOCK_TIME |
929 | 933 | rewards, telemetry = calculate_anti_double_mining_rewards( |
930 | 934 | test_db, epoch=0, total_reward_urtc=150_000_000, current_slot=current_slot |
931 | 935 | ) |
|
0 commit comments