more proxy work
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@ AI/MCP/*
|
|||||||
.fuse_hidde*
|
.fuse_hidde*
|
||||||
*.pyc
|
*.pyc
|
||||||
MINE/rin/mining_log.txt
|
MINE/rin/mining_log.txt
|
||||||
|
*mining_log.txt
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
================================================================================
|
================================================================================
|
||||||
RinCoin Mining Log
|
RinCoin Mining Log
|
||||||
================================================================================
|
================================================================================
|
||||||
Started: 2025-09-23 18:00:59
|
Started: 2025-09-23 18:18:32
|
||||||
Target Address: rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q
|
Target Address: rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q
|
||||||
Stratum: 0.0.0.0:3334
|
Stratum: 0.0.0.0:3334
|
||||||
RPC: 127.0.0.1:9556
|
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
|
||||||
|
@@ -39,7 +39,7 @@ class RinCoinStratumProxy:
|
|||||||
# Dynamic difficulty adjustment
|
# Dynamic difficulty adjustment
|
||||||
self.share_stats = {} # Track shares per client
|
self.share_stats = {} # Track shares per client
|
||||||
self.last_difficulty_adjustment = time.time()
|
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
|
# Production monitoring
|
||||||
self.stats = {
|
self.stats = {
|
||||||
@@ -245,21 +245,21 @@ class RinCoinStratumProxy:
|
|||||||
hashes = [coinbase_txid]
|
hashes = [coinbase_txid]
|
||||||
for tx in transactions:
|
for tx in transactions:
|
||||||
hashes.append(bytes.fromhex(tx['hash'])[::-1]) # Reverse for little-endian
|
hashes.append(bytes.fromhex(tx['hash'])[::-1]) # Reverse for little-endian
|
||||||
|
|
||||||
# Build merkle tree
|
# Build merkle tree
|
||||||
while len(hashes) > 1:
|
while len(hashes) > 1:
|
||||||
if len(hashes) % 2 == 1:
|
if len(hashes) % 2 == 1:
|
||||||
hashes.append(hashes[-1]) # Duplicate last hash if odd
|
hashes.append(hashes[-1]) # Duplicate last hash if odd
|
||||||
|
|
||||||
next_level = []
|
next_level = []
|
||||||
for i in range(0, len(hashes), 2):
|
for i in range(0, len(hashes), 2):
|
||||||
combined = hashes[i] + hashes[i + 1]
|
combined = hashes[i] + hashes[i + 1]
|
||||||
next_level.append(hashlib.sha256(hashlib.sha256(combined).digest()).digest())
|
next_level.append(hashlib.sha256(hashlib.sha256(combined).digest()).digest())
|
||||||
|
|
||||||
hashes = next_level
|
hashes = next_level
|
||||||
|
|
||||||
return hashes[0] if hashes else b'\x00' * 32
|
return hashes[0] if hashes else b'\x00' * 32
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Merkle root calculation error: {e}")
|
print(f"Merkle root calculation error: {e}")
|
||||||
return b'\x00' * 32
|
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
|
network_diff = self.calculate_network_difficulty(self.current_job['target']) if self.current_job else 1.0
|
||||||
|
|
||||||
if is_new_client:
|
if is_new_client:
|
||||||
# Start new clients at 0.5% of network difficulty
|
# Use optimized difficulty based on updated hashrate analysis (680kH/s, 20s intervals)
|
||||||
initial_difficulty = network_diff * 0.005 # 0.5% of network difficulty
|
# 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
|
# Ensure reasonable bounds
|
||||||
min_difficulty = 0.000001 # Absolute minimum
|
min_difficulty = 0.0001 # Absolute minimum
|
||||||
max_difficulty = network_diff * 0.05 # Maximum 5% of network
|
# 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))
|
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
|
return initial_difficulty
|
||||||
|
|
||||||
# For existing clients, adjust based on actual hashrate performance
|
# For existing clients, adjust based on actual hashrate performance
|
||||||
@@ -569,12 +586,12 @@ class RinCoinStratumProxy:
|
|||||||
# Remove shares older than 60 seconds
|
# 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['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
|
self.stats['current_share_rate'] = len(self.stats['shares_last_minute']) / 60.0
|
||||||
|
|
||||||
# Enhanced logging
|
# Enhanced logging
|
||||||
timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
|
timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
network_percentage = (share_difficulty / network_difficulty) * 100 if network_difficulty > 0 else 0
|
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
|
stratum_percentage = (share_difficulty / client_stratum_diff) * 100 if client_stratum_diff > 0 else 0
|
||||||
|
|
||||||
# Progress indicator based on difficulty comparison
|
# Progress indicator based on difficulty comparison
|
||||||
if meets_network_difficulty:
|
if meets_network_difficulty:
|
||||||
progress_icon = "🎉" # Block found!
|
progress_icon = "🎉" # Block found!
|
||||||
@@ -588,7 +605,7 @@ class RinCoinStratumProxy:
|
|||||||
progress_icon = "💫" # Some progress
|
progress_icon = "💫" # Some progress
|
||||||
else:
|
else:
|
||||||
progress_icon = "📊" # Low progress
|
progress_icon = "📊" # Low progress
|
||||||
|
|
||||||
print(f"[{timestamp}] {progress_icon} SHARE: job={job['job_id']} | nonce={nonce} | hash={block_hash_hex[:16]}...")
|
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" 🎯 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")
|
print(f" 📈 Progress: {network_percentage:.4f}% of network, {stratum_percentage:.1f}% of stratum")
|
||||||
@@ -691,11 +708,15 @@ class RinCoinStratumProxy:
|
|||||||
# Submit block
|
# Submit block
|
||||||
block_hex = block.hex()
|
block_hex = block.hex()
|
||||||
print(f" 📦 Submitting block of size {len(block_hex)//2} bytes...")
|
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])
|
result = self.rpc_call("submitblock", [block_hex])
|
||||||
|
print(f" 📡 RPC RESPONSE: {result}") # Log the actual RPC response
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
print(f" ✅ Block accepted by network!")
|
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
|
# Update block stats
|
||||||
self.stats['blocks_found'] += 1
|
self.stats['blocks_found'] += 1
|
||||||
# Log wallet balance after successful block submission
|
# Log wallet balance after successful block submission
|
||||||
@@ -704,6 +725,7 @@ class RinCoinStratumProxy:
|
|||||||
else:
|
else:
|
||||||
print(f" ❌ Block rejected: {result}")
|
print(f" ❌ Block rejected: {result}")
|
||||||
print(f" 🔍 Debug: Block size {len(block_hex)//2} bytes, {len(job['transactions'])} transactions")
|
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}"
|
return False, f"Block rejected: {result}"
|
||||||
else:
|
else:
|
||||||
# Valid stratum share but not network-valid block (normal mode only)
|
# Valid stratum share but not network-valid block (normal mode only)
|
||||||
|
Reference in New Issue
Block a user