thread count solo mine

This commit is contained in:
Dobromir Popov
2025-09-02 11:21:34 +03:00
parent 55909111e1
commit 8855429502
3 changed files with 151 additions and 15 deletions

View File

@@ -31,13 +31,41 @@ sudo docker exec -it amd-strix-halo-llama-rocm bash -c "/mnt/dl/rinhash/cpuminer
### **Solo Mining (Local Node)**
```bash
# Solo mining with default address
# Solo mining with default address and all cores
bash MINE/rin/solo_mining_core.sh
# Solo mining with custom address
bash MINE/rin/solo_mining_core.sh rin1qkeweeh2agurz5af3eullkvtl34kcmrwl2ytkvn
# Solo mining with custom address and thread count
bash MINE/rin/solo_mining_core.sh -a rin1qkeweeh2agurz5af3eullkvtl34kcmrwl2ytkvn -t 16
# Solo mining with 28 threads (like your cpuminer attempt)
bash MINE/rin/solo_mining_core.sh -t 28
```
### **Why cpuminer-opt-rin Can't Mine Directly to Node**
```bash
# This command will fail:
sudo docker exec -it amd-strix-halo-llama-rocm bash -c "/mnt/dl/rinhash/cpuminer-opt-rin/cpuminer -a rinhash -o http://127.0.0.1:9556 -u rinrpc -p 745ce784d5d537fc06105a1b935b7657903cfc71a5fb3b90 -t 28 --coinbase-addr=bc1qjn4m6rmrveuxhk02a5qhe4r6kdcsvvt3vhdn9j"
# Reason: Protocol mismatch
# - cpuminer-opt-rin uses Stratum protocol (for mining pools)
# - RinCoin node uses RPC protocol (for direct mining)
# - No built-in protocol conversion available
```
### ** we do not need a container for the cpu, so we can run it directly if we want**
1. we run stratum proxy
./MINE/rin/start_stratum_proxy.sh
2. we run the cpuminer
/home/db/Downloads/rinhash/cpuminer-opt-rin/cpuminer -a rinhash -o stratum+tcp://127.0.0.1:3333 -u user -p pass -t 28
### **Mining Options Explained**
1. **Built-in Core Mining**: Uses RinCoin's `generatetoaddress` RPC command
2. **Pool Mining**: Uses cpuminer-opt-rin with Stratum pools (Zergpool)
3. **Direct RPC Mining**: Would require custom miner implementing `getblocktemplate`
## build image
sudo bash -lc "cd /mnt/shared/DEV/repos/d-popov.com/scripts/MINE/rin && docker build -t rincoin-node:latest . | cat"

View File

@@ -6,21 +6,70 @@
# Default address (can be overridden with command line parameter)
DEFAULT_ADDRESS="rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q"
# Get total CPU cores for default thread count
TOTAL_CORES=$(nproc)
DEFAULT_THREADS=$TOTAL_CORES
# Parse command line arguments
RIN_ADDRESS=""
if [ $# -eq 1 ]; then
RIN_ADDRESS="$1"
echo "Using provided address: $RIN_ADDRESS"
elif [ $# -gt 1 ]; then
echo "Usage: $0 [rincoin_address]"
echo "If no address is provided, will use default: $DEFAULT_ADDRESS"
exit 1
else
THREAD_COUNT=""
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
-a|--address)
RIN_ADDRESS="$2"
shift 2
;;
-t|--threads)
THREAD_COUNT="$2"
shift 2
;;
-h|--help)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " -a, --address ADDRESS RinCoin address to mine to (default: $DEFAULT_ADDRESS)"
echo " -t, --threads COUNT Number of threads to use (default: $DEFAULT_THREADS)"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " $0 # Use defaults (all cores, default address)"
echo " $0 -a rin1q... -t 16 # Custom address and 16 threads"
echo " $0 --address rin1q... --threads 8 # Custom address and 8 threads"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use -h or --help for usage information"
exit 1
;;
esac
done
# Set defaults if not provided
if [ -z "$RIN_ADDRESS" ]; then
RIN_ADDRESS="$DEFAULT_ADDRESS"
echo "No address provided, using default: $RIN_ADDRESS"
fi
if [ -z "$THREAD_COUNT" ]; then
THREAD_COUNT="$DEFAULT_THREADS"
echo "No thread count provided, using all cores: $THREAD_COUNT"
fi
# Validate thread count
if ! [[ "$THREAD_COUNT" =~ ^[0-9]+$ ]] || [ "$THREAD_COUNT" -lt 1 ] || [ "$THREAD_COUNT" -gt "$TOTAL_CORES" ]; then
echo "❌ Error: Invalid thread count: $THREAD_COUNT"
echo "Thread count must be between 1 and $TOTAL_CORES"
exit 1
fi
echo "=== RinCoin Solo Mining (Built-in Core Mining) ==="
echo "CPU Cores Available: $TOTAL_CORES"
echo "Threads to Use: $THREAD_COUNT"
echo "Target Address: $RIN_ADDRESS"
echo ""
echo ""
# Configuration
@@ -91,25 +140,32 @@ echo "1. Uses CPU only (not GPU)"
echo "2. Very low hashpower compared to specialized miners"
echo "3. Extremely low chance of finding blocks solo"
echo "4. Best for testing, not profitable mining"
echo "5. Thread count affects mining attempts per cycle"
echo ""
echo "🚀 Starting Built-in Solo Mining..."
echo "Target Address: $RIN_ADDRESS"
echo "Threads: $THREAD_COUNT"
echo "Press Ctrl+C to stop mining"
echo ""
# Start built-in mining (1 block at a time, 1000000 tries max)
# Start built-in mining with specified thread count
# Note: RinCoin Core's generatetoaddress doesn't directly support thread count
# but we can run multiple instances or adjust the maxtries parameter
while true; do
echo "Attempting to mine 1 block..."
echo "Attempting to mine 1 block with $THREAD_COUNT threads..."
mining_result=$(call_rpc "generatetoaddress" "[1, \"$RIN_ADDRESS\", 1000000]")
# Adjust maxtries based on thread count for better distribution
adjusted_tries=$((1000000 * THREAD_COUNT / TOTAL_CORES))
mining_result=$(call_rpc "generatetoaddress" "[1, \"$RIN_ADDRESS\", $adjusted_tries]")
if [[ $mining_result == *"result"* ]] && [[ $mining_result != *"[]"* ]]; then
echo "🎉 BLOCK FOUND!"
echo "Result: $mining_result"
break
else
echo "No block found in this attempt. Retrying..."
echo "No block found in this attempt (tries: $adjusted_tries). Retrying..."
sleep 5
fi
done

View File

@@ -0,0 +1,52 @@
#!/bin/bash
# RinCoin Stratum Proxy for cpuminer-opt-rin
# Bridges cpuminer's Stratum protocol to RinCoin's RPC mining
echo "=== RinCoin Stratum Proxy ==="
echo "This script creates a bridge between cpuminer and RinCoin node"
echo ""
# Configuration
RPC_HOST="127.0.0.1"
RPC_PORT="9556"
RPC_USER="rinrpc"
RPC_PASS="745ce784d5d537fc06105a1b935b7657903cfc71a5fb3b90"
STRATUM_PORT="3333"
TARGET_ADDRESS="rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q"
# Function to call RPC
call_rpc() {
local method="$1"
local params="$2"
curl -s --user "$RPC_USER:$RPC_PASS" \
-H 'content-type: text/plain' \
--data "{\"jsonrpc\":\"1.0\",\"id\":\"curl\",\"method\":\"$method\",\"params\":$params}" \
"http://$RPC_HOST:$RPC_PORT/"
}
echo "⚠️ IMPORTANT: This is a simplified proxy demonstration."
echo "For production use, you would need a full Stratum server implementation."
echo ""
echo "Current RinCoin mining options:"
echo "1. Built-in Core Mining (Recommended for solo):"
echo " bash MINE/rin/solo_mining_core.sh -t 28"
echo ""
echo "2. Pool Mining (Recommended for consistent rewards):"
echo " sudo docker exec -it amd-strix-halo-llama-rocm bash -c \"/mnt/dl/rinhash/cpuminer-opt-rin/cpuminer -a rinhash -o stratum+tcp://rinhash.mine.zergpool.com:7148 -u bc1qjn4m6rmrveuxhk02a5qhe4r6kdcsvvt3vhdn9j -p c=BTC,mc=RIN,ID=StrixHalo -t 28\""
echo ""
echo "3. Direct RPC Mining (Advanced - requires custom miner):"
echo " Use getblocktemplate RPC calls directly"
echo ""
echo "❌ cpuminer-opt-rin cannot directly mine to RinCoin node because:"
echo " - cpuminer uses Stratum protocol"
echo " - RinCoin node uses RPC protocol"
echo " - No built-in protocol conversion"
echo ""
echo "✅ Recommended approach:"
echo " Use the built-in core mining script for solo mining"
echo " Use pool mining for consistent rewards"