Understanding rollups on Tezos

Claude Barde
8 min readJun 5, 2023

Everything you need to know to understand one of the greatest upgrades on the Tezos blockchain

“Rollups” are all the rage at the moment in the crypto world, many blockchains have added them to their portfolio, and with all the technical jargon involved in this technology, it can be easy to be lost. Although the details of their inner workings can be technically complex, their general functioning and the purpose they fulfil are pretty easy to wrap your head around.

The upgrade of the Tezos blockchain that happened in March 2023 called Mumbai introduced optimistic rollups. By the end of this article, you will know everything you need to understand what a rollup is, how it works, and why it is such a big deal.

As this article is written for a technical and non-technical audience alike, some concepts will be simplified and some shortcuts may be taken for the sake of clarity. If you want to have more technical details about the functioning of a rollup, you can check the official documentation.

What’s a rollup?

The best way to understand what a rollup is to use an analogy.

Think about your phone, it has very basic features, like giving/receiving calls, sending/receiving text messages, giving you the time and date, etc. But it also allows you to download apps. Apps will plug into your phone as a base layer and provide additional functionalities, for example, they let you play games, check your bank account, post and read on social media, etc. All are functionalities your phone doesn’t have natively.

As you may have guessed, your phone in this analogy represents the Tezos blockchain, it has specific, limited features. A rollup is like an app that you install on your phone, you can use it to enhance the overall experience of Tezos and provide access to features and services that otherwise would be impossible.

Purpose of a rollup

A rollup is simply a piece of software that plugs into the blockchain to provide additional features. Because it uses the Tezos blockchain as a base layer, it must follow some conventions to interact flawlessly with it. Outside of these conventions, the rollup can implement a lot of different features that are not possible directly on the Tezos blockchain.

With these characteristics in mind, you probably see now that the possibilities offered by a rollup are endless. You may have heard about the EVM rollup, a technology that will be able to emulate the Ethereum blockchain in order to run Solidity smart contracts in a Tezos rollup, but many other projects will enjoy this new addition to Tezos.

For example, game developers will be able to harness the power of a rollup to create ultra-fast games that require a high transaction throughput. DeFi platforms will also be able to run in a rollup and implement more complex functionalities like an order book.

Why optimistic?

The rollup is called optimistic because we hope that whoever is running it won’t introduce malicious operations that could make their way to the Tezos blockchain. This hope is guaranteed by a deposit of 10,000 XTZ that the maintainer of the rollup will lose in case they provide an invalid state, 5,000 XTZ will be burned and lost forever, 5,000 XTZ will be awarded to the third party that discovered the invalid state.

The optimistic part of the rollup can appear a little naive at first sight, but it is actually one of its greatest strengths.

So it’s not just wishful thinking, there is a real incentive to keep a correct state in the rollup and commit a correct state to the Tezos blockchain!

The different components

This is where things get a little technical, but fear not, everything will make sense very quickly 🙂

Here is a diagram representing the different components involved in the execution of a rollup:

Note that approximations will be used in this part in order to give a general idea of the functioning of a rollup to technical and non-technical people. The full process is more complex and has been simplified as much as possible while remaining correct.

There are 3 elements involved in the well-functioning of a rollup:

  1. the rollup itself
  2. the Tezos blockchain
  3. the global inbox

These elements work in unison to ensure perfect communication with the rollup and utmost security when exchanging information.

The rollup is a separate service that runs a program called a kernel that implements the behavior of the rollup. The global inbox receives messages coming from the whole blockchain that will be read by each rollup. The rollup can also receive messages from the outside world through metadata requests.

After the rollup runs and its state updates, the new state can be committed to the blockchain. Third parties then have 2 weeks to verify this state and refute it if they find that it’s incorrect.

Examples on other chains

Optimistic rollups exist on other blockchains, mostly on Ethereum, and although the general idea is the same, their implementation and working are quite different from a smart rollup on Tezos:

  • Optimism
  • Arbitrum

On other chains, rollups are not embedded into the protocol and are free to implement (or not) their own safety layer.

In general, this means that the state produced by the rollup is sent as a transaction to Layer 1 and recorded in a smart contract while a centralized entity verifies in a more or less public fashion that the state is correct.

Interactions from Tezos to the rollup

The layer 1 (i.e. the Tezos blockchain) can communicate with the layer 2 (i.e. the rollup) through an inbox. The rollup can find the messages in the inbox and update its state made up of two components: a transient state and a persistent state.

The inbox

The communication between the Tezos blockchain and a rollup happens through the inbox. The inbox can receive 2 types of messages: internal messages and external messages.

External messages are messages made of bytes that are sent by a third party. For example, it is possible to send them with the octez-client. Because they can be made of any arbitrary bytes, the kernel of the rollup is in charge of decrypting them and making sure they are intended for this specific rollup.

Internal messages are messages that come from smart contracts existing on Tezos. When a rollup is originated, it is given a Michelson type. The internal messages sent to the rollup must be of that same type.

The states

To keep track of the operations happening inside its kernel, the rollup contains 2 states:

  • the transient state is used by the kernel to store information necessary for the current execution, it is destroyed at the end of the execution of the kernel program
  • the persistent state is made of 3 elements:
    - an inbox that receives messages from the Tezos blockchain
    - an outbox that sends transactions to contracts on the Tezos blockchain
    - a durable storage to persist data between each execution of the kernel

Interactions from the rollup to Tezos

Just as information can be transferred from the Tezos blockchain to the rollup, the rollup can send information to the Tezos blockchain as well.

The exchange of information from the rollup to the Layer 1 is more complex because the data transferred to the blockchain must be validated and we must be 100% sure that it is correct.

It involves 3 different steps:

  • Populating the outbox with messages
  • Committing the messages
  • Refuting the messages (if required)

The outbox

The outbox is a collection of messages that are waiting to be committed to the blockchain. The kernel of the rollup creates messages in a specific format that represents transactions targeting smart contracts on Layer 1.

The messages will stay in the outbox for 2 weeks for what is called the “cementation period”. During this period, anybody can come and verify the validity of the messages created by the kernel.

If the messages are correct, they stay in the outbox for 2 weeks and the transactions they represent can be triggered and pushed to the Tezos blockchain and update the states of the different smart contracts they target.

If one of the messages is not correct, the “refutation game” can start.

The refutation game

Although the rollup is “optimistic”, this doesn’t prevent malicious users from committing a wrong state to Layer 1 from their rollup.

The transactions sitting in the outbox go through a cementation process during which another participant can put a stake in the rollup to refute the existing transactions if one or more are incorrect. Because of the deterministic nature of the kernel, it is possible to prove that a message is incorrect, and honest participants are always rewarded for their honesty.

First, the participants must agree on the first discrepancy in the messages. Once it is found, they must provide a proof that their calculations up to the discrepancy are correct.

From this point, there can be only 2 possible outcomes:

  • One of the participants provided an incorrect proof
  • Both participants provided incorrect proofs

In the first situation, the participant that provided the wrong proof loses their stake in the rollup, and half of it is awarded to the participant that refuted the state. In the second situation, both participants lose their stake and the stakes are burned.

Note that these interactions must happen in a certain window. Each participant gets up to one week to provide a proof of the correctness of their proposed state. If nothing happens during that period, the participant is simply dismissed.

Interactions from outside to the rollup

In addition to the interactions that happen between the rollup and the Tezos blockchain in both directions, the rollup can also receive information from outside sources. This information must follow 2 important rules:

  1. The data size cannot exceed 4 kB. If a larger amount of data needs to be sent to the rollup, the data must be split and organized in a way that is known by the rollup before the data is sent. For example, if you have a lot of data to send, you could send first a table pointing at the different bundles of data that will be sent after the table.
  2. The information must be previously known by the rollup. To keep the deterministic nature of the rollup, any bit of data that is sent to it from an outside source must have been transferred beforehand through Layer 1 as a hash or hardcoded in the rollup kernel.

Conclusion

Rollups are a powerful new technology that can significantly improve the scalability and performance of Tezos.

By offloading computation and storage to off-chain servers, rollups can enable up to a million transactions per second while maintaining the security and decentralization of the underlying blockchain.

Rollups are a promising new technology that has the potential to revolutionize the blockchain industry. The Mumbai upgrade is a major step forward for Tezos, and it is expected to lead to the widespread adoption of this technology in the future.

--

--

Claude Barde

Self-taught developer interested in web3 and functional programming