Cover Image for A Comprehensive Guide to the Beacon Chain and How It Works

A Comprehensive Guide to the Beacon Chain and How It Works

Beacon Chain
ETH2

The Beacon Chain is a fundamental component of the Ethereum blockchain. Before the merge, the Ethereum blockchain used the Proof of Work (POW) consensus mechanism — a process that requires a group of validators to solve a mathematical puzzle to win the chance to add a block to the blockchain.

Over the years, there have been a ton of issues (like scalability issues, high energy consumption, indirectly susceptible to centralization, and so on) about the POW consensus mechanism. So, the Ethereum Foundation decided to tackle this problem by changing the consensus mechanism of the blockchain to Proof of Stake (POS). POS is a consensus mechanism that allows you to stake your cryptocurrency to become a validator on the blockchain.

On September 15, 2022, Ethereum transitioned from POW to POS, which is also known as the Beacon Chain.

What is the Beacon Chain, and how does it affect the stability, decentralization, and security of the Ethereum blockchain? Let’s check that out!

What is the Beacon Chain?

Simply put, the ETH Beacon Chain is the central component of the Ethereum blockchain responsible for adding a valid block to the blockchain. The Beacon Chain maintains and coordinates the state of the Ethereum blockchain.

After the transition to POS, the Ethereum blockchain splits into two layers. In a literal sense, the blockchain is still a single blockchain. A closer look under the hood reveals that Ethereum contains two interdependent layers (the execution and the consensus layer).

The Execution Layer known as Ethereum 1.0 is usually referred to as the ‘Brain' of the blockchain. The Consensus Layer is the Beacon Chain, which is also known as the ‘Heart’ of the Ethereum blockchain. Just as the human heart coordinates blood production and maintains the heartbeat, the Beacon Chain coordinates the creation, validation, and addition of blocks to the blockchain.

The Beacon Chain doesn’t process any smart contract transaction, but it validates transactions and coordinates the behavior of the network validators. It also handles the block and consensus logic and deals with network validation.

Why Does Ethereum Transition to POS

In the introduction, we've seen an overview of what led to Ethereum transitioning from POW to POS. Now let’s go through some of the reasons for the transition.

  1. Energy Efficiency

The POW consensus mechanism requires miners (validators) to compete with other miners to solve complex mathematical puzzles. The first to correctly solve the problem will be assigned to add a new block to the blockchain. This consensus mechanism is resource-intensive and environmentally unfriendly because it consumes a lot of energy. Therefore, it receives a lot of backlash from environmentalists.

On the other hand, however, the POS uses a different mechanism to assign block production. Instead of running energy-intensive hardware, the POS system requires anyone who wants to become a validator on the network to stake a certain amount as collateral. The validators are randomly selected to create new blocks, which will only be added to existing blocks and finalized if two-thirds of the validators guarantee that the block created correctly aligns with the existing blocks in the chain. This system of mechanism consumes less energy when compared to the POW mechanism.

  1. Scalability and Transaction cost

Pre-merge, when Ethereum still runs on the POW mechanism, the blockchain can only process 15 transactions per second (tps) — that’s even when the blockchain is running at optimal performance. This performance can’t meet the demand of real-life (financial or technological) use cases if compared to the efficiency of Visa, which claims to process 50k tps.

While the transaction processing and scalability haven’t been solved, the Ethereum blockchain transitioning to POS has started on the path to reaching that high scalability and efficiency. With the Beacon Chain, Ethereum is on the path that will improve the scalability of the chain and reduce the transaction cost (gas fee) paid for processing a transaction.

  1. Security and Decentralization

The immutability of the blockchain makes it a great tool with great potential in the real world. Over the years, as technology and knowledge increase, the security of the blockchain is becoming more and more threatened by centralization.

The introduction of mining pools and farms led to the centralization of the miners (validators), which makes blockchain susceptible to censorship. You know POW is energy-intensive, and as a way to reduce energy costs, mining farms moved to regions with sufficient energy production and low energy cost.

On the other hand, the difficulty of the mathematical puzzles reduces the probability of individual miners winning a reward. So, those interested in blockchain validation usually pool their resources together to increase their odds against institutional miners. And this leads to the centralization of power.

But with the introduction of the Eth Beacon Chain, validators can’t pool their resources together to gain a higher chance to create a block — you only need 32ETH to be a validator — nothing more, nothing less.

Finally, as a security measure, POS promotes responsible behavior while it discourages bad actors through economically disincentivizing them. Validators risk losing their staked ETH if they work against the system.

The Feature of the Beacon Chain

The Beacon Chain is the core component of the Ethereum network, and it manages the consensus layer. In this section, let's look at the features of the Beacon Chain that qualify it as the backbone or the heart of the system.

  1. Slot

The slot is a unique time when a validator is assigned the responsibility of proposing a new block and attesting to the validity of the block. If the Beacon Chain is the heart, the slot is the heartbeat. Each slot is usually a 12-second window.

This strict time window enables validators (proposers) to propose and propagate a block to the selected validators (attesters), who vote on the block and propagate all slot activity to the next slot’s block proposal.

  1. The Epoch

An Epoch is a bundle of 32 slots, which the validator proposes and attests. It represents the complete round of the POS protocol. A complete epoch usually takes 6.4 minutes (32 slots and 12sec each per slot). The Epoch determines the schedule of events on the blockchain network.

Each Epoch (bundle of 32 slots) is usually finalized after the progression of two more Epoches after it. The first slot of every Epoch is like a checkpoint where previous blocks are justified and then finalized.

  1. Committee

The committee is a group of validators randomly selected to reach a consensus on a slot to add a block to the blockchain. In the Eth Beacon Chain, each slot usually has a committee of a minimum of 128 validators. This means that an attacker has less than a one in a trillion probability of controlling the two-thirds of the selected committee.

The committee is an integral part of the Ethereum consensus layer and plays a significant role. The group of validators is randomly split across the slots to form a committee. The committee members are only allowed to vote once and get disbanded immediately.

Moreover, the committee members are pseudo-randomly selected to ensure decentralization and to prevent predictability.

The committee is divided into two roles —- the Block Proposer and the Attester

  1. The Block Proposer

As the name implies, the block proposer proposes new blocks to the committee during their assigned slot. A block proposer's job is to create and broadcast the blocks to the Beacon Chain network for attestation.

  1. The Attesters

These groups are responsible for attesting to the validity of blocks proposed by the block proposer. Their job is to confirm the correctness of the block by voting for the blocks that should be the new head of the block.

Their job is to finalize blocks and contribute to network security. This group signs and broadcasts an attestation that expresses support for a block. An attester's vote is weighed by their staked balance.

How to Monitor the Beacon Chain Data Using Bitquery

Bitquery is a blockchain data company that indexes, parses, and stores blockchain data. Blockchain data are usually transparent, immutable, and openly accessible. Bitquery helps you index and transform data into useful information to make informed decisions. The data tool offers access to over 40 blockchains, offering you access to unlimited possibilities.

Monitoring the Beacon Chain should be important to persons who work with data. With Beacon Chain analysis, you can identify trends and patterns and make informed decisions. In this section, we’ll get familiarized with the Beacon Chain data using the Bitquery Beacon Chain APIs.

  1. Attestation API

Attestation is the process where validators agree on the state of the block by signing and broadcasting their attestation. It’s a vote made by each validator to reach a consensus or to approve a transaction backed up by their staked balance. Attestation plays a vital role in achieving consensus and maintaining the integrity of the Ethereum blockchain.

The Bitquery Attestation API helps analysts gain insight into the attestation submitted to the Beacon Chain. You can get information about the epoch, slot number, community index, and attestation. You can also gain detailed information about the block where the attestation was included.

This query below gives you access to information about the Attestation Slot index 5593804

The slot_Attestation_info query below pulls the block proposer (index and public key) information, ParentRoot hash, committee Index, deposit count, and the specific date of proposal and Attestation of slot 5593804.

query slot_Attestation_info {
  ethereum2(network: eth2) {
    attestations(attestationSlot: {is: 5593804}) {
      proposer {
        index
        pubkey
      }
      parentRoot
      committeeIndex
      eth1 {
        depositCount
      }
      date {
        date(format: "%y-%m-%d")
      }
    }
  }
}

The attestation_committee_info query below pulls committee information (committee index, total attestations submitted, total validators, and the total attestation slots) created between Jan 1 and February 23, 2024.

query Attestation_committee_info {
  ethereum2(network: eth2) {
    attestations(
      options: {desc: "attestations", limit: 10}
      date: {since: "024-01-01", till: "024-02-23"}
    ) {
      committeeIndex
      attestations: count(uniq: attestations)
      validators: count(uniq: validators)
      attestation_slots: count(uniq: attestation_slots)
    }
  }
}

You can also pull several other data from the Ethereum Beacon chain using different available information (including block proposer index, blockroot hash, committee index, and so on).

  1. AttesterSlashing API

Attester slashing is the penalty imposed on validators who work against the goodwill of the chain. If the attester violates the protocol's rule, their staked balance is usually slashed (i.e. they lose a percentage of their money for breaking the rule).

The Bitquery attestation slashings API allows you to query for validators who have been slashed. You gain in-depth information about who they are — The API helps you retrieve data about the validator’s parent root, validator’s index and public key, deposit count, and so on.

The count_of_slashings query below returns the total number of epochs that were slashed after the merge. (For context, the merge occurred on 16 September 2022)

query Count_of_Slashings {
  ethereum2(network: eth2) {
    attesterSlashings(date: {after: "2022-09-15"}) {
      count(uniq: attestation_epochs)
    }
  }
}

The attester_slashing_info query pulls information about all attesters that were slashed after the merge. The query below pulls the validators’ information (index and public key), total slashings per validator, and their first and last block as attesters.

query Attester_slashing_count {
  ethereum2(network: eth2) {
    attesterSlashings(
      options: {desc: "count", limit: 10, offset: 0}
      date: {after: "022-09-16"}
    ) {
      validator {
        index
      }
      validator {
        pubkey
      }
      count: count
      min_date: minimum(of: date)
      max_date: maximum(of: date)
    }
  }
}

  1. Validator API

With this metric, you gain insight into the beacon chain validators’ information, including their statuses.

The Validator Updates API allows you to query data relating to the validators. You can use this API to get information about their deposit, token unlock, balance, withdrawal information, etc.

This validator_balance_change query returns the validator’s public key, index, and the balance change of the top 10 validators with the most balance change since the start of 2024.

query Validator_balance_change {
  ethereum2(network: eth2) {
    validatorUpdates(
      options: {desc: "validatorBalanceChange", limit: 20, offset: 0}
      date: {since: "2024-01-01"}
    ) {
      validator {
        index
        pubkey
      }
      validatorBalanceChange
    }
  }
}

  1. Deposit API

With this metric, you gain insight into the deposit made into the Beacon Chain. You gain insightful information about the deposit made, validator information blocks, etc.

The ETH2 deposits API lets you access data on the top validators based on the deposited amount.

With this query, you can learn about the total count of deposits made in 2024 by validators.

query Validators_count {
  ethereum2(network: eth2) {
    deposits(date: {since: "2024-01-01"}) {
      count: count(uniq: validators)
    }
  }
}

  1. Proposer Slashing API

A proposer is a validator assigned to create and broadcast new blocks. This validator is chosen in a pseudo-random process. They are responsible for creating blocks and broadcasting them to the attesters who validate and attest to the correctness of the block if it adheres to the consensus rule.

Proposer slashing is a penalty mechanism in the Beacon Chain that deters nefarious activities by block proposers. When a validator violates the protocol rule, their staked ETH will be slashed i.e. a certain percentage of their staked Ethereum will be confiscated.

The proposer slashing API returns information about the proposer slashing, the block height, the Validator index, and other information about the proposer slashing.

Conclusion

No doubt, the Beacon Chain is a significant part of the Ethereum blockchain and a source of information for developers, analysts, and even traders. But the most crucial point is that the information is only useful if you can access it. With this article, you’ve gained a wealth of experience in the capabilities of Bitquery Beacon Chain APIs.

About Bitquery

Bitquery is a set of software tools that parse, index, access, search, and use information across blockchain networks in a unified way. Our products are:

  • Coinpath® APIs provide blockchain money flow analysis for more than 24 blockchains. With Coinpath’s APIs, you can monitor blockchain transactions, investigate crypto crimes such as bitcoin money laundering, and create crypto forensics tools. Read this to get started with Coinpath®.

  • Digital Assets API provides index information related to all major cryptocurrencies, coins, and tokens.

  • DEX API provides real-time deposits and transactions, trades, and other related data on different DEX protocols like Uniswap, Kyber Network, Airswap, Matching Network, etc.

If you have any questions about our products, ask them on our Telegram channel or email us at sales@bitquery.io. Also, subscribe to our newsletter below, we will keep you updated with the latest in the cryptocurrency world.

Blog written by Emmanuel

Subscribe to our newsletter

Subscribe and never miss any updates related to our APIs, new developments & latest news etc. Our newsletter is sent once a week on Monday.