Blockchain Layers

Feb 27, 2024 3:14:38 PM

Today, one of the most studied topics in the environment is using layer two chains to increase network scalability. The idea is to create chains that work on top of other ones; instead of performing all tasks in layer one - known as - transactions are processed in layer two - known as - and the layers communicate with each other. Thus, it is possible to gain scalability but also take advantage of the greater security of layer one.

Let’s look at an example of a layer two mechanism that is called payment channels.

Let’s say Alice sends 10 bitcoins to Bob. Soon after, it’s Bob’s turn to send 5 bitcoins to Alice. At the end of the day, it’s as if Alice only sent 5 bitcoins to Bob, but that took two transactions. As the transaction cost in Bitcoin is currently a few dollars, micropayments in Bitcoin are not feasible.

In the example above, Alice and Bob can create a payment channel with ten bitcoins each on layer one, the Bitcoin network. From that moment on, Alice and Bob can send bitcoins to each other in layer two, which costs much less. Alice or Bob can close the payment channel at any time, at which point the final balance will be distributed among them.

Alice or Bob can’t cheat their peer on the payment channel. Each transaction that performed off-chain is signed, even if it is not executed. If Alice or Bob tries to close the payment channel with an amount that is different from the one currently due, anyone can send proof of this, and the user who attempted the malicious act will be punished with the loss of their coins.

So Alice and Bob only need to do two transactions on layer one, one to open and another to close the payment channel. Alice and Bob can do as many transactions as they want in this interval, always transacting in layer two. The network security is maintained because the actual bitcoins are secure at layer one, and the of the payment channels is developed so that one of the participants can’t act maliciously.

Payment channels were one of the first layer-two solutions to be implemented. On Bitcoin, a layer two payment network is the Lighting Network, which has been used in some countries to perform micropayments with bitcoins. The problem with payment channels is that they only work for payments. They are not suitable for general-purpose blockchains that implement smart contracts.

Examples of layer-two solutions are side-chains and plasma chains. In them, a bridge is established between layers, and assets can be transferred from one layer to another. We say that layer two is the side-chain of layer one. Plasma is the that ensures that layer two users can always withdraw their funds back to layer one if they notice any malicious behavior. Thus, the assets are secured by layer one. Plasma has had some implementations but has now been dropped and replaced by rollup-type solutions.

The most widely used layer-two solution at present is the rollup mechanism. It also has a bridge connecting layers one and two and it allows sending assets in both directions, as in the case of side-chains. Furthermore, layer two records all transactions in layer one but not individually; they are condensed and recorded together, hence the name rollup. By joining several transactions into a single one, it is possible to lower the costs of each transaction at layer two, where they are effectively processed by a virtual machine.

There are two main types of rollups: Optimistic rollups and Zero-Knowledge rollups. In Optimistic rollups, recording on layer one is done optimistically. The validity of transactions is assumed to be true, and it is up to users to report any attempts to manipulate the blockchain. In Zero-Knowledge rollups, cryptographic proofs are generated, which guarantees that transactions are valid and that there has been no tampering. Zero-Knowledge rollups are more secure than Optimistic rollups, as blocks can be finalized immediately without waiting for a period so that anyone can present fraud-proof, as in the case of optimistic rollups.