Skip to main content

Blockchain & Consensus Mechanism

· 24 min read
0xMacintosh

Blockchain Visual Photo by Authena

Blockchain

What is a blockchain?

A blockchain is a distributed database or ledger that is shared among the nodes of a computer network. As a database, a blockchain stores information electronically in digital format. Blockchains are best known for their crucial role in cryptocurrency systems, such as Bitcoin, for maintaining a secure and decentralized record of transactions. The innovation with a blockchain is that it guarantees the fidelity and security of a record of data and generates trust without the need for a trusted third party.

One key difference between a typical database and a blockchain is how the data is structured. A blockchain collects information together in groups, known as blocks, that hold sets of information. Blocks have certain storage capacities and, when filled, are closed and linked to the previously filled block, forming a chain of data known as the blockchain. All new information that follows that freshly added block is compiled into a newly formed block that will then also be added to the chain once filled.

A database usually structures its data into tables, whereas a blockchain, as its name implies, structures its data into chunks (blocks) that are strung together. This data structure inherently makes an irreversible timeline of data when implemented in a decentralized nature. When a block is filled, it is set in stone and becomes a part of this timeline. Each block in the chain is given an exact timestamp when it is added to the chain.

KEY TAKEAWAYS

  • Blockchain is a type of shared database that differs from a typical database in the way that it stores information; blockchains store data in blocks that are then linked together via cryptography.
  • As new data comes in, it is entered into a fresh block. Once the block is filled with data, it is chained onto the previous block, which makes the data chained together in chronological order.
  • Different types of information can be stored on a blockchain, but the most common use so far has been as a ledger for transactions.
  • In Bitcoin's case, blockchain is used in a decentralized way so that no single person or group has control—rather, all users collectively retain control.
  • Decentralized blockchains are immutable, which means that the data entered is irreversible. For Bitcoin, this means that transactions are permanently recorded and viewable to anyone.

Block

Blocks are data structures within the blockchain database, where transaction data in a cryptocurrency blockchain are permanently recorded. A block records some or all of the most recent transactions not yet validated by the network. Once the data are validated, the block is closed. Then, a new block is created for new transactions to be entered into and validated.

A block is thus a permanent store of records that, once written, cannot be altered or removed.

KEY TAKEAWAYS

  • A block is a place in a blockchain where information is stored and encrypted.
  • Blocks are identified by long numbers that include encrypted transaction information from previous blocks and new transaction information.
  • Blocks and the information within them must be verified by a network before new blocks can be created.
  • Blocks and blockchains are not used solely by cryptocurrencies. They also have many other uses.

A blockchain network witnesses a great deal of transaction activity. When used in cryptocurrency, maintaining a record of these transactions helps the system track how much was or wasn't used and which parties were involved. The transactions made during a given period are recorded into a file called a block, which is the basis of the blockchain network.

A block stores information. There are many pieces of information included within a block, but it doesn't occupy a large amount of storage space. Blocks generally include these elements, but it might vary between different types:

  • Magic number: A number containing specific values that identify that block as part of a particular cryptocurrency's network.
  • Blocksize: Sets the size limit on the block so that only a specific amount of information can be written in it.
  • Block header: Contains information about the block.
  • Transaction counter: A number that represents how many transactions are stored in the block.
  • Transactions: A list of all of the transactions within a block.

The transaction element is the largest because it contains the most information. It is followed in storage size by the block header, which includes these sub-elements:

  • Version: The cryptocurrency version being used.
  • Previous block hash: Contains a hash (encrypted number) of the previous block's header.
  • Hash Merkle root: Hash of transactions in the Merkle tree (binary hash tree) of the current block.
  • Time: A timestamp to place the block in the blockchain.
  • Bits: The difficulty rating of the target hash, signifying the difficulty in solving the nonce.
  • Nonce: The encrypted number that a miner must solve to verify the block and close it.

One 32-bit number in the header is called a nonce—the mining program uses random numbers to "guess" the nonce in the hash. When a nonce is verified, the hash is solved when the nonce, or a number less than it, is guessed. Then, the network closes that block, generates a new one with a header, and the process repeats.

Mining's Relationship to Blocks

Mining is the term used for solving the number that is the nonce, the only number that can be changed in a block header. It is also the process the cryptocurrency's network uses if proof-of-work is used in the protocol.

Cryptocurrency mining is commonly thought to be a complex mathematical problem; it is actually a random number generated through hashing. Hashing is the process of encrypting information using the encryption method a cryptocurrency uses. For example, Bitcoin uses SHA256 for its encryption algorithm. For a miner to generate the "winning" number, the mining program must use SHA 256 to hash random numbers and place them into the nonce to see if it is a match.

The difficulty lies in that all previous block headers are encrypted randomly. Hence, the current block header is a randomly generated encrypted number based on the randomly generated encrypted numbers of previous blocks and information from the current block.

How Does a Blockchain Work?

The goal of blockchain is to allow digital information to be recorded and distributed, but not edited. In this way, a blockchain is the foundation for immutable ledgers, or records of transactions that cannot be altered, deleted, or destroyed. This is why blockchains are also known as a distributed ledger technology (DLT).

First proposed as a research project in 1991, the blockchain concept predated its first widespread application in use: Bitcoin, in 2009. In the years since, the use of blockchains has exploded via the creation of various cryptocurrencies, decentralized finance (DeFi) applications, non-fungible tokens (NFTs), and smart contracts.

Transaction Process

Resource:


Consensus Mechanism

What Is a Consensus Mechanism?

A consensus mechanism is a fault-tolerant mechanism that is used in computer and blockchain systems to achieve the necessary agreement on a single data value or a single state of the network among distributed processes or multi-agent systems, such as with cryptocurrencies. It is useful in record-keeping, among other things.

On the Bitcoin blockchain, for instance, the consensus mechanism is known as Proof-of-Work (PoW), which requires the exertion of computational power in order to solve a difficult but arbitrary puzzle in order to keep all nodes in the network honest.

KEY TAKEAWAYS

  • A consensus mechanism refers to any number of methodologies used to achieve agreement, trust, and security across a decentralized computer network.
  • In the context of blockchains and cryptocurrencies, proof-of-work (PoW) and proof-of-stake (PoS) are two of the most prevalent consensus mechanisms.
  • Critics of Bitcoin miners have argued that PoW is overly energy-intensive, which has sparked the creation of new and more efficient mechanisms.

Consensus Mechanism Explained

In any centralized system, like a database holding key information about driving licenses in a country, a central administrator has the authority to maintain and update the database. The task of making any updates—like adding/deleting/updating names of people who qualified for certain licenses—is performed by a central authority who remains the sole in-charge of maintaining genuine records.

Public blockchains that operate as decentralized, self-regulating systems work on a global scale without any single authority. They involve contributions from hundreds of thousands of participants who work on verification and authentication of transactions occurring on the blockchain, and on the block mining activities.

In such a dynamically changing status of the blockchain, these publicly shared ledgers need an efficient, fair, real-time, functional, reliable, and secure mechanism to ensure that all the transactions occurring on the network are genuine and all participants agree on a consensus on the status of the ledger. This all-important task is performed by the consensus mechanism, which is a set of rules that decides on the legitimacy of contributions made by the various participants (i.e., nodes or transactors) of the blockchain.

Blockchain Consensus Mechanisms

There are different kinds of consensus mechanism algorithms, each of which works on different principles.

The proof of work (PoW) is a common consensus algorithm used by the most popular cryptocurrency networks like bitcoin and litecoin. It requires a participant node to prove that the work done and submitted by them qualifies them to receive the right to add new transactions to the blockchain. However, this whole mining mechanism of bitcoin needs high energy consumption and a longer processing time.

The proof of stake (PoS) is another common consensus algorithm that evolved as a low-cost, low-energy consuming alternative to the PoW algorithm. It involves the allocation of responsibility in maintaining the public ledger to a participant node in proportion to the number of virtual currency tokens held by it. However, this comes with the drawback that it incentivizes cryptocoin hoarding instead of spending.

While PoW and PoS are by far the most prevalent in the blockchain space, there are other consensus algorithms like Proof of Capacity (PoC) which allow sharing of memory space of the contributing nodes on the blockchain network. The more memory or hard disk space a node has, the more rights it is granted for maintaining the public ledger. Proof of Activity (PoA), used on the Decred blockchain, is a hybrid that makes use of aspects of both PoW and PoS. Proof of Burn (PoB) is another that requires transactors to send small amounts of cryptocurrency to inaccessible wallet addresses, in effect "burning" them out of existence.

Another, called Proof of History (PoH), developed by the Solana Project and similar to Proof of Elapsed Time (PoET), encodes the passage of time itself cryptographically to achieve consensus without expending many resources.

Proof-of-Work & Mining

Proof of work (PoW) describes a system that requires a not-insignificant but feasible amount of effort in order to deter frivolous or malicious uses of computing power, such as sending spam emails or launching denial of service attacks. The concept was subsequently adapted to securing digital money by Hal Finney in 2004 through the idea of "reusable proof of work" using the SHA-256 hashing algorithm.

Following its introduction in 2009, Bitcoin became the first widely adopted application of Finney's PoW idea (Finney was also the recipient of the first bitcoin transaction). Proof of work forms the basis of many other cryptocurrencies as well, allowing for secure, decentralized consensus.

KEY TAKEAWAYS

  • Proof of work (PoW) is a decentralized consensus mechanism that requires members of a network to expend effort solving an arbitrary mathematical puzzle to prevent anybody from gaming the system.
  • Proof of work is used widely in cryptocurrency mining, for validating transactions and mining new tokens.
  • Due to proof of work, Bitcoin and other cryptocurrency transactions can be processed peer-to-peer in a secure manner without the need for a trusted third party.
  • Proof of work at scale requires huge amounts of energy, which only increases as more miners join the network.
  • Proof of Stake (POS) was one of several novel consensus mechanisms created as an alternative to proof of work.

Understanding Proof of Work

This explanation will focus on proof of work as it functions in the bitcoin network. Bitcoin is a digital currency that is underpinned by a kind of distributed ledger known as a "blockchain." This ledger contains a record of all bitcoin transactions, arranged in sequential "blocks," so that no user is allowed to spend any of their holdings twice. In order to prevent tampering, the ledger is public, or "distributed"; an altered version would quickly be rejected by other users.

The way that users detect tampering in practice is through hashes, long strings of numbers that serve as proof of work. Put a given set of data through a hash function (bitcoin uses SHA-256), and it will only ever generate one hash. Due to the "avalanche effect," however, even a tiny change to any portion of the original data will result in a totally unrecognizable hash. Whatever the size of the original data set, the hash generated by a given function will be the same length. The hash is a one-way function: it cannot be used to obtain the original data, only to check that the data that generated the hash matches the original data.

Generating just any hash for a set of bitcoin transactions would be trivial for a modern computer, so in order to turn the process into "work," the bitcoin network sets a certain level of "difficulty." This setting is adjusted so that a new block is "mined"—added to the blockchain by generating a valid hash—approximately every 10 minutes. Setting difficulty is accomplished by establishing a "target" for the hash: the lower the target, the smaller the set of valid hashes, and the harder it is to generate one. In practice, this means a hash that starts with a very long string of zeros.

FAST FACT

Proof of work was initially created as a proposed solution to the growing problem of spam email.

Special Considerations

Since a given set of data can only generate one hash, how do miners make sure they generate a hash below the target? They alter the input by adding an integer, called a nonce ("number used once"). Once a valid hash is found, it is broadcast to the network, and the block is added to the blockchain.

Mining is a competitive process, but it is more of a lottery than a race. On average, someone will generate acceptable proof of work every ten minutes, but who it will be is anyone's guess. Miners pool together to increase their chances of mining blocks, which generates transaction fees and, for a limited time, a reward of newly-created bitcoins.

Proof of work makes it extremely difficult to alter any aspect of the blockchain, since such an alteration would require re-mining all subsequent blocks. It also makes it difficult for a user or pool of users to monopolize the network's computing power, since the machinery and power required to complete the hash functions are expensive.

Important

If part of a mining network begins accepting an alternative proof of work, it is known as a hard fork.

What happens if two miners mine the next block at the same time?

In Bitcoin terms, simultaneous answers occur frequently, but at the end of the day, there can only be one winning answer. When multiple simultaneous answers are presented that are equal to or less than the target number, the Bitcoin network will decide by a simple majority—51%—which miner to honor.

Typically, it is the miner who has done the most work or, in other words, the one that verifies the most transactions. The losing block then becomes an "orphan block." Orphan blocks are those that are not added to the blockchain. Miners who successfully solve the hash problem but haven't verified the most transactions are not rewarded with bitcoin.

Source: How Does Bitcoin Mining Work?

What is a 51% Attack

A 51% attack is an attack on a cryptocurrency blockchain by a group of miners who control more than 50% of the network's mining hash rate. Owning 51% of the nodes on the network gives the controlling parties the power to alter the blockchain. This group then introduces an altered blockchain to the network at a very specific point in the blockchain, which is theoretically accepted by the network because the attackers would own most of it.

The attackers would be able to prevent new transactions from gaining confirmations, allowing them to halt payments between some or all users. They would also be able to reverse transactions that were completed while they were in control of the network. Reversing transactions could allow them to double-spend coins, one of the issues consensus mechanisms like proof-of-work were created to prevent.

KEY TAKEAWAYS

  • Blockchains are distributed ledgers that record every transaction made on a cryptocurrency's network.
  • A 51% attack is an attack on a blockchain by a group of miners who control more than 50% of the network's mining hash rate.
  • Attackers with majority network control can interrupt the recording of new blocks by preventing other miners from completing blocks.
  • Changing historical blocks is difficult due to the hard-coding of past transactions into Bitcoin software.
  • Although a successful attack on Bitcoin or Ethereum is unlikely, smaller networks are frequent targets for 51% attacks.

Changing historical blocks—transactions locked in before the start of the attack—would be extremely difficult even in the event of a 51% attack. The further back the transactions are, the more difficult it is to change them. It would be impossible to change transactions before a checkpoint, where transactions become hard-coded into Bitcoin's software.

In addition to the costs, a group that attempts to attack the network using a 51% attack must not only control 51% of the network but must also introduce the altered blockchain at a very precise time. Even if they own 51% of the network hashing rate, they still might not be able to keep up with the block creation rate or get their chain inserted before valid new blocks are created by the 'honest' blockchain network.

Again, this is possible on smaller cryptocurrency networks because there is less participation and lower hash rates. Large networks make it nearly impossible to introduce an altered blockchain.

Proof-of-Stake

Proof-of-stake is a cryptocurrency consensus mechanism for processing transactions and creating new blocks in a blockchain. A consensus mechanism is a method for validating entries into a distributed database and keeping the database secure. In the case of cryptocurrency, the database is called a blockchain—so the consensus mechanism secures the blockchain.

Learn more about proof-of-stake and how it is different from proof-of-work. Additionally, find out the issues proof-of-stake is attempting to address within the cryptocurrency industry.

KEY TAKEAWAYS

  • With proof-of-stake (POS), cryptocurrency owners validate block transactions based on the number of coins a validator stakes.
  • Proof-of-stake (POS) was created as an alternative to Proof-of-work (POW), the original consensus mechanism used to validate a blockchain and add new blocks.
  • While PoW mechanisms require miners to solve cryptographic puzzles, PoS mechanisms require validators to simply hold and stake tokens.
  • Proof-of-stake (POS) is seen as less risky in terms of the potential for an attack on the network, as it structures compensation in a way that makes an attack less advantageous.
  • The next block writer on the blockchain is selected at random, with higher odds being assigned to nodes with larger stake positions.

Proof-of-stake reduces the amount of computational work needed to verify blocks and transactions that keep the blockchain, and thus a cryptocurrency, secure. Proof-of-stake changes the way blocks are verified using the machines of coin owners. The owners offer their coins as collateral for the chance to validate blocks. Coin owners with staked coins become "validators."

Validators are then selected randomly to "mine," or validate the block. This system randomizes who gets to "mine" rather than using a competition-based mechanism like proof-of-work.

To become a validator, a coin owner must "stake" a specific amount of coins. For instance, Ethereum will require 32 ETH to be staked before a user can become a validator. Blocks are validated by more than one validator, and when a specific number of the validators verify that the block is accurate, it is finalized and closed.

Different proof-of-stake mechanisms may use different methods for validating blocks—when Ethereum transitions to PoS, it will use shards for transaction submissions. A validator will verify the transactions and add them to a shard block, which requires at least 128 validators to attest to. Once shards are validated and block created, two-thirds of the validators must agree that the transaction is valid, then the block is closed.

FAST FACT

To summarize the Ethereum PoS process, you might say it is validation sharing across a cryptocurrency network instead of a validation competition.


Ethereum Consensus Mechanism

Proof-of-work

Ethereum, like Bitcoin, currently uses a proof-of-work (PoW) consensus protocol.

Block creation

Proof-of-work is done by miners, who compete to create new blocks full of processed transactions. The winner shares the new block with the rest of the network and earns some freshly minted ETH. The race is won by the computer which is able to solve a math puzzle fastest - this produces the cryptographic link between the current block and the block that went before. Solving this puzzle is the work in "proof-of-work".

Security

The network is kept secure by the fact that you'd need 51% of the network's computing power to defraud the chain. This would require such huge investments in equipment and energy; you're likely to spend more than you'd gain.

More on proof-of-work


Ethereum Proof-of-Stake

Ethereum plans to upgrade to a proof-of-stake (PoS) consensus protocol.

Proof-of-stake comes with a number of improvements to the proof-of-work system:

  • better energy efficiency - there is no need to use lots of energy on proof-of-work computations
  • lower barriers to entry, reduced hardware requirements - there is no need for elite hardware to stand a chance of creating new blocks
  • reduced centralization risk - proof-of-stake should lead to more nodes securing the network
  • because of the low energy requirement less ETH issuance is required to incentivize participation
  • economic penalties for misbehaviour make 51% style attacks exponentially more costly for an attacker compared to proof-of-work
  • the community can resort to social recovery of an honest chain if a 51% attack were to overcome the crypto-economic defenses.

VALIDATORS

To participate as a validator, a user must deposit 32 ETH into the deposit contract and run three separate pieces of software: an execution client, a consensus client, and a validator. On depositing their ether, the user joins an activation queue that limits the rate of new validators joining the network. Once activated, validators receive new blocks from peers on the Ethereum network. The transactions delivered in the block are re-executed, and the block signature is checked to ensure the block is valid. The validator then sends a vote (called an attestation) in favor of that block across the network.

Whereas under proof-of-work, the timing of blocks is determined by the mining difficulty, in proof-of-stake, the tempo is fixed. Time in proof-of-stake Ethereum is divided into slots (12 seconds) and epochs (32 slots). One validator is randomly selected to be a block proposer in every slot. This validator is responsible for creating a new block and sending it out to other nodes on the network. Also in every slot, a committee of validators is randomly chosen, whose votes are used to determine the validity of the block being proposed.

FINALITY

A transaction has "finality" in distributed networks when it's part of a block that can't change without a significant amount of ether getting burned. On proof-of-stake Ethereum, this is managed using "checkpoint" blocks. The first block in each epoch is a checkpoint. Validators vote for pairs of checkpoints that it considers to be valid. If a pair of checkpoints attracts votes representing at least two-thirds of the total staked ether, the checkpoints are upgraded. The more recent of the two (target) becomes "justified". The earlier of the two is already justified because it was the "target" in the previous epoch. Now it is upgraded to "finalized". To revert a finalized block, an attacker would commit to losing at least one-third of the total supply of staked ether (currently around $10,000,000,000). The exact reason for this is explained in this Ethereum Foundation blog post. Since finality requires a two-thirds majority, an attacker could prevent the network from reaching finality by voting with one-third of the total stake. There is a mechanism to defend against this: the inactivity leak. This activates whenever the chain fails to finalize for more than four epochs. The inactivity leak bleeds away the staked ether from validators voting against the majority, allowing the majority to regain a two-thirds majority and finalize the chain.

FORK CHOICE

When the network performs optimally and honestly, there is only ever one new block at the head of the chain, and all validators attest to it. However, it is possible for validators to have different views of the head of the chain due to network latency or because a block proposer has equivocated. Therefore, consensus clients require an algorithm to decide which one to favor. The algorithm used in proof-of-stake Ethereum is called LMD-GHOST, and it works by identifying the fork that has the greatest weight of attestations in its history.

ATTESTATIONS

Every epoch (6.4 minutes) a validator proposes an attestation to the network. The attestation is for a specific slot in the epoch. The purpose of the attestation is to vote in favor of the validator's view of the chain, in particular the most recent justified block and the first block in the current epoch (known as source and target checkpoints). This information is combined for all participating validators, enabling the network to reach consensus about the state of the blockchain.

The attestation contains the following components:

  • aggregation_bits: a bitlist of validators where the position maps to the validator index in their committee; the value (0/1) indicates whether the validator signed the data (i.e. whether they are active and agree with the block proposer)
  • data: details relating to the attestation, as defined below
  • signature: a BLS signature that aggregates the signatures of individual validators

The first task for an attesting validator is to build the data. The data contains the following information:

  • slot: The slot number that the attestation refers to
  • index: A number that identifies which committee the validator belongs to in a given slot
  • beacon_block_root: Root hash of the block the validator sees at the head of the chain (the result of applying the fork-choice algorithm)
  • source: Part of the finality vote indicating what the validators see as the most recent justified block
  • target: Part of the finality vote indicating what the validators see as the first block in the current epoch

Once the data is built, the validator can flip the bit in aggregation_bits corresponding to their own validator index from 0 to 1 to show that they participated.

Finally, the validator signs the attestation and broadcasts it to the network.


Block creation

Proof-of-stake is done by validators who have staked ETH to participate in the system. A validator is chosen at random to create new blocks, share them with the network and earn rewards. Instead of needing to do intense computational work, you simply need to have staked your ETH in the network. This is what incentivises healthy network behaviour.

Security

A proof-of-stake system is kept secure by the fact that you'd need 51% of the total staked ETH to defraud the chain. And that your stake is slashed for malicious behaviour.


Ethereum Misc. and Ethereum 2.0

Why Are Most dApps Built on Ethereum?

Decentralized applications (dApps) are built on blockchain networks and use smart contracts to create platforms that streamline and democratize the entry into industries ranging from finance to gaming — all without intermediaries and centralized authorities. In terms of front-end user experience, dApps appear nearly identical to traditional web applications. However, on the back-end, dApps function much differently than their conventional counterparts. Instead of employing the HTTP protocol to communicate with the broader network, dApps connect to the blockchain in a decentralized manner rather than routing through centralized servers.

The Ethereum network currently dominates dApp development for several reasons. Ethereum implements a development interface that reduces programming time and helps quickly launch projects. Beyond this, the Ethereum developer community has grown remarkably since the platform's launch. And Ethereum retains formidable network effects from its global coalition of technologists who remain committed to maintaining the network and actively developing user resources that drive adoption. Further, the ability to adequately monetize dApp projects incentivizes others to partake in the Ethereum ecosystem.

  • The Ethereum Virtual Machine (EVM)
    • Ethereum is known for providing a distinct and accommodating developer experience that makes it easier for novice blockchain developers to enter the space. A prime example of this is the Ethereum Virtual Machine (EVM), a unique software system that allows developers to launch any dApp regardless of the underlying coding language. Ethereum also uses a network-native language known as Solidity for coding smart contracts. This network architecture eliminates the need to develop an entirely new blockchain for every dApp.
    • Developers can work with the ready-made Ethereum system to fast-track onboarding and get their applications up and running sooner than other alternatives. This dynamic continues to drive the rapid development of DeFi products on the Ethereum network. By combining application templates, MetaMask integration, and the EVM, the overall Ethereum development kit allows companies to focus on refining their applications and developing on top of open-source code among a global, mission-based developer community that prioritizes cooperation over competition.
  • Developer Community and Network
    • Since launching in 2015, Ethereum has moved quickly from first mover to legacy status in the decentralized blockchain ecosystem. The network benefits from a highly skilled community of developers who have since built out crucial extension documentation and network updates to help the broader community. For example, Microsoft's Blockchain Development Kit for Ethereum and Diligence's Solidity Visual Auditor extension for Visual Studio code are used to enhance development on the Ethereum network. The increasing number of developers utilizing these solutions has perpetuated the development of better tools, better code, better platforms, and ultimately, better dApps.
    • Further, dApps like MakerDAO, IDEX, Bancor, and even CryptoKitties serve to amplify this network effect, drawing even greater attention to the Ethereum ecosystem. The function of composability, exemplified by dApps using open source code from other projects and building out token interoperability between platforms, has reinforced the cooperative infrastructure of the network. As a result, Ethereum has become the infrastructure of choice in every single dApp market segment.
  • Monetizing Ethereum dApps
    • Many dApps utilize a native token that facilitates activity within the application — also known as a utility token. On the Ethereum network, these tokens adhere to the ERC-20 tokenization standard, a set of rules that ensure Ethereum-based tokens can interact seamlessly with one another. This component of network architecture is critical to ensuring the continuity of Ethereum-based applications. To generate revenue, dApps can monetize their assets on existing crypto exchanges or launch their own decentralized exchange (DEX).
    • The ERC-20 standard enables the frictionless exchange of these crypto assets. Further, the increase in trading volume brings more awareness to dApps residing within the Ethereum ecosystem; the network reinvests in itself. A clear path toward monetization results from Ethereum's vast community and robust, interoperable network infrastructure.

Ethereum 2.0

Five Stages of Ethereum 2.0 Development (All about scaling, security, efficiency, and sustainability)

Vitalik Buterin:

“The Merge is proof of stake. The Surge is sharding, and The Verge is Verkle Trees, The Purge is things like state expiry and deleting old history, and The Splurge is basically just all of the other fun stuff.”

  • The Merge

    • 現時的以太坊主鏈和 Beacon Chain 將會合併,原本的 PoW (工作量證明) 共識將會轉成 PoS (權益證明)。由於 PoS 的電力消耗會比 PoW 低 99.95%, 消耗的電力比起 PoW 幾乎可以忽略不計, 這對在可持續發展方面有更多考量的企業來說, 以太坊變成了一個可行的選擇, 不會再因為環保問題被垢病。
    • 在 PoS 機制中,不再需要發行大量新的代幣去補貼礦工,因為發行量的減少,以太坊會有新的加密經濟模型,大部分的 ETH 代幣都會被質押,市場上的供應量會大大減少,令以太幣變成更稀有的硬通貨。
  • The Surge

    • 將區塊鏈的整個網路分成更小的分區,以後多條分片鏈將能同時進行交易與驗證,提升整個 Ethereum 網絡的效率。The Surge 其實就是以太坊 2.0 一直在強調的分片設計。The Surge 會將區塊鏈的整個網路分成更小的分區,以後多條分片鏈將能同時進行交易與驗證,提升整個網絡的效率。分片是以太幣的擴容方案中最複雜和最難實行的設計,為了確保分片能順利進行,分片會發生較後期的更新階段,給開發者充足的時間開發和測試。最新的分片提案和過往的已經有一些出入,更加以 Rollup 為中心來進行各種優化和升級,例 如在分片的設計方案上會更方便 Rollup 去調用數據。
    • Sharding is the process of splitting one blockchain into multiple blockchains known as shards. It makes the entire network more efficient as a single validator does not have to handle the workload alone.
    • Every validator maintains information related to “their” shard. These validators are also shuffled between shards regularly to avoid any kind of manipulation. The Beacon Chain is used for the communication and coordination of the shards.
    • The Beacon Chain is a ledger of accounts that conducts and coordinates the network of stakers. It isn't quite like the Ethereum Mainnet of today. It does not process transactions or handle smart contract interactions.
  • The Verge

    • The verge will implement what Buterin calls “Verkle trees” (a type of mathematical proof) and “stateless clients.” These technical upgrades will allow users to become network validators without having to store extensive amounts of data on their machines. In a proof-of-stake network, validators with locked-up or “staked” ETH confirm and verify transactions. In Buterin's view, the verge will be “great for decentralization.”
    • This upgrade involves a “powerful upgrade to Merkle proofs” which optimizes data storage for Ethereum nodes. It will also assist with Ethereum scaling, as it allows for a greater number of blockchain transactions while keeping the blockchain decentralized.
    • 在原來區塊鏈的設計中, 如果客戶端想要確認一個交易的狀態, 會需要用到 Merkle Proof, 而在引入 Verkle Tree 後, 因為所佔用的空間將大幅減少, 也令「Stateless Client」的概念變得可行。
    • 簡單來說 Stateless Clients 就是「不需要儲存所有狀態,卻能參與交易驗證」的角色,現在區塊鏈網絡裏所有的共識和驗證都是由全節點完成的,但有了 Stateless Clients 之後,將不再需要花大量的記憶體儲存相關的數據,令整條區塊鏈更有效率。
  • The Purge: 通過剔除歷史數據和消除技術債務,驗證者不再需要使用大量硬盤空間去進行驗證工作。

    • “The purge: trying to actually cut down the amount of space you have to have on your hard drive, trying to simplify the Ethereum protocol over time and not requiring nodes to store history,” Buterin said of the phase.
    • 現時以太坊的驗證者需要下載自 2014 年開始的整個以太坊交易歷史數據,佔用的記憶體空間太大,甚至還隨這時間過去而不斷增加。
    • The Purge 目的是要改變這一點,減少節點的存儲需求,甚至不需要節點儲存歷史數據,從而大大提高效率,增加 TPS。
  • The Splurge: 四個不同部分升級後的協調,旨在減少錯誤 (Bugs) 的出現和確保網絡能暢順運作。

Ethereum Layer 2

Scaling Ethereum without compromising on security or decentralization.

Layer 2 (L2) is a collective term to describe a specific set of Ethereum scaling solutions. A layer 2 is separate blockchain that extends Ethereum and inherits the security guarantees of Ethereum.

Now let's dig into it a bit more, and to do this we need to explain layer 1 (L1).

Layer 1 is the base blockchain. Ethereum and Bitcoin are both layer 1 blockchains because they are the underlying foundation that various layer 2 networks build on top of. Examples of layer 2 projects include "rollups" on Ethereum and the Lightning Network on top of Bitcoin. All user transaction activity on these layer 2 projects can ultimately settle back to the layer 1 blockchain.

Ethereum also functions as a data availability layer for layer 2s. Layer 2 projects will post their transaction data onto Ethereum, relying on Ethereum for data availability. This data can be used to get the state of the layer 2, or to dispute transactions on layer 2.

Ethereum as the layer 1 includes:

  1. A network of node operators to secure and validate the network
  2. A network of block producers
  3. The blockchain itself and the history of transaction data
  4. The consensus mechanism for the network

Why do we need layer 2?

Three desirable properties of a blockchain are that it is decentralized, secure, and scalable. The blockchain trilemma states that a simple blockchain architecture can only achieve two out of three. Want a secure and decentralized blockchain? You need to sacrifice scalability.

Ethereum has reached the network's current capacity with 1+ million transactions per day and high demand for each of these transactions. The success of Ethereum and the demand to use it has caused gas prices to rise substantially. Therefore the need for scaling solutions has increased in demand as well. This is where layer 2 networks come in.

Scalability

The main goal of scalability is to increase transaction speed (faster finality) and transaction throughput (higher transactions per second) without sacrificing decentralization or security.

The Ethereum community has taken a strong stance that it would not throw out decentralization or security in order to scale. Until sharding, Ethereum Mainnet (layer 1) is only able to process roughly 15 transactions per second. When demand to use Ethereum is high, the network becomes congested, which increases transaction fees and prices out users who cannot afford those fees. That is where layer 2 comes in to scale Ethereum today.

Rollups

Rollups are currently the preferred layer 2 solution for scaling Ethereum. By using rollups, users can reduce gas fees by up to 100x compared to layer 1.

Rollups bundle (or 'roll up') hundreds of transactions into a single transaction on layer 1. This distributes the L1 transaction fees across everyone in the rollup, making it cheaper for each user. Rollup transactions get executed outside of layer 1 but the transaction data gets posted to layer 1. By posting transaction data onto layer 1, rollups inherit the security of Ethereum. There are two different approaches to rollups: optimistic and zero-knowledge - they differ primarily on how this transaction data is posted to L1.


Credits

Blockchain Facts

Block (Blockchain Block)

Consensus Mechanism (Cryptocurrency)

How Does Bitcoin Mining Work?

The proof of work (PoW)

PoS

What is a 51% Attack

Ethereum Consensus Mechanism

Why Are Most dApps Built on Ethereum?

Merge, Surge, Verge, Purge, Splurge 到底是什麼?

Ethereum 2.0

Layer 2

Ethereum Merge? Get Ready for the 'Surge, Verge, Purge, and Splurge', Says Vitalik Buterin