Decoding ZkSync

MetronomeDAO
6 min readJul 5, 2023

A look into how zkSync works and the more technical aspects of zk-rollups

Overview

Introduction to ZkSync

If you’re involved in DeFi, you’re likely all too familiar with the challenges of high gas fees and slow transaction times. As Ethereum continues to grow and expand, these issues have become a genuine concern, calling for robust upgrades. One solution that has emerged to address these issues is zkSync.

zkSync is a Layer 2 scaling solution that promises to help us navigate around the current limitations of Ethereum by performing operations off-chain and reducing the load on-chain.

In order to achieve this, zkSync uses zero-knowledge (ZK) rollups. Zk rollups take transaction data off the Ethereum mainnet, processes it outside the network, and then brings it back as a single proof. This dramatically reduces the amount of data that needs to be stored on-chain, thereby speeding up transactions and lowering gas fees. For more information about the features of ZkSync, check out Vesper’s overview.

What are ZkRollups?

As we mentioned earlier, zkSync utilizes what’s known as zk rollup architecture. But let’s break that down a bit more to fully understand the role zk rollups play in this process.

The principle behind zk rollups is to hold funds in a smart contract on the Layer 1 chain while performing all the heavy lifting and data storage off-chain. Remember, this off-chain approach is key as it enhances the overall efficiency and scalability of the network.

Here’s why this is so impactful: traditionally, on Ethereum, each transaction needs to be verified individually, which can be quite intensive, leading to higher costs and slower processing times. Zk rollups, however, enable multiple transactions to be ‘rolled up’ into a single transaction.

The process works by users first signing their transactions and handing them over to validators. These validators, rather than verifying each transaction individually, roll up a multitude of transactions into a single block. This block is then represented by a cryptographic commitment, specifically a root hash of the new state, which is submitted to the smart contract on mainnet.

Alongside this commitment is a cryptographic proof, known as a SNARK, that confirms this new state is legitimate. As well as this proof, a state, representing a small amount of data for every transaction, is published over the mainchain network which enables anyone to recreate the state.

Finally, the smart contract verifies the proof and the state, thereby validating the authenticity of all the transactions within the block. This method of SNARK verification is far less resource-intensive than individually verifying each transaction, and off-chain state storage proves to be significantly cheaper than on-chain EVM storage.

ZK-rollup transaction process — Source: Messari

Excluding the above, what makes Zk rollups so different and sets them apart in the realm of Layer 2s is their security capabilities. Key to this is their inability to steal funds. This high level of security is upheld even if validators stop cooperating, ensuring that users can always retrieve their funds, an advantage not shared by everyone.

Zk rollups are distinct from optimistic rollups in that they eliminate the need for continuous monitoring by a single trusted third party to prevent fraud. This feature significantly enhances the system’s reliability, as it isn’t dependent on a constant presence for its security.

The Inner Workings of ZkSync

Finality

When it comes to transaction finality, the SNARK proofs previously discussed play a critical role. Essentially, once a zkSync block’s SNARK proof is generated and acknowledged by the smart contract, the transaction reaches its finality on Ethereum. This process typically takes around 10 minutes post-submission, giving it the same level of finality as any other Ethereum transaction. When compared to Optimistic rollups, or any other fraud-based scaling solutions, zk rollups come out on top due to their finality times shorter.

Confirmations

As it stands, zkSync doesn’t quite offer instant confirmations, but the future of zkSync holds promise for instantaneous confirmations, thanks to an upcoming feature — security bonds. This feature will offer guarantees of instant economic finality. It’s an exciting progression, considering that while transactions submitted to zkSync are instantly confirmed and immediately visible to the recipient, both via the user interface and the API, they are currently promises from the zkSync validator’s perspective. This means that users who do not trust the validator are required to wait for full finality before considering the assets as fully received. The introduction of security bonds, however, will transform this, giving more trust and bringing us one step closer to real-time transaction finality.

So how exactly do these security bonds work?

  1. Selected validators deposit a sizeable security bond into the zkSync smart contract.
  2. These validators run a consensus, quickly confirming that a user’s transaction will be in the next zkSync block (signed by a supermajority).
  3. Once a new zkSync block is made and submitted to the mainchain, it can’t be undone.
  4. If the block doesn’t include the promised transactions, validators who signed the receipt and the new block will be slashed. Only validators who acted dishonestly face penalties.
  5. The slashed funds are divided up: part compensates the transaction recipient, and the rest is burned.

Congestion

If we’re talking about congestion, then fraud-proof solutions like Optimistic rollups might face challenges of their own. They rely on bots to have their fraud-proof transactions mined, which could become a real problem if congestion increases, posing a potential security threat to the assets they manage.

However, zkSync is well equipped for such scenarios, thanks to its use of zero-knowledge validity proofs. With this, any asset transfer must include a proof of validity, minimizing the risk to the network. Also, zkSync’s validator nodes are designed to automatically increase their prices in response to network congestion. This ensures that zkSync blocks are given high priority in mining. While this might sound like it would raise costs for users, the reality is that because zkSync’s fees are a fraction (1/100th) of those on mainnet, users remain largely unaffected.

Security

One of the standout features that makes zkSync such a prominent choice is its formidable security. As long as there is correct implementation along with valid cryptographic assumptions, zkSync offers users a security level the same as holding funds in an Ethereum mainnet account. Here are some noteworthy characteristics:

  • Users do not need to constantly monitor the network.
  • The protocol is foolproof against validator's ill-intentions, making it impossible for them to either steal funds or tamper with the zkSync state.
  • The ability to store private keys in cold storage.
  • In any situation, regardless of the actions of validators, users retain the ability to move their assets back onto the mainnet.

A critical aspect of zkSync’s security design lies in its continuous control mechanism over funds. This is made possible through use of the ‘priority queue’, which serves as an emergency exit plan if validators unexpectedly become unresponsive. This works by:

  • If validators do not respond, and transactions are being ignored, users can submit an exit request directly on the mainnet via the priority queue.
  • Validators are required to process priority queue requests within a week.
  • If validators fall short in processing these requests, the system activates ‘exodus mode’. During this, users can immediately withdraw all their assets by conducting a direct transaction on mainnet.

Summary

zkSync is a Layer 2 solution using zk-rollups to enhance Ethereum’s scalability by reducing on-chain data and gas fees. Its security features are robust, ensuring the same level of protection as the Ethereum mainnet, and provides users with full control over their funds. Zksync is well-equipped to handle network congestion through the use of zero-knowledge validity proofs, minimizing the risk to the network. The unique ‘priority queue’ system is an additional safety net, ensuring that users can always retrieve their funds, even in unlikely situations where validators become unresponsive. Overall, zkSync is an exciting solution with many more upgrades on the horizon, this is definitely one to watch.

--

--

MetronomeDAO

A community-drive DeFi ecosystem. Our first protocol, Synth, is now live in beta - https://app.metronome.io