Live data from Hacker News

Show HN: SHAllenge – Compete to get the lowest hash

shallenge.quirino.net

41–50 of 136 posts

Re: Show HN: SHAllenge – Compete to get the lowest hash

#41
post #18
post #16

Earlier quoted context omitted.

The top competitors are very likely using GPUs, I guess that would make this cost much much lower...

At least I'm not (second place currently), I'm using a single threaded rust program that chatgpt wrote for me. I'm getting 10-15 million hashes per second. But seletskiy is, as you can see in his nonce which tells us that he uses an RTX4090 and has 18 Giga Hashes per second. I'm really curious how he wrote that program, as I have a Rx 7900 XTX and would love to use it for this competition haha

Hey. It's nothing very fancy. About 150 lines of C/CUDA code with no deps, including args parsing and logging.

The code runs at steady rate of 18.00-18.40 GH/s at cloud GPU. In fact it's not hashes-per-second, but actually messages-per-second checked.

It launches a 64⁶ kernels in a loop, where each launch checks first two bytes of the SHA of a message concatenated with unique 6-byte nonce per kernel + 6-byte incremental nonce for each launch. There is only one block, so SHA algorithm is heavily trimmed. Also, most of the message is hard-coded, so pre-calculated SHA state is used; it's 10 loops less than needed to encode whole block. Since we only 2 bytes of the hash to check, last two loops also unrolled by hand to exclude parts that we wouldn't need. All code also in big-endian since SHA is, so message hardcoded in big-endian as well.

Base64-encoding is pretty time-consuming, so I've optimized it a bit by reordering the alphabet to be in ASCII-ascending order. I've got to the point where single binary-op optimization can earn 100-500 MH/s speed-up, and I don't really know what else here is remaining.

I don't have RTX4090, so instead I just rented 4090 GPU to run code on. It's less than $0.3 per hour.

I've tried GPT-4 to get some directions for optimization, but every single proposal was useless or straight wrong.

I by no means a C/GPU programmer, so probably it can be optimized much more by someone who more knowledgeable of CUDA.

GPU's are ridiculously fast. It freaks me out that I can compute >18,000,000,000 non-trivial function calls per second.

Anyways, if you want to chat, my e-mail is in the profile.

Re: Show HN: SHAllenge – Compete to get the lowest hash

#42
post #40
post #25

Earlier quoted context omitted.

I'm also yak shaving currently, as I'm using NixOS... which means spending more time looking for the correct packages and creating environments.

FWIW I got it working with rust and opencl, most of it is written by chatgpt as I have no clue about opencl. GPU usage is only 50-60% and I get 100MH/s. With hashcat and opencl I could get 12GH/s but I couldn't find a way to use hashcat for this use case.

I've parked CUDA for now, I don't understand it enough to care to fix the tooling.

Got an optimised C++ version with no deps averaging about ~24 MH/s on an i7-11800H.

I've got 9 zeros; if I get a result that ranks top 10 I think I'll submit and call it a day.

Re: Show HN: SHAllenge – Compete to get the lowest hash

#43
post #39

Earlier quoted context omitted.

Isn't the reason more about limiting currency. Most of the crypto bros all hate the money printers. The fact that faster hashers will come about just adds some natural competition, but it's still about limiting money supplies.

The hashing is about consensus. It's related how a low hash stands as proof of computational power, you can't just fake it. The "adding more zeros" is done automatically, according to an algorithm, so that the time between blocks is more or less the same. There's this incredible MIT course about all of this, it's where I got the idea for the site from: https://youtube.com/playlist?list=PLUl4u3cNGP61KHzhg3JIJdK08...

Thanks for the playlist! I've already been going through the later videos.

Re: Show HN: SHAllenge – Compete to get the lowest hash

#44
post #42
post #40

Earlier quoted context omitted.

FWIW I got it working with rust and opencl, most of it is written by chatgpt as I have no clue about opencl. GPU usage is only 50-60% and I get 100MH/s. With hashcat and opencl I could get 12GH/s but I couldn't find a way to use hashcat for this use case.

I've parked CUDA for now, I don't understand it enough to care to fix the tooling. Got an optimised C++ version with no deps averaging about ~24 MH/s on an i7-11800H. I've got 9 zeros; if I get a result that ranks top 10 I think I'll submit and call it a day.

Wow 24MH/s on an i7 with 8 cores sounds really good!

I don't know how I got it working, but I'm now at 3GH/s with my OpenCL implementation. I basically converted 90% of my rust logic to opencl and now my GPU is at 100% usage and I also needed to switch to a tty, as my window manager became unresponsive haha

I'm kind of glad about this HN post, as I had absolutely no clue about how sha256 and opencl worked before this challenge.

Thanks @quirino

Re: Show HN: SHAllenge – Compete to get the lowest hash

#45
post #44
post #42

Earlier quoted context omitted.

I've parked CUDA for now, I don't understand it enough to care to fix the tooling. Got an optimised C++ version with no deps averaging about ~24 MH/s on an i7-11800H. I've got 9 zeros; if I get a result that ranks top 10 I think I'll submit and call it a day.

Wow 24MH/s on an i7 with 8 cores sounds really good! I don't know how I got it working, but I'm now at 3GH/s with my OpenCL implementation. I basically converted 90% of my rust logic to opencl and now my GPU is at 100% usage and I also needed to switch to a tty, as my window manager became unresponsive haha I'm kind of glad about this HN post, as I had absolutely no clue about how sha256 and opencl worked before this…

I'm glad you had some fun! This experiment went about as well as I could hope!

If anyone's curious, I'm getting 4.5MH/s single-threaded and 12.2MH/s multi-threaded on a slightly old i7 with 4 cores.

It's my own C++ implementation, which I've made about 20% faster than the fastest one I found online (Zig/stdlib, also tried Go/stdlib, C++/cgminer, rust/ring, C++/VanitySearch and Python/stdlib).

I think it might be faster just because I was able to skip some steps, since all inputs are short and of the same length.

I've just finished testing 10^12 inputs. I think I'll stop with 10 zeroes, which is very likely to happen in the next couple of days, according to my calculations. I might revisit it later to learn some GPU programming.

Re: Show HN: SHAllenge – Compete to get the lowest hash

#46
post #18

Earlier quoted context omitted.

At least I'm not (second place currently), I'm using a single threaded rust program that chatgpt wrote for me. I'm getting 10-15 million hashes per second. But seletskiy is, as you can see in his nonce which tells us that he uses an RTX4090 and has 18 Giga Hashes per second. I'm really curious how he wrote that program, as I have a Rx 7900 XTX and would love to use it for this competition haha

Hey. It's nothing very fancy. About 150 lines of C/CUDA code with no deps, including args parsing and logging. The code runs at steady rate of 18.00-18.40 GH/s at cloud GPU. In fact it's not hashes-per-second, but actually messages-per-second checked. It launches a 64⁶ kernels in a loop, where each launch checks first two bytes of the SHA of a message concatenated with unique 6-byte nonce per kernel + 6-byte incremen…

Thanks, I sent you an e-mail, you might need to check in spam folder, as gmail doesn't like my mail server.

Re: Show HN: SHAllenge – Compete to get the lowest hash

#47
post #45
post #44

Earlier quoted context omitted.

Wow 24MH/s on an i7 with 8 cores sounds really good! I don't know how I got it working, but I'm now at 3GH/s with my OpenCL implementation. I basically converted 90% of my rust logic to opencl and now my GPU is at 100% usage and I also needed to switch to a tty, as my window manager became unresponsive haha I'm kind of glad about this HN post, as I had absolutely no clue about how sha256 and opencl worked before this…

I'm glad you had some fun! This experiment went about as well as I could hope! If anyone's curious, I'm getting 4.5MH/s single-threaded and 12.2MH/s multi-threaded on a slightly old i7 with 4 cores. It's my own C++ implementation, which I've made about 20% faster than the fastest one I found online (Zig/stdlib, also tried Go/stdlib, C++/cgminer, rust/ring, C++/VanitySearch and Python/stdlib). I think it might be fast…

Very cool!

But same, I also was able to skip some steps as I can make some assumptions about the input as its fixed in length and doesn't need padding.

I got lucky and found a hash with 12 zeroes in 60s with my OpenCL implementation, and now I got my second spot back.

GPUs are so crazy

Re: Show HN: SHAllenge – Compete to get the lowest hash

#48
post #4

I like that you linked to a javascript miner. Makes it really easy to try instead of needing to write up some code. Design/colour scheme is nice too.

Thank you! Curiously most of the code for that JS miner was written on my phone, with the help of ChatGPT. I didn't have my laptop with me and was curious how fast a phone browser would be able to mine.

Coding and testing JS with the help of ChatGPT is several multitasking levels above what I’d be willing to even try on a phone. Android, I assume? Big screen? BT keyboard even?

Re: Show HN: SHAllenge – Compete to get the lowest hash

#49
post #4

Earlier quoted context omitted.

Thank you! Curiously most of the code for that JS miner was written on my phone, with the help of ChatGPT. I didn't have my laptop with me and was curious how fast a phone browser would be able to mine.

Coding and testing JS with the help of ChatGPT is several multitasking levels above what I’d be willing to even try on a phone. Android, I assume? Big screen? BT keyboard even?

It was actually much easier than I expected. Just asked for it as a single HTML page, copied the output to a file and opened it on Chrome. Did very few adjustments.

Re: Show HN: SHAllenge – Compete to get the lowest hash

#50

Earlier quoted context omitted.

I guess either my computer or my code is really bad! I only got a mid-8 0s with multiple hours.

How many hashes does your code go through per second? I just tried your HN username, and it took me these times: 19 seconds for 7 0s - nonce: 293576344 28 seconds for 8 0s - nonce: 436316829

Curious. I tried with a C program that ChatGPT spat out using 12 threads of my CPU and I get the 8 zeroes almost instantly. It calculates 1 billion in about 13 seconds, apparently.

Start time: 1718742386

1718742387 SHA-256 hash of "NAHWheatCracker/486005487" is: 00000000cbed8e14c5e52b0c9bef443f017564aa6870da37f85ec92dd01b544d

1718742394 SHA-256 hash of "NAHWheatCracker/993155254" is: 0000000031fadb4805db8036ec66d872bdd9f04a507e0bbfea9f60d1d00b86f2

1718742395 SHA-256 hash of "NAHWheatCracker/436316829" is: 00000000e20d059e8a7dc687b85bd6b33e891f7d4b27e98aaf0c991d0264066e

End time: 1718742403

EDIT: To be clear, I'm not submitting anything to the leaderboard as I appreciate the spirit of the challenge is writing your own code. I'm just having some fun.

EDIT 2: Added some better timing. Interestingly, I modified it to use 64 bit integers and it was dramatically slower. Like, orders of magnitude slower.

Post reply on HN