ethminer

最後更新: 2021-02-11

目錄

  • ethminer 介紹
  • ethminer Usage (0.18)
  • Stratum(-P)
  • ethminer API
  • gid

ethminer 介紹

 

HomePage: https://github.com/ethereum-mining/ethminer

Features

  • OpenCL mining
  • Nvidia CUDA mining
  • realistic benchmarking against arbitrary epoch/DAG/blocknumber
  • on-GPU DAG generation (no more DAG files on disk)
  • stratum mining without proxy
  • OpenCL devices picking
  • farm failover (getwork + stratum)

Install

https://github.com/ethereum-mining/ethminer/releases

wget https://github.com/ethereum-mining/ethminer/releases/download/v0.13.0/et...

tar -zxf ethminer-0.13.0-Linux.tar.gz

mv bin/ethminer /usr/bin/ethminer

rmdir bin

Changelog

0.18.0

  •  

0.14.0

  • Secure TLS stratum pool connections now fully supported.
  • Expanded support for up to 32 GPUs.
  • 用 "-P URL" 去 Set specify a pool URL

0.13.0

........

 


ethminer Usage (0.18)

 

ethminer --version

ethminer 0.18.0
Build: linux/release/gnu

ethminer --list-devices

ethminer 0.18.0
Build: linux/release/gnu

 Id Pci Id    Type Name                          CUDA SM  CL    Total Memory  Cl Max Alloc  Cl Max W.Grp
--- --------- ---- ----------------------------- ---- --- ----  ------------  ------------  ------------
  0 04:00.0   Gpu  GeForce GTX 1070              Yes  6.1 Yes        7.93 GB       1.98 GB     1024.00 B
  1 06:00.0   Gpu  GeForce GTX 1070              Yes  6.1 Yes        7.93 GB       1.98 GB     1024.00 B
  2 07:00.0   Gpu  GeForce GTX 1070              Yes  6.1 Yes        7.93 GB       1.98 GB     1024.00 B

Benchmark

-M,--benchmark N       # 用 N 張 Display Card 去做 benchmark

-Z,--simulation N         # 設定 Block Height, 建議用 Latest Blocks(https://etherscan.io/)

i.e.

ethminer -M 3

 m 20:29:54 ethminer 0:00 A0 12.88 Mh - cu0 5.40, cu1 4.59, cu2 2.90
 m 20:29:59 ethminer 0:00 A0 93.47 Mh - cu0 31.17, cu1 31.16, cu2 31.14
 ...

ethminer -M 3 -Z 11842139

P.S.

沒有設定 Block Height 時, Benchmark 會比實際 mining 高的

Other opts

--farm-recheck <n>    # n ms between poll geth (or eth-proxy) for new work (Default: 500)

                                 # It has no meaning in stratum mode

過熱保護

-HWMON 0       # GPU hardware monitoring level. Default = 0 (No monitoring)

                       # 1 Monitor temperature and fan percentage, 2 As 1 plus monitor power drain

--tstart            # UINT[30 .. 100] Default = 0

                       # Suspend mining on GPU which temperature is above this threshold. Implies --HWMON 1

                       # If not set or zero no temp control is performed

--tstop             # UINT[30 .. 100] Default = 40, Implies --HWMON 1

                       # Resume mining on previously overheated GPU when temp drops below this threshold.

                       # Must be lower than --tstart

mining with GPU (V 0.18.0)

# By default ethminer will try to use all devices types

-U,--cuda            When mining use the GPU via CUDA. # Help: ethminer -H cl

-G,--opencl         Mine/Benchmark using OpenCL only   # Help: ethminer -H cu

ethminer -U --list-devices

ethminer 0.18.0
Build: linux/release/gnu

 Id Pci Id    Type Name                          CUDA SM   Total Memory
--- --------- ---- ----------------------------- ---- ---  ------------
  0 04:00.0   Gpu  GeForce GTX 1070              Yes  6.1       7.93 GB
  1 06:00.0   Gpu  GeForce GTX 1070              Yes  6.1       7.93 GB
  2 07:00.0   Gpu  GeForce GTX 1070              Yes  6.1       7.93 GB

CUDA configuration:

--cuda-devices <0 1 ..n> Select which CUDA GPUs to mine on. Default is to use all

--cuda-block-size   # Set the CUDA block work size. Default is 128

--cuda-grid-size     # Set the CUDA grid size. Default is 8192

--cuda-streams      # Set the number of CUDA streams. Default is 2

--cuda-schedule <mode>

Set the schedule mode for CUDA threads waiting for CUDA devices to finish work.

Default is 'sync'. Possible values are:

  • auto - Uses a heuristic based on the number of active CUDA contexts in the process C
              and the number of logical processors in the system P. If C > P, then yield else spin.
  • spin - Instruct CUDA to actively spin when waiting for results from the device.
  • yield - Instruct CUDA to yield its thread when waiting for results from the device.
  • sync - Instruct CUDA to block the CPU thread on a synchronization primitive
               when waiting for the results from the device.

--cuda-parallel-hash <1 2 ..8>       # Default=4

Define how many hashes to calculate in a kernel, can be scaled to achieve better performance.

 


Stratum(-P)

 

https://en.bitcoin.it/wiki/Stratum_mining_protocol

--work-timeout <n>

Defaults to 180 seconds. Don't set lower than max. avg. block time

If no new work received from pool after this amount of time the connection is dropped

reconnect/failover after n seconds of working on the same (stratum) job.

--failover-timeout

Sets the number of minutes ethminer can stay connected to a fail-over pool

before trying to reconnect to the primary (the first) connection.

-R, --report-hashrate

Report current hashrate to pool (please only enable on pools supporting this)

i.e.

# V 0.18.0

用 "-P URL" 去 Set specify a pool URL.

The 1st for for the primary pool, and the 2nd for the failover pool.

nanopool.sh

#!/bin/bash

logH1=/root/scripts/eth/log-H1.txt
myAddr="0x???"
eMail="???%40gmail.com"

ethminer -U -R --api-port 3333 \
 --tstart 50 --tstop 70 \
 -P stratum1+tcp://${myAddr}@eth-asia1.nanopool.org:9999/H1/${eMail} \
 -P stratum1+tcp://${myAddr}@eth-jp1.nanopool.org:9999/H1/${eMail} &> $logH1 &

Remark

tstart 在卡情況, 很難解到 Default 的 40C, 所以要 set 成 50

log

 m 01:16:23 ethminer 0:01 A0 82.79 Mh - cu0 28.40 55C 60%, cu1 27.94 60C 65%, cu2 26.45 63C 70%
 i 01:16:24 ethminer Job: fa500323… eth-asia1.nanopool.org [139.99.102.74:9999]
 i 01:16:25 ethminer Job: 267c4c8e… eth-asia1.nanopool.org [139.99.102.74:9999]
 i 01:16:25 ethminer Job: 85f31107… eth-asia1.nanopool.org [139.99.102.74:9999]
 ...

 


ethminer API

 

Messages exchanged through this channel must conform the Jsonrpc v.2 specifications

--api-port <portnum>

# Use 0 to disable. Default=0

read-only mode

means only query to get data

# add the - (minus) sign in front of the port

ethminer [...] --api-bind -3333

miner_ping

echo '{"id":0,"jsonrpc":"2.0","method":"miner_ping"}' | netcat 127.0.0.1 3333

miner_getstat1

A collection of statistical data (miner_getstat1)

echo '{"id": 1,"jsonrpc": "2.0","method": "miner_getstat1"}' | netcat 127.0.0.1 3333 | jq

{
   "id":1,
   "jsonrpc":"2.0",
   "result":[  
    "0.16.0.dev0+commit.41639944",          // The actual release of ethminer
    "48",                                   // Total running time in minutes
    "87221;54;0",                           // ETH hashrate in KH/s, submitted shares, rejected shares
    "14683;14508;14508;14508;14508;14508",  // Detailed ETH hashrate in KH/s per GPU
    "0;0;0",                                // (not used) DCR hashrate in KH/s, submitted shares, rejected shares
    "off;off;off;off;off;off",              // (not used) Detailed DCR hashrate in KH/s per GPU
    "53;90;50;90;56;90;58;90;61;90;60;90",  // Temp and fan speed pairs per GPU
    "eu1.ethermine.org:4444",               // Mining pool currently active
    "0;0;0;0"                               // ETH invalid shares, ETH pool switches, DCR invalid shares, DCR pool switches
   ]
}

miner_shuffle

The mining process is nothing more that finding the right number(nonce) which,

applied to an algorithm (ethash) and some data,

gives a result which is below or equal to a given target.

This process in very very (very) short !

The range of nonces to be searched is a huge number:

2^64 = 18446744073709600000 ~ possible values.

Each one has the same probability to be the right one.

Every time ethminer receives a job from a pool

  you'd expect the miner to begin searching from the first but that would be boring.

So the concept of scramble nonce has been introduced to achieve these goals:

 * Start the searching from a random point within the range

 * Ensure all GPUs do not search the same data(without overlapping)

"miner_shuffle" method does is to re-initialize a new random scramble nonce to start from in next jobs.

{"id": 1, "jsonrpc": "2.0", "method": "miner_shuffle"}

miner_restart

useful if you detect one, or more, GPU are in error but in a recoverable state

recoverable state = no hashrate but the GPU has not fallen off the bus

原理: restart ethminer without loosing connection to the pool )

過程

  1. Stop actual mining work
  2. Unload generated DAG files
  3. Reset devices (GPU)
  4. Regenerate DAG files
  5. Restart mining

echo '{"id": 1, "jsonrpc": "2.0", "method": "miner_restart"}' | netcat 127.0.0.1 3333

Connect 切換 Pool 的連線

miner_getconnections     

Returns the list of connections held by ethminer.

用來獲得 miner_setactiveconnection 的 params

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "miner_getconnections"
}

miner_setactiveconnection     

Instruct ethminer to immediately connect to the specified connection

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "miner_setactiveconnection",
  "params": {
    "index": 0
  }
}

miner_pausegpu     

Pause/Start mining on specific GPU

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "miner_pausegpu",
  "params": {
    "index": 0,
    "pause": true
  }
}

miner_getscramblerinfo     

Retrieve information about the nonce segments assigned to each GPU

挖的位置: start_nonce + ((2^segment_width) * device_index))

 


grid

 

Host C++ code gives an initial nonce value. (start_nonce)

Each CUDA thread derives the nonce doing this :

start_nonce + gid

if you launch a kernel execution with a grid size of 1024 and a block size of 64,

there will be 1024 * 64 == 65536 threads.