Special thanks to Sanket Shah of Polygon for assisting in this research.
Ethereum-compatible networks that aim to radically reduce the cost and time to conduct transactions have a variety of names — Layer 2s, rollups, sidechains, commit-chains, and plasma chains — based on their approaches to scaling. As the Ethereum mainnet continues to face congestion and high gas fees due to increasing demand, popular applications and users have been exploring effective alternatives. Enter Polygon Proof of Stake (PoS), the leading Ethereum “commit-chain”. On January 1st 2021, approximately $40 million worth of assets were locked in Polygon PoS. Today, almost $7.5 billion worth of assets are locked in Polygon PoS, an increase of more than 187x in just six months. Clearly, users are embracing Polygon wholeheartedly today to swap tokens, play games, participate in prediction markets, and more.
But how does Polygon actually work? Last month, we proposed a framework to assist Ethereum developers and users to analyze any Ethereum scaling solution. In this post, we applied that framework to answer some of the fundamental questions regarding the functionality of Polygon:
Who operates it?
How’s the data?
What’s the stack like?
How does it prepare for the worst?
Who Operates Polygon?
Just as a quick refresher, on the Ethereum Mainnet, miners process transactions that are broadcasted by users of the network with a Proof of Work consensus mechanism. Ethereum will soon change to a Proof of Stake consensus mechanism. Scaling solutions, such as Polygon’s Proof of Stake (PoS) chain, requires a similar “operator” role on its network to process transactions. There are a few differences, however. For example, along with processing and authorizing transactions like a miner, an operator may also facilitate users entering and exiting the Polygon PoS chain itself.
Polygon relies on a set of validators, who are their operators, to secure the network. The role of validators is to run a full node, produce blocks, validate and participate in consensus and commit checkpoints on the Ethereum Mainnet. To become a validator, one needs to stake MATIC tokens with staking management contracts residing on the Ethereum mainnet.
Rewards are distributed to all stakers proportional to their stake at every checkpoint with an exception being the proposer getting an additional bonus. User reward balance gets updated in the contract which is referred to while claiming rewards.
Of course, validating does have some risks. Stakes are at risk of getting slashed in case the validator node commits a malicious act like double signing, validator downtime which also affects the linked delegators at that checkpoint.
As long as ⅔ of the weighted stake of the validators is honest, the chain will progress accurately. Validators stake their MATIC tokens as collateral to work for the security of the network and in exchange for their service, earn rewards.
In most token design patterns, the token is minted on Ethereum and can be sent to Polygon PoS. To move such a token from Ethereum to Polygon PoS, the user needs to lock funds in a contract on Ethereum, and the corresponding tokens are then minted on Polygon PoS.
This bridge relay mechanism is run by the Polygon PoS validators who need ⅔ to agree on the locked token event on Ethereum to mint the corresponding token amount on Polygon PoS.
Withdrawing assets back to Ethereum is a two step process in which the asset tokens are first burnt on the MATIC chain, and then the proof of this burn transaction has to be submitted on the Ethereum mainnet.
Funds are typically available within 1 - 3 hours, depending on the frequency of checkpoints. This transfer is executed via a message passing mechanism that is termed as `state sync`. A special bridge mechanism is used to accomplish this feat. When the user wishes to exit to Ethereum, instead of the usual method of unlocking the tokens from a special contract, it is minted.
But what if there is a dispute regarding an invalid Polygon transaction? Currently, there is no way on-chain to dispute an invalid Polygon PoS transaction. However, validators of the Polygon PoS chain submit periodic checkpoints to Ethereum. It is possible to verify a transaction on the Polygon PoS chain on Ethereum by constructing a Merkle tree proof and verifying it against the periodic checkpoints that happen on Ethereum of the Polygon PoS transaction and receipt of Merkle tree roots.
How’s the Stack?
If you're an Ethereum Developer, you're already a Polygon PoS developer. All the tools you're familiar with are supported on Polygon PoS out of the box: Truffle, Remix, Web3js, Infura, and many, many more. Recently, Truffle and Infura announced support in the form of an Infura API and Truffle box to help developers deploy on Polgyon PoS. There are no significant differences between Polygon and Ethereum from a stack perspective.
Preparing for the Worst
As long as ⅔ of the validators are honest, funds on the chain are secure. In case this assumption is not valid, in such a scenario the chain can stop or reordering can happen. Social consensus will be needed to then restart the chain from an earlier state - including snapshots of the Polygon PoS state that are submitted via checkpoints that can be used to do this.
What about bugs?
Care has been taken to reuse battle-tested components in the build out of the system. However, if there is a bug or exploit in a critical part of the system, restoring the chain to an earlier state via social consensus is the main solution.