Navigation

Friday, August 29, 2014

Uploading Old Projects - Part 2

Project Ates

C# (.Net/Mono) Bitcoin CPU/GPU Alternative Mining Program


Part 2 of this series is for a "newer" old project called "Ates". I googled a four letter word to use as a project name starting with the letter "A" and this is what I got. It has nothing to do with Bitcoin or mining, but oh well.


This home project started around summer 2013 when Bitcoin was starting to get pretty popular. I actually heard about Bitcoin back in 2010 but at the time I thought to myself "this will never go anywhere". Oh how I was so wrong. When I started investigating more into Bitcoin and this whole thing about mining I got instantly hooked. It was such an interesting idea, users "mine" coins by computing a hash algorithm to give a certain output. 

I started with the popular programs available like CGMiner and various wiki pages to figure out exactly how mining worked. It was very difficult to find this information. There were pieces everywhere but never in one single location. In my attempt to actually understand how it works I started creating my own Bitcoin miner. I started with CPU single threading, then moved to parallel threads. This was a huge learning curve for me as I am a electrical engineer that mostly does hardware with a little software here and there. I then dove into OpenCL to work on my GPU. By the time this was all done ASICs starting rolling in that instantly made GPU mining obsolete.

I didn't want to try and get an ASIC, too many risks with pre-payment and sketchy companies. Instead I had a thought. Is there a better way to solve the Bitcoin hash, which is just a double SHA256 hash of the block header. Could a pattern be found? Most likely not, the SHA256 hash algorithm is meant to be as random as it gets, hence why it's used everywhere. I was still up for the challenge!

What I needed was DATA and a whole crap load of it. With enough data, perhaps there's a pattern in the sense that one could "look" at a block header and determine if any of the 2^32 nonce values would give a result of greater then difficulty 1.

I starred at this for a very long time to figure out how I should approach this and where a possible pattern can be found. This is what I call a "visual hash" that I created for block height 267593. It shows each step of the double hash procedure.



My fist step was to tweak my Bitcoin miner to output the oh so precious data I needed. For every 2^32 nonce values attempted the program will output the lowest result (the smallest 256bit value from the resultant hash) when a greater then difficulty 1 was achieved. That would be deemed "true" and "false" for less then difficulty 1.



I would then take this data and process it via RapidMiner. In RapidMiner I would take the block header and split it into 32 bit chunks and call these my X1[] dimensions and use the hash result as my X2[] dimensions. Now to plot >11 dimensions is a bit tricky, so I applied some dimension reduction methods (I tried a whole bunch of different methods to have good variance). In the end I got a X1 vs X2 graph. "One" would be a block header that had a nonce give a greater then 1 difficulty and a "Zero" would not.


So do you see the pattern? Yeah I didn't either. 

I played around with this for another month or two, trying everything I knew or could quickly learn, I am NO expert in machine learning/pattern recognition. I was learning all I can as fast as I can all while accumulating more and more data. I tried different machine learning algorithms, I played with the data, but I got nothing. 

At one point I thought I was so clever (fool I was) and found a magic algorithm, I called it "Baz Algo" which was just a version of K-NN. I ran a bunch of validation test but my results were, you guessed it, RANDOM.

At this point 2nd and 3rd generation ASICs were on the market just destroying the difficulty level. My day-job was getting pretty busy with some very important projects and so required all my brain power. This project then died a slow death.

Moral of the story? Random is random, I'm no Rain Man.

I will say though that I learned a lot of new skills! I learned parallel programming, OpenCL, Bitcoin mining, machine learning algorithms, GPU architecture, and much more. All in all I actually had a lot of fun doing this project. Maybe one day I will re-visit.

I decided to make this project open source. Maybe someone else out there will have better luck.

https://github.com/Mr-EE/Ates

No comments:

Post a Comment