Exploring Ethereum’s Layer 2 Solutions: How Layer 2 solutions are slashing Gas Fees and Fueling…

Exploring Ethereum’s Layer 2 Solutions: How Layer 2 solutions are slashing Gas Fees and Fueling Efficiency

Layer 2 Scaling Solutions (Definition + 4 Examples) — WhiteboardCrypto

Are you sick and tired of paying exorbitant gas fees when using Ethereum? Well, these L2 scaling solutions may be the key to circumventing these issues. Creating a scalable, cost-efficient, and decentralized means of using Ethereum.

The Backbone of Ethereum’s Layer 2 Solutions

The congestion and high costs associated with Ethereum’s network have led to the development of layer 2 solutions, each designed to tackle these challenges head-on. These include rollups, state channels, plasma, sidechains, and validium, each with its unique approach to improving Ethereum’s network performance.

Rollups: A Game-Changer in Transaction Efficiency

Rollups have emerged as a pivotal layer 2 solution, processing transactions outside the main Ethereum chain and posting transaction data back to it. They come in two flavors:

Optimistic Rollups: Operating on the principle of assumed validity, these rollups only verify transactions when challenged. Notable examples include Optimism and Arbitrum.Zero-Knowledge Rollups (ZK-Rollups): These rollups take hundreds of transactions off-chain, produce a cryptographic proof (zero-knowledge proof), and post this proof alongside the transaction data to the main chain, exemplified by zkSync and Loopring.

Please note that Zk Rollups consist of Zk-Snark and ZK-Stark, however, for simplicity purposes, I will only be discussing Zk-rollups as a whole.

Simple Explanation: Rollups

Rollup: multiple transactions ROLLED into one transaction.

Example:

Imagine Ethereum is a busy motorway with a toll booth, the cars on the motorway are the transactions. During peak hours, the motorway becomes congested, leading to delays and higher toll fees (gas fees). To alleviate congestion, two new lanes are introduced: zk-rollups and optimistic rollups. These two new lanes allow cars to group into buses (bundled transactions), which means instead of having individual toll fees for each car, you now just have one toll fee for the whole bus (which consists of individual cars).

The toll booth only needs to process fewer transactions (buses) instead of individual cars. The rollups increase the scalability of the highway and reduce the costs (transaction fees).

Simple Explanation: Zk-Rollups

Zk rollups: combine a bunch of things into one rolled-up thing, HOWEVER, they do not use smart contracts.

Layer 2 Scaling Solutions (Definition + 4 Examples) — WhiteboardCrypto

Zk-Rollups (zero knowledge rollups): take all transactions off-chain combine them into a single transaction, and then generate a cryptographic proof known as zero-knowledge proof. The cryptographic proof + data about transactions is submitted to the Ethereum blockchain. The zero-knowledge proof attests that all transactions in the bundle are valid without revealing specific details about them.

Essentially, you are bundling transactions into one single transaction and then generating a cryptographic proof called a ZKP which is submitted to the Ethereum blockchain and attests all bundled transactions are valid without actually revealing details about the transaction.

Example:

– Send secret message to a friend in a locked box

– You send the key to open the box via a secure courier

– Your friend receives the box and the key but doesn’t know the courier’s identity or how the key was sent

Similarly, zk-Rollups ensure transaction validity without revealing transaction contents through zero-knowledge proofs

Optimistic Rollups

Optimistic rollups: optimistic rollups have their own optimistic virtual machine, which allows them to do stuff with smart contracts HOWEVER they are slower and less efficient.

Layer 2 Scaling Solutions (Definition + 4 Examples) — WhiteboardCrypto

Optimistic rollups assume all transactions bundled together and submitted to the Ethereum blockchain are valid by default, however, there is a challenge period during which these transactions can be disputed if someone believes a transaction is fraudulent. If a transaction is fraudulent, it is rolled back (transaction reversed/unsent). i.e. optimistic rollups are OPTIMISTIC about all transactions being valid.

Here’s a step-by-step process of how optimistic rollups occur:

1) Submission: transactions bundled together and submitted to the Ethereum blockchain as a single batch via the optimistic roll-up system. The optimistic rollup system assumes these transactions are valid, without performing validation checks.

2) Challenge period: after submission, there is a designated waiting period (challenge period) where anyone can challenge and question the validity of the transactions in the batch. If someone detects a fraudulent or incorrect transaction, they can submit a challenge against it

3) Challenge process: if the challenge is valid, and proves that a transaction within the batch was invalid, the specific transaction is targeted for reversal

4) Rollback: reverse specific transactions, not all the bundled transactions. The blockchain ledger is updated to reflect the state before the invalid transaction was executed. For example: if the transaction involved transferring 10ETH from Alice to Bob, rolling back the transaction would restore the 10 ETH to Alice’s account as if the transfer to Bob never happened

5) Impact on the Batch: the rest of the transactions in the batch, if they are not challenged would remain valid and processed.

Zk-Rollups vs Optimistic Rollups

Similarities

Both layer 2 scaling solutions aim to improve transaction throughput and reduce transaction feesBoth bundle multiple transactions into a batchBoth maintain the security and integrity of transactions while operating outside the main layer 1 blockchain.

Differences

Computational complexity:

Zk-Rollups: require significant computational power to generate zero-knowledge proofs which are complex and resource-intensive. Example: completing a highly detailed and complex jigsaw puzzle that requires specific techniques and tools. The process is intricate and requires time and resources, akin to generating zero-knowledge proofs.Optimistic Rollups: less computationally demanding as they don’t require the generation of complex proofs. Example: write a book draft and ask for feedback later.

Use Cases

Zk-Rollups: ideal for high-throughput applications like payments and simple contract executions, where speed and privacy are crucial. Example: high-speed train system (zk-Rollups) efficiently move a large number of passengers (transactions) quickly and on schedule, ideal for daily commutesOptimistic rollups: better suited for complex smart contracts due to their compatibility with Ethereum’s EVM, allowing for more flexible application development. Example: a cargo ship (optimistic rollup) can carry various types of goods (complex smart contracts) and adapt to different cargo needs, but it may not be as fast as the high-speed train.

Validation Mechanism

Zk-Rollups: validate transactions within the batch using cryptographic proofs (zero-knowledge proofs) before posting to the blockchain. This means the validity of each transaction is proven without revealing its contents. Example: a game where you prove you solved a puzzle without showing the solution. You provide a seal (the zero-knowledge proof) that only someone who solved the puzzle could create. Others accept you’ve solved the puzzle based on the seal’s authenticity, without needing to see the solved puzzle.Optimistic rollups: assume transactions are valid by default and post them without comprehensive validation. A challenge period allows users to dispute transactions if they believe they are invalid/fraudulent. Example: leaving a suggestion box in the community center. Everyone’s welcome to drop in their suggestions (transactions) without checking them first, however, there’s a weekly review where anyone can challenge the suggestions. If the challenged suggestion is found to be against the rules, it’s removed.

State Channels: Direct, Efficient, and Private

Layer 2 Scaling Solutions (Definition + 4 Examples) — WhiteboardCrypto

State channels enable participants to conduct transactions in a private channel, significantly reducing the load on the main Ethereum blockchain. This is especially useful for scenarios requiring numerous transactions between a fixed set of participants, with Raiden Network and Connext leading the charge.

Simplified Explanation: State Channels

State channels allow participants to interact in a private channel, allowing participants to conduct numerous transactions amongst themselves within this private channel, without posting all of these transactions to the blockchain immediately. This speeds up transactions and reduces costs, as transactions do not occur on the main blockchain. Once participants are done transacting, the final state is settled on the blockchain.

They are essentially private channels for participants to send and receive transactions that do not occur on the main blockchain. Once transactions have finished, the final state of transactions is settled on the blockchain.

How it works:

1) Open channel: participants deposit a certain amount of crypto e.g. ETH into a smart contract on the blockchain, opening a state channel. This initial deposit establishes the rules for the interaction within the channel

2) Transacting off-chain: after the channel is open, participants can freely and instantly exchange numerous transactions amongst themselves, these transactions are not recorded on the blockchain but are signed by the parties involved, ensuring they are secure and verifiable

3) Closing the channel: when participants decide to conclude their business, the final state of their transactions, who owns what after all exchanges is submitted to the blockchain. The smart contract then distributes these funds according to this final state.

4) Dispute resolution: if there is disagreement about the final state of transactions when trying to close the channel, the smart contract as an arbitrator (judge), and uses the history of the signed transactions to determine the correct distribution of funds

Example: Pay-per-minute streaming service

A pay-per-minute video streaming service, where you pay for each minute of video content you watch.

You and the streaming service open a state channel by depositing ETH into a smart contract on the blockchain. The deposit is the maximum amount you are willing to pay to watchInstead of sending a transaction to the blockchain for every minute watched, you and the streaming service provider keep track of the minutes off-chain.After your binge-watching session, the final tally of minutes watched is agreed upon e.g. watched 90 minutes, you owe 0.1ETH. The final state is submitted to the blockchain, and the smart contract redistributes the deposited funds accordingly- paying the service for the content watched, and returning the remaining amount of the deposit to you.If there is a disagreement on the final number of minutes watched, the smart contract can use off-chain transaction history (Signed messages) to determine the correct amount.

Plasma: Creating a Lattice of Child Blockchains

Plasma’s approach involves creating child blockchains anchored to the main Ethereum blockchain, facilitating independent transactions that only interact with the main chain for security purposes, a technique employed by Polygon.

Plasma: Simplified Explanation

Plasma creates child chains that are anchored to the main Ethereum blockchain, allowing for off-chain transaction processing in a way that can dramatically reduce the burden on the main chain.

By child chains, we mean secondary blockchains anchored to the main layer 1 blockchain.

How it works:

Create child chains (secondary chains) that operate off the main Ethereum blockchain, these child chains have their own rules and operate independentlyTransactions occur on these child chains, and periodically the child chains’ transactions and recordings are posted to the main Ethereum chainUsers can withdraw their assets from the child chain to the main Ethereum chain by submitting a withdrawal request. If there are disputes or fraud detected on the child chain, users can submit fraud proofs to the main chain to challenge the dishonesty, ensuring assets are protected by the security mechanisms of the main Ethereum blockchain

Example: The Arcade Token System

An arcade where each game machine accepts special arcade tokens. The arcade is popular, and to manage the demand, the owner decides to issue sub-tokens for different sections of the arcade, with each section representing a child chain.

Each section of the arcade (e.g. racing games, shooting games, classic games) has its sub-tokens, similar to creating child chains off the main Ethereum blockchain. Players can exchange the main arcade tokens for these specific sub-tokens for each section.The game plays are quick and efficient because there handled within the section as individuals do not need to go to the main token desk every time, to exchange their tokens for subtokens. Instead, they already have subtokens available in each section. The subtokens being issued at individual sections reducing the amount of load on the main desk issuing tokens, is akin to plasma child chains handling transactions, off the main chain.At the end of the day, the arcade owner counts the sub-tokens from each section and records this in the main ledger, similar to how the state of the child chain is periodically committed to the Ethereum main chain. This ensures all sub-token transactions are ultimately accounted for under the main arcade token system.If a player wants to leave the arcade, they exchange their sub tokens back to the main arcade tokens (withdrawal back to the main Ethereum chain). If there is a dispute (a machine not awarding the correct amount of sub-tokens), players can bring it up with the management (submitting a fraud-proof), to ensure fairness, secured by the overarching governance of the arcade (the Ethereum main chain).

Sidechains: Independence with a Bridge

Running parallel to Ethereum, sidechains have their consensus mechanisms and are connected to the Ethereum mainnet via two-way bridges. This allows for asset transfers between the mainnet and the sidechain, a functionality embraced by Polygon’s PoS chain and xDai (Gnosis Chain).

Sidechains: Simplified Explanation

Ethereum mainnet (main blockchain) is a central library, where people come to borrow books (conduct transactions). Due to its popularity, the library is often crowded, making the process of borrowing books slow and expensive due to the high demand for the librarian’s time (high gas fees on the Ethereum blockchain).

To alleviate this, the library opens several reading rooms (sidechains) dedicated to specific genres; one for fiction, one for non-fiction, and another for academic texts. Each reading room operates independently, with its checkout system (consensus mechanism) and buyers can take books (assets) from the main library into one of these rooms to read in a quieter, more focused environment.

How it works:

1) Depositing books (Asset locking and minting)

Locking: choose a book in the main library to read in a quiet reading room. The library marks this book as “checked out” in its system, making it unavailable to other patronsMinting: simultaneously, a duplicate of the book is created for you in the reading room, allowing you to read it there without affecting its availability in the main library.

2) Reading in the reading room (transactions on the sidechain)

You enjoy reading the book in the calm environment of the reading room, where it is easier and quicker to read because of fewer distractions,

3) Returning books (asset unlocking and burning)

Burning: when you finish, you return the duplicate book to the reading room’s desk, where it is removed from their records.Unlocking: concurrently, the main library updates its system to show the original book as checked in, making it available again for others to borrow.

Real World Example: The Polygon Network

A practical example of a sidechain in the cryptocurrency world is the Polygon Network, designed to scale Ethereum transactions. Polygon acts as a sidechain that allows for faster and cheaper transactions than directly on the Ethereum mainnet. Users can transfer assets (such as ETH or ERC-20 tokens) from Ethereum to Polygon, perform transactions within the Polygon network, and then transfer assets back to the Ethereum mainnet. This process involves locking assets on Ethereum, minting them on Polygon, and then, when transferring back, burning them on Polygon and unlocking the original assets on Ethereum.

The sidechain concept, exemplified by Polygon, showcases how sidechains can offer a scalable, efficient solution for blockchain transactions, addressing the limitations of the main blockchain without sacrificing its foundational security and trust.

Sidechains vs State Channels vs Plasma: A comparison

Similarities

Off-chain Scaling: All three solutions aim to scale blockchain capabilities by handling transactions off the main chain.Reduced Burden on Main Chain: By moving transactions off-chain, they significantly reduce the computational load and associated costs on the main blockchain.

Differences

Operational Mechanics: While sidechains operate as independent blockchains and require asset transfers, state channels, and Plasma operate more closely tied to the main chain. State channels keep the interaction off-chain and only settle on-chain, while Plasma uses a hierarchical chain structure to manage its operations.Security Model: Sidechains may have varying security protocols independent of the main chain, whereas state channels and Plasma benefit from the underlying security of the main blockchain.Use Cases: Sidechains are versatile and can be customized for a variety of applications. State channels are ideal for applications requiring frequent and rapid microtransactions, such as gaming or payment services. Plasma is well-suited for high-throughput use cases where participants don’t need to interact frequently with the main chain.

Validium: A Fusion of Efficiency and Security

Validium blends the best of ZK-rollups and Plasma, processing transactions off-chain, storing data off-chain, and using zero-knowledge proofs for main-chain verification.

How Validium Works:

Transaction Processing Off-Chain: Similar to ZK-rollups, Validium processes transactions outside of the main Ethereum chain (off-chain). This helps in reducing the load on the main chain, thereby increasing transaction throughput.Data Storage Off-Chain: Unlike ZK-rollups, which store data on-chain, Validium stores transaction data off-chain. This further decreases the data burden on the main blockchain but requires strong data availability guarantees to ensure that data can be retrieved when needed.Zero-Knowledge Proofs: Validium uses zero-knowledge proofs to validate transactions. These proofs are cryptographic methods that allow one party to prove to another party that a statement is true without revealing any information beyond the validity of the statement itself.Security: The main blockchain still provides security through these zero-knowledge proofs, even though the data is stored off-chain. The proofs ensure that all transactions are valid, and because they are submitted to the main chain, they benefit from its security properties.

Example to Understand Validium:

Imagine a large stadium hosting a concert with thousands of attendees entering through a single gate. This gate represents the main Ethereum blockchain where each transaction (entry) needs to be processed, causing delays and high costs (high gas fees).

Now, consider the introduction of a new system — Validium:

Off-Chain Ticket Checks: Instead of checking each ticket at the main gate, there are multiple smaller gates (off-chain processing) around the stadium where tickets are scanned quickly and efficiently.Storing Information Off-Site: The results of these ticket checks (transaction data) are not stored at the main gate but in a secure off-site location (off-chain data storage). This reduces the congestion at the main gate.Validation at the Main Gate: At the end of the concert, a trusted official (using zero-knowledge proofs) visits the main gate and confirms that all tickets checked at the smaller gates are valid without having to bring all the individual ticket data to the main gate. This validation uses cryptographic proofs that confirm the legitimacy of all tickets checked without revealing the ticket details themselves.

Validium vs Zk-Rollups

Validium and Zero-Knowledge (ZK) Rollups are both Layer 2 scaling solutions for blockchains such as Ethereum. They aim to enhance transaction throughput and reduce the load on the main blockchain. Here’s a comparison that details their similarities and differences:

Similarities

Zero-Knowledge Proofs:

Both use zero-knowledge proofs to verify the correctness of transactions off-chain before submitting this proof to the main blockchain. This ensures that the transactions are valid without revealing the actual transaction data.

Off-Chain Computation:

Both Validium and ZK Rollups perform transaction computations off-chain, which helps reduce the load on the main blockchain and speeds up processing times.

Enhanced Scalability:

By processing transactions off-chain, both technologies significantly increase the scalability of the network, allowing it to handle much higher transaction volumes than would be possible on the main chain alone.

Security Reliance on Main Chain:

They both leverage the security of the main blockchain by submitting proofs to it, ensuring that even though the computation is done off-chain, the integrity and security of transactions are not compromised.

Differences

Data Availability:

ZK Rollups: Store transaction data on-chain. This means all the data needed to reconstruct the state of the rollup is available on the Ethereum blockchain, which enhances security and trustworthiness because data can always be accessed and verified by anyone.Validium: Stores transaction data off-chain. While this approach further reduces the data burden on the Ethereum mainnet, it introduces potential risks related to data availability. If the off-chain data is lost or inaccessible, it might be impossible to reconstruct the state or prove the validity of transactions.

Custody and Trust Model:

ZK Rollups: Because they store data on-chain, they generally require less trust in external parties to maintain and manage the system.Validium: Requires more trust in the operators who manage the off-chain data storage, as users must rely on these operators to maintain data integrity and availability.

Use Cases:

ZK Rollups: These are suitable for applications where on-chain data availability and decentralization are critical, such as in financial applications and DeFi platforms where users must be able to independently verify all aspects of the system.Validium: This may be more appropriate for use cases where privacy is more critical, and the application can tolerate some level of trust in third parties for managing data.

Cost and Efficiency:

ZK Rollups: While they reduce computation loads on the main chain, they still require storing data on-chain, which incurs gas costs associated with data storage.Validium: Potentially offers even lower transaction costs than ZK Rollups because it does not incur on-chain data storage fees, making it more cost-effective for applications with massive data throughput needs.

Validium vs Plasma

Similarities

Off-Chain Transaction Processing:

Both Validium and Plasma process transactions off the main blockchain (off-chain), reducing the load and increasing the scalability of the main chain.

Security Anchoring:

They rely on the main blockchain for security. Both solutions periodically submit proofs or data to the main blockchain to ensure that the off-chain operations are secure and can be verified.

Scalability Focus:

The primary goal of both technologies is to enable higher transaction throughput than what the main blockchain can handle natively.

Differences

Data Availability:

Validium: Stores transaction data off-chain and relies on zero-knowledge proofs to validate transactions. This method can introduce concerns regarding data availability, as the necessary data to prove the state or challenge transactions is not stored on the main blockchain.Plasma: Requires data to be available for users to challenge fraudulent exits and invalid state transitions. Plasma chains frequently commit state roots to the main blockchain, which helps in verifying the state maintained off-chain.

Transaction Validation:

Validium: Uses zero-knowledge proofs for validating transactions. These proofs are submitted to the main blockchain, verifying that all transactions are correct without revealing any specific transaction details.Plasma: Utilizes fraud proofs where users can challenge invalid transactions or exits by submitting proof of fraud to the main blockchain. This process relies on users being vigilant and actively monitoring Plasma chains.

Complexity in User Interaction:

Validium: Generally simpler for end-users since they do not need to participate in challenging invalid state transitions; the integrity of transactions is guaranteed by the zero-knowledge proofs.Plasma: Users must be capable of challenging fraudulent activities, requiring them to monitor the network and understand the process of submitting fraud proofs. This adds a layer of complexity and responsibility for the users.

Use Cases:

Validium: Well-suited for applications where privacy and scalability are paramount, and where users can trust a third party for managing off-chain data.Plasma: Better suited for applications that require decentralized security without relying heavily on a third party to manage data, as users have the tools to enforce the network’s integrity themselves.

Trust Model:

Validium: Requires a higher degree of trust in the entity managing the off-chain data storage, since data is not stored on the blockchain.Plasma: Offers a more trust-minimized environment as it allows anyone to challenge fraudulent states, which means users are not heavily reliant on a single third party’s honesty.

Embracing Ethereum’s Layer 2 Future

Ethereum’s layer 2 solutions are not just technological advancements; they are stepping stones towards a more scalable, efficient, and inclusive digital ecosystem. As these solutions continue to evolve, they promise to open new avenues for blockchain applications, making Ethereum’s network more accessible to users worldwide.

By understanding and embracing these layer 2 solutions, the Ethereum community is well on its way to overcoming scalability challenges, setting a precedent for future blockchain innovations.

Exploring Ethereum’s Layer 2 Solutions: How Layer 2 solutions are slashing Gas Fees and Fueling… was originally published in The Dark Side on Medium, where people are continuing the conversation by highlighting and responding to this story.