A Byte of Blockchain: Week 58 - Discovering Layer 2 Solutions (State Channel)

·

5 min read

A Byte of Blockchain: Week 58 - Discovering Layer 2 Solutions (State Channel)

Image by Larry White from Pixabay

Recap

Last week, we delved into Layer 1 solutions, as listed below:

1. Sharding

2. Improving Consensus Mechanisms

We examined the advantages and disadvantages of sharding. Improving consensus mechanisms entails modifying the underlying consensus protocol, primarily transitioning from the energy-intensive Proof-of-Work to a more stake-based Proof-of-Stake.

Both protocols make executing fraudulent transactions prohibitively expensive by:

1. Imposing high energy costs through cryptographic problem-solving (in Proof-of-Work), or

2. Confiscating the validator's stake (in Proof-of-Stake). But Proof-of-Stake protocol does not involve complex computations which consume energy & take time to solve.

Newer Blockchains are moving towards Proof-of-Stake eg., Tezos, Cardano, Solana, Algorand etc.

Layer 1 Solutions involve modifying the underlying Blockchain. The underlying Blockchain is referred to as Layer 1. Layer 2 solutions involve adding an overlaying network over Layer 1.

Layer 2 Solutions

Can Layer 2 solutions enhance the performance, security, and scalability of a Blockchain without altering the underlying infrastructure? If so, how would this model function?

Layer 2 Solutions are designed to reduce stress on the main Blockchain by moving transactions & related computations from the main Blockchain to another chain or in other words, moving it off-chain. In doing so, they significantly improve the performance & capacity of the underlying Blockchain.

Some of the solutions being experimented with are :

  1. State Channels

  2. Rollups - which can be divided into:

    1. Zero-Knowledge Rollups

    2. Optimistic Rollups

  3. Nested Blockchains

  4. Side Chains

Let us go down the rabbit hole & explore each of the above:

State Channels

Before we get into State Channels, let us understand what is "State".

A State is like a snapshot of the Blockchain at a point in time e.g., balances, transaction status etc. A real-life analogy of a State is a Balance Sheet that reflects a firm's state (assets, liabilities & capital) at a particular point in time.

A change in State or State Transition occurs due to a transaction. A transaction changes the balance of the initiator (balance decreases) & the recipient (balance increases). Please refer to Week 36 for a detailed discussion on State Transition.

Typically, a transaction is initiated, verified, validated, and added to the database within the primary blockchain (Layer 1). This process contributes to the Trilemma, leading to increased processing times.

The concept of State Channels involves utilizing side channels for updating states and processing transactions off the primary blockchain. This implies that transactions are not processed on the primary Blockchain, but rather on a separate side channel.

What is a Channel?

Channels are simple peer-to-peer protocols that allow two parties to make many transactions between themselves & then only post the final results to the Blockchain. (Source: here).

Once the transactions are processed & the state is finalized in the side chain (which means the final balances are determined), it is written back to the main chain.

Now that we have defined State & Channel, let us explore the steps involved in transaction processing in State Channels:

  1. A portion of the Blockchain state is locked under a smart contract to ensure consensus between the participants of the state they are currently in.

  2. Participants who are part of that state channel deploy funds into the smart contract.

  3. Next, off-chain transaction processing & interaction between participants start which updates the state (balances) outside the main Blockchain.

  4. Once the final state is achieved, the state channel is closed & the final state is written back to the main Blockchain.

  5. The locked part of the Blockchain is unlocked.

Visualizing the above steps:

We can see from the above that the interaction is between participants only & there is no requirement for third parties like Miners to confirm transactions. So, how are transactions validated & what controls are there to ensure the genuineness of transactions finally written to the main Blockchain?

  1. This smart contract which locks a portion of the Blockchain is a multi-sig smart contract which means multiple signatures from different addresses are needed to execute the contract. This is like cheques which need multiple authorized signatures to be valid. So, all the participants are required to execute the contract

  2. Cryptography is used in the channels to ensure the transaction summary generated is valid & is actually from the individual transactions in the side channel.

So, the logic is to move transactions off-chain with relevant controls in place to ensure the genuineness & authenticity of transactions & then only book the summary of the transactions into the main chain. This reduces the load on the main Blockchain thus increasing transaction throughput & reducing processing times.

But is this the perfect solution? Let us understand the pros & cons of State Channels.

Pros of State Channel:

  1. Handles high volume of transactions at a lower cost because it decreases the computational load on the main Blockchain lowering gas fees

  2. Instead of paying gas fees for each transaction, participants pay when they open & close a state channel.

  3. State Channels help preserve user privacy as transactions are known between the participants in the channel unlike in layer 1 Blockchain where everyone can view the transactions.

Cons of State Channel:

  1. High channel set-up costs.

  2. Best used where the participants are defined. Any change in participants requires a change in the smart contract.

  3. Funds are required to be locked up in smart contracts.