Exciting News! CoinSmart is officially a publicly-traded company on the NEO Exchange trading under ticker SMRT. 

Share on twitter
Share on facebook
Share on linkedin

Blockchain Scalability Techniques: Layer 2

Please Pick Your Crypto Level

Blockchain Scalability Techniques: Layer 2

Previously, we learnt about layer-1 scalability techniques. Today, let’s look at the other side of the equation – layer-2 scalability techniques.

What Are Layer-2 Scalability Techniques?

“Layer-2” is a term used to describe a series of protocols or networks that lie on top of the base blockchain. The idea is to delegate complex processes to the layer-2 protocols while using the base blockchain solely for finality purposes (irreversibly committing the transaction or the process to the chain). In particular, we will be looking at:

  • Sidechains
  • Payment Channels
  • Rollups

Sidechains

blockchain scalability techniques Image Credit

Sidechains are side blockchains that are linked to the main blockchain via a two-way peg. Cryptographic mechanisms allow tokens to flow back and forth from the main chain to the side chain. This is how the mechanism works:

  • The user must first lock up their main chain tokens to an output address.
  • When this lock-up process is complete, the transaction confirmation is relayed across the chain.
  • Following the transaction confirmation, the system goes through a predetermined waiting period for security purposes.
  • Following that, the tokens get transferred to the sidechain,
  • The users must now follow these steps in reverse to go back to the main chain.


Of course, the most well-known example of a sidechain is SegWit or Segregated Witness.

What is SegWit?

SegWit is a sidechain activated on the Bitcoin blockchain in August 2017 and was first suggested in 2015 by Blockstream’s Dr. Peter Wiulle. The SegWit solution came about during the Bitcoin blocksize debate. Here is a small breakdown of the entire SegWit activation timeline:

  • July 20, 2017: BIP-91, the first stage of SegWit activation, kicks in.
  • August 8. 2017: The SeGwit activation got enough votes to reach the “point of no return.”
  • August 24, 2017: SegWit got fully activated in the network.


To understand the importance of SegWit, let’s see how transactions work in Bitcoin. If Alice wants to send BTC to Bob, she will need to send it to Bob’s public address by signing it off with her cryptographic signature. Unfortunately, the signature data tend to be very bulky and takes up a lot of space in the block.

In hindsight, the solution was pretty obvious.

SegWit transfers the bulky signature data from the transactions and puts them in the sidechain.

SegWit: Pros and Cons


Pros

  • SegWit was the first proper step that the Bitcoin network had taken in achieving scalability.
  • The alternate solution touted was to increase the block size, which would have increased centralization (check the layer-1 scalability article1 to know why).
  • By transferring signature data to the SegWit chain it would be possible to fit in more transactions inside the block.


Cons

  • Due to the size and popularity of the Bitcoin blockchain, Bitcoin needs more scalability solutions on top of SegWit.

Payment Channels

blockchain scalability techniques lightning network Image Credit

Payment Channels like Bitcoin’s Lightning Network are another form of layer-2 scalability. Again, the idea is pretty straightforward. Instead of Alice and Bob directly interacting on the Bitcoin blockchain, they interact multiple times on layer-2 and finally add the final state of transactions to the core blockchain.

So, how does this work? We have seen multiple uses of this in our real life. For example, imagine that you are going to your local grocery shop and know the shopkeeper pretty well. You have an arrangement with him, wherein you buy items from the shop for the entire month without paying for anything. Finally, at the end of the month, you settle everything by paying the bill in full.

In a nutshell, the two parties conduct several microtransactions without committing anything to the blockchain. Finally, when they are done transacting, the final state gets uploaded to the core chain.

While there have been several proposed channel designs to implement this mechanism, the method that has worked out most successfully is called “HTLC” or “hashed timelock contract.”

How Do HTLCs Work?

HTLCs are smart contracts or mechanisms used in blockchain applications to enable state channels by eliminating counterparty risk. The core principle is relatively straightforward – if Bob wants to get some money from Alice, he should generate a specific cryptographic proof within a given timeframe. This is how it works:
  • Suppose Alice wants to communicate with Charlie.
  • Both have a common connection with Bob.
  • Alice opens up a channel using HTLC with Bob, and Bob opens up an HTLC with Charlie.
  • Alice sends the payment to Charlie through Bob, provided Charlie can provide the proof in time through Bob.

Rollups

blockchain scalability techniques Image Credit

“Rollup” is a well-known layer-2 scalability solution that Ethereum 2.0 will implement. The rollup moves the computation off-chain from the core blockchain to layer-2. Then, following transaction execution, the rollup batches them together and commits them to the main chain. There are two kinds of rollups:
  • Optimistic rollups: The mechanism assumes that transactions are valid by default (hence the optimism). If the network raises a red flag, the rollups will run a fraud-proof event.
  • Zero-knowledge rollup: Rolls up batches of transactions off-chain and generates a cryptographic validity proof.

Here are a couple more things to keep in mind.
  • The complex transaction computations are done off-chain. Finality is settled on the core chain.
  • “Rollup Operators” must stake a bond in the rollup contract to ensure they are economically incentivized to carry out the operation.

Optimistic rollups

The Optimistic rollup layer runs parallel to the main blockchain and can offer exponential improvements upon the base scalability. Optimistic rollups already assume that all the transactions are properly executed. However, if a rollup operator notices a fraud transaction, they can submit a fraud proof. This is what happens after that:
  • The red-flagged transaction is executed again on the main chain.
  • If the transaction is fraudulent, the party responsible is punished by getting their bonded ETH slashed.
  • However, if the transaction isn’t fraudulent, the operator who red-flagged it in the first place gets punished by getting their bonded ETH slashed.

Zero-knowledge rollups (ZK-rollups)

In cryptography, a zero-knowledge proof is a system where one party (the prover) can prove to another (the verifier) that they have a specific knowledge without explicitly telling them what that information is.
To understand this, let’s take an example.
Suppose you want to enter a nightclub. You need to show your ID card without giving away any unnecessary details. So, you place some paper on the card, such that only your face and year of birth are visible. This way, you can prove that you are above the drinking age without giving away any other details.
In the context of the blockchain systems, the proof you show is known as a “SNARK,” aka “succinct non-interactive argument of knowledge.”
Alright, so keeping all this in mind, let’s see how ZK-rollups work.
  • ZK-rollups bundle multiple transactions off-chain and generate a SNARK.
  • The SNARK is a validity proof and gets posted on layer-1.
  • The rollup maintains all transactions states on layer-2.
  • Since all the transaction data is already validated via zk-SNARKs, they no longer require fraud-proofs.

Optimistic Rolliups vs Zero-knowledge Rollups


  • Optimistic rollups are a bit slower than zk-rollups since there are no potential red flags when the transactions move from layer-2 to layer-1.
  • Implementing zero-knowledge in Ethereum’s ecosystem can be pretty complicated. It is much simpler to implement optimistic rollups.

Conclusion

We have looked at three layer-2 scalability techniques today:
  • Sidechains.
  • Payment Channels.
  • Rollups (both Optimistic and ZK).

Do not forget to check out our part 1 on layer-1 scalability techniques!
Shadowed section separator
Shadowed section separator
Do you know
CoinSmart’s GetSmart Hub?

Your Destination for Crypto Knowledge & Learning Tools.