From a6c271d3f32f53afeafcbd13b3fe53a23e53fd57 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Tue, 23 Sep 2025 18:20:17 +0300 Subject: [PATCH] more proxy work --- .gitignore | 1 + MINE/rin/mining_log.txt | 4 +-- MINE/rin/stratum_proxy.py | 54 +++++++++++++++++++++++++++------------ 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 8300d53..5937352 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ AI/MCP/* .fuse_hidde* *.pyc MINE/rin/mining_log.txt +*mining_log.txt diff --git a/MINE/rin/mining_log.txt b/MINE/rin/mining_log.txt index 4729580..67a3143 100644 --- a/MINE/rin/mining_log.txt +++ b/MINE/rin/mining_log.txt @@ -1,10 +1,10 @@ ================================================================================ RinCoin Mining Log ================================================================================ -Started: 2025-09-23 18:00:59 +Started: 2025-09-23 18:18:32 Target Address: rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q Stratum: 0.0.0.0:3334 RPC: 127.0.0.1:9556 ================================================================================ -[2025-09-23 18:00:59] 💰 Wallet Balance: 25.00000000 RIN +[2025-09-23 18:18:32] 💰 Wallet Balance: 25.00000000 RIN diff --git a/MINE/rin/stratum_proxy.py b/MINE/rin/stratum_proxy.py index fe37e3d..aecc5aa 100644 --- a/MINE/rin/stratum_proxy.py +++ b/MINE/rin/stratum_proxy.py @@ -39,7 +39,7 @@ class RinCoinStratumProxy: # Dynamic difficulty adjustment self.share_stats = {} # Track shares per client self.last_difficulty_adjustment = time.time() - self.target_share_interval = 120 # Target: 1 share every 2 minutes per miner (aligned with ~1min blocks) + self.target_share_interval = 20 # Target: 1 share every 20 seconds (optimized from public pool data) # Production monitoring self.stats = { @@ -245,21 +245,21 @@ class RinCoinStratumProxy: hashes = [coinbase_txid] for tx in transactions: hashes.append(bytes.fromhex(tx['hash'])[::-1]) # Reverse for little-endian - + # Build merkle tree while len(hashes) > 1: if len(hashes) % 2 == 1: hashes.append(hashes[-1]) # Duplicate last hash if odd - + next_level = [] for i in range(0, len(hashes), 2): combined = hashes[i] + hashes[i + 1] next_level.append(hashlib.sha256(hashlib.sha256(combined).digest()).digest()) - + hashes = next_level - + return hashes[0] if hashes else b'\x00' * 32 - + except Exception as e: print(f"Merkle root calculation error: {e}") return b'\x00' * 32 @@ -400,15 +400,32 @@ class RinCoinStratumProxy: network_diff = self.calculate_network_difficulty(self.current_job['target']) if self.current_job else 1.0 if is_new_client: - # Start new clients at 0.5% of network difficulty - initial_difficulty = network_diff * 0.005 # 0.5% of network difficulty + # Use optimized difficulty based on updated hashrate analysis (680kH/s, 20s intervals) + # Updated: Doubled hashrate requires doubled difficulty for same share rate + optimal_difficulty = 0.003182 # Optimized for 680kH/s (2x original 340kH/s) + + # Scale based on network difficulty to maintain relative percentage + target_percentage = 0.003924 # 0.3924% of network (updated for 680kH/s) + scaled_difficulty = network_diff * target_percentage + + # Use the better of the two approaches + initial_difficulty = min(optimal_difficulty, scaled_difficulty) # Ensure reasonable bounds - min_difficulty = 0.000001 # Absolute minimum - max_difficulty = network_diff * 0.05 # Maximum 5% of network + min_difficulty = 0.0001 # Absolute minimum + # IMPORTANT: DO NOT CHANGE THIS VALUE. our pool may grow big in the future, so we need to be able to handle it. + max_difficulty = network_diff * 0.1 # Maximum 10% of network initial_difficulty = max(min_difficulty, min(max_difficulty, initial_difficulty)) - print(f" 📊 NEW CLIENT {addr}: Network diff {network_diff:.6f}, starting with {initial_difficulty:.6f} (0.5% of network)") + percentage = (initial_difficulty / network_diff) * 100 + print(f" 📊 NEW CLIENT {addr}: Network diff {network_diff:.6f}") + print(f" 🎯 Starting difficulty: {initial_difficulty:.6f} ({percentage:.4f}% of network)") + miner_hashrate = self.clients.get(addr, {}).get('estimated_hashrate', 0) + if miner_hashrate > 0: + print(f" Target: 1 share every {self.target_share_interval}s @ {miner_hashrate:.0f} H/s") + else: + print(f" Target: 1 share every {self.target_share_interval}s (miner hashrate unknown)") + print(f" 🔧 Per-miner adjustment: Difficulty will adapt to each device's actual hashrate") return initial_difficulty # For existing clients, adjust based on actual hashrate performance @@ -569,12 +586,12 @@ class RinCoinStratumProxy: # Remove shares older than 60 seconds self.stats['shares_last_minute'] = [t for t in self.stats['shares_last_minute'] if current_time - t <= 60] self.stats['current_share_rate'] = len(self.stats['shares_last_minute']) / 60.0 - + # Enhanced logging timestamp = time.strftime("%Y-%m-%d %H:%M:%S") network_percentage = (share_difficulty / network_difficulty) * 100 if network_difficulty > 0 else 0 stratum_percentage = (share_difficulty / client_stratum_diff) * 100 if client_stratum_diff > 0 else 0 - + # Progress indicator based on difficulty comparison if meets_network_difficulty: progress_icon = "🎉" # Block found! @@ -588,7 +605,7 @@ class RinCoinStratumProxy: progress_icon = "💫" # Some progress else: progress_icon = "📊" # Low progress - + print(f"[{timestamp}] {progress_icon} SHARE: job={job['job_id']} | nonce={nonce} | hash={block_hash_hex[:16]}...") print(f" 🎯 Share Diff: {share_difficulty:.2e} | Stratum Diff: {client_stratum_diff:.6f} | Network Diff: {network_difficulty:.6f}") print(f" 📈 Progress: {network_percentage:.4f}% of network, {stratum_percentage:.1f}% of stratum") @@ -691,11 +708,15 @@ class RinCoinStratumProxy: # Submit block block_hex = block.hex() print(f" 📦 Submitting block of size {len(block_hex)//2} bytes...") - + print(f" 🚀 Calling RPC: submitblock([block_hex={len(block_hex)//2}_bytes])") + result = self.rpc_call("submitblock", [block_hex]) - + print(f" 📡 RPC RESPONSE: {result}") # Log the actual RPC response + if result is None: print(f" ✅ Block accepted by network!") + print(f" 🎊 SUCCESS: Block {job['height']} submitted successfully!") + print(f" 💰 Reward earned: {job['coinbasevalue']/100000000:.8f} RIN") # Update block stats self.stats['blocks_found'] += 1 # Log wallet balance after successful block submission @@ -704,6 +725,7 @@ class RinCoinStratumProxy: else: print(f" ❌ Block rejected: {result}") print(f" 🔍 Debug: Block size {len(block_hex)//2} bytes, {len(job['transactions'])} transactions") + print(f" 📋 Full RPC error details: {result}") return False, f"Block rejected: {result}" else: # Valid stratum share but not network-valid block (normal mode only)