Title: Testing my own hashing code Post by: Michael Rolle on May 22, 2019, 02:20:13 AM I'm writing my own software to do the double SHA-256 hashing on my Windows 10 system.
I want to test it on real data, i.e., testnet. My code can be called from C++, Python, or run as an executable from a command line. It will take a message header as an input, and try to find a hash that satisfies the level of difficulty. I expect that my code will be invoked with many such headers before it succeeds, even on testnet. If I understand it correctly, the nodes on the network each receive different versions of the current block (with the extra nonce varying). So I'm looking for a program that will get current data from the network, feed the message header to my program, try again if not successful, and post the success when successful. I'd like to see that eventually, I will have successfully mined something. Alternatively, I'd like to access an older block on the network to see if I can duplicate the successful hashing of that block, using the version of the message that was actually solved by the miner. That way, I know that my program should succeed. Can I get access to test cases which have a known result? Is there a way I can estimate how many hashing attempt it would take, on average, to solve a hashing problem? I know this will vary over time because of the adjustments to the level of difficulty, but I'd be interested in a ball-park answer for the testnet. If the answer is in days (given the hashing speed of my software), then I might want to abandon attempts to successfully mine with live data and try some other approach. Title: Re: Testing my own hashing code Post by: Jean_Luc on May 22, 2019, 08:24:44 AM Is there a way I can estimate how many hashing attempt it would take, on average, to solve a hashing problem? A hash function can be seen as a pseudo number generator. In the case of a 256 bit hash, the hash will produce a random number uniformly distributed in the range [0,2^256-1]. So depending on the minimum hash value you want you can compute the actual difficulty (from the number of acceptable hash) and deduce the probabilty to find a match after n tries using Bernouilli. 1-(1-number of acceptable hash/2^256)^n The BTC difficulty (displayed on www.blockchain.com) is computed as (actual difficulty/2^32). Title: Re: Testing my own hashing code Post by: DaCryptoRaccoon on May 22, 2019, 11:08:06 AM I'm writing my own software to do the double SHA-256 hashing on my Windows 10 system. I want to test it on real data, i.e., testnet. My code can be called from C++, Python, or run as an executable from a command line. It will take a message header as an input, and try to find a hash that satisfies the level of difficulty. I expect that my code will be invoked with many such headers before it succeeds, even on testnet. If I understand it correctly, the nodes on the network each receive different versions of the current block (with the extra nonce varying). So I'm looking for a program that will get current data from the network, feed the message header to my program, try again if not successful, and post the success when successful. I'd like to see that eventually, I will have successfully mined something. Alternatively, I'd like to access an older block on the network to see if I can duplicate the successful hashing of that block, using the version of the message that was actually solved by the miner. That way, I know that my program should succeed. Can I get access to test cases which have a known result? Is there a way I can estimate how many hashing attempt it would take, on average, to solve a hashing problem? I know this will vary over time because of the adjustments to the level of difficulty, but I'd be interested in a ball-park answer for the testnet. If the answer is in days (given the hashing speed of my software), then I might want to abandon attempts to successfully mine with live data and try some other approach. Here are the first 50 nonce values for bitcoin. There is no way to know exactly how long hashing would take it's all down to the numbers. Code: 1639830024 Title: How does a mining rig communicate? Post by: Michael Rolle on May 25, 2019, 09:05:59 PM A program like Bitcoin Core assumes there's an external rig somewhere, and so there must be some sort of communications protocol, by which the app (Bitcoin Core) sends blocks and receives hash results.
I haven't been able to find any reference online about any protocols for this, but I'm sure there must be a standard that the rig manufacturers follow. Can someone please point me to this standard. This way, I can write some software that will follow this standard and then employ my own hashing code. Title: Re: How does a mining rig communicate? Post by: odolvlobo on May 25, 2019, 11:14:10 PM A program like Bitcoin Core assumes there's an external rig somewhere, and so there must be some sort of communications protocol, by which the app (Bitcoin Core) sends blocks and receives hash results. I haven't been able to find any reference online about any protocols for this, but I'm sure there must be a standard that the rig manufacturers follow. I don't understand what you wrote. I think your understanding and assumptions may be off. Here is the code in Bitcoin Core that computes a SHA-256 hash: https://github.com/bitcoin/bitcoin/blob/master/src/crypto/sha256.cpp Here is the SHA-256 standard: https://csrc.nist.gov/publications/detail/fips/180/4/final Here is some documentation on the Bitcoin message protocol: https://en.bitcoin.it/wiki/Protocol_documentation |