layer 2 – Finematics https://finematics.com decentralized finance education Mon, 02 Aug 2021 16:23:54 +0000 en-GB hourly 1 https://wordpress.org/?v=5.8.1 https://finematics.com/wp-content/uploads/2017/09/cropped-favicon-32x32.png layer 2 – Finematics https://finematics.com 32 32 Rollups – The Ultimate Ethereum Scaling Solution https://finematics.com/rollups-explained/?utm_source=rss&utm_medium=rss&utm_campaign=rollups-explained&utm_source=rss&utm_medium=rss&utm_campaign=rollups-explained https://finematics.com/rollups-explained/#respond Mon, 02 Aug 2021 16:23:52 +0000 https://finematics.com/?p=1390

So what are rollups all about? What’s the difference between optimistic and ZK rollups? How is Arbitrum different from Optimism? And why are rollups considered to be the holy grail when it comes to scaling Ethereum? You’ll find answers to these questions in this article.

Intro

Ethereum scaling has been one of the most discussed topics in crypto. The scaling debate usually heats up during periods of high network activity such as the CryptoKitties craze in 2017, DeFi Summer of 2020 or the crypto bull market at the beginning of 2021. 

During these periods, the unparalleled demand for the Ethereum network resulted in extremely high gas fees making it expensive for everyday users to pay for their transactions. 

To tackle this problem, the search for the ultimate scaling solution has been one of the top priorities for multiple teams and the Ethereum community as a whole. 

In general, there are 3 main ways to scale Ethereum or in fact, most other blockchains: scaling the blockchain itself – layer 1 scaling; building on top of layer 1 – layer 2 scaling and building on the side of layer 1 – sidechains. 

When it comes to layer 1, Eth2 is the chosen solution for scaling the Ethereum blockchain. Eth2 refers to a set of interconnected changes such as the migration to Proof-of-Stake (PoS), merging the state of the Proof-of-Work (PoW) blockchain into the new PoS chain and sharding. 

Sharding, in particular, can dramatically increase the throughput of the Ethereum network, especially when combined with rollups. 

If you’d like to learn more about Eth2 you can check out this article here.   

When it comes to scaling outside of layer 1, multiple different scaling solutions have been tried with some mixed results. 

On the one hand, we have layer 2 solutions such as Channels that are fully secured by Ethereum but work well only for a specific set of applications. 

Sidechains, on the other hand, are usually EVM-compatible and can scale general-purpose applications. The main drawback – they are less secure than layer 2 solutions by not relying on the security of Ethereum and instead having their own consensus models. 

Most rollups aim at achieving the best of these 2 worlds by creating a general-purpose scaling solution while still fully relying on the security of Ethereum.

This is the holy grail of scaling as it allows for deploying all of the existing smart contracts present on Ethereum to a rollup with little or no changes while not sacrificing security. 

No wonder rollups are probably the most anticipated scaling solution of them all. 

But what are rollups in the first place? 

Rollups 

A rollup is a type of scaling solution that works by executing transactions outside of Layer 1 but posting transaction data on Layer 1. This allows the rollup to scale the network and still derive its security from the Ethereum consensus. 

Moving computation off-chain allows for essentially processing more transactions in total as only some of the data of the rollup transactions has to fit into the Ethereum blocks. 

To achieve this, rollup transactions are executed on a separate chain that can even run a  rollup-specific version of the EVM. 

The next step after executing transactions on a rollup is to batch them together and post them to the main Ethereum chain. 

The whole process essentially executes transactions, takes the data, compresses it and rolls it up to the main chain in a single batch, hence the name – a rollup. 

Although this looks like a potentially good solution, there is a natural question that comes next: 

“How does Ethereum know that the posted data is valid and wasn’t submitted by a bad actor trying to benefit themselves?” 

The exact answer depends on a specific rollup implementation, but in general, each rollup deploys a set of smart contracts on Layer 1 that are responsible for processing deposits and withdrawals and verifying proofs. 

Proofs are also where the main distinction between different types of rollups comes into play. 

Optimistic rollups use fraud proofs. In contrast, ZK rollups use validity proofs.

Let’s explore these two types of rollups further. 

Optimistic Vs ZK Rollups

Optimistic rollups post data to layer 1 and assume it’s correct hence the name “optimistic”. If the posted data is valid we are on the happy path and nothing else has to be done. The optimistic rollup benefits from not having to do any additional work in the optimistic scenario.

In case of an invalid transaction, the system has to be able to identify it, recover the correct state and penalize the party that submits such a transaction. To achieve this, optimistic rollups implement a dispute resolution system that is able to verify fraud proofs, detect fraudulent transactions and disincentivize bad actors from submitting other invalid transactions or incorrect fraud proofs. 

In most of the optimistic rollup implementations, the party that is able to submit batches of transactions to layer 1 has to provide a bond, usually in the form of ETH. Any other network participant can submit a fraud proof if they spot an incorrect transaction. 

After a fraud proof is submitted, the system enters the dispute resolution mode. In this mode, the suspicious transaction is executed again this time on the main Ethereum chain. If the execution proves that the transaction was indeed fraudulent, the party that submitted this transaction is punished, usually by having their bonded ETH slashed. 

To prevent the bad actors from spamming the network with incorrect fraud proofs, the parties wishing to submit fraud proofs usually also have to provide a bond that can be subject to slashing.

In order to be able to execute a rollup transaction on layer 1, optimistic rollups have to implement a system that is able to replay a transaction with the exact state that was present when the transaction was originally executed on the rollup. This is one of the complicated parts of optimistic rollups and is usually achieved by creating a separate manager contract that replaces certain function calls with a state from the rollup. 

It’s worth noting that the system can work as expected and detect fraud even if there is only 1 honest party that monitors the state of the rollup and submits fraud proofs if needed. 

It’s also worth mentioning that because of the correct incentives within the rollup system, entering the dispute resolution process should be an exceptional situation and not something that happens all the time. 

When it comes to ZK rollups, there is no dispute resolution at all. This is possible by leveraging a clever piece of cryptography called Zero-Knowledge proofs hence the name ZK rollups. In this model, every batch posted to layer 1 includes a cryptographic proof called a ZK-SNARK. The proof can be quickly verified by the layer 1 contract when the transaction batch is submitted and invalid batches can be rejected straight away. 

Sounds simple right? Maybe on the surface. In practice to make it work, multiple researchers spent countless hours iterating on these clever pieces of cryptography and maths. 

There are a few other differences between optimistic and ZK rollups, so let’s go through them one by one. 

Due to the nature of the dispute resolution process, optimistic rollups have to give enough time to all the network participants to submit the fraud proofs before finalizing a transaction on layer 1. This period is usually quite long to make sure that even in the worst-case scenario, fraudulent transactions can still be disputed. 

This causes the withdrawals from optimistic rollups to be quite long as the users have to wait even as much as a week or two to be able to withdraw their funds back to layer 1. 

Fortunately, there are a few projects that are working to improve this situation by providing fast “liquidity exists”. These projects offer almost instant withdrawals back to layer 1, another layer 2 or even a sidechain and charge a small fee for the convenience. The Hop protocol and Connext are the projects to look at. 

ZK rollups don’t have the problem of long withdrawals as the funds are available for withdrawals as soon as the rollup batch, together with a validity proof, is submitted to layer 1. 

So far it looks like ZK rollups are just a better version of optimistic rollups, but they also come with a few drawbacks. 

Due to the complexity of the technology, it’s much harder to create an EVM-compatible ZK rollup which makes it more difficult to scale general-purpose applications without having to rewrite the application logic. Saying this, ZKSync is making significant progress in this area and they might be able to launch an EVM-compatible ZK rollup quite soon. 

Optimistic rollups have a little bit of an easier time with the EVM compatibility. They still have to run their own version of the EVM with a few modifications, but 99% of contracts can be ported without making any changes. 

ZK rollups are also way more computation-heavy than optimistic rollups. This means that nodes that compute ZK proofs have to be high-spec machines, making it hard for other users to run them. 

When it comes to scaling improvements, both types of rollups should be able to scale Ethereum from around 15 to 45 transactions per second (depending on the transaction type) up to as many as 1000-4000 transactions per second.

It’s worth noting that it is possible to process even more transactions per second by offering more space for the rollup batches on layer 1. This is also why Eth2 can create a massive synergy with rollups as it increases the possible data availability space by creating multiple shards – each one of them able to store a significant amount of data. The combination of Eth2 and rollups could bring Ethereum transaction speed up to as many as 100k transactions per second. 

Now, let’s talk about all the different projects working on both optimistic and ZK rollups.

Optimistic Rollups 

Optimism and Arbitrum are currently the most popular options when it comes to optimistic rollups. 

Optimism has been partially rolled out to the Ethereum mainnet with a limited set of partners such as Synthetix or Uniswap to ensure that the technology works as expected before the full launch. 

Arbitrum already deployed its version to the mainnet and started onboarding different projects into its ecosystem. Instead of allowing only limited partners to be able to deploy their protocols first, they decided to give a window of time for all protocols that want to launch on their rollups. When this period of time is finished, they will open the flood gates to all the users in one go. 

Some of the most notable projects launching on Arbitrum are Uniswap, Sushi, Bancor, Augur, Chainlink, Aave and many more. 

Arbitrum has also recently announced its partnership with Reddit. They’ll be focusing on launching a separate rollup chain that will allow Reddit to scale their reward system. 

Optimism is partnering with MakerDAO to create the Optimism Dai Bridge and enable fast withdrawals of DAI and other tokens back to layer 1. 

Although both Arbitrum and Optimism try to achieve the same goal – building an EVM-compatible optimistic rollups solution – there are a few differences in their design.

Arbitrum has a different dispute resolution model. Instead of rerunning a whole transaction on layer 1 to verify if the fraud proof is valid, they have come up with an interactive multi-round model which allows narrowing down the scope of the dispute and potentially executes only a few instructions on layer 1 to check if a suspicious transaction is valid. 

This also resulted in a nice side effect where smart contracts deployed on Arbitrum can be larger than the maximum allowed contract size on Ethereum. 

Another major difference is the approach to handling transaction ordering and MEV.

Arbitrum will be initially running a sequencer that is responsible for ordering transactions, but they want to decentralize it in the long run.

Optimism prefers another approach where the ordering of transactions, and hence the MEV, can be auctioned off to other parties for a certain period of time.  

It’s also worth mentioning a few other projects working on optimistic rollups. Fuel, the OMG team with OMGX and Cartesi to name a few. Most of them try to also work on an EVM-compatible version of their rollups. 

ZK Rollups

Although it looks like the Ethereum community is mostly focusing on optimistic rollups, at least in the short run, let’s not forget that the projects working on ZK rollups are also progressing extremely quickly. 

With ZK rollups we have a few options available.

Loopring uses ZK rollup technology to scale its exchange and payment protocol. 

Hermez and ZKTube are working on scaling payments using ZK rollups with Hermez also building an EMV-compatible ZK rollup. 

Aztec is focusing on bringing privacy features to their ZK rollup technology. 

StarkWare-based rollups are already extensively used by projects such as DeversiFi, Immutable X and dYdX. 

As we mentioned earlier, ZKSync is working on an EMV-compatible virtual machine that will be able to fully support any arbitrary smart contracts written in Solidity. 

Summary

As we can see, there are a lot of things going on in both the optimistic and the ZK rollup camps and the competition between different rollups will be interesting to watch. 

Rollups should also have a big impact on DeFi. Users who were previously not able to transact on Ethereum due to high transaction fees will be able to stay in the ecosystem the next time the network activity is high. They will also enable a new breed of applications that require cheaper transactions and faster confirmation time. All of this while being fully secured by the Ethereum consensus. It looks like rollups may trigger another high growth period for DeFi. 

There are however a few challenges when it comes to rollups. 

Composability is one of them. In order to compose a transaction that uses multiple protocols, all of them would have to be deployed on the same rollup. 

Another challenge is fractured liquidity. For example, without the new money coming into the Ethereum ecosystem as a whole, the existing liquidity present on layer 1 in protocols such as Uniswap or Aave will be shared between layer 1 and multiple rollup implementations. Lower liquidity usually means higher slippage and worse trade execution. 

This also means that naturally there will be winners and losers. At the moment, the existing Ethereum ecosystem is not big enough to make use of all scaling solutions. This may and probably will change in the long run, but in the short run, we may see some of the rollups, and other scaling solutions, becoming ghost towns. 

In the future, we may also see users living entirely within one rollup ecosystem and not interacting with the main Ethereum chain and other scaling solutions for long periods of time. This could be particularly visible if we’re going to see more centralized exchanges enabling direct deposits and withdrawals to and from rollups. 

Nevertheless, rollups seem like the ultimate strategy for scaling Ethereum and the challenges will be most likely mitigated in one way or another. It will be clearly super interesting to see how rollups gain more and more users’ adoption. 

One question that comes up very often when discussing rollups is if they are a threat to sidechains. Personally, I think that sidechains will still have their place in the Ethereum ecosystem. This is because, although the cost of transactions on Layer 2 will be much lower than on Layer 1, it will most likely still be high enough to price out certain types of applications such as games and other high volume apps. 

This may change when Ethereum introduces sharding, but by then sidechains may create enough network effect to survive long term. It will be interesting to see how this plays out in the future. 

Also, the fees on rollups are higher than on sidechains because each rollup batch still has to pay for the Ethereum block space. 

It’s worth remembering that the Ethereum community puts a huge focus on rollups in the Ethereum scaling strategy – at least in the short to mid-term and potentially even longer. I recommend reading Vitalik Buterin’s post on a rollup-centric Ethereum roadmap.

So what do you think about rollups? What are your favourite rollup technologies? 

If you enjoyed reading this article you can also check out Finematics on Youtube and Twitter.

]]>
https://finematics.com/rollups-explained/feed/ 0
Polygon (Matic) – Ethereum’s Internet Of Blockchains https://finematics.com/polygon-matic-explained/?utm_source=rss&utm_medium=rss&utm_campaign=polygon-matic-explained&utm_source=rss&utm_medium=rss&utm_campaign=polygon-matic-explained https://finematics.com/polygon-matic-explained/#respond Sun, 14 Mar 2021 17:33:58 +0000 https://finematics.com/?p=1285

So what is Polygon, previously Matic, all about? How will it help with scaling Ethereum? Why does it claim to be Ethereum’s Internet of Blockchains? And why is it sometimes compared to Polkadot and Cosmos? You’ll find answers to these questions in this article. 

Now, let’s see how Polygon came into existence. 

Matic Network

Before the rebranding to Polygon, the project was known as Matic or Matic Network.

Matic was started in 2017 by 3 founders who were active participants in the cryptocurrency community in India and decided to band together and tackle Ethereum’s scaling problems. 

The team worked on 2 main solutions:

Plasma Chains – a layer 2 scaling solution based on Matic’s implementation of Plasma and a PoS Chain – a Proof-Of-Stake Ethereum sidechain. 

The token behind Matic Network – MATIC – was distributed through the Binance Launchpad’s initial exchange offering in April 2019 and the team was able to raise $5.6M. 

After over 2.5 years of work, The Matic Network Mainnet went live in mid-2020 and quickly started attracting more and more attention. This was supercharged by the increasing gas fees on Ethereum that showed an urgent need for finding robust scaling solutions.  

Polygon Rebranding

At the beginning of 2021, the Matic team decided to expand the scope of their project and rebranded themselves to Polygon. 

Polygon aims at creating a more generalised scaling solution. 

When it comes to scaling there are 2 main ways of doing it: Layer 2 scaling and sidechains. 

Layer 2 scaling relies on the security of the main layer – the Ethereum blockchain. Plasma, Optimistic rollups and ZK rollups are the most popular options. 

Sidechains rely on their own security models, usually by having a separate consensus mechanism. Matic PoS chain or xDai are good examples here.

If you’re interested in learning more about these different scaling solutions you can check out this article here

Instead of providing one or two scaling solutions, Polygon aims at creating an ecosystem that makes it easy to connect multiple different scaling solutions – everything from sidechains with different consensus mechanisms to Layer 2 options such as Plasma, Optimistic Rollups and ZK rollups. 

We can think about the existing Matic scaling solutions – the PoS and the Plasma chains basically becoming one of many scaling options available in the whole Polygon ecosystem. 

Polygon also provides a framework that makes it easy for new projects to quickly build their own highly-customisable scaling solution if they decide this is the path they want to choose. 

Now, let’s have a closer look at the technology behind Polygon to understand the project a bit better. 

Polygon Architecture

Polygon supports two major types of Ethereum-compatible blockchain networks: stand-alone networks and secured chains – networks that leverage a “security as a service” model. 

Stand-alone chains rely on their own security, for example, they can have their own consensus models such as Proof-Of-Stake or Delegated-Proof-Of-Stake. These kind of networks are fully sovereign which presents them with the highest level of independence and flexibility, but it makes it more difficult for them to establish a reliable security model. For example, PoS requires a high number of reliable validators. This kind of model is usually suitable for enterprise blockchains and already established projects with strong communities. 

Secured chains utilise the “security as a service” model. This can be either provided directly by Ethereum, for example via fraud proofs used by Plasma, or by a pool of professional validators. These validators are run in the Polygon ecosystem and they can be shared by multiple projects – a concept similar to Polkadot’s shared security model. Secured chains offer the highest level of security but sacrifice independence and flexibility. This model is usually preferred by startups and security-focused projects. 

As we’ve probably noticed, the distinction between stand-alone chains and secured chains is even more generic than the usual split between sidechains and layer 2 solutions that we described earlier. This allows Polygon to accommodate pretty much all possible scaling solutions. 

Now, as we know what kind of solutions are supported by Polygon, let’s dive a bit deeper into the architecture. 

Polygon architecture consists of 4 abstract and composable layers. 

The Ethereum Layer. Polygon chains can use Ethereum as their base layer and leverage Ethereum’s high security. This layer is implemented as a set of smart contracts on Ethereum and can be used for things like finality and checkpointing, staking, dispute resolution and messaging between Ethereum and Polygon chains. 

This layer is optional as Polygon-based chains are not obligated to use it.

The next one is the Security Layer. This is another non-mandatory layer that can provide a “validators as a service” function. This function allows Polygon chains to make use of a set of validators that can periodically check the validity of any Polygon chain in return for a fee.  

This layer is usually implemented as a meta blockchain that runs in parallel to Ethereum and is responsible for things like validator management – registering/deregistering, rewards, shuffling and Polygon Chains validation. 

The Security Layer is fully abstract and can have multiple implementations with different characteristics. This layer can also be implemented directly on Ethereum and leverage Ethereum’s miners as validators. 

The next layer is the Polygon Networks Layer. This is the first mandatory layer in the Polygon architecture. This layer consists of sovereign blockchain networks where each network can maintain the following functions: transaction collation, local consensus and block production. 

Last, but not least is the Execution Layer. This layer is responsible for interpreting and executing transactions that are included in Polygon’s chains. It consists of the execution environment and execution logic sublayers. 

The main takeaway when it comes to Polygon’s architecture is that it is deliberately made to be generic and abstract. This allows other applications, that are looking to scale, to choose the best scaling solution that perfectly fits their needs. 

As we know, different applications may want to optimise for different things such as security, transaction speed, transaction cost or sovereignty and to excel in one of them usually means making a sacrifice somewhere else. 

As an example, a DeFi protocol that aims at storing billions of dollars locked in smart contracts probably wants to optimise for security and might be happy with sacrificing sovereignty. A protocol like this would most likely use the Ethereum Layer. 

Another project, let’s say an NFT marketplace, may want to optimise for ultra-low transaction costs and would be ok with making a sacrifice by lowering their security from extremely high to high enough. Such a project could skip the Ethereum Layer and rely on the Security Layer, with a set of shared validators. 

Or maybe a blockchain-based game wants to rely on its own consensus mechanism with ultra-fast block time. In this case, they can entirely skip both the Ethereum and the Security Layer and focus on the Polygon Network Layer. 

As we can see, Polygon can provide multiple options and the teams behind different applications can decide to pick the one that perfectly fits their use cases. It also aims at making it easy to migrate from one scaling solution to another one. This might be needed if the circumstances behind a project change, or if another better scaling solution becomes available.

This architecture also allows for multiple different Polygon-based scaling solutions to communicate with each other. This is super important, as it prevents creating siloed systems. 

At the moment, the only scaling solutions available in the Polygon ecosystem are the Matic PoS chain and the Matic Plasma Chain solutions. The team is also actively working on adding multiple other options such as ZK rollups, optimistic rollups, enterprise chains and other side chains.

Currently, projects launching on Polygon start with the Matic PoS and the Matic Plasma Chains.

Matic PoS Chain And Matic Plasma Chains

Matic Plasma Chains is an Ethereum Layer 2, predicate-based Plasma implementation. Plasma, in essence, is a framework for building scalable decentralized applications.

Plasma allows for offloading transactions from the main chain into child chains which enables fast and cheap transactions. One of the drawbacks of Plasma is a long waiting period for users who want to withdraw their funds from Layer 2. Plasma cannot be used to scale general-purpose smart contracts.

Matic PoS Chain is a permissionless sidechain and runs in parallel to the Ethereum chain. The chain is secured by the Proof-Of-Stake consensus mechanism with its own validators. 

Although Matic PoS Chain has its own consensus mechanism it also relies on Ethereum’s security when it comes to validator staking and checkpoints. 

Matic PoS chain is EVM-compatible, which allows Ethereum-based projects to effortlessly migrate their smart contracts. 

So far, Matic PoS Chain and Matic Plasma Chains were able to onboard over 80 applications, process over 5M transactions and secure over $200M of users’ funds.

Some of the projects that have either already migrated to Matic PoS Chain, launched directly on Matic, or are in the process of migrating include Quickswap – a fork of Uniswap, Sushiswap, Aavegotchi, Polymarket, Polkamarkets and Superfarm.

Besides that, infrastructure projects such as The Graph and Chainlink also decided to expand to Polygon. 

Recently, Polygon also announced a partnership with a big player in the video gaming industry – Atari.

Summary

So far, it looks like Matic’s rebranding to Polygon and the expansion of the scope of the project was a really good idea. 

This is mainly because it becomes clearer and clearer that there will be a spectrum of different scaling solutions available in the future. 

In the new architecture, Polygon can facilitate connections between these different scaling options. 

It also looks like there is a big focus on both optimistic rollups and ZK rollups which Polygon can also add to the multitude of available scaling solutions. 

The main risk here would be if one of these popular scaling technologies gets adopted on its own without integrating with Polygon. But even if this happens, there is a chance that this technology would eventually be integrated into Polygon anyway.  

It will be interesting to track Polygon’s progress when it comes to adding more scaling options and onboarding more and more projects. 

We’ll also have to see how easy it will be to communicate between different scaling solutions with different security guarantees. 

It’s also worth mentioning that Polygon’s whitepaper has direct comparisons to other layer 1 blockchains such as Polkadot, Cosmos or Avalanche that also focus on the interoperability between different blockchains. 

In contrast to these projects, Polygon focuses on the Ethereum ecosystem, with the Ethereum chain being the main hub that connects everything. 

This, of course, has a lot of advantages such as a strong community of users and developers, a well-known programming language – Solidity – and the most popular virtual machine in the cryptocurrency space  – EVM. 

Besides that, Ethereum has a long history of serving as a reliable base chain that handles trillions of dollars in economic activities. Something that took time to develop and is hard to be replicated by a completely new blockchain. 

The power of familiarity with the Ethereum stack cannot be overlooked as shown by the recent rise of Binance Smart Chain. 

So what do you think about Polygon? Will this be the ultimate way of scaling Ethereum? 

If you enjoyed reading this article you can also check out Finematics on Youtube and Twitter.

Finematics is also now participating in Round 9 of Gitcoin Grants based on the quadratic funding mechanism where even the smallest contribution matters. If you’d like to show your extra support, check out this link here.

]]>
https://finematics.com/polygon-matic-explained/feed/ 0