Mina Deep Dive- L1 leveraging zk-proofs to build the privacy layer of web
We do a technical analysis of Mina Protocol & it's workings, network activity & more.
Mina is Layer 1 blockchain that’s leveraging recursive zk-snarks to build the privacy & security layer of web 3. It is the world’s lightest blockchain has a fixed size of just 22kB, thus unlocking greater consensus participation. Blockchains didn’t find a way to deal with the network’s constantly growing data, thus fewer people being able to participate in consensus. An increased focus on scalability over the years, came at the cost of node decentralisation.
1. Understanding State Bloat
State bloat is the issue of blockchains having to store an ever growing amount of data that’s being produced due to growth in the network.
In order securely verify the state of the blockchain in a trustless manner, every single node must store the previous state of the blockchain right from the genesis block.
Why is this a challenge?
As the state bloat increases, the costs to sync the entire blockchain until validation increases, thus leading to node centralisation.
Whilst older blockchains like Ethereum suffer from state bloat due to extended histories, the newer L1s face the same issue due to their high throughput. Geth, Ethereum’s most popular client today has a state size of over 700GB with about 11 GB added every week. Although it can currently operate on regular consumer hardware, the expanding state size might make it unfeasible in the future. Ethereum intends to tackle the state size issue with upcoming upgrades known as "The Purge".
In contrast, Solana, generates data at an impressive rate of 1 GB per second or 4 PB per year. Initially, it aimed to manage historical transactions through "Archivers," while nodes would store recent data. This plan changed, and Solana now looks to utilize Arweave’s permaweb for ledger data storage. However, Arweave's current capacity is only 52 TB, requiring substantial scaling to meet Solana's needs. As of now, Solana lacks a decentralized solution for storing transaction history and temporarily employs Google's Big Table as a storage option.
This is where Mina is different. Whilst other L1s have prioritised scalability, Mina’s focus has been on maximising decentralisation of the network. Mina uses recursive zk-snarks to validate the state of the blockchain, effectively constraining its size to a mere 11 Kb. Which means you can even run a node on your smartphone.
2. Understanding how Mina works
Mina uses zk-SNARKS, a type of zero knowledge proof which is small and easy to verify, and takes less than 200 ms to verify on Mina. zk-STARKs on the other hand are designed for extreme scalability and offer a higher level of transparency, but they come with trade-offs in terms of proof size and verification complexity. Which is why you often see rollups using them.
Pickles- Recursive zk-snarks
Mina released their own zk-proof system called Pickles, which has the ability to refer itself in a recursive manner. By generating a proof of a proofs, it is able to maintain a fixed blockchain size.
Furthermore, an important feature of Pickles is its departure from the conventional SNARKs, as it operates without the need for a trusted setup. The move away from a trusted setup is particularly valuable since it eliminates the reliance on users having faith in the fairness and effectiveness of the initial setup process.
Nevertheless, relying solely on a cryptographic proof isn't sufficient for a full node to operate effectively. This proof by itself doesn't provide the necessary details for the node to operate, like knowing the protocol state.
For a node to operate properly, it requires an additional set of four elements. Firstly, there's the protocol state which holds hashed data structures, including the ledger. Secondly, a verification key for both the SNARK proof and the protocol state is necessary. Additionally, the node needs to retain account information and a corresponding Merkle path aligned with the protocol. This pairing ensures that the account information is accurately linked to the current protocol state in a trustworthy manner.
Even with all these details, the combined size of all the information required to run a node on Mina comes down to 11KB. But, the node can’t take part in consensus as it doesn’t have a complete history of transaction, and instead rely on proofs to verify the state. Despite this, Mina’s non-consensus node is much powerful than a light node in other blockchains as it operates without trust assumptions, which means it can independently verify the state of the blockchain & broadcast transactions.
Consensus
Mina uses a consensus mechanism called Ouroboros Samasika, a modified version of Cardano’s. The main difference lies in replacing the long-range chain checking with a minimum-density function, or a single number that stands in for checking all the blocks on a chain. In layman terms, it works with a blockchain that doesn’t have a history of transactions.
Furthermore, like other proof of stake chains, the probability of being selected as a block producer on Mina depends on the total amount of Mina staked by the node in comparison with the overall staked amount. Unlike Ethereum, Mina doesn’t have a minimum requirement to stake funds, nor is there a lockup, and the network doesn’t slash the funds. The network only stops distribution of Mina when a node goes offline, or engages in bad faith.
Another important characterstic that adds to Mina’s overall security is the fact that the network doesn’t know the next block producer, and based on their consensus mechanism multiple block producers may qualify. This uncertainity around block rewards helps the protocol maintain a natural defence against DDos attacks.
However, this approach does have a drawback in that it can occasionally lead to short-term forks. In situations where multiple block producers generate different valid blocks simultaneously, the subsequent block producer adheres to standard consensus rules by extending the longest blockchain. If multiple chains of the same length exist, block producers choose the first-seen chain or replace it with another if it has a higher output from the verifiable random function.
As a result of this design decision, Mina's finality is probabilistic. For instance, with a 90% honest stake and a block time of 4 minutes, Mina achieves 99.9% finality within 15 blocks, equivalent to approximately 60 minutes. This finality duration is considerably longer compared to newer blockchains like Solana and Avalanche, which achieve transaction finality within seconds.
It's important to note that while Mina's probabilistic finality takes longer than some other blockchains, it's not inherently "bad." The finality time reflects the trade-off between security and speed. Mina prioritizes security by ensuring that transactions are thoroughly verified over a defined number of blocks before they are considered irreversible. While faster finality might be desirable in certain use cases, Mina's approach aims to strike a balance between security and efficiency.
3. Transaction Process
In the Mina transaction process, two key roles come into play: block producers and SNARKers. Think of block producers as similar to validators in other proof-of-stake chains. They're randomly chosen to create blocks based on their total stake. On the other hand, SNARKers (or SNARK workers) generate SNARK proofs for individual transactions in the blockchain. To grasp their functions better, let's delve into how transactions work on Mina.
To initiate a transaction, users share it with the network along with the fee they're willing to pay. This fee is collected in the transaction mempool.
Separately, SNARKers continuously focus on creating SNARK proofs for these transactions so that they can be incorporated into blocks.
Once a block producer is selected, they prioritize the most lucrative transactions with higher fees from the mempool. However, block producers must also include SNARK proofs for the same number of transactions as they're adding to the queue. They can either create these SNARK proofs themselves or purchase them from SNARKers.
SNARKers compete to supply the lowest-cost SNARK proof. Interestingly, according to Mina Explorer, all SNARK proofs in the last 100 blocks were provided for free by SNARKers. In the future, SNARKers might receive incentives similar to mining rewards, known as SNARK mining.
The block producer then updates the queue, ensuring it maintains a consistent size as the number of new, unSNARKed transactions matches the number of transactions removed after being SNARKed.
Next, the block producer incorporates the SNARKed transactions into the block and updates the zk-SNARK proof of the protocol state.
The freshly created block and SNARK proof spread across the network and gain confirmation from other nodes.
4. Token model
The native token of the blockchain is MINA, which is used to pay for transaction fees & incentivises consensus participaton in the network through block rewards.
Of the 42% of the funds allocated for community grants, 4.4% was allocated to genesis members, 7.5% was sold through a token sale on Coinlist, and 11% for project grants similar to Near. By allocating 42% of the tokens to the community, Mina has managed to sufficiently decentralise the network in terms of token holding, as well as the 11% allocated for grants will help Mina build a thriving developer ecosystem. The allo
MINA is an inflationary currency with initial inflation of 12% that will reduce to settle at 7% after four years from mainnet launch. Inflation is fixed, and staking yields change with the staking participation rate. While inflation may seem high, it helps to keep the chain secure as it encourages staking participation.
5. Zk-Apps
zkApps (zero knowledge apps) are Mina Protocol’s smart contracts powered by zero knowledge proofs. zkApps employ an off-chain model, where only a flat fee is required to send the resulting zero knowledge proof to the chain. They are written using SnarkyJS, a Typescript library that leverages zero knowledge proofs. Let’s take a look at some of the key features that sets them apart-
Privacy Preservation
Today, users have no control over their private data and are forced into handing them over to centralised entities. Mina changes. Rather than sharing the data, users can share proofs of their data thus unlocking new use cases without putting their privacy at risk. One good example of this is being able to share that your creditworthiness without giving out your private data to an on-chain dapp.
Off-chain Computations
Whilst other blockchains typically use a variable gas fee based model that’s highly dependent on the supply and demand of the network, zkApps use a flat fee model. The apps can perform all the complex computation off-chain & send a proof of it on-chain for verification at a flat fee.
Web2 to Web3 Connectivity
Mina’s zkApps can privately interact & access real world data for use on-chain. Developers can access any publicly available data on the web and share relevant proofs. There’s no need to trust a third party oracle or use custom integrations, thus massively saving time & cost. One of the challenges with using oracles like Chainlink is it exposes sensitive user data to counterparties. Mina’s zkApps keeps everything private. Furthermore, Mina allows you to connect to any public HTTPS site without needing an agreement unlike Chainlink.
Interoperability across chains
Considering Mina’s lightweight architecture & off-chain nature of smart contract computations, other chains can leverage Mina’s proof system for specific use cases. There’s already a bridge that has been established between Mina & Ethereum where dapps can leverage Mina’s privacy persevering features.
Developer Onboarding
zkApps use SnarkyJS, a Typescript-based library, rather than requiring developers to learn a new language. This approach significantly widens the pool of developers who can easily start building zkApps.
Whilst Mina prioritised decentralisation, it came at the cost of scalability. Which is why Zeko, a modular zk-rollup ecosystem is being incubated by the O(1) Labs team. Let us take a look at it-
6. Zeko- A Layer2 for zkApps
Zeko is a Layer 2 ZK Rollup ecosystem specifically designed for zkApps. Zeko’s initial release will be a fully Mina-equivalent application layer where ZK developers can easily build and deploy zkApps and enjoy dramatically higher throughput and fast transaction confirmation times. All while inheriting security of and relying on tooling, libraries and integrations of Mina. Let’s take a look at some of the key offerings of Zeko-
Programmable Privacy
Zeko will allow developers to build decentralised applications with programmable privacy, at scale. In layman terms, developers can decide which part of their application can remain private & which public. For example- A credit scoring app can selectively disclose that the user is above a certain threshold & have a public profile, but doesn’t reveal any personal details.
Modularity
Zeko offers a modular stack for constructing custom ZK Rollups. Developers can leverage reusable modules for DA (Data Availability), proving, and shared sequencing. This empowers them to build app-specific rollups that are both highly configurable and efficient. Notably, any zkApp producing pickles-wrapped kimchi proofs of state transitions can be seamlessly settled onto Mina through Zeko's shared sequencer.
Interoperability Layer
Zeko is an L2 interoperability layer for zkApps. Compositional properties are innumerable due to Kimchi's recursion capabilities. Proofs on Zeko L2s , similar to Mina's full blockchain, can be folded inside a Mina zkApp.
Now that we’ve taken the time to understand the in and outs of Mina’s ecosystem. The question arises-
How will Mina position itself?
Conclusion
Ethereum has positioned itself as the global settlement layer, and is leveraging rollups for scalability. Solana is the defacto chain for consumer grade applications which require high throughput. Mina is uniquely positioned to be the privacy layer of the web. There’s massive value waiting to be unlocked in the world- especially around RWA, healthcare, supply chain logistics and new identity primitives. My firm thesis is Mina’s infrastructure will be leveraged by apps across chains as the momentum towards building privacy first world increases.