Skip to content

Conversation

@jtimon
Copy link
Contributor

@jtimon jtimon commented Jun 26, 2014

Nobody is using the miner besides testing, there's more efficient CPU miners out there and I don't think bitcoind needs more than a very basic miner for testing and maybe educational purposes.
This PR makes the miner code less efficient but clearer.

@sipa
Copy link
Member

sipa commented Jun 26, 2014

2014-06-26 23:07:19 ERROR: CheckProofOfWork() : hash doesn't match nBits

src/miner.cpp Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the negation. Did you test this?

@sipa
Copy link
Member

sipa commented Jun 26, 2014

If you additionally remove the "CheckProofOfWork() : hash doesn't match nBits" (which causes a few 100000 lines of logging to be written while mining otherwise), the speed of the miner only drops by a factor 2-2.5x. I'm not sure I consider that acceptable, but I expected a lot more (it's decoding nBits into a uint256 in every iterations...).

@laanwj
Copy link
Member

laanwj commented Jun 27, 2014

Could as well remove the internal miner completely, instead of crippling it first...

@Diapolo
Copy link

Diapolo commented Jun 27, 2014

Still NACK on removing.

@laanwj
Copy link
Member

laanwj commented Jun 27, 2014

Anyhow, I don't feel like this discussion again, ACK if the pulltester OK.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this the only usage of AllowMinDifficultyBlocks() anyway? I also think this is testnet related and has nothing to do with just making the code here more clear, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Params().AllowMinDifficultyBlocks() is for testnet, yes. It's also called inside UpdateTime and inside GetNextWorkRequired.
But this condition is no longer necessary because UpdateTime already updates pblock->nBits in testnet case and there's no hashTarget variable to update with pblock->nBits

@jtimon
Copy link
Contributor Author

jtimon commented Jun 27, 2014

Made changes suggested by @sipa
@laanwj isn't it already crippled (when compared to other miners)? We still need a minimal miner for testing.

@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4423_fa5da469388ad5ef4520eed59c279ce220dca4b5/ for binaries and test log.
This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/
Contact BlueMatt on freenode if something looks broken.

@jgarzik
Copy link
Contributor

jgarzik commented Jun 27, 2014

NAK. Just leave it as-is, or remove it completely.

Making it slower is just dumb. If you want an example of mining code, look at in-tree pyminer or out-of-tree cpuminer.

@luke-jr
Copy link
Member

luke-jr commented Jun 27, 2014

(there's also BFGMiner and libblkmaker's GBT example which uses libgcrypt for hashing)

@Diapolo
Copy link

Diapolo commented Jun 27, 2014

Perhaps you really should create a pull, which removes everything related to the internal miner. If this is done properly and we add some doc how to quickly mine regtest or testnet, I'm going to accept the voice of the majority!

@sipa
Copy link
Member

sipa commented Jun 27, 2014

The python tests do create blocks, I believe. We'll need a replacement for those committed to the repo if we want to drop the internal miner completely.

@gavinandresen
Copy link
Contributor

Yes, the regression tests use the internal miner to create chains.

So NACK from me on removing (unless replaced by something better).
And NACK on making the internal miner slower. As jgarzik says, see contrib/pyminer for a slow-but-easy-to-understand miner.

@laanwj
Copy link
Member

laanwj commented Jun 27, 2014

Ok, closing.

@laanwj laanwj closed this Jun 27, 2014
@jtimon jtimon deleted the nominer branch July 7, 2014 08:59
@jtimon
Copy link
Contributor Author

jtimon commented Jul 28, 2014

Did anyone tested how much slower this is for the regtest case (the one we're using and want to keep)?
Do we really need to print the hashes per second? Removing that would also make it simpler to refactor the POW generation out to pow.h as in #4377

@sipa
Copy link
Member

sipa commented Jul 28, 2014

I benchamrked your earlier naive miner (which just looped and performed CheckProofOfWork on each solution); IIRC it was 2-3x slower.

@jtimon jtimon restored the nominer branch August 28, 2014 14:36
@jtimon
Copy link
Contributor Author

jtimon commented Aug 28, 2014

@sipa I understand that your benchmarks have been maybe in hash/s which is what someone CPU mining with bitcoind in either mainnet or testnet would care about. My point is, as discussed we want to maintain the regtest miner which we use for testing. So my question was, did anybody tested how the performance of the tests suffers with this?
It is plausible that is even faster.

Anyway there's other solutions to encapsulate the proof of work related parts of miner.o in pow.o without removing the optimization so I think it's worth asking here.
The most obvious solution was to move the whole optimization to the Proof class, which @laanwj and I dislike.
I'm open to code several possibilities to help people chose what they like most.

But in my opinion one thing is clear: all of them will look much nicer if I can just get rid of the hashmeter first.
Would anybody oppose to the removal of the hashmeter?
Users of bitcoind's miner hashmeter, show yourselves.
Oh, wait, @sipa were you using that for the benchmark?
Mhmm, if so, it is not a fair comparison since my version works more for the hashmeter, look https://github.com/bitcoin/bitcoin/pull/4423/files#diff-4a59b408ad3778278c3aeffa7da33c3cL519

Anyway, jokes apart, I'm just looking for some more feedback on how to encapsulate the mining part of the pow in the Proof class.
I promise that if my regtest-only argument it's not convincing, I won't insist like I did with CTxDestination.

@sipa
Copy link
Member

sipa commented Oct 10, 2014

For regtest mode the speed of the internal miner is not relevant, which is why I don't care strongly about this. It seems other don't like making it slower (presumably for other purposes?), though.

jtimon referenced this pull request Nov 27, 2014
Speed up generating blocks in regression test mode, by moving
block-creating and nonce-finding directly into the setgenerate
RPC call (instead of starting up a mining thread and waiting for
it to find a block).

This makes the forknotify RPC test three times quicker, for
example (10 seconds runtime instead of 30 seconds, assuming
the initial blockchain cache is already built).
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants