Sidechains vs Rollups: Differences and Choices of Scalability Solutions

Deep Tide TechFlow
2023-07-26 18:28:27
Collection
This article provides an overview of Rollups and sidechains, and explores their differences in architecture, security guarantees, scalability performance, and other aspects.

Original Title: 《Sidechains vs. Rollups: Breaking down the differences for dapp development

Author: Emmanuel Awosika

Translated by: 深潮 TechFlow

Sidechains and Rollups are two solutions to the blockchain scalability problem. The core idea behind both solutions is to offload computation from resource-constrained blockchains (like Ethereum) to independent blockchains optimized for scalability. This approach brings several benefits, such as lower transaction costs, reduced latency, and increased overall throughput. But that’s where the similarities end.

Sidechains and Rollups fundamentally differ in their scaling approaches and also in their design decisions and trade-offs. For developers looking to leverage these two solutions to build scalable dapps, understanding their differences is crucial.

This article outlines Rollups and sidechains and explores their differences in architecture, security guarantees, scalability performance, and more.

What is a Sidechain?

A sidechain is a blockchain network that runs in parallel to another blockchain (referred to as the "main chain"). Typically, sidechains are connected to the main chain via a bidirectional cross-chain bridge, allowing for the transfer of assets and potentially any data, such as contract states, Merkle proofs, and results of specific transactions.

Most sidechains have their own consensus mechanisms and validators, separate from the main chain. This allows sidechains to settle and finalize transactions without relying on other blockchains. However, this also means that the security of funds bridged to the sidechain depends on the existence of strong cryptoeconomic incentives to prevent malicious behavior among validators.

Types of Sidechains

EVM-compatible and non-EVM sidechains: EVM-compatible sidechains use a custom implementation of the Ethereum Virtual Machine (EVM), which is the execution environment for deploying smart contracts on Ethereum. In practice, most of these blockchains were initially forked from go-ethereum (also known as Geth, the most popular implementation of the Ethereum protocol).

While retaining most of the features of Ethereum's design (such as support for smart contracts), EVM-compatible sidechains have been optimized in other areas, particularly the consensus mechanism, to improve execution efficiency and throughput. Today, EVM-compatible sidechains run the majority of smart contracts written in EVM languages like Solidity, while reducing costs and latency for decentralized application users.

Non-EVM sidechains implement different virtual machine architectures and cannot run Ethereum-native dapps without significant code refactoring. Developers building on non-EVM chains cannot use familiar EVM development environments and tools (like Truffle, Remix, Hardhat) and may need to learn other languages (like Rust or Golang) to create dapps.

Note: Avalanche, Fantom, Celo, and Palm are examples of EVM-compatible sidechains. NEAR, Solana, and Algorand are examples of non-EVM sidechains.

Commit chains and Optimistic sidechains: Not every sidechain relies entirely on its own security; some sidechains, especially commit chains and Optimistic chains, depend on the main chain to provide certain security guarantees. Commit chains periodically submit cryptographic commitments (such as block headers) to another blockchain to update their latest state. The main chain cannot verify these state proofs since it cannot access the sidechain's state, but it ensures that honest participants can challenge invalid block headers before confirmation.

This is typically accomplished by implementing a smart contract on the main chain that handles rewards, staking, rotation, and penalties for sidechain validators. If a validator commits a provable misbehavior (such as signing two blocks at the same height), anyone can submit evidence to the smart contract and slash that validator's stake.

Optimistic chains operate similarly, requiring validators to periodically submit block headers to a smart contract on the main chain. However, Optimistic chains do not have a separate consensus mechanism—block headers are simply assumed to be valid until challenged by anti-fraud measures. Thus, Optimistic chains can operate with just one (honest) validator, while commit sidechains require multiple validators to function properly.

In both cases, honest participants can prove malicious behavior occurring on the sidechain to the parent blockchain. This way, even if most validators on the sidechain are acting maliciously, users can still obtain some security guarantees.

However, it is important to note that honest participants cannot prove malicious behavior without access to the state data stored in the blocks. Since the main chain only receives block headers from the sidechain (not the block bodies), it cannot guarantee the availability of the blocks. This allows dishonest block proposers to engage in dishonest behavior by hiding block data, such as stealing funds from the cross-chain bridge.

This issue is known as the data availability problem, which is central to the differences in security properties among all sidechains (not just commit chains, Optimistic sidechains, and Rollups).

What is a Rollup?

Rollups improve the scalability of the underlying blockchain by processing transactions in a separate execution environment. Similar to sidechains, Rollups have cross-chain bridges for transferring assets between the parent blockchain and the Rollup. They also implement optimizations to improve computational speed and cost-effectiveness for users.

However, Rollups periodically submit blocks to the main chain, inheriting the security and decentralization characteristics of the main chain. This means that the parent blockchain provides the following security guarantees for Rollups:

  • Availability: The availability of Rollup blocks is guaranteed because the data is stored on a more decentralized and secure parent network. For example, users can always prove details of the Rollup state (such as ownership of certain tokens) to the cross-chain bridge contract and withdraw funds even when Rollup validators hide transaction data.
  • Validity: Only Rollup blocks that meet the validity conditions enforced by the parent chain can be finalized.
  • Liveness: Since Rollup data is stored on the base layer, anyone can reconstruct the last valid state of the Rollup and generate new blocks. Additionally, users can force their inclusion in the Rollup by sending transactions to the Rollup's on-chain smart contract.

Types of Rollups

Rollups come in two forms: Optimistic and Zero-Knowledge. Zero-Knowledge Rollups (also known as validity Rollups) submit blocks along with proofs to the parent chain to confirm the correct execution of off-chain transactions. If the proof passes verification on-chain, the block will be finalized on the base layer.

Optimistic Rollups submit blocks without any proof to verify the validity of off-chain computations. Unless another party challenges the result of a transaction with a "fraud proof," the block is simply assumed to be valid. Fraud proofs take the form of a verification game, where two parties dispute a computation under the intervention of the parent chain until the dishonest party is discovered.

Optimistic Rollups are named for their assumption of mostly valid state transitions. However, this optimistic assumption is combined with cryptoeconomic incentives that ensure that unless an invalid block goes unchallenged for a long time, it will never be finalized by the main chain.

Note: Arbitrum and Optimism are examples of Optimistic Rollups.

EVM compatibility is another notable distinction between Optimistic and Zero-Knowledge Rollups. While Optimistic Rollups are EVM-compatible, Zero-Knowledge Rollups differ in terms of EVM compatibility. Since proving native EVM instructions in proof circuits is complex and resource-intensive, some validity Rollups use a custom instruction set optimized for more efficient proofs.

For EVM-compatible ZK-Rollups, we describe their execution environment as "Zero-Knowledge EVM" (ZK-EVM). ZK-EVM can execute Ethereum smart contracts off-chain and prove that all parts of the computation were executed correctly. Therefore, compared to Optimistic Rollups, which rely on cryptoeconomic incentives and honest assumptions to prevent invalid execution, ZK-Rollups are considered more secure.

Linea is an example of a second-layer validity Rollup with full EVM support, allowing developers to reuse Ethereum infrastructure and tools to build dapps. In contrast, deploying on non-EVM ZK-Rollups (like StarkNet) requires (a) using a different stack to build smart contracts or (b) modifying the codebase to run in the StarkNet virtual machine.

How do Sidechains and Rollups Differ?

Throughput: The average transaction throughput of sidechains is typically higher than that of Rollups because they do not rely on the consensus and data availability of the main chain. For example, sidechains can achieve larger block sizes and extremely fast block times for higher throughput, which Rollups cannot do.

Rollups must avoid processing too many transactions to the point where transaction batches cannot fit into a single main chain block. Otherwise, this would reintroduce congestion at the base layer and make it difficult to keep up with the blocks produced by the Rollup. Thus, the data bandwidth of the parent chain imposes effective limits on the throughput of Rollups.

Even sidechains that partially rely on the security of the main chain (like commit chains and Optimistic chains) still have higher throughput than Rollups.

Cost: Users may pay lower fees for transactions on sidechains compared to Rollups. Like other distinctions between sidechains and Rollups, this is related to the Rollup's reliance on the main chain for settlement and finality. Here are some operational costs incurred by Rollups (which are borne by users):

  • Data storage: Submitting Rollup blocks to the base layer incurs fixed costs (the cost of including transactions in a block) and variable costs (based on the size of the Rollup block). Therefore, Rollups charge users for computation and data, with larger transactions incurring higher fees and vice versa.
  • Proof generation and verification: Zero-Knowledge Rollups require generating validity proofs for verification on the base layer, which incurs additional costs. Validating validity proofs consumes significant resources, with current costs on Ethereum being around 500,000 Gas.

Pure sidechains do not incur the above costs, making their fees lower. Commit chains or Optimistic sidechains may incur some additional costs, such as submitting block headers, but these costs can be negligible. Moreover, costs can be reduced by aggregating multiple block headers in a single transaction.

Finality: Sidechains that are fully responsible for their security have instant finality, meaning that once a block is approved by a majority of validators, it cannot be revoked. However, commit chains or Optimistic sidechains do not apply to this rule, as they must consider challenges that may delay block header finalization.

Generally, Rollups have longer finality times than pure sidechains for various reasons. For example, Optimistic Rollups delay transaction confirmations to ensure that honest participants have enough time to challenge invalid state updates.

Validity Rollups have instant finality (once verified), but their finality times are longer compared to pure sidechains. Due to the high costs of generating and verifying validity proofs, sequencers are more inclined to accumulate a large number of transactions before generating and submitting validity proofs for batches.

Security: The security of Rollups (whether Optimistic or Zero-Knowledge) is guaranteed by the underlying blockchain, reducing the trust assumptions for users. As explained earlier, Rollups rely on the (economically secure) main chain for consensus and data availability (unlike sidechains). This reduces risks such as censorship, frozen withdrawals, and invalid execution.

Pure sidechains are responsible for their own security. However, launching a diverse and reliable set of validators can be challenging, which is why sidechains are considered less secure than Rollups.

Commit chains and Optimistic sidechains are slightly more secure than pure sidechains, but users must trust the validators and proposers for data availability. If data hiding attacks can be conducted without incurring penalties, commit chains and Optimistic sidechains will have no security guarantees.

Cross-chain bridges: Rollups and sidechains (in most cases) use the same asset bridging scheme: locking X tokens in a smart contract on the main chain and minting X tokens for users on the child chain. Their distinction lies in how the funds deposited in the bridging contracts are secured.

Since Rollups are dedicated to specific base layer blockchains, there is typically a "normative bridge" connecting the two. The funds deposited in the Rollup bridge are secured by the parent chain:

  • Funds deposited in a validity Rollup can only be withdrawn after the proof related to the batch containing the exit transaction is verified on-chain.
  • For Optimistic Rollups, users can only withdraw funds after the block containing their withdrawal transaction has not been challenged at the end of the dispute window (approximately 1-2 weeks).

In contrast, the security of funds deposited in sidechain bridges depends on their design. For example, if a sidechain has a normative cross-chain bridge with another blockchain, the security of the bridged funds is related to the honesty of the validators. Another issue is whether the bridging is validated by the entire set of validators (e.g., Polygon PoS bridge) or a small group of external validators (e.g., Avalanche-Ethereum bridge).

The differences in finality times between Rollup and sidechain bridging also explain their distinctions. For instance, Optimistic Rollup users experience more delays when bridging funds back to the main chain due to the need to wait for the dispute window. With sidechains, users can withdraw funds from the cross-chain bridge contract as soon as they receive the finalized block header (and a valid Merkle proof if necessary).

Choosing Between Rollups and Sidechains

When deploying smart contracts, the choice between using a Rollup or a sidechain depends on your goals, user feedback, and project requirements. Here are the advantages of using Rollups, sidechains, or both in different scenarios.

When to use Rollups:

  • Your users want the highest security guarantees.
  • Your users can tolerate slightly higher costs and increased latency/finality. Rollup costs are significantly lower than Ethereum, and they are faster (by orders of magnitude), but they cannot compete with sidechains on these metrics.
  • You (or your users) want to establish a closer relationship with the parent chain ecosystem (e.g., Ethereum).
  • You plan to improve the user experience for DApp users on the Rollup. This may involve using liquidity providers to reduce the delay in withdrawing funds from Optimistic Rollups or implementing code optimizations to reduce the transaction data generated when users interact with your smart contracts.
  • You want to use EVM tools and infrastructure when building your DApp. Most Rollups are EVM-compatible and use the same tools, client software, and node APIs as Ethereum.

When to use Sidechains:

  • Your users want to transact at the lowest possible fees.
  • Your users want transactions to be processed quickly, especially when bridging funds.
  • Your users can tolerate increased trust assumptions and lower security guarantees.
  • You (or your users) do not consider a close relationship with the parent chain ecosystem a priority.
  • You are willing to learn a new set of programming languages, tools, and infrastructure to build your DApp (if using non-EVM sidechains).

When to use both Sidechains and Rollups:

  • Your project has already established strong network effects on one blockchain and is ready to expand simultaneously into multiple ecosystems (e.g., to leverage liquidity).
  • You want to cater to different types of users and avoid alienating one side of the market.
  • Your project has sufficient resources to handle cross-chain expansion. This may mean having different teams responsible for deploying your DApp on different blockchain platforms.
ChainCatcher reminds readers to view blockchain rationally, enhance risk awareness, and be cautious of various virtual token issuances and speculations. All content on this site is solely market information or related party opinions, and does not constitute any form of investment advice. If you find sensitive information in the content, please click "Report", and we will handle it promptly.
ChainCatcher Building the Web3 world with innovators