DEV Community

Cover image for How Polygon Blockchain works...
SK Sabiruddin
SK Sabiruddin

Posted on • Updated on

How Polygon Blockchain works...

About:

  • Polygon is a blockchain platform which aims to create a multi-chain blockchain system compatible with Ethereum. As with Ethereum, it uses a proof-of-stake consensus mechanism for processing transactions on-chain. Polygon's native token is named MATIC. Matic is an ERC-20 token, allowing for compatibility with other Ethereum cryptocurrencies.
  • Polygon uses a modified proof of stake consensus mechanism that enables a consensus to be achieved with every block. Achieving consensus using traditional proof of stake requires processing many blocks to achieve consensus.
  • The proof of stake method requires network participants to stake—agree to not trade or sell—their MATIC tokens, in exchange for the right to validate Polygon network transactions. Successful validators in the Polygon network are rewarded with MATIC tokens.
  • The Polygon network aims to address problems within the Ethereum platform, namely high transaction fees and slow processing speeds.
  • Layer 2 solution. Off Chian computation. It's Decentralised.
  • Scalability issues solved. High throughput (High TPS). Enhance the capability of Ethereum.
  • Can achieve 10000 TPS.
  • Provide SDK. Mobile apps can build using this.
  • Matic js : to build Polygon apps using JS.
  • It has Polygon mainnet and mumbai testnet.

Architecture of Polygon:

Polygon Architecture

  • Polygon network is divided into 3 Parts/Layers:

    • 1) Ethereum Mainnet. / BeaconChain. It has: (All the SC that polygon is using i.e. Staking Contract , checkpoint contract and Reward Contract etc. ⮃
    • 2)Heimdall (POS for Polygon): <- (Polygon consensus layer).It contains POS mechanism. (2/3 voting)
    • 3) BOR layer. For adding new Blocks. (MATIC Chain = Native token for Polygon.)
  • The Heimdall node is responsible for aggregating or rolling up blocks produced by the Bor node into a Merkle tree and publishing the Merkle root onto the Ethereum blockchain in periodic intervals called checkpoints.

  • Checkpointing provides finality on the Ethereum network which is used in the withdrawal of assets from Polygon to Ethereum through Proof of Burn proofs.

  • The Bor node, a Geth fork, is the execution layer of Polygon. It’s responsible for processing transactions into blocks and passing those blocks to Heimdall for validation.

  • Polygon network blocks are by default proposed in the BOR layer, after which they are forwarded to the Ethereum layer after consensus is reached via the POS mechanism in the Heimdall layer.

  • There are various checkpoints available in Polygon POS. One block is minted in every 2 seconds in the BOR chain.

  • Each block will have its own blockhash. One block has between 100 and 200 TXN.

  • For example, five blocks with various TXNs connected to a POS polygon checkpoint. The merkel root hash for all block hashes was then represented by combining the block hashes of the individual blocks. The ethereum mainnet will receive that single merkle root hash.

  • Thus, 1 hash will be used to represent 600 transactions on the mainnet. Block will be put to the Ethereum blockchain after the Merkel root and TXN have been verified. Only the final polygon transaction, not the individual blocks, will be able to alter the Ethereum State.

  • Make sure a specific transaction is real or not by using the Merkel root.

  • At checkpoints, the BOR layer continuously generates new blocks and adds them to the Heimdall layer.

  • In every 10-20 minutes, checkpointing and snapshots of every block (Merkel Root) are taken i.e., all suggested blocks are added to the Heimdall layer on the checkpoint every 20 minutes.

  • These blocks from BOR networkswere added by randomly selected validators from the POS polygon.

  • In order to avoid doing transactions on the Ethereum blockchain, Polygon must execute the majority of its Transactions or operations in the offchain. Just To confirm the transactions, it uses Ethereum.

Heimdall Chain: (POS network , acting like BeaconChain)

  • It is the POS verification layer of polygon.it does the Checkpointing of BOR blocks/ Plasma blocks representation.
  • Transferring the Merkel root to the Ethereum blockchain from a checkpoint. And all the logic to validate this three-layer architecture is contained in the Polygon Smart Contract that was implemented on Ethereum.
  • The Ethereum mainnet is where the staking contract is deployed. It includes all the logic for proposing new blocks, allocating voting rights to various validators, selecting a random validator, and overseeing checkpoints.
  • On the Ethereum blockchain, Heimdall is able to perform function calls to the staking smart contracts. Polygon uses the Ethereum Mainnet for all it's security.
  • Aggregation of blocks produced by BORat the checkpoints. Then, verify the block signature and hashs of the Individual blocks. It merged the blocks to create the root hash after it was validated.
  • After successful validation, the blocks are merged to create the root hash and then it will be sent to Ethereum mainnet as final transaction.
  • Tendermint software need to install in order to become a validator.
  • Every new block, one valiadtor will perform the following duties:
    • Validate all blocks since the last checkpoint.
    • Creates a merkel tree of block hashes.
    • Final hash can be checkpointed and send to the mainnet.
    • polygon will do 1-1 mapping with the mainnet.
  • Checkpoint importance/Task:
    • Providing finality on the root chain.
    • Providing proof of burn in the withdrawal assets.
    • How transfer of token happens in both chain (zkEVM)

ERC20 polygon <-> Mainnet ETH. Tokens that are mapped to equivalent amounts, that should be added to the mainnet, will be burned on polygon before being transferred to the mainnet and vice versa.

Top comments (0)