Learn

Introducing recursive zkRollups: A recursive improvement to zkRollups and zkApps for Mina

Recursive zkRollups are a scalable and adaptable zero knowledge proof (ZKP) accumulator tool that the Mina ecosystem can use to efficiently process transactions and optimize blockspace utilization for zkApps. Learn more about them in this blog.

By: Yonatan Medina, Founder of ycry.ptx (advised by Evan Shapiro, co-founder of Mina Protocol)

 

Mina Protocol is a beacon of innovation in the blockchain sphere. Its constant-size blockchain powered by its proving system with recursive zk-SNARKs, ensures maximum L1 security with a lightweight design that enables instant chain synchronization akin to a full node.

It serves not only as a foundation for L1 smart contracts but is rapidly burgeoning into a hub for zkApps with multifaceted applications powered by native zero knowledge (ZK) features such as modular proofs, unbounded off-chain computation, and no gas fees. As the number and complexity of these applications scale, there’s an emergent need for leveraging the versatility of the protocol’s core value— blockspace. This is where the proof accumulation comes into play, specifically recursive zero knowledge rollups.

The key advantage of recursive zkRollups is by leveraging Mina’s recursion, zkRollups and ZK app chains on Mina can reach whatever scale they need for their application. Furthermore, applications can dynamically trade off latency and throughput based on demand. The TPS can also be scaled with commodity hardware without requiring specialized machines.

These features, enabled by Mina Protocol’s recursion, are substantial improvements to existing zkRollup architectures, which often have max throughputs requiring specialized high-capacity machines, and can have very long settlement latency depending on their level of transaction demand.

With this blogpost, you will also be introduced to Hazook, an implementation of a recursive zkRollup for Mina built on Hadoop. Hazook is open-source and built to be easily integrated with o1js zkApps and zkRollups.

Maximizing Blockspace Utility with Mina: Your Key to Scale

A fundamental aspect of blockspace is its role to users of a blockchain to complete and record transactions — in other words, blockspace is needed for the data space or memory allocated to your transaction. 

But how much can you achieve in a single transaction (i.e. a single blockspace purchase)? On most chains, blockspace purchasers (users who submit transactions to the chain) can run into significant gas fees when they try to perform a large computation in their transaction. Fundamentally, the cost of blockspace on these chains is determined by how long it takes for nodes to re-execute the transaction that blockspace purchasers have done to agree on a new ledger state. 

Naturally, all users of a layer-one blockchain compete for blockspace so if one person uses all the blockspace, nobody can do anything else. One popular example of this was when CryptoKitties’ explosive growth congested the Ethereum network in 2017 causing a halt. This is a great example for why users should be mindful of blockspace and optimize each byte carefully. Ensuring efficient utilization of blockspace is crucial, as exhaustively occupying it could hinder performance for other users.

But can you do more with less? It turns out, yes! The core principle of ZK is computational integrity — the ability to prove that a computation was done correctly (and quite cheaply) with the simplest of computers verifying the work of several supercomputers. 

Because Mina is a zk-native Proof-of-Stake chain, network validators don’t have to re-execute transactions, they only have to quickly verify the transaction proof. This is revolutionary because if any computation can be quickly verified in constant time then it doesn’t matter how large the computation was, its proof can be verified in constant time.

With Mina’s zkDSL o1js, developers can not only create programs that perform specific operations but they can also merge the program’s execution proofs together. These proofs are composable and allow developers to aggregate many proofs together into a single proof and update the state of a layer-one smart contract that can be verified for a flat transaction fee (no gas!).

Recursive zkRollups thrive in this arena. At its core, it acts as a funnel, taking in a large set of transactions and consolidating them into one cohesive proof. Doing so amplifies the potential of a single blockspace purchase, ensuring each zkApp can do more in a single transaction.

In contrast to non-recursive zkRollups, recursive zkRollups allow for condensing the proof size of an app to just a single one. This computation is run off-chain to save on costs associated with processing on-chain.

To contribute positively to the Mina network, consider adopting the design pattern employed by Hazook— an integration-ready and open-source, proof-of-concept of Recursive zkRollups allowing the processing of a substantial number of transactions within a single blockspace purchase.

Hazook’s Flexibility for Future Innovation With Recursive zkRollups

Hazook is built for anyone that is looking to leverage greater utilization of their blockspace purchases on Mina or in app-chains, rollups, and layer twos. It is also generic and adaptable meaning it’s poised to cater to a vast spectrum of zkApps, from those that underscore private voting to the more intricate app-chains features. As zkApps diversify, Hazook’s inherent flexibility ensures it remains a robust and relevant tool to many.

A recursive zkRollup is a framework for processing parallelizable problems (proof accumulation) over many computers. This graph visualizes how it works.

Check out GitHub to learn about how to use any zkProgram with Hazook.

Testing Results of Hazook: On-Demand Throughput and Cost Savings

Recursive zkRollups allow zkApps to process an arbitrary throughput of transactions on demand, with commodity hardware. Below are the results after testing Hazook using AWS EC2 m5.xlarge (or similar sized instances).

As the system handles larger volumes of proofs, it becomes more efficient in processing them. In the charts below you can see that while the number of proofs exponentially increases, the L2 block time / latency only increases linearly.

While the cost for the total computation scales with the number of transactions, the cost per transaction stays constant. This property means that the expense is significantly lower than the cost of submitting transactions directly to Mina. Furthermore, this approach avoids chain congestion that would prevent others from interacting with Mina.

For example, with Hazook running proofs for 4000 user transactions should cost about $245, or ~$.06 per transaction (at $0.24 * 1024 instances/hour * ~1 compute hour)

Developers who are familiar with Terraform and TypeScript will be able to easily deploy. Check out the documentation for how to bring your ZK program.

When to use Recursive zkRollups: Use Cases

Any o1js zkProgram should practically work out of the box, but it should be built as a zkRollup (i.e. with a merge step, that gives the ability to combine two proofs into one) as described in Mina’s documentation. However, dynamic load L2s and high load app-chains can especially benefit.

Layer Two solutions and app-chains aim to combine multiple operations into a single state update on the layer-one, shifting the state root from point A to point B. However, unlike those solutions, recursive zkRollups don’t need to send a fixed amount of data or satisfy certain load times in order to settle to Mina each time it updates the state. Instead, they bring on-demand infrastructure that allows it to scale effectively, satisfying increased load with heightened activity as it continues to post new state updates to Mina.

One powerful use case is governance. For example, no matter how long a voting period may be, most users wait until the final hours before casting their votes. Implementations like Hazook are built to scale with the help of on-demand cloud services in order to meet the required computing power needed to meet a surge in user demand. 

What’s Next

Hazook is in its first implementation and improvements can be made. Building this kind of infrastructure with the native language of Mina’s proving system, OCaml, can significantly enhance performance and enable faster proving.

Contributions from Mina community members to recreate this infrastructure in OCaml are welcome and will enable the use of the native prover instead of relying on the WASM prover from o1js. If you’re interested in contributing, please submit a request for comment through the Core Grants Program.

Additionally, another project within Mina’s ecosystem, Protokit, has also implemented similar features to Hazook. However, unlike Hazook, Protokit doesn’t require using on-demand cloud infrastructure, empowering users to create zkApps with these functionalities under the hood.

TLDR 

Recursive zkRollups are a scalable and adaptable zero knowledge proof (ZKP) accumulator tool that the Mina ecosystem can use to efficiently process transactions and optimize blockspace utilization for zkApps.

Venturing into the realms of app-chains, the role of Hazook and Protokit are mission critical. It becomes indispensable for sequencer nodes tasked with block production and enormous amounts of data. Recursive zkRollups elegantly compress this information, ensuring blocks remain lean. At the same time, it uncompromisingly safeguards the integrity of the app-chain in alignment with the designated zkPrograms.

It’s not just a tool; it’s an enabler, ensuring that Mina Protocol and the zkApps built upon it are optimally efficient, versatile, and primed for the future. As we progress in the blockchain era, recursive zkRollups will stand out as a cornerstone of advanced zkApp interaction and design. 

To try out Hazook, visit the GitHub page.

About Mina Protocol

Mina is the world’s lightest blockchain, powered by participants. Rather than apply brute computing force, Mina uses advanced cryptography and recursive zk-SNARKs to design an entire blockchain that is about 22kb, the size of a couple of tweets. It is the first layer-1 to enable efficient implementation and easy programmability of zero knowledge smart contracts (zkApps). With its unique privacy features and ability to connect to any website, Mina is building a private gateway between the real world and crypto—and the secure, democratic future we all deserve.

More from our Blog

SEE ALL POSTS
Announcement,Resource / 2024-04-25 / Vitor Silva
Mina Protocol’s Upcoming Major Upgrade: Everything You Need to Know
Mina Protocol, the native-ZK blockchain live on mainnet since 2021, is on the verge of a major upgrade poised to be a game-changer for the entire crypto ecosystem.
Read more
Announcement / 2024-04-23 / Mina Foundation
Mina Protocol to Integrate Celestia’s Modular Data Availability Layer
Read more
Learn / 2024-04-04 / Vitor Silva
Mina’s Berkeley Upgrade – What to Expect
Read more
Retro / 2024-03-21 / Vitor Silva
Upgrade Mechanism Testing Retrospective
Read more

About the Tech

AboutTechCta

Mina uses advanced cryptography and recursive zk-SNARKs to deliver true decentralization at scale.

Get Started

GetStartedCta

Getting started with ZK on Mina is simple.