Bitcoin Forum
November 21, 2024, 05:21:52 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 »
  Print  
Author Topic: New demonstration CPU miner available  (Read 386313 times)
jgarzik (OP)
Legendary
*
Offline Offline

Activity: 1596
Merit: 1100


View Profile
November 25, 2010, 12:45:23 AM
Last edit: July 13, 2011, 03:18:15 AM by jgarzik
 #1

A new CPU miner is now available, making use of the new 'getwork' RPC command.

In the beginning, this is intended largely to demonstrate a 'getwork' miner.  It is written in straight C, with minimal dependencies (libcurl, jansson).

It has successfully generated blocks on testnet, mainnet and almost all pools.

Linux/BSD release tarball: http://yyz.us/bitcoin/cpuminer-1.0.2.tar.gz
Windows installer: http://yyz.us/bitcoin/cpuminer-installer-1.0.2.zip
git repository: git://github.com/jgarzik/cpuminer.git

Contributions welcomed!  (GPL v2 license)

UPDATE:  This has largely been superceded by Con Kolivas's cgminer fork.  See cgminer's official forum thread for updates and details.


Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
slush
Legendary
*
Offline Offline

Activity: 1386
Merit: 1097



View Profile WWW
November 25, 2010, 02:14:17 AM
 #2

In the beginning, this is intended largely to demonstrate a 'getwork' miner.  It is written in straight C, with minimal dependencies (libcurl, libcrypto, jansson).

Cool, I like simplicity of your code. I want to try similar implementation in javascript. Partially because of curiosity and partialy because (inspired by hashcash) it can generate few hashes by fighting comments spam :-).

I just made few tests. In four javascript threads I get ~4khash/s, which is EXTREMELY slow. Probably because javascript is interpreted and without any JIT yet. Would be great if javascript supports GPU. Flash will support GPU soon, so we will see Wink.

sturle
Legendary
*
Offline Offline

Activity: 1437
Merit: 1002

https://bitmynt.no


View Profile WWW
November 25, 2010, 01:28:45 PM
 #3

In the beginning, this is intended largely to demonstrate a 'getwork' miner.  It is written in straight C, with minimal dependencies (libcurl, libcrypto, jansson).
Cool, I like simplicity of your code. I want to try similar implementation in javascript. Partially because of curiosity and partialy because (inspired by hashcash) it can generate few hashes by fighting comments spam :-).

I just made few tests. In four javascript threads I get ~4khash/s, which is EXTREMELY slow. Probably because javascript is interpreted and without any JIT yet. Would be great if javascript supports GPU. Flash will support GPU soon, so we will see Wink.
Is your JavaScript code available?

I wish the getwork RPC command could be allowed for non-authenticated users from other hosts.  It isn't revealing any secret information, is it?

Sjå https://bitmynt.no for veksling av bitcoin mot norske kroner.  Trygt, billig, raskt og enkelt sidan 2010.
I buy with EUR and other currencies at a fair market price when you want to sell.  See http://bitmynt.no/eurprice.pl
Warning: "Bitcoin" XT, Classic, Unlimited and the likes are scams. Don't use them, and don't listen to their shills.
wumpus
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1022

No Maps for These Territories


View Profile
November 25, 2010, 01:34:05 PM
 #4

Nice idea on the independent C miner.

On the JS one: Oh no, soon all kinds of websites will be sneakily generating bitcons on the background while you browse them, hogging your CPU even more Tongue

Bitcoin Core developer [PGP] Warning: For most, coin loss is a larger risk than coin theft. A disk can die any time. Regularly back up your wallet through FileBackup Wallet to an external storage or the (encrypted!) cloud. Use a separate offline wallet for storing larger amounts.
slush
Legendary
*
Offline Offline

Activity: 1386
Merit: 1097



View Profile WWW
November 25, 2010, 02:53:20 PM
 #5

Is your JavaScript code available?

I wish the getwork RPC command could be allowed for non-authenticated users from other hosts.  It isn't revealing any secret information, is it?

Will be available if I finish that. It is just for curiosity because it will be slow as hell. Also network overhead will be significant.

I expect simple PHP proxy will do good work for hiding credentials to client. something like yourdomain.com/getwork.php which call rpc to localhost and return json encoded data.

wumpus
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1022

No Maps for These Territories


View Profile
November 25, 2010, 02:59:26 PM
 #6

Will be available if I finish that. It is just for curiosity because it will be slow as hell. Also network overhead will be significant.
I believe that IE has cryptographic extensions that you can use from javascript. Maybe that will speed it up?

Bitcoin Core developer [PGP] Warning: For most, coin loss is a larger risk than coin theft. A disk can die any time. Regularly back up your wallet through FileBackup Wallet to an external storage or the (encrypted!) cloud. Use a separate offline wallet for storing larger amounts.
slush
Legendary
*
Offline Offline

Activity: 1386
Merit: 1097



View Profile WWW
November 25, 2010, 04:47:30 PM
 #7

I believe that IE has cryptographic extensions that you can use from javascript. Maybe that will speed it up?


 Do you have any link or reference? I found only 3rd party ActiveX component here http://www.chilkatsoft.com/js-sha512-hash.asp.

teknohog
Sr. Member
****
Offline Offline

Activity: 520
Merit: 253


555


View Profile WWW
November 26, 2010, 01:41:39 PM
 #8

Should I use a particular version of jansson? I installed it from git, and get the following compile error:

Code:
util.c: In function ‘json_rpc_call’:
util.c:133:2: warning: passing argument 2 of ‘json_loads’ makes integer from pointer without a cast
/usr/local/include/jansson.h:188:9: note: expected ‘size_t’ but argument is of type ‘struct json_error_t *’
util.c:133:2: error: too few arguments to function ‘json_loads’
/usr/local/include/jansson.h:188:9: note: declared here

world famous math art | masternodes are bad, mmmkay?
Every sha(sha(sha(sha()))), every ho-o-o-old, still shines
jgarzik (OP)
Legendary
*
Offline Offline

Activity: 1596
Merit: 1100


View Profile
November 26, 2010, 06:10:29 PM
 #9

Nice work.

But :
Quote
DBG: found zeroes in hash:
6c1e0d9af9b06eab5aae7fbe058760708c1c7869870142b91b9c0ae300000000
PROOF OF WORK FOUND?  submitting...
PROOF OF WORK RESULT: false (booooo)
[...]
DBG: found zeroes in hash:
c155613cbd70edad88bf56b06cbd788329a2a741b27ee78f25abdb2e00000000
PROOF OF WORK FOUND?  submitting...
PROOF OF WORK RESULT: false (booooo)

I don't know if this is a bug or not.
The miner has been compiled with cygwin, I don't know if it matters.

Not a bug.  The miner finds a hash with "several" zeroes in it, but then relies on bitcoin to do the full 256-bit hash < target value comparison.  It's normal that some hashes will be found by the CPU miner, then rejected by bitcoin.  We call those almost-solutions Smiley

Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
jgarzik (OP)
Legendary
*
Offline Offline

Activity: 1596
Merit: 1100


View Profile
November 26, 2010, 07:47:02 PM
 #10

FWIW, the default bitcoin miner also does this -- it just doesn't print out when it "finds some zeroes", only when a real proof of work is found.

Thus, my CPU miner always shows when it stops working on a solution, and starts working on a new solution.  Just giving you a bit more information on the whole process.

Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
jgarzik (OP)
Legendary
*
Offline Offline

Activity: 1596
Merit: 1100


View Profile
November 26, 2010, 09:32:51 PM
 #11

Attached is a Windows executable build with mingw32.  I'd be interested to know if it works.

run "minerd.exe --help" or "minerd.exe -h" to show command line options.

minerd.exe SHA-1 sum: 722fa3b956de3ed3438ed3294fe191f0d55c1514
minerd.exe MD5 sum: 9f75f8da7a5d02da1d45d46d4a032489

Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
jgarzik (OP)
Legendary
*
Offline Offline

Activity: 1596
Merit: 1100


View Profile
November 26, 2010, 09:45:54 PM
Last edit: November 26, 2010, 10:33:31 PM by jgarzik
 #12

Should I use a particular version of jansson? I installed it from git, and get the following compile error:

Code:
util.c: In function ‘json_rpc_call’:
util.c:133:2: warning: passing argument 2 of ‘json_loads’ makes integer from pointer without a cast
/usr/local/include/jansson.h:188:9: note: expected ‘size_t’ but argument is of type ‘struct json_error_t *’
util.c:133:2: error: too few arguments to function ‘json_loads’
/usr/local/include/jansson.h:188:9: note: declared here

It's been tested with jansson 1.2 and 1.3 release versions.

EDIT:  If you lack jansson, current cpuminer.git will build an in-tree version.  Thus, you may opt to fix the problem by... removing jansson from your system.

Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
satoshi
Founder
Sr. Member
*
Offline Offline

Activity: 364
Merit: 7248


View Profile
November 26, 2010, 10:02:41 PM
 #13

You should try it with tcatm's 4-way SSE2 SHA in sha256.cpp.  It compiles fine as a C file, just rename sha256.cpp to sha256.c.  I was able to get it to work in simple tests on Windows, but not when linked in with Bitcoin.  It may have a better chance of working as part of a C program instead of C++.

Currently it's only enabled in the Linux build, so if you get it to work you could make it available to Windows users.  It's about 100% speedup on AMD CPUs.
jgarzik (OP)
Legendary
*
Offline Offline

Activity: 1596
Merit: 1100


View Profile
November 26, 2010, 11:03:51 PM
 #14

You should try it with tcatm's 4-way SSE2 SHA in sha256.cpp.  It compiles fine as a C file, just rename sha256.cpp to sha256.c.  I was able to get it to work in simple tests on Windows, but not when linked in with Bitcoin.  It may have a better chance of working as part of a C program instead of C++.

I'll take a look.  VIA Padlock support may also be similarly easy to integrate.

Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
BitLex
Hero Member
*****
Offline Offline

Activity: 532
Merit: 505


View Profile
November 26, 2010, 11:27:55 PM
 #15

Quote
I'd be interested to see how well this works on Vista, XP, 7, ...
complaining about "libcurl-4.dll missing" (although it's there at c:\CPU-miner\usr\i686-pc-mingw32\sys-root\mingw\bin\) it won't even start on 64bit XP&7, 32bit XP,
am i missing something?

jgarzik (OP)
Legendary
*
Offline Offline

Activity: 1596
Merit: 1100


View Profile
November 27, 2010, 12:06:59 AM
 #16

Quote
I'd be interested to see how well this works on Vista, XP, 7, ...
complaining about "libcurl-4.dll missing" (although it's there at c:\CPU-miner\usr\i686-pc-mingw32\sys-root\mingw\bin\) it won't even start on 64bit XP&7, 32bit XP,
am i missing something?

Try adding c:\CPU-miner\usr\i686-pc-mingw32\sys-root\mingw\bin\ to your PATH, then run minerd.exe?

Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
slush
Legendary
*
Offline Offline

Activity: 1386
Merit: 1097



View Profile WWW
November 27, 2010, 12:08:44 AM
 #17

complaining about "libcurl-4.dll missing" (although it's there at c:\CPU-miner\usr\i686-pc-mingw32\sys-root\mingw\bin\) it won't even start on 64bit XP&7, 32bit XP,
am i missing something?

Same here (WinXP)

jgarzik (OP)
Legendary
*
Offline Offline

Activity: 1596
Merit: 1100


View Profile
November 27, 2010, 12:09:30 AM
 #18

You should try it with tcatm's 4-way SSE2 SHA in sha256.cpp.

Added.  Users may select this by enabling SSE2 instructions in their compiler during build, and then

Code:
$ minerd --algo=4way

will select the 4way implementation, rather than the default 'c' implementation.  Run "minerd --help" to make sure 4way is listed as an available option first; if not, you did not build with SSE2 enabled (-msse2, or many values of -march=xxx).

Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
jgarzik (OP)
Legendary
*
Offline Offline

Activity: 1596
Merit: 1100


View Profile
November 27, 2010, 12:11:18 AM
 #19

complaining about "libcurl-4.dll missing" (although it's there at c:\CPU-miner\usr\i686-pc-mingw32\sys-root\mingw\bin\) it won't even start on 64bit XP&7, 32bit XP,
am i missing something?

Same here (WinXP)

Clearly my installer-maker is having a problem  Sad   Will investigate (though probably tomorrow).

Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
jgarzik (OP)
Legendary
*
Offline Offline

Activity: 1596
Merit: 1100


View Profile
November 27, 2010, 12:32:04 AM
Last edit: November 27, 2010, 12:47:09 AM by jgarzik
 #20

Quote
I'd be interested to see how well this works on Vista, XP, 7, ...
complaining about "libcurl-4.dll missing" (although it's there at c:\CPU-miner\usr\i686-pc-mingw32\sys-root\mingw\bin\) it won't even start on 64bit XP&7, 32bit XP,
am i missing something?

Updated the installer at http://yyz.us/bitcoin/cpuminer-installer.zip

Does the problem still exist?

EDIT:  Here are the checksums for the latest Windows installer zipfile...
     Size: 1978933 bytes
     SHA1: fdea8a045db5e09b7441a4059fbdba186490e742  
     MD5: e60dbfb7c3b458c2a98e71cb295f9b7d  

Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
Pages: [1] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 »
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!