Polygon (MATIC) Network Basics

How Polygon Became The Swiss Army Knife of Ethereum Scaling Solutions

Jake and Stake
BanklessDAO

--

Polygon Basics. (Cover design by Tim Balabuch).

Introduction

Polygon was originally launched as an L1 under the name Matic (hence the token name). At launch, Matic intended to become an “Internet of Blockchains,” allowing developers to build products with cross-chain compatibility and interoperability. But as Ethereum emerged as the dominant smart-contract chain, it became evident that Ethereum’s users would be burdened with high transaction costs and long inclusion times. In response, the Polygon team pivoted to become a framework for building and connecting Ethereum-compatible blockchains to help Ethereum scale, turning their “Internet of Blockchains” into an “Internet of Blockchains of Ethereum”.

Polygon has always focused on its users’ and developers’ experience. Since the rebrand, developers have flocked to Polygon and the mantra of “follow the developers’’ has rung true. Polygon grew tremendously in 2021 due to its dual focus on developer experience and alleviating Ethereum’s scaling issues.

Contracts deployed on Polygon have outpaced that of Ethereum over the past six months. (Source: Nansen.ai)
Daily Active Addresses have increased substantially since May 2021 (Source: Nansen.ai)

To continue its growth, Polygon must both attract new developers and retain them. To keep developers (and ultimately users) engaged with its ecosystem, Polygon has focused on allowing easy deployment of blockchain networks while promoting modular security (“Security as a Service”).

Ethereum Problems; Polygon Solutions

As Ethereum became the dominant blockchain and many users suffered through high gas prices, Polygon’s strategic decision to focus on the Ethereum ecosystem proved prescient. During the first half of 2021, gas fees were consistently over 100 gwei, ballooning to over 350 gwei at the peak.

Depending on the price of Ethereum and the complexity of interaction with the network, a single transaction could cost users tens or hundreds of USD while transaction inclusion times also increased. Combine high gas prices with long inclusion times, and both users and developers will seek alternatives.

Source: etherscan.io

Polygon aims to solve the twin problems of high transaction costs and increased inclusion times by providing a variety of scaling solutions without pulling users away from the Ethereum ecosystem. Polygon is highly aligned with Ethereum in its goals and philosophy, demonstrated through EVM compatibility, arbitrary message passing, and most importantly, Polygon’s utilization of Ethereum for security.

In summary, Polygon seeks to provide users and developers with access to the advantages of Ethereum (security, interoperability, and developer experience) with the benefits of other chains (sovereignty, scalability, and flexibility).

The Polygon Framework: An Overview

polygon.technology

Stand-alone and Secured Chains

Two types of blockchains are deployable on Polygon: stand-alone chains and secured chains.

“Stand-alone” chains are blockchains that do not rely on Ethereum’s consensus for security. This solution is geared towards projects that already have their own validators or are looking to implement another kind of scalability solution. These stand-alone chains are typically used by enterprise networks or established chains that want to integrate with the Polygon-Ethereum ecosystem. One such enterprise chain is being developed with Ernst & Young, as they are collaborating with Polygon using Nightfall to implement enterprise solutions for the Ethereum Ecosystem.

“Secured” chains are chains that do not have their own validator pool and instead rely on Polygon’s Security Layer. Polygon boasts a high level of security while allowing developers to choose between a variety of security solutions, with the most popular being the Polygon PoS (Proof-of-Stake) chain. These secured chains are designed to help start-ups and projects that require a high level of security.

Both stand-alone chains and secured chains are relatively simple for developers to deploy. This ease of deployment gives developers a wide range of options to meet the needs of their users, but such flexibility would not be possible without the architecture underlying Polygon.

Architecture

Whether stand-alone or secured, blockchains deployed on Polygon all operate within the same architectural framework. At a high level, there are four components to Polygon’s architecture: the Ethereum Layer, the Security Layer, the Polygon Networks Layer, and the Execution Layer.

Polygon Architecture (by Finematics)

Ethereum Layer

Polygon uses Ethereum as its base-layer. This layer is composed of a set of smart contracts on Ethereum that are used for settlement by checkpointing, staking, and passing messages between the Polygon and Ethereum ecosystems. This layer is responsible for resolving disputes that are eventually settled on Ethereum.

While this layer is optional, and developers have the flexibility to avoid using Ethereum’s decentralization and security, this component of the architecture is what gives Polygon its advantage. By utilizing Ethereum as a point of finality, Polygon can benefit from Ethereum’s native security. Ultimately, all disputes must be settled on Ethereum, making Ethereum the highest court in the land.

Security Layer

The second architectural layer is an optional Security Layer. This layer has been coined “validators as a service”, as it allows developers to utilize several security solutions to validate transactions. Users can adopt plasma fraud proofs or the PoS sidechain (among other solutions) for security.

To date, the most popular security solution is the PoS sidechain. The PoS sidechain utilizes a set of approximately 100 validators to secure blockchain projects (for a fee) and perform validator management. Alternatively, this layer can employ Ethereum’s miners (eventually validators) for consensus.

Again, this layer is optional. Generally, moving away from Layer 1 weakens security but improves throughput and user experience. Not all chains need to utilize Polygon’s security. Some projects, like blockchain games, might even prefer less security in exchange for faster settlement times.

Polygon Networks Layer

The Polygon Networks Layer is a network of independent blockchains that order transactions, produce blocks, and determine the consensus of their respective chains.

These chains can be stand-alone or secured. The block producers of these chains group their respective transactions, and depending on the security solution, the Networks Layer will post a Merkle root as a Layer 1 checkpoint.

Execution Layer

Finally, we have the Execution Layer. The Execution Layer interprets and executes the transactions agreed upon by the Polygon Networks Layer. There are two components to this layer:

  • Execution environment — A pluggable virtual machine implementation. Akin to the EVM, it keeps track of the blockchain state.
  • Execution logic — Implements the state transition of a particular Polygon blockchain. This logic is the set of contracts used to define the transition to the next blockchain state. Ethereum can be thought of as an “infinite state machine”.

Yet of all of these layers, the key value-add for developers is the Security Layer, as that is what allows the flexibility of the Polygon framework to really shine. Developers can choose the security solution that works for their project and swap solutions if they choose to change course. The goal is to give developers a suite of tools to spin up customized blockchain projects.

The Security Layer: A Deep Dive

While low transaction costs and short inclusion times are the primary drivers of Polygon’s growth, none of that growth would have been possible without Polygon’s modular security solutions. These “Security as a Service” solutions include Polygon’s PoS sidechain and plasma fraud proof mechanisms, while new solutions like Avail and Hermez ZK-rollups are still in development. Some of these solutions can hybridize, but all rely on the Polygon SDK.

Polygon SDK

The Polygon SDK (Software Development Kit) is a set of frameworks for projects to launch their own EVM compatible chains. This SDK is what enables “Security as a Service”, permitting developers to choose the ideal scaling solution for their project.

(polygon.technology)

As the above diagram demonstrates, the Polygon framework separates functions, allowing developers to choose their own consensus mechanism, or to develop their own consensus mechanism, while maintaining interoperability with the other chains within the Polygon ecosystem.

Such interoperability allows Polygon chains with different scaling solutions to communicate with each other, permitting developers to choose custom-tailored security solutions. Polygon also plans to add more out-of-the-box consensus mechanisms, database implementations, and other auxiliary services.

PoS Security

Polygon’s most popular scaling solution is its Proof-of-Stake sidechain. With the PoS sidechain, MATIC tokens are staked on Ethereum, where the set of validators/stakers is maintained. These stakers choose a “proposer” to create checkpoints to send to the Ethereum Network. The proposer then gathers the transactions from the blocks in the Polygon Networks Layer and creates a Merkle root. This root is validated by other stakers and is subsequently posted to Ethereum.

The Polygon PoS chain has two components: Heimdall and Bor. These layers perform different functions for the PoS chain: Heimdall performs validator management and checkpointing, while Bor aggregates transactions into blocks for Heimdall.

Bor block producers are a subset of validators chosen by Heimdall, which are periodically rotated. Once a set of blocks have been produced by Bor, Heimdall will create a merkle root using those blocks. This merkle root is then posted to Ethereum as a checkpoint. The checkpoint proposers are chosen through Tendermint consensus (a weighted round robin algorithm).

Plasma Security

Polygon has another set of smart contracts on Ethereum that enable Polygon’s plasma solution. Ethereum transactions are off-loaded to plasma chains to enable fast and cheap transactions, as plasma chains use their own consensus to order blocks; this consensus mechanism can be Proof of Work, Proof of Stake, or other options.The child (plasma) chain subsequently creates fraud proofs that are posted to the Ethereum main chain, where they can be challenged and eventually resolved.

There are several downsides to using plasma chains. These include long withdrawal times (seven-day withdrawal period) and a limited set of features. Plasma can support basic token transfers, swaps, and other simple transactions, but not general computation. Ethhub has an in-depth explanation of plasma solutions.

Notably, developers can choose between the PoS contracts, the plasma contracts, or a hybrid of the two, giving developers greater flexibility to choose the appropriate security solution.

Bridging Assets from Ethereum

The same smart contracts that permit plasma to run on Polygon also control the bridging of assets to and from the Ethereum main chain. While the plasma bridge requires a seven-day withdrawal period, the PoS bridge allows for faster withdrawal times.

(polygon.technology)

The security of the PoS bridge relies on Polygon validators and users are unable to challenge disputes, unlike Plasma. In short, the PoS bridge has more trust assumptions, but is still more popular than the plasma bridge. By bridging tokens, your assets are locked in the bridge contracts and new tokens are minted on the sidechain’s network. Similarly, when you initiate a withdrawal, assets must be burned on the sidechain before they can be transferred out of the bridge contract.

The Future of Security on the Polygon Network.

Polygon is working on two new security solutions: its native Avail Data Availability Chain and the Hermez ZK-rollup.

Avail Security

Avail” is Polygon’s data availability and security chain. As detailed in the Avail whitepaper, Avail is designed to decouple data hosting, execution, and consensus. Data availability chains allow sidechains to focus on code execution and then leverage Avail as a Security Layer and data store.

In essence, data can be stored on the Avail chain, allowing projects to focus on state execution. Avail becomes the consensus mechanism (Security Layer) and is responsible for ordering transaction data and guaranteeing data availability, reducing the problem of block verification to data availability verification.

Light clients can verify blocks by asking other nodes for a fraud proof (data-availability proof) of the block. If a fraud proof is provided, the block is rejected. However, nodes require adequate data availability to construct a fraud proof, so if the block proposer provides incomplete data, nodes will not be able to generate the proof (Sidenote: Vitalik wrote a piece about verifying data availability using fraud proofs and erasure codes).

Avail can verify data availability at scale using data sampling, a probabilistic method for data availability verification. A block is only approved if the data for that block’s computation is available and correctly ordered. While still under development, Avail may prove to be the blockchain framework many developers will choose to rely on in the future.

Polygon Hermez (ZK-rollup) Security

Polygon recently acquired/merged with Hermez, a ZK-rollup solution. Hermez is working on an EVM-equivalent ZK-rollup, a very promising Layer 2 solution optimized for secure, low-cost token transfers. ZK-rollups take batches of transactions and condense them into small amounts of data in the form of validity proofs (or zk-SNARKs). This data is then posted on-chain to enable verification of the proof’s correctness. Hermez boasts a 133x throughput improvement with one-tenth the transaction cost when compared to Ethereum.

This solution does not have plasma’s downside of seven-day withdrawal times because there is no need to challenge the data via fraud proofs, as the SNARK proof is computationally easy to verify. However, the construction of validity proofs is still computationally intensive, and research is ongoing. Deployment is still in the future, but as with Avail, the future for ZK-rollups looks promising.

Polygon Miden

Polygon also recently announced a new ZK project called Miden, a STARK-based, EVM-compatible rollup. The project is headed up by Bobbin Threadbare, the core developer of other ZK technologies Distaff VM (a STARK-based VM) and Winterfell (a highly performant STARK prover).

This solution will be purely STARK-based, supporting arbitrary transactions and automatically generating proofs of execution. Miden will compile Solidity code into Miden Assembly, which will be used by the Miden VM to execute transactions and generate zero-knowledge proofs.

Where Hermez aims to be fully EMV-compatible (at the op-code level), Miden will begin with Solidity compilation and move to other languages. This is a very recent announcement, so expect more information to come.

Conclusion

Polygon’s decision to focus on providing scaling solutions for Ethereum has proven successful, as the Polygon network has seen explosive growth throughout 2021. To continue this growth, Polygon is hard at work building out-of-the-box scaling and security solutions to enable developers to leverage Polygon’s reduced transaction costs and inclusion times. With over $1B USD in its treasury dedicated to ZK-rollup solutions alone, Polygon has the resources to further expand its suite of solutions to help Ethereum scale to meet the projected network loads of tomorrow.

Author Bio

Jake and Stake is a contributor to BanklessDAO with a background in computer science and cybersecurity. He’s a crypto-native on the Bankless journey with interests in DAOs, DeFi, and the intersection of humanity and technology.

Editor Bios

Hiro Kennelly is a writer and editor at BanklessDAO. Core Team DAOpunksNFT. Come for the tech, stay for the revolution.

Trewkat is an editor and active BanklessDAO Writers Guild member. She’s interested in learning as much as possible about crypto and NFTs, with a particular focus on how best to communicate this newfound knowledge to others.

BanklessDAO is an education and media engine dedicated to helping individuals achieve financial independence.

--

--