-
Notifications
You must be signed in to change notification settings - Fork 0
Mining
- Introduction to Webchain mining (main wiki)
Currently, mining reward is the full amount of 5 ether per block, with a small bonus for included uncles. Uncle miners can receive up to 7/8*5 ether. With the forthcoming ECIP-1017 changes, these rewards will change. Mining rewards are discussed in detail here.
At Frontier, the first release of Webchain, you'll just need a) a GPU and b) an Webchain client, Webchaind. CPU mining will be possible but too inefficient to hold any value.
Webchaind only includes a CPU miner
NOTE: Ensure your blockchain is fully synchronised with the main chain before starting to mine, otherwise you will not be mining on the main chain.
When you start up your ethereum node with webchaind it is not mining by default. To start it in mining mode, you use the --mine command line option. The -minerthreads parameter can be used to set the number parallel mining threads (defaulting to the total number of processor cores).
webchaind --mine --minerthreads=4
You can also start and stop CPU mining at runtime using the console. miner.start takes an optional parameter for the number of miner threads.
> miner.start(8)
true
> miner.stop()
true
Note that mining for WEB only makes sense if you are in sync with the network (since you mine on top of the consensus block). Therefore the webchain blockchain downloader/synchroniser will delay mining until syncing is complete, and after that mining automatically starts unless you cancel your intention with miner.stop().
In order to earn ether you must have your etherbase (or coinbase) address set. This etherbase defaults to your primary account. If you don't have an etherbase address, then webchaind --mine will not start up.
You can set your etherbase on the command line:
webchaind --etherbase 1 --mine 2>> webchaind.log // 1 is index: second account by creation order OR
webchaind --etherbase '0xa4d8e9cae4d04b093aac82e6cd355b6b963fb7ff' --mine 2>> webchaind.log
You can reset your etherbase on the console too:
miner.setEtherbase(webchain.accounts[2])
Note that your etherbase does not need to be an address of a local account, just an existing one.
There is an option to add extra Data (32 bytes only) to your mined blocks. By convention this is interpreted as a unicode string, so you can set your short vanity tag.
miner.setExtra("ΞTHΞЯSPHΞЯΞ")
...
debug.printBlock(131805)
BLOCK(be465b020fdbedc4063756f0912b5a89bbb4735bd1d1df84363e05ade0195cb1): Size: 531.00 B TD: 643485290485 {
NoNonce: ee48752c3a0bfe3d85339451a5f3f411c21c8170353e450985e1faab0a9ac4cc
Header:
[
...
Coinbase: a4d8e9cae4d04b093aac82e6cd355b6b963fb7ff
Number: 131805
Extra: ΞTHΞЯSPHΞЯΞ
...
}
See also this proposal
You can check your hashrate with miner.hashrate, the result is in H/s (Hash operations per second).
> miner.hashrate
712000
After you successfully mined some blocks, you can check the ether balance of your etherbase account. Now assuming your etherbase is a local account:
> webchain.getBalance(webchain.coinbase).toNumber();
'34698870000000'
In order to spend your earnings on gas to transact, you will need to have this account unlocked.
> personal.unlockAccount(webchain.coinbase)
Password
true
You can check which blocks are mined by a particular miner (address) with the following code snippet on the console:
function minedBlocks(lastn, addr) {
addrs = [];
if (!addr) {
addr = webchain.coinbase
}
limit = webchain.blockNumber - lastn
for (i = webchain.blockNumber; i >= limit; i--) {
if (webchain.getBlock(i).miner == addr) {
addrs.push(i)
}
}
return addrs
}
// scans the last 1000 blocks and returns the blocknumbers of blocks mined by your coinbase
// (more precisely blocks the mining reward for which is sent to your coinbase).
minedBlocks(1000, webchain.coinbase);
//[352708, 352655, 352559]
Note that it will happen often that you find a block yet it never makes it to the canonical chain. This means when you locally include your mined block, the current state will show the mining reward credited to your account, however, after a while, the better chain is discovered and we switch to a chain in which your block is not included and therefore no mining reward is credited. Therefore it is quite possible that as a miner monitoring their coinbase balance will find that it may fluctuate quite a bit.
The logs show locally mined blocks confirmed after 5 blocks. At the moment you may find it easier and faster to generate the list of your mined blocks from these logs.
Mining success depends on the set block difficulty. Block difficulty dynamically adjusts each block in order to regulate the network hashing power to produce a 12 second blocktime. Your chances of finding a block therefore follows from your hashrate relative to difficulty. The time you need to wait you are expected to find a block can be estimated with the following code:
INCORRECT...CHECKING
etm = webchain.getBlock("latest").difficulty/miner.hashrate; // estimated time in seconds
Math.floor(etm / 3600.) + "h " + Math.floor((etm % 3600)/60) + "m " + Math.floor(etm % 60) + "s";
// 1h 3m 30s
Given a difficulty of 3 billion, a typical CPU with 800KH/s is expected to find a block every ....?
To debug webchaind:
webchaind --rpccorsdomain "localhost" --verbosity 6 2>> webchaind.log
To debug the miner:
make -DCMAKE_BUILD_TYPE=Debug -DETHASHCL=1 -DGUI=0
gdb --args ethminer -G -M
Note hashrate info is not available in webchaind when GPU mining. Check your hashrate with ethminer, miner.hashrate will always report 0.
- ether-proxy, a web interface for mining rigs (supports solo and pool mining proxy with web interface and rigs availability monitoring)
- ethereum forum mining FAQ live update
- yates randall mining video
- https://blog.ethereum.org/2014/07/05/stake/
- https://blog.ethereum.org/2014/10/03/slasher-ghost-developments-proof-stake/
- https://blog.ethereum.org/2014/06/19/mining/
- https://github.com/ethereumproject/wiki/wiki/Ethash
- Benchmarking results for GPU mining
- historic moment
- live mining statistic
- netstat ethereum network monitor
❤️ Stay Classy