Author

Topic: Headfirst mining (Read 602 times)

legendary
Activity: 1344
Merit: 1024
Mine at Jonny's Pool
March 08, 2016, 06:23:48 PM
#2
This is SPV mining... why would we want to take this approach?  It leads to the kind of crap AntPool, f2pool, etc are doing - i.e. empty blocks.  We are already suffering enough unconfirmed transactions - or did everyone forget the recent backlog that caused such a ruckus?

This is especially nonsensical since pools that fully validate their blocks before providing work to miners already exist (see ckpool).
staff
Activity: 4270
Merit: 1209
I support freedom of choice
March 08, 2016, 05:54:29 PM
#1
Quote
Implement head-first mining: have getblocktemplate build an empty block on the most-work block header while the full block is being fetched/validated.

It will do this for at most 30 seconds, to prevent a 'create a valid proof-of-work block then withhold its data to stop the network processing transactions' attack. If it takes longer than 30 seconds to download/validate the block data, then the previous fully-validated block is mined.

Adds a new command-line option: -blockheadernotify Just like -blocknotify, only notify as soon as a new best-work header is received and validated.

This should be easier to review commit-by-commit.

Tested by running the existing sendheaders.py and getblocktemplate_longpoll.py regression tests, and also running with
Code:
-blocknotify='/tmp/notify.sh block %s' -blockheadernotify='/tmp/notify.sh header %s'

... where /tmp/notify.sh is this simple little script:

Code:
#!/usr/bin/env bash

echo $@ >> /tmp/NOTIFY_MSGS
/Users/gavin/src/classic/src/bitcoin-cli getblocktemplate | head -20 >> /tmp/NOTIFY_MSGS

After running on the main network for a while, /tmp/NOTIFY_MSGS should show getblocktemplate giving an empty-transaction template after a header, then a few seconds later a normal template when the new block is fully validated.

PR: https://github.com/bitcoinclassic/bitcoinclassic/pull/138
Reddit discussion: https://www.reddit.com/r/btc/comments/49ktb5/headfirst_mining_by_gavinandresen_pull_request/
Jump to: