Bitcoin Forum
June 22, 2024, 09:27:48 PM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: {CurlyBrace}-First PHP WebMiner-a proof of concept[v0.4]  (Read 1511 times)
W-M (OP)
Full Member
***
Offline Offline

Activity: 210
Merit: 100

In Crypto we Trust.


View Profile
April 06, 2013, 08:57:53 PM
Last edit: April 07, 2013, 09:49:45 PM by W-M
 #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 PHP Hypertext Preprocessor Miner  (with a little bit of JavaScript as well)
(Disclaimer: This is a proof-of-concept. But it mines. For Real!)


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 asks the pool for a getblocktemplate reply.
-Client sends the returned block data to one or multiple server slaves, asking them to hash until they 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, to ensure that each server is looking at a different part of the possible hashes at one time.
-This continues on until a solution is found.
-Client submits solution back as a share to the pool. (this part might not be fully functional yet)


What still needs to be done?
-Support to increment the extra nonce (change the coinbase) when all 32int nonce values have been tried. (Right now the code is so slow that this never really happens before other parts die in one way or another, but its something to consider in the future.)
-Possibly change the way the final solution is padded together and submitted as a share (Might not work yet).
-Stop searching and load the next block when the current block has timed out. (Right now the script will continue searching on the current block until a solution has been found by it)
-Enforcing that the correct getblocktemplate and block version is used.
-Support for the optional parts of the getblocktemplate specification.
-Bugfixing. Lots of it.
-Possiblility implementing a scrypt algorithm as well(started, but currently disabled.)



Why  the need for a client webpage to operate the miner?
1. PHP is executed in a synchronious fashion, JavaScript on a web page is not. This allows parallellization(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, which I'm using right now) seems like a better option.


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

Alternatively, you can currently see the script working here. Note that you shouldn't keep this version running for a long time as it doesn't use your own computing power but a few free webservers. I don't want to choke them. ;-)



Why do you post this here in such an early stage of development?
Basically I would love it if some people took the time to look through my code, and tell me if my calculations of the bitcoin hashing is correct. The main reason I started this project was to learn the inner workings of the bitcoin, so this would mean a lot for me.

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'd like to donate, you can thow a few coins in my direction here: 1MUZQsCSifF27XX98W13JLz6E9YaU3mVqG .


Have a great day!

~W-M

SatoshiCarnival.co ♢ Refreshing ♥ Fair ♧ Bitcoin Casino

WMCode ~ Web Development ~ Design
Xenland
Legendary
*
Offline Offline

Activity: 980
Merit: 1003


I'm not just any shaman, I'm a Sha256man


View Profile
April 07, 2013, 06:22:02 AM
 #2

I haven't tested this out or actually looked at any of the source code links, but I must say that although this might not get popularity for usage I think if its legit, seing a PHP / JS miner implementation would help increase the "learning" curve we all have.
W-M (OP)
Full Member
***
Offline Offline

Activity: 210
Merit: 100

In Crypto we Trust.


View Profile
April 07, 2013, 07:47:54 PM
 #3

I haven't tested this out or actually looked at any of the source code links, but I must say that although this might not get popularity for usage I think if its legit, seing a PHP / JS miner implementation would help increase the "learning" curve we all have.
Hey there, Xenland, thanks a lot for your reply! Yes, this might be somewhat of a 'niche' application. I am mainly building it to get some better understanding about Bitcoin myself; It probably doesn't have practical purposes because it is extremely slow. That being said, up till now I've only tried it on free web servers. Paid web hosts, virtual machines or dedicated servers might perform much better, maybe even good enough to make profit. I didn't have the chance to try this out up till now.

Performance right now is somewhere between 2-4Megahash/second

What do you mean with " if it's legit"? The code works right now. The only thing that probably doesn't work is the submission of shares. It has produced a few shares before, but this was before the submission part of the script was in place. This application takes almost forever to come up with a share, so I have not been able to try out if the current implementation is correct.(It might be that I still need to change the answer over from big-endian to little-endian or something, before the pool will accept it).

It would be great if this can be some kind of example for other people to learn how to create their own miming applications. Altough for now the code is still very messy  Tongue

~W-M

SatoshiCarnival.co ♢ Refreshing ♥ Fair ♧ Bitcoin Casino

WMCode ~ Web Development ~ Design
Xenland
Legendary
*
Offline Offline

Activity: 980
Merit: 1003


I'm not just any shaman, I'm a Sha256man


View Profile
April 07, 2013, 08:28:24 PM
 #4

What do you mean with " if it's legit"? The code works right now.

No offence intended, just poking at the author thats all.... hehe I'm checking out the code now.
W-M (OP)
Full Member
***
Offline Offline

Activity: 210
Merit: 100

In Crypto we Trust.


View Profile
April 07, 2013, 08:28:50 PM
 #5

I get an error


Hmm... it seems that I forgot to upload the latest version, that fixes that bug.

Try again now  Wink.

SatoshiCarnival.co ♢ Refreshing ♥ Fair ♧ Bitcoin Casino

WMCode ~ Web Development ~ Design
Xenland
Legendary
*
Offline Offline

Activity: 980
Merit: 1003


I'm not just any shaman, I'm a Sha256man


View Profile
April 07, 2013, 08:32:39 PM
 #6

I'm doing some "code" poking around, I was curious of where you got "data" from and why is this line static? Its probably because of "testing" everything is usually static until it works so I can understand that but I want to make sure this data value isn't anything significant other than that reason?

Also note I've never made my own miner before I just understand Bitcoin client interworkings so this is slightly new to me. Cheers!

Code:
data:{json: { "startingnonce": startingnonce, "error": null, "result": {   "coinbasetxn": {     "data": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1302955d0f00456c6967697573005047dc66085fffffffff02fff1052a010000001976a9144ebeb1cd26d6227635828d60d3e0ed7d0da248fb88ac01000000000000001976a9147c866aee1fa2f3b3d5effad576df3dbf1f07485588ac00000000"   },   "previousblockhash": "000000004d424dec1c660a68456b8271d09628a80cc62583e5904f5894a2483c",   "transactions": {0:"a", 1:"b", 2:"c", 3:"d", 4:"e", 5:"f"},   "expires": 120,   "target": "000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",   "longpollid": "some gibberish",   "height": 23957,   "version": 2,   "curtime": 1346886758,   "mutable": ["coinbase/append"],   "bits": "ffff001d" }, "id": 0} },

W-M (OP)
Full Member
***
Offline Offline

Activity: 210
Merit: 100

In Crypto we Trust.


View Profile
April 07, 2013, 09:54:38 PM
 #7



Ok so we know this isn't tested well


What browser are you using? Thus far I have only ran it in FireFox(20.0, on Windows 7). Don't worry, I'll sit down and fix browser compatibility issues during the next few days (But now I first need some sleep...)

I'm doing some "code" poking around, I was curious of where you got "data" from and why is this line static? Its probably because of "testing" everything is usually static until it works so I can understand that but I want to make sure this data value isn't anything significant other than that reason?

Also note I've never made my own miner before I just understand Bitcoin client interworkings so this is slightly new to me. Cheers!

Code:
data:{json: { "startingnonce": startingnonce, "error": null, "result": {   "coinbasetxn": {     "data": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1302955d0f00456c6967697573005047dc66085fffffffff02fff1052a010000001976a9144ebeb1cd26d6227635828d60d3e0ed7d0da248fb88ac01000000000000001976a9147c866aee1fa2f3b3d5effad576df3dbf1f07485588ac00000000"   },   "previousblockhash": "000000004d424dec1c660a68456b8271d09628a80cc62583e5904f5894a2483c",   "transactions": {0:"a", 1:"b", 2:"c", 3:"d", 4:"e", 5:"f"},   "expires": 120,   "target": "000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",   "longpollid": "some gibberish",   "height": 23957,   "version": 2,   "curtime": 1346886758,   "mutable": ["coinbase/append"],   "bits": "ffff001d" }, "id": 0} },

This is testing data, for the most part copied directly from the getblocktemplate wiki page. It doesn't mean anything else.

It seems the URL to the source was also linking to an older version. Here you can see the newer version which has pool communication implemented.
(also, link in the first post is now updated to link to version 0.4 instead of 0.1)

Good night, I'll talk to you tomorrow.

~W-M

SatoshiCarnival.co ♢ Refreshing ♥ Fair ♧ Bitcoin Casino

WMCode ~ Web Development ~ Design
dimitry-js
Newbie
*
Offline Offline

Activity: 18
Merit: 0


View Profile
June 30, 2013, 08:31:16 PM
 #8

Running PHP bitcoin miner does not make much sense unless you have a dedicated server since the shared hosting services are very sensitive to your CPU usage. Therefore, you would not be able to occupy their servers for this purpose.
TheRandomGuy
Full Member
***
Offline Offline

Activity: 162
Merit: 100


View Profile
July 02, 2013, 01:20:10 PM
 #9

So.

I could make a bunch of accounts on free webhosts and than upload this?


Also, could you make a git repo for this? :3

BTC: 1wbGAAabrsu8pjVXWUQvjUUhe18e721K2
FAUCET ROTATOR SCRIPT
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!