> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polygon.technology/llms.txt
> Use this file to discover all available pages before exploring further.

# Polygon PoS Architecture

> Architectural overview of Polygon PoS from a node perspective, covering the Heimdall-v2 consensus layer and Bor execution layer.

Polygon PoS is structured as a two-layer system: a consensus layer called Heimdall-v2 and an execution layer called Bor.

Nodes on Polygon are designed around this two-layer split. Bor handles block production; Heimdall-v2 handles validation, checkpoint submission, and coordination with Ethereum.

<img src="https://mintcdn.com/polygon-labs/538SapMSabh-Xfju/img/pos/architecture.png?fit=max&auto=format&n=538SapMSabh-Xfju&q=85&s=c1ba889f3e93999492389d6352f4cddd" alt="Figure: Ethereum, Bor and Heimdall architecture" width="5760" height="3600" data-path="img/pos/architecture.png" />

## Three-layer view

The network can be described as three layers:

* **Ethereum layer**: a set of contracts on Ethereum mainnet. These include staking contracts, checkpoint storage, and the bridge.
* **Heimdall-v2 layer**: a set of proof-of-stake nodes running in parallel to Ethereum mainnet. Heimdall-v2 monitors staking contracts on Ethereum, validates Bor block data, and submits checkpoints to Ethereum. Built on Cosmos SDK and CometBFT.
* **Bor layer**: a set of block-producing nodes shuffled by Heimdall. Built on Go Ethereum.

## Staking contracts on Ethereum

The PoS mechanism relies on staking management contracts deployed on Ethereum mainnet. These contracts:

* Allow anyone to stake POL tokens and register as a validator.
* Distribute staking rewards for validating state transitions on the network.
* Record checkpoints submitted by Heimdall.

The PoS mechanism also provides a partial mitigation for the data unavailability problem on Polygon sidechains, since checkpoint data is anchored to Ethereum.

## Heimdall-v2: validation layer

Heimdall-v2 aggregates blocks produced by Bor into Merkle trees and publishes the Merkle root periodically to Ethereum. These periodic snapshots are called checkpoints.

For every set of Bor blocks, a Heimdall-v2 validator:

1. Validates all blocks since the last checkpoint.
2. Creates a Merkle tree of the block hashes.
3. Publishes the Merkle root hash to Ethereum mainnet.

Checkpoints serve two purposes:

* Providing finality on Ethereum for cross-chain withdrawals.
* Providing proof of burn for asset withdrawal to Ethereum.

Block producer selection works as follows:

* A subset of active validators from the pool is selected as block producers for a span. These producers create and broadcast blocks.
* A checkpoint includes the Merkle root hash of all blocks in a given interval. All nodes validate the hash and attach their signatures.
* A proposer from the validator set collects all signatures and submits the checkpoint to Ethereum mainnet.
* Validator selection probability is proportional to stake ratio in the overall pool.

Heimdall-v2 is a complete rewrite of the original Heimdall. It is based on Cosmos SDK and CometBFT. The migration is specified in:

* [PIP-43: Replacing Tendermint with CometBFT](https://github.com/maticnetwork/Polygon-Improvement-Proposals/blob/cb371136414b5e198c44750cd4c30f7aad16043a/PIPs/PIP-43.md)
* [PIP-44: Upgrade Cosmos-SDK](https://github.com/maticnetwork/Polygon-Improvement-Proposals/blob/cb371136414b5e198c44750cd4c30f7aad16043a/PIPs/PIP-44.md)
* [PIP-62: Heimdall-v2 Migration](https://github.com/maticnetwork/Polygon-Improvement-Proposals/blob/cb371136414b5e198c44750cd4c30f7aad16043a/PIPs/PIP-62.md)

Throughout these docs, "Heimdall" refers to Heimdall-v2 unless otherwise specified.

## Bor: block production layer

Bor is Polygon PoS's block producer, responsible for aggregating transactions into blocks. Block producers are a rotating subset of validators selected periodically by Heimdall based on stake.

See [Bor architecture](/pos/architecture/bor/introduction/) for detailed mechanics.
