Cover photo

An Introduction to zkSync

zkSync is a L2 blockchain that uses zkRollups to enable high throughput and low-gas transfers. This post is my understanding of zkSync and zkRollups. The following topics are discussed in this post:

  • The blockchain trilemma and goal of layer 2 scaling solutions.

  • A definition of zkSync, zkRollup, and zkSNARK.

  • An explanation of how zkSync achieves high throughput, fast finality, and low-gas transfers.

This is written in May 2022. The accuracy of information in this post can change based on upgrades to zkSync or Ethereum.

The Scalability Problem

Ethereum is a decentralized and secure blockchain, but it’s not scalable due to its low throughput of roughly 15 transactions per second. When the network gets busy, transaction speed slows down, resulting in a queue of transactions. During slow speeds, users participate in a bidding war, increasing their gas prices in an effort to jump the queue and get included in the next block. Ethereum miners change the order of transactions in favor of those with the highest priority fee. This creates a slow and expensive user experience.

The goal of scalability is to increase transaction throughput and speed of finality. The challenge is doing this without sacrificing decentralization or security. This challenge is known as the blockchain trilemma, the idea that blockchains can only achieve two out of the three properties with respect to decentralization, security, and scalability. In an attempt to solve the blockchain trilemma, upgrades to Ethereum aim to make the network more scalable and secure without sacrificing decentralization.

There are many approaches to scaling Ethereum, including on-chain solutions like sharding and off-chain solutions like plasma, state channels, rollups, and sidechains. Layer 2 (L2) is a category of scaling solutions that consists of smart contracts deployed on Layer 1 (L1) that are responsible for processing deposits, withdrawals, and verifying proofs, while computation and storage are performed off-chain. Unlike sidechains, L2 inherits the security of the L1 network. It is one of the most promising scaling solutions available today. There are currently three main L2 solutions: State Channels, Plasma, and Rollups.

zkRollups, zkProofs, zk-SNARKs

A rollup is a type of L2 scaling solution that batches transactions off-chain and submits them to L1 as a single transaction. There are two types of rollups, Oprimistic Rollups and Zero Knowledge Rollups (zkRollups). In this post, I will only cover zkRollups, the scaling mechanism used by zkSync. zkRollups is a type of rollup that uses Zero-Knowledge Proofs (ZKP) to prove the validity of transactions in a rollup block (batch of transactions).

Zero Knowledge (ZK) refers to one party being able to prove to another that a particular set of information is true, without revealing what that information is, hence there is zero knowledge of the information but there is proof that it exists. Zero-Knowledge Succinct Non-Interactive Argument of Knowledge (zk-SNARK) is a type of ZKP used by zkRollups. A zk-SNARK is generated for each rollup block which is then verified on-chain by the L1 contract. Each zk-SNARK includes a proof of the validity of every single transaction in a rollup block.

Processing transactions off-chain enables rollups to increase throughput. Computation executed off-chain does not affect the speed of the on-chain part of the transaction. Rollups use compression to reduce the size of on-chain data. By reducing the size of on-chain data, rollups not only increase finality speeds, but they reduce the cost of gas. Having less on-chain data saves processing power, time, and storage.

The Contender

zkSync is a L2 blockchain that uses zkRollups to enable high transaction throughput and low-gas transfers.

High Transaction Throughput

zkSync scales transaction throughput with speeds of 2000+ transactions per second. It achieves this by reducing the amount of on-chain transaction data, allowing for transactions to be processed more quickly and for more transactions to fit in a block. Only a cryptographic proof and the state delta (the change in the state of the L2 blockchain) are stored on-chain.

Fast Finality

Finality in a rollup block can be reached in as fast as 10 minutes. Transactions in zkSync reach finality as soon as a SNARK proof for a particular rollup block is posted and verified by the L1 smart contract. This is a significant advantage over Fraud Proofs, which require up to 7 days for a transaction to reach finality.

The off-chain confirmation for transactions on zkSync are instant, however, users still rely on the validator to include the transaction in a rollup block. In the future, zkSync validators will be required to add a security bond to the network as an economic guarantee that they will include the transaction in a rollup block.

Low Gas Fees

As a result of using SNARK validity proofs and compressing on-chain data, zkSync is able to reduce gas costs by up to 200x compared to a L1 transaction. SNARKs allow zkSync to only store the SNARK itself and the state delta on-chain. Everything else is computed and stored off-chain, where operation costs are fractions of a cent per transaction. The data for every rollup block is published as a root hash in L1 calldata, the lowest-cost data location. By bundling thousands of transactions, users split the cost of a single L1 transaction, reducing gas costs even further.

Gasless Meta-Transactions

zkSync supports gasless meta-transactions, enabling users to pay gas fees in the token being transferred. Meta-transactions are transactions in which a relayer pays the gas fee in ether on behalf of the sender. Dapps on zkSync can choose to sponsor the fee or they can have validators accept ERC-20 tokens for gas fees. This abstracts gas from the UX because it no longer requires users to have an ether balance or adjust gas settings.

Scalable Payments

Given the low-gas transfers and high throughput of zkRollups, zkSync works as an exceptional solution for scalable payments. With transaction throughput equal to, if not greater than Visa, zkSync can be used as a payment solution for p2p, e-commerce, retail, and more. zkCheckout allows users to accept token payments on zkSync via payment links that function as payable invoices. Developers can use the zkCheckout SDK to implement payments via zkSync onto any website. zkCheckout has already been implemented into Gitcoin Grants as a checkout option.

Mainnet-Level Security

Because zkSync is a L2 solution, it inherits the security and decentralization of Ethereum. Once the rollup block is verified and produced in L1, it is immutable. Users do not have to rely on 3rd parties or validators for the security of their funds. Validators are not able to corrupt the state of the L2 blockchain nor steal user funds. If zkSync validators stop cooperating and fail to include user transactions in a rollup block, users can use an emergency exit function to withdraw funds back to L1. There is no operational activity required on zkSync to keep the funds safe.

Conclusion

Ethereum L2 scaling solutions are live and thriving with close to $5 billion in combined TVL. Currently, there are several implementations of an EVM-compatible Optimistic Rollup. zkRollups are getting there, with several projects working towards EVM-compatibility. The scaling and gas improvements brought forward by zkSync are a significant step towards mass crypto adoption.

Smart contract support will come at the release of zkSync 2.0, an upgrade that will include an EVM-compatible zkRollup. It will enable existing Ethereum applications to seamlessly launch on zkSync as well as allow Solidity developers to building natively on L2. The uptick in banking on a fast, cheap, and secure L2 is near.

__

Feedback? Message me on Twitter. Questions? Join the zkSync Discord.