10 min read
Detailed Look at the zkSync Architecture
As one of the top Layer-2 solutions, zkSync's mission is to increase Ethereum's throughput while preserving its core principles of trustlessness, security, reliability, censorship resistance, and sovereignty. However, Ethereum lacks privacy and hyperscalability, and that is where zkSync comes in. With the help of zero-knowledge (ZK) technology, Ethereum can achieve limitless scalability and become a stronghold for privacy.
Hyperscalability is zkSync's solution to satiate Web3's thirst for more blockspace. Furthermore, zkSync will scale Ethereum with ZK tech while avoiding the adverse side effects of increased costs and decreased security.
Today, we will explore zkSync's architecture and ecosystem, including zkSync Era, Hyperchains, and zkPorter. This article assumes some familiarity with ZK tech, so if you need to get up to speed on how ZK-Rollups work, please follow the link to read our explainer article first.
The team at Matter Labs created zkSync Era as an EVM-compatible ZK-Rollup. It is the updated version of zkSync Lite, which was designed to handle basic payments. zkSync Era builds off the Lite version to offer new features and improvements that bring greater scalability and low-cost transactions to Ethereum. And because of it's compatibility with Ethereum's technology and security, it feels just like Ethereum.
As for the developer experience, migrating projects is seamless. Support exists for most tools and popular frameworks like Hardhat and Foundry. Moreover, developers can still write smart contracts in Solidity or Vyper, like with other EVM-compatible chains. However, there will be massive improvements in scalability with significantly lower fees.
Regarding UX, transactions get instant confirmations and quick finality on Layer 1, and the low fees can be paid with ERC-20 tokens thanks to native account abstraction. In fact, zkSync Era claims to be the first EVM-compatible chain to implement native account abstraction, which will change how accounts operate.
There are two types of accounts on Ethereum—externally owned accounts (EOAs) and contract accounts. Only EOAs can initiate transactions, and only contract accounts can implement arbitrary logic. In instances where things like smart contract wallets are involved, this can cause friction as such applications require an EOA to facilitate transactions.
However, zkSync Era accounts can initiate transactions, like an EOA. They can also behave like a smart contract with arbitrary logic implemented. This feature is called "account abstraction." It's still in the early stages, so the team has cautioned that there could be some forthcoming breaking changes. For now, no incompatibilities have been found when implementing account abstraction into EVM projects.
zkSync Era computes transactions off-chain and stores most of the data off-chain, thus reducing storage costs multiple times compared to Layer 1. Moreover, with its powerful ZK tech stack (which includes an award-winning GPU prover, an LLVM-based Solidity compiler, and the upcoming Redshift proof system), zkSync reduces average transaction costs to a fraction of a penny. So, by publishing only the final storage state updates, zkSync lets developers maximize the inexpensive computation.
Now that we know some of the features of zkSync Era, let's look at its workflow. With zkSync Era, users can deposit, receive, and transfer assets. They can also withdraw their holdings to a Layer 1 address. Here's how its rollup transactions operate:
A user creates a rollup transaction.
The operator processes this request, creates a rollup operation, and adds it to the block.
The operator sends the completed block to the zkSync smart contract (block commitment).
The proof (for the block) gets sent to the zkSync smart contract for block verification.
Lastly, the new state is considered final when the verification succeeds.
Further, each Layer-2 block progresses through the stages below until it's finalized.
The operator has received the transaction but has yet to process it.
The operator processed the transaction, and it's confirmed to be included in the next block.
This block's transaction data has been posted to Ethereum. Although it's not proven to be executed in a valid way, the availability of the block data is ensured.
The transaction's validity proof is submitted and verified by the smart contract. Once this step concludes, the transaction is considered finalized.
For developers, zkSync usually treats the (2) Processed and (3) Committed states as a single "committed state" since there is no difference from a UX standpoint.
Another popular player in the Layer-2 ecosystem is Polygon zkEVM. zkSync and Polygon are both open-source and use Ethereum as their data availability layer. But the primary difference is that zkSync Era is EVM compatible while Polygon zkEVM is EVM equivalent. "Compatible" and "equivalent" can sound like the same thing, but there are differences, as described in Vitalik Buterin's article about different types of zkEVMs.
That's because instead of gunning for EVM equivalence, zkSync Era uses its custom VM for quicker proof generation. So, while its VM is not EVM equivalent, it can compile code from languages like Solidity or Vyper. So, that makes Polygon zkEVM a Type 3, while zkSync Era is closer to a Type 4.
Ready to learn about crypto staking? Find out how Luganodes enables secure crypto staking in our recent article.
zkSync describes Hyperchains as "fractal-like instances of zkEVM running parallel with the common settlement on the Layer-1 mainnet." So, while a single monolithic blockchain can't handle the world's value transactions, simultaneously running multiple Hyperchains can achieve parallelization. That's why zkSync Era consists of a network of ZK-powered Hyperchains.
These Hyperchains are modular blockchains that function on top of their Layer 2. Notably, they bring near-instant liquidity transfers between the various protocols in the system. The good news is that anyone can deploy their Hyperchain with a data availability policy and custom consensus while inheriting finality and security from the underlying Layer 1.
Additionally, because Hyperchain implementation follows a modular approach, developers can pick different components of their blockchains from the ZK Stack or implement their own. That means they can use the ZK Stack to develop and deploy Hyperchains while keeping full rights to the code to customize the chain as they see fit. However, for generic dApps that don't need customization, devs can deploy on an existing Hyperchain rather than reinventing the wheel by building their own.
Hyperchains stay interconnected by a network of trustless Hyperbridges that enable quick and low-cost-per-transaction interoperability. Hyperbridge gets its name from "hyperlinks," where users navigate between websites. Likewise, Hyperbridges connect zkSync Hyperchains. Moreover, deploying Hyperbridges eradicates the need for insecure token bridges, which have been a consummate weak point regularly exploited by hackers.
Hyperbridges are sets of smart contracts that verify Merkle proofs of transactions occurring on other chains. The original asset stays locked up on Layer 1 in the shared bridge contract, thus keeping unified liquidity running throughout the ecosystem.
Below are the steps to Hyperbridging between Hyperchains:
A Hyperchain initiates the transaction, sending it cross-hyperchain.
The Hyperchain sending the transaction settles its proof on Layer 1.
Once the proof gets settled, it updates the Transaction Root, which is a commitment to all the Hyperbridge transactions occurring inside the ecosystem.
The receiving Hyperchain imports the Transaction Root, similar to how Layer 1 to Layer 2 messages get imported.
A relayer sends the transaction along with a Merkle Proof (that connects it to the Transaction Root) to the receiving Hyperchain.
The Merkle proof and transaction get verified against the Transaction Root. If the proof is correct, the transaction gets executed, and the relayer receives its reward.
The receiving Hyperchain verifies the imported Transaction Root and settles its proof.
Another exciting feature is "layering." By layering, Hyperchains can settle their proof on a Layer 2 Hyperchain, effectively making it a Layer 3. Layer 3s settling on the same Layer 2 will achieve faster messaging and inexpensive atomicity while preserving interoperability within the broader ecosystem.
Another significant part of zkSync's architecture is zkPorter. It can offer the benefit of much lower costs via a decentralized storage option, albeit with reduced security. That's why the team expects zkPorter to be more popular, with users willing to take higher security risks in exchange for inexpensive transactions.
zkSync's architecture will be divided into two parts:
The first is the ZK-Rollup we already discussed in zkSync Era. It comes with on-chain data availability.
It will operate with off-chain data availability.
Both parts will be interoperable and composable. Contracts on the rollup side (zkSync Era) will be able to interact seamlessly with those on the zkPorter side and vice versa. Since most rollup fees accrue from publishing data to Ethereum, zkPorter accounts can save money with thousands of transactions, only needing to post one update to Ethereum.
Regarding data availability, zkSync token holders (Guardians) will use the zkSync token to participate in proof of stake (PoS) consensus to secure the network. They will track state changes on the zkPorter side by signing blocks to confirm data availability. So, any data availability failures will get the Guardian(s) slashed. This penalty provides crypto-economic incentives to guarantee data availability.
zkSync's PoS consensus mechanism is significantly more secure than other systems like sidechains, mainly because Guardians can't run off with users' funds. The worst they can do is freeze the zkPorter state, but by doing so, they would also freeze their stake.
And when it comes to Optimistic Rollups, they can't achieve zkPorter's scaling level. That is because they lack the inherent cryptography of ZK-Proofs. If an Optimistic Rollup moved data availability off-chain, a malicious operator could steal the funds in the Rollup without challenge.
So, Optimistic Rollups can't achieve zkPorter's scaling levels. Further, a successful attack against an Optimistic Rollup can result in the hacker stealing all the funds in the Rollup. Such a potential for quick gain can incentivize attackers. But again, an attack on zkPorter can only stop block production, not steal the funds. Thus, there are far fewer incentives for attackers to target zkPorter.
Nonetheless, users are free to pick their threshold for risk. Those who prefer to keep data availability on-chain can stick with the Rollup. However, fee-sensitive users like active traders can choose the zkPorter option.
Presently, Ethereum can process about 13 transactions per second (TPS). But it must somehow scale to handle millions of TPS to meet future global on-chain financial demand. So, it's no surprise that accomplishing this feat in a decentralized infrastructure poses significant challenges. While some have introduced various solutions, such as multi-chain or shard architectures, the issue of complete trust still needs to be addressed.
Therefore, ZK-tech, with its cryptographic security, has risen to become a widely accepted solution to overcome these challenges. With ZK Rollups and a data availability layer, Ethereum can become a secure, scalable ecosystem accessible to all.
The zkPorter testnet launched in May, and Matter Labs predicted it to be production-ready within six months of the zkSync Era network launch. That went live in February 2023. So, zkPorter should be launched sometime in early 2024.
With zkEra live and zkPorter on the way, one wonders when the zkSync token will become public. Rumors abound regarding possible airdrops, but nothing is certain yet. When public staking of its token becomes available, look to Luganodes for the simplest, most secure way to participate!
Luganodes is a world-class, Swiss-operated, non-custodial blockchain infrastructure provider that has rapidly gained recognition in the industry for offering institutional-grade services. It was born out of the Lugano Plan B Program, an initiative driven by Tether and the City of Lugano. Luganodes maintains an exceptional 99.9% uptime with round-the-clock monitoring by SRE experts. With support for 45+ PoS networks, it ranks among the top validators on Polygon, Polkadot, Sui, and Tron. Luganodes prioritizes security and compliance, holding the distinction of being one of the first staking providers to adhere to all SOC 2 Type II, GDPR, and ISO 27001 standards as well as offering Chainproof insurance to institutional clients.