Layer 2 Solutions for Ethereum — How Do They Work?
For many years the smart contract platforms have been drawing a lot of attention from developers, businesses and governments. They have a lot of potential applications in various fields: registries, finance, healthcare, supply chains, gaming. However, the problem is that blockchain technology still suffers from very serious limitations; the worst of them is the speed of transactions.
Even Ethereum, which is the most popular blockchain platform, still doesn’t have any mainstream services or applications. All popular applications such as Cryptokitties clogged the network so much that the regular transaction was taking one day to be completed. At the same time, all networks that can achieve higher throughput are more centralized — such as EOS, Tron, NEO, all of them have only 20–100 nodes. That’s why large businesses can’t build anything on these platforms — they simply don’t trust them.
Another problem is that none of these platforms uses the rich arsenal of tools for Ethereum developers, trying to invent their own tools, and the large community of Ethereum developers doesn’t want to touch these platforms, preferring to wait until Ethereum gets upgraded.
That’s where layer 2 solutions can shine. What is layer 2 for a blockchain? That’s another chain connected to the main one, that can be used to transfer assets from Layer 1.
The layer 2 scaling solution for Bitcoin is called Lightning Network. The solution for Ethereum is called Plasma. The concepts for both are developed by Joseph Poon. There are two types of layer 2 blockchains — side chains and child chains and currently, there are two working implementations of Plasma, OMG Network (OMG) and Polygon (previously Matic). The first one is the child chain Plasma implementation, and it roots its security in the Ethereum parent chain. Polygon, on the other hand, is a child chain with its rules, connected to Ethereum. The only true Plasma according to the initial design is OMG, but a side chain implementation can also be useful for scaling.
How do they work?
OMG Network’s blockchain is anchored to Ethereum. Assets get sent to a smart contract on Layer 1 and then can be transferred on Layer 2. When necessary, the network can save the current state and balances on Ethereum. The security of the network is controlled by decentralized Watchers, special smart contracts that supervise the network. Currently, all blocks are generated by a single producer node, called the Operator, but in the future, it will be possible to switch to a decentralized scheme of the PoS consensus.
The most important feature is the total security of funds, meaning that even if some operators go malicious and try to attack the chain, all users will still be able to exit safely to the main chain retrieving all their funds.
Polygon on the other hand works as a PoS Plasma side-chain hosted on the Tendermint blockchain. Currently, its maximum throughput is 10,000 tx/s. It can also be scaled in the future by launching additional side chains. It has its own security scheme which doesn’t rely completely on Ethereum security.
Polygon owners stake their tokens in the root contract of the Ethereum chain to be able to verify transactions on the 2nd layer, on the Tendermint side chain, the main Polygon 2nd layer. Stakers also choose Block Producers who have to stake a significant amount of MATIC tokens to be nominated. There is a very low number of Block Producers to achieve faster block generation times. Any user can deposit ERC-20 or ERC-721 in the Polygon contract on the Ethereum chain.
When the transaction gets completed, the same amount of tokens appears on the Polygon chain and then can be sent to any address with a very small fee and faster confirmations (1 second or less). When a user wants to exit the Polygon chain, they can withdraw the remaining tokens from the Root contract. The current state of the Polygon chain gets saved on the Ethereum chain from time to time, every several Polygon blocks.
If somebody finds a fraudulent transaction from the bad actor on the Polygon layer, they can challenge the transaction, and if they’re right, the fraudulent node gets slashed and all its tokens go to the reporter. That’s a small additional security measure.
Overall, both Plasma implementations are very good and can be used in many areas, such as DeFi, lending platforms, exchange platforms, healthcare, and even games, as they allow to transfer ERC-721 non-fungible tokens such as CryptoKitties. Layer 2 solutions are probably going to be widely used in the future to scale blockchains.
Originally published at https://getblock.io on February 10, 2021.