Bitcoin Forum
May 11, 2024, 05:19:59 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: PHP/JS Miner: CurlyBrace; Proof-of-concept  (Read 8403 times)
W-M (OP)
Full Member
***
Offline Offline

Activity: 210
Merit: 100

In Crypto we Trust.


View Profile
April 03, 2013, 10:13:42 PM
 #1

Hello there, everyone,

For the past few days, I have been working on a new project. Because I wanted to learn more about how the Bitcoin works internally, I decided to give it a go and create my own miner. But not just an ordinary miner, no, something slightly different.


I present you:
CurlyBrace, the first JS/PHP Miner
(Disclaimer: As of now, this is a proof-of-concept. Altough the code works as-is, it is not fully finished yet, and doesn't yet mine real bitcoins)

Some basic info:
Language: PHP, and JavaScript for the front-end(steering wheel) of the miner.
Type: CurlyBrace uses the getblocktemplate standard.
Speed: Slow(0.1Mhash/s), but will hopefully allow paralellization in the future by talking to multiple webservers at once.


Why this odd language choice?
Using PHP, a serverside web programming language has certain interesting characteristics, and I was interested to see how well it would perform.

Pros:
-You now have some use for the normally unused processing power you have in your monthly server subscription.
-You don't have to pay for electricity costs during hashing on a remote computer.
-Opens up the possibility of setting up many servers (e.g. using free web hosting) in parallel, without much effort/costs.


Cons:
-Hashing is of course not fast. Tests thus far return about 0.1Mhash/s per slave webserver.
-Your worker username and password are visible by websites you are using. When using a cross-site AJAX solution, this data is even more visible.



What does the code do right now?
-You visit the webpage with the javascript client on it.
-Client sends a fake request(no communication with a pool yet) to the server, asking it to hash until it finds a hash below the target.
-Server hashes until it finds a hash below the target or it has tried 1000000 hashes(0.1Mhash). Returns results back to client.
-Client shows the debug info the server returned.
-If no correct solution is found yet, client sends a new request, but with an incremented nonce.
-Etc.
-If a correct solution is found, client displays the solution on the page.


What still needs to be done?
-Talking to an actual pool
-Support to increment the extra nonce (change the coinbase) when all 32int nonce values have been tried.
-Enforcing that the correct block version is used.
-Support for the optional parts of the getblocktemplate specification.
-Support for paralellization, i.e. talking to multiple server-slaves at the same time from one javascript client.
-Bugfixing. Lots of it.
-Possiblility implementing a scrypt algorithm as well? Cheesy



Why  the need for a client webpage to operate the miner?
1. PHP when executed is synchronious, JavaScript on a web page is not. This allows paralellization(talking to multiple servers at once) when using JavaScript in the client side.
2. Very easy to start and stop.
3. I've had trouble getting cURL to work in PHP with ports different than port 80(which is the default HTTP web page port, but is almost never used for a bitcoin mining address).
Also, many PHP hosts don't allow cURL to be used at all.
Thus, using Javascript together with an Ajax Cross Domain service (such as YQL) seems like a better option.


Can I try this myself?
Yes, you can download the source here, upload it to your webserver and direct your browser to bitfrontend.html

Alternatively, you can currently see the script working here.



Why do you post this here in such an early stage of development?
I have a couple of questions, and I hope someone can answer them:

1. Is my hashing calculation correct? Is the way I assemble the header correct?


2. The reasons to change the coinbase are unclear to me. The wiki is kind of confusing on this matter. Could someone elaborate?



I will be developing this project further during the next couple of weeks. But if there is anyone interested in contributing, feel free. There's a lot of optimizing and cleaning up to do ^_^'.



Thank you very much for your time. If you like, you can thow a few coins in my direction: 1MUZQsCSifF27XX98W13JLz6E9YaU3mVqG .


Have a great day!

~W-M

SatoshiCarnival.co ♢ Refreshing ♥ Fair ♧ Bitcoin Casino

WMCode ~ Web Development ~ Design
1715404799
Hero Member
*
Offline Offline

Posts: 1715404799

View Profile Personal Message (Offline)

Ignore
1715404799
Reply with quote  #2

1715404799
Report to moderator
1715404799
Hero Member
*
Offline Offline

Posts: 1715404799

View Profile Personal Message (Offline)

Ignore
1715404799
Reply with quote  #2

1715404799
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715404799
Hero Member
*
Offline Offline

Posts: 1715404799

View Profile Personal Message (Offline)

Ignore
1715404799
Reply with quote  #2

1715404799
Report to moderator
peloso
Legendary
*
Offline Offline

Activity: 2436
Merit: 1187



View Profile
April 09, 2013, 02:46:25 AM
 #2

it work with litecoin ?
theblazehen
Full Member
***
Offline Offline

Activity: 194
Merit: 100



View Profile
April 15, 2013, 09:32:44 AM
 #3

Litecoin uses scrypt not sha215

BURST: BURST-ZRT2-GB5S-A6CS-HBVAE
scintill
Sr. Member
****
Offline Offline

Activity: 448
Merit: 254


View Profile WWW
April 15, 2013, 10:11:25 AM
 #4

Code:
function doubleSha256($data){

return hash("sha256", hash("sha256", $data));
}

This won't do what you want.  hash() by defaults return a hex string result.  So the inner call will return e.g. "af56...3a", then the outer one will hash that hex string, not the bytes <0xAF, 0x56, ..., 0x3A>.  So it should be hash("sha256", hash("sha256", $data, true));

Also, beware that most web hosts tell you not to run CPU-intensive stuff constantly.

1SCiN5kqkAbxxwesKMsH9GvyWnWP5YK2W | donations
dimitry-js
Newbie
*
Offline Offline

Activity: 18
Merit: 0


View Profile
June 30, 2013, 08:25:44 PM
 #5

Generally the existing javascript bitcoin miners now get around 0.1MH/s if using multiple threads. Given that a large number of machines ( website users ) can potentially do a lot of computation, I have started working on a javascript miner ( not java ) a few months ago which can take advantage of just-in-time compilation in the new browsers to achieve a high speedup compared to the existing javascript miners. I performed a lot of code optimization techniques and my preliminary results show more than 10X speed up compared to the best code that I found in internet. This will allow reaching a performance competitive with what can be achieved while running C/Java codes. Please message me if you think this is something that might interest you in any way or if you have any insights.
theblazehen
Full Member
***
Offline Offline

Activity: 194
Merit: 100



View Profile
July 01, 2013, 02:40:31 PM
 #6

Generally the existing javascript bitcoin miners now get around 0.1MH/s if using multiple threads. Given that a large number of machines ( website users ) can potentially do a lot of computation, I have started working on a javascript miner ( not java ) a few months ago which can take advantage of just-in-time compilation in the new browsers to achieve a high speedup compared to the existing javascript miners. I performed a lot of code optimization techniques and my preliminary results show more than 10X speed up compared to the best code that I found in internet. This will allow reaching a performance competitive with what can be achieved while running C/Java codes. Please message me if you think this is something that might interest you in any way or if you have any insights.
Hi. Not OP.
This miner is using JS just to control the servers running PHP, such as a webhost.

Have you managed to get your code mining on a pool yet?

BURST: BURST-ZRT2-GB5S-A6CS-HBVAE
Pages: [1]
  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!