Fahrenheit Is Stupid, Bitcoin Is Not.

How Bitcoin mining really works, why we should all switch to Celsius, a new season of F1 is among us, and ETH Denver is on the horizon.

Yo. Welcome to Week 7. A conference next week has been keeping me busy, but I think you’ll like this one.

How does Bitcoin Mining ~Really~ Work

Ok ok I know, I’ve talked about Bitcoin a lot already. But recently I’ve been trying to get more into the “guts”, to understand how it really works. Today we’re diving into mining again, but looking at it from a bit more of a technical side, but hopefully still in a way thats understandible.

So, what is a block? A block in a blockchain consists of (for simplicity) 4 things.

  • The hash of the previous block

  • The group of transactions in the block

  • The block number

  • A nonce

Lets talk about hashing, as its kinda an essential step. A hashing algorithm is an algorithm that takes an arbitrary (and potentially infinite) input, and returns a fixed length output. Bitcoin uses an algorithm called SHA-256, which was invented by the NSA in 2001. The key feature of hashing algorithms is that a small change in the input completely changes the output. Lets take a look at an example using python.

hashlib.sha256("Hello World!".encode()).hexdigest()

7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069
hashlib.sha256("Hello World".encode()).hexdigest()

a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e

Here you can see the SHA-256 hash of “Hello World!“. When we remove the exclamation mark, however, instead of a small change, the entire hash changes.

Hashing makes the blockchain well… a chain of blocks. Because the hash of the previous block is included in the current block, it is impossible to alter the state of the state of the blockchain. With even the smallest change (say 1 transaction sending you 1 million dollars) the hash of every block following that would change, and it would be obvious that somethings not right.

Ok, back to mining. So 3 out of 4 of the contents of the block are relatively clear - the hash of the previous block, the transactions in the current block, and the block number - but the last one, the nonce, is they key to mining.

Nonce is a portmanteau of number used only once. (Yes I took that from google. You think I know wtf that word means?) To create a new block, these 4 elements are hashed together using the SHA-256 algorithm.

The key is, to mine a block, the the first X numbers of the hash of the 4 elements must be 0.

The X above varies every 2 weeks to make it either easier or harder to mine blocks, such that a new block is mined every 10 minutes. I know, its getting a little complicated. So lets look at real examples.

The first ever Bitcoin block (mined January 8, 2009) had the hash:

00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048

As you can see, it had eight 0’s to start, and had a nonce of 2,573,394,689. Thats right. With the information encoded in the block, it took the above nonce to create a hash with eight 0’s at the start of the hash.

Looking at a recent Bitcoin block (number 778,429), it had the hash:

000000000000000000009f8a2d38776f7228504886a2a59953724f09cac4153b

This block had a nonce of 3,294,173,007. More than 14 years after the genesis block, it takes twenty 0’s at the start of a hash for a block to be mined. There are significantly more miners now than before (the hash rate), thus to keep the block time the same (~10 minutes on average), the difficulty of finding the nonce is increased.

To put it another way, mining is really a process of guessing and checking. You take all of the important information (hash of the previous block, transactions in the current block, and the block number), then search for a nonce that gives a hash with a certain number of 0’s at the start. Once that nonce is found, the block is published, and the miner (computer) that found the correct nonce and publishes it with the hash gets rewarded in Bitcoin.

This process of guessing and checking is very computationally expensive (and competitive on top of that). But once the nonce is calculated and published, it is extremely easy to verify that the hash produced is valid (this is what nodes do, among other things).

Hopefully this wasn’t too complex to understand. From this, you can write a simple program to join the Bitcoin mining pool that you could run on your laptop (or write highly efficient programs run on complex GPU’s to similarly mine). This is much simpler than I thought mining was, and a great lesson in the complex efficiency of Bitcoin.

Fahrenheit is Stupid

I think in Fahrenheit, and I can’t really help it. Its just how I was taught and nothing I can do about it for now. But lets do a little history lesson…

Where did Celsius start?

The Celsius scale is named after the Swedish Andre Celsius (an astronomer ??) in 1942. Celsius makes a lot of sense. It is 0° at the freezing point of water, and 100° at the boiling point of water. Pretty nice.

There’s also the Kelvin scale (which is primarily used in scientific calculations). Kelvin scale is named after physicist William Thompson, 1st Baron Kelvin. Yes, thats his name. Kelvin sets 0° to be absolute 0. The coldest possible thermodynamic temperature, where both the enthalpy and entropy of an ideal gas are at their minimum value.

The Kelvin scale moves with the Celsius scale, just offset by 273.15°. Why 273.15, you may ask? Well thats just the difference between absolute 0 and the freezing point of water. If thats not satisfying enough of an answer, go ask science.

Ok so where does Fahrenheit fit in?

The Fahrenheit scale started in 1724, proposed by German physicist Daniel Gabriel Fahrenheit. 0° F is defined as the point where water, ice, and ammonium chloride (a salt) are stabilized… He then set the freezing point of water to be 32° F, and the temperature of the human body at 96° F… yea, that makes sense. The logic was that if water is 32°, then the human body temperature is 64° more than that of water.

Since 64 is 26 , 32 is 25 , the idea was that you could divide in half the distance between the human body temperature and the freezing point of water 6 times to calculate 1°.

Scientists later noticed water boils at almost 180° higher than it froze, so they readjusted the scale to make it exactly 180°, hence the human body temperature is 98.6° not 96°.

So why does the US use it? Well, in the 18 years that Fahrenheit was the standard temperature (1724-1742) the British Royal Society adopted it and the UK spread it to its colonies, aka the US. It took until the 1960’s for the UK to switch over to the metric system to be instep with the rest of Europe. The US however? We can barely change a lightbulb.

TLDR: Fahrenheit is stupid, and we should all use Celsius.

Formula 1: Drive to Survive Season 5

Get ready, because weekly F1 debriefs are coming. With testing completed last week, we’re only 6 days away from the season opener in Bahrain. With that, comes the new season of Drive to Survive on Netflix.

If you find yourself not caring at all about F1, I’d suggest watching Drive to Survive. Though I thought this season was a little boring compared to last (it was always going to be), its more than solid and is still definitely worth the watch.

ETH Denver

The annual Ethereum conference is coming up next week in Denver. With over 15,000 tickets sold, its gonna be chaos.

With all facets of the Ethereum ecosystem being covered, this conference goes on for over 2 weeks. This is my first year going and I couldn’t be more excited. Next week will likely be a debrief, so get ready for that.

Thanks for reading, I hope you learned something, and I’ll see you next week.