Learn Ethereum in 2024. #3. Blocks, blockchain and consensus.

João Paulo Morais
6 min readMar 6, 2024

--

A blockchain is an immutable ledger of transactions, organized as a data structure comprising blocks, where each block can be understood as a page of this book. Similar to pages in a book, blocks are also numbered and ordered. Typically, the initial block in the chain is designated as number zero and referred to as the “genesis block”. Every blockchain includes a genesis block.

Bitcoin’s genesis block emerged on January 3, 2009, while Ethereum’s genesis block appeared on July 30, 2015. Bitcoin’s genesis block did not include any transactions, but it featured a message recorded in a particular field: “The Times 03/Jan/2009 Chancellor on brink of second bailout for banks,” taken from the cover headline of the British newspaper The Times. Following the original concept of blockchains, Bitcoin was employed to ensure the timestamp of a publication.

The Ethereum genesis block encompassed 8,893 transactions, involving the transfer of Ethers, Ethereum’s currency. To fund its development, this currency was sold prior to its launch. Consequently, unlike Bitcoin, Ethereum was introduced with an initial supply of 72 million Ether. Details of the genesis block can be accessed at the following address: https://etherscan.io/block/0.

The fundamental structure of a block comprises its header and a set of transactions, collectively referred to as its body. The header contains various pertinent information, including its number, the time of creation, and the identity of the creator. We will soon explore the detailed structure of a block.

Commencing from the genesis block, the blocks adhere to a numerical sequence: 1, 2, 3, and so forth. While blocks possess a numerical identifier, it is not their sequential number that forms a chain. Instead, each block bears a signature generated by applying a hash function to its header. If you’re not yet familiar with what a hash function is, don’t worry; simply grasp that it produces a signature uniquely identifying the block.

The hash of a block is not embedded within the block itself; instead, it is incorporated into the subsequent block. In other words, each block retains the hash of the preceding block, creating a chain of blocks known as the blockchain. Altering any information within a block will modify its hash, subsequently affecting the following hash, and so forth. It is this inherent structure that makes a blockchain fraud-proof.

How blockchains are secure

It has been previously mentioned that the concept of proof of work is a fundamental part of the consensus mechanism of Bitcoin (and Ethereum until 2022). However, it is inaccurate to state that it is the consensus mechanism itself. The consensus mechanism is a set of rules that determines, among all possible chains, which one should be considered the valid chain.

Blockchains operate without a central owner, requiring participants to collectively decide which chain is deemed correct. When a new member joins the network and encounters two conflicting chains presented by different participants, they must choose one. In Bitcoin, the rule guiding this choice is the longest chain. Since the longest chain rule is simpler to explain, I will adhere to it for the moment.

Initially, I will present a version that is simpler to comprehend but incorrect. Subsequently, I will elaborate on the accurate version. In this simplified version, the chain’s validity is determined by the number of blocks it contains. For instance, if Alice presents a chain originating from the genesis block with 10 blocks, and Bob presents a chain with 11 blocks, the correct course of action is to disregard Alice’s chain and accept Bob’s chain because it is the longer chain.

In the most accurate version, what matters is the chain with the highest difficulty. Each block possesses a difficulty, essentially reflecting the challenge in generating the block. To determine the total difficulty of a chain, one must sum up the difficulties of each block within it. Consequently, when presented with two different chains, the correct course of action is to accept the chain with the highest difficulty.

Now, I can elucidate why a blockchain, based on proof of work, is secure. Let’s consider a scenario where Eve attempts to cheat by altering a transaction from 10 blocks ago in her favor. Modifying the transaction will inevitably alter the hash of the block, rendering all subsequent hashes invalid. In essence, Eve’s chain will be 10 blocks shorter than the official chain, and it will be rejected by anyone adhering to the established rules.

What options does Eve have to circumvent this security measure? She could attempt to generate a chain larger than the official one, but this undertaking demands an immense amount of computational power for each new block. Eve would need to outpace (possess more computational power than) the entire network combined to construct the largest chain and establish her chain as the official one. This scenario is recognized as the 51% attack, where a user or group of users gains control of 51% of the network’s total computing power. Only in this specific circumstance can the integrity of the chain be compromised.

Presently, Ethereum employs a proof-of-stake mechanism, mitigating the risk of a 51% attack. In this context, if Eve aims to modify a past transaction, she must cast her vote within the consensus mechanism, persuading the majority of other users to support the alteration. It is accurate to assert that a mistake occurred in this scenario — either in the vote for the original chain or in the vote for the proposed new chain.

It’s crucial to note that errors or malicious actions on Ethereum are met with consequences through a process called slashing, which involves forfeiting a portion of stored Ethers. Consequently, attempting to alter an already established chain would entail the risk of destroying billions of dollars in Ether. This makes it challenging to fathom any financial incentive for changing a well-established chain — unless, of course, one possesses an indifference to money, reminiscent of the Joker watching the circus burn down.

Block exploring

A blockchain functions as a database, a fundamental concept to grasp. This database stores details about blocks and their corresponding transactions. While performing local queries is possible if the database is on our machine, the Ethereum database, encompassing approximately 1TB, makes it impractical for the majority of users to maintain it locally. Consequently, users often need to seek this information elsewhere.

A valuable resource for obtaining information about the blockchain is a block explorer — a website facilitating searches for blocks, transactions, accounts, tokens, and more. Etherscan stands out as the most widely used block explorer on the Ethereum network.

As an experiment, you can visit the following address to retrieve information about block 1,000,000: https://etherscan.io/block/1000000. The block number is referred to as Block Height. The creation time of the block is known as TimeStamp, and for this block, it is Feb-13–2016 10:54:13 PM +UTC. It was mined at the address 0x2a65Aca4D5fC5B5C859090a6c34d164135398226. The Gas used was 50,244, and the block contains only 2 transactions, along with other relevant information. Don’t worry about comprehending all the details at this point; just observe that the information is available.

It was mentioned that the block was mined because Ethereum was still in the proof-of-work period, with active miners. The header with information about the block was simpler back then. If you search for information about the most recent block, you will find details related to the recent proof-of-stake epoch, such as Slot, Epoch, Proposer Index, among others.

It’s not crucial to understand all the details of the block header. We’ll revisit the most important information in due time. In the next article, we’ll address the question: where is the blockchain? Where is Ethereum?

--

--

João Paulo Morais
João Paulo Morais

Written by João Paulo Morais

Astrophysicist, full-stack developer, blockchain enthusiast. Technical Writer @RareSkills.

No responses yet