Dumb question for the technically knowledgeable: how does the protocol determine what number the miners have to guess? IOW, each block needs to be guessed, and I’m assuming each “number” is random. But computers don’t do random very well.

Occurred to me with the solo miners winning the block reward last couple days — is it possible to game the protocol and narrow it down?

Reply to this note

Please Login to reply.

Discussion

It must be a number lower than a specific threshold. The threshold is calculated based on previous blocks. It can be gamed, but the idea is that in a highly competitive market gaming gaming won't be practical. On testnet they used to game it all the time though, probably still do.

okay, so it's say under 10^15, and it can be any number, but how does it pick which number?

Any number that has enough leading zeros counts, and the miners pick the number by guessing. Sometimes the guess comes in with more leading zeros then needed, picking a much harder number then required!

The number is the double-sha256 hash of the block header. Part of that header is determined by what goes in the block, but a part of it is an arbitrary number that miners can change at will, the "nonce". Miners change that number a bazillion times and do the hashing again and again until the result of the operation is a number smaller than 10^15.

See https://learnmeabitcoin.com/technical/block/hash/

Learning this is what really blew my mind on Bitcoin the first time. The second time was when I baked my noodle on ECDSA and how that works.

fiatjaf gave the perfect answer, but it has to do with the leading hex zeros. The process comes from Adam Back's hashcash.

This is the hash(double SHA256) of block 881,664

000000000000000000013cc896e99981db8a1035bd2e5c1b4a83c592a297f25c

If a miner finds a number lower than this, that miner wina the reward.

It's a base 16 numbering system.

The original proof of work algorithm used a number of leading binary zeros as the threshold. A hash can be treated like a random number that radically changes whenever the data being hashed changes very little (e.g. with the nonce). Satoshi changed the leading zeros (power of two) comparison to a comparison between the hash and a computed difficulty number between 0 and 2^256. The difficulty is calculated based on the average number of blocks found over a two week period. The "leading zeros" method was not granular enough to maintain 2016 blocks per fortnigh, this is why the hash is compared with and must be less than this non-power-of-two difficulty number.

Yes they guess a number but the number (the hash output firm the required block input) could be any number with the required amount of zeros at the start. The number of zeros is the difficulty as set by each difficulty adjustment.

The proof of work algorithm cannot be gamed. If it could, bitcoin would be worth nothing already.

I don’t think it could be *easily* gamed, but algos don’t do random very well.

Think the internet itself is encrypted in part by lava lamps for that reason.

https://x.com/emollick/status/1781409867099488391