Protocol Architecture & Features
Last updated
Last updated
Blockchain networks face a scalability trilemma where they cannot have everything all at once: robust security, genuine decentralization, and high throughput. However, layer 2 are the most promising solutions to higher blockchain scalability.
ZK-rollup is a layer 2 scaling solution that helps process transactions faster by handling them off the main blockchain (off-chain) but still records the transaction data on the main blockchain (on-chain). It uses ZK-proofs to ensure that these transactions are valid without revealing any private information.
MetaFi uses ZK-Rollup technology to improve scalability, reduce fees, speed up transactions, transaction throughput, and protect privacy through efficient batch processing and zero-knowledge proofs. ZK-Rollup uses validity proofs for off-chain computation and stores a small amount of transaction data on the chain.
Zk-rollups are one of the most promising technologies for meaningfully scaling the blockchain economy while keeping its critical properties of censorship resistance and trust-minimization intact. Scaling through rollups also has the added benefit of developers being able to tailor a layer-2 network to their specific requirements and create highly specialized computing environments that still inherit the security of a public decentralized base layer.
A fully realized Web3 ecosystem will have to handle an exceedingly large number of transactions, and as more blockspace becomes available through the widespread adoption of rollups, more activity will be unlocked and more industries can leverage the benefits of blockchain technology.
Zero-knowledge technology is a subset of cryptography that is helping blockchain projects overcome the scaling and privacy limitations inherent to many layer-1 blockchains. The technology enables blockchain projects to facilitate greater transaction throughput, protect user data while still being able to verify identities, and support complex computation, while also allowing enterprises to adopt blockchain technology while protecting their intellectual property. Underpinning all of these use cases is zero-knowledge proofs.
A zero-knowledge rollup (zk-rollup) is a layer-2 scaling solution that moves computation and state off-chain into off-chain networks while storing transaction data on-chain on a layer-1 network (for example, Ethereum). State changes are computed off-chain and are then proven as valid on-chain using zero-knowledge proofs.
Zero-knowledge proof blockchain projects help developers build advanced dApps that scale the Web3 ecosystem while protecting users' privacy.
Zero-knowledge solutions grant developers a way to leverage the security of an existing layer-1 blockchain like Ethereum while enabling dApps to scale through higher throughput and faster transactions, protecting users’ personal information by keeping it hidden off-chain, and lowering the cost for end-users by publishing transactions in batches. Ultimately these advantages enable projects to build advanced dApps that rival the performance and functionality of Web2 systems while maintaining the benefits of decentralization.
At their core, ZK-rollups work through a smart contract on the layer 1 blockchain. This smart contract is crucial as it maintains an authoritative record known as the state root.
State Root: The state root is a Merkle tree of batches of information about the rollup’s accounts, balances, and contract code. Users, like the sequencer, publish new batches (a compressed collection of transactions) along with the old and new state roots (pre- and post-state roots). The smart contract then checks the old state root against the current root. If they match, it switches the current version to the new state root.
Deposits & Withdrawals: Naturally, rollups have to allow inputs and outputs from the “outside” to enable withdrawals and deposits. The transaction that submits the batch containing “outside” inputs also moves assets to the smart contract. When the transaction submits the batch containing “outside” outputs, the contract initiates the withdrawal process. Hence, the underlying smart contract synchronizes state changes across the base-layer and the rollup.
Post-State Verification: How to verify the correctness of the post-state root? Up until now, a malicious actor would have been able to submit any version of the state root (e.g., where they transfer all assets to their account). However, rollups have addressed this issue in two different ways: validity proofs and fraud proofs. Hence, we have two schemes: zero-knowledge and optimistic rollups.
Validity Proofs: ZK-rollups rely on validity proofs to ensure the post-state root contains no manipulations. For that reason, every new batch of transactions comes with a zk-SNARK (or zk-STARK) – an argument of knowledge that proves the batch computation indeed produces the same result as the new state root. And the most important part: even the heaviest computations can be verified quickly on-chain thanks to the highly complex math behind ZK-proofs.
Zk-rollups bundle transactions into batches that are executed off-chain and verified on-chain using a validity proof.
Zk-rollups increase scalability as instead of having to post all transaction data on-chain, they only need to periodically provide valid bundled-up transaction batches that are executed using off-chain computation. These bundles are then “rolled up” into one summary of the state changes that are verified by the base layer using a validity proof that proves the correctness of the changes using a zero-knowledge proof, demonstrating with mathematical certainty that the state changes proposed by the layer 2 are correct and are the result of the execution of the given batch of transactions.
Zk-rollups typically rely on the base layer for data availability, settlement, and censorship resistance. The rollup’s state is maintained by a smart contract deployed on the layer-1 network. When a user submits a transaction on the rollup, it’s usually submitted to a layer-2 operator for inclusion in the next transaction batch. These operators can be a centralized entity called a sequencer that executes transactions, bundles them up in batches, and submits the batch to the layer-1 network. Zk-rollups can also use a proof-of-stake system where the role of executing and bundling transactions is rotated between a set of validators who have deposited funds into a rollup staking contract.
MetaFi uses STARK proofs as opposed to the more common SNARK proofs. STARK proofs are a more recent advance in proving technology which aim to solve the key problems with SNARK-rollups, namely that:
SNARKs require a trusted setup ceremony
SNARKs are not post-quantum secure
SNARKs rely on extremely complex cryptography and can be prone to implementation errors
STARK proofs are larger and cost more to publish on-chain: we consider this an acceptable tradeoff for greater user security.