Level up your open finance game three times a week. Subscribe to the Bankless program below.
Dear Crypto Natives,
Two things are important for scaling crypto money systems.
First, scaling economic bandwidth. Second, scaling transactions per second (TPS). And you have to scale both in a trustless way, otherwise what’s the point?
Is it possible to scale transactions in a separate chain that’s still secured by the base chain? How about the holy grail—what if you want to run DeFi protocols in it?
Turns out it’s a tough problem. Progress has been disappointing.
So when I first heard about rollups I wasn’t optimistic. Another layer 2 scaling solution? Yeah sure. What’s the catch?
So I learned more. I tried it for myself.
Maybe something real here. Maybe the tech crypto’s been waiting for.
I learned that rollups:
Didn’t require a new token
Didn’t require an Ethereum killer
Didn’t require the redesign of DeFi protocols and wallets
Didn’t have clumsy exit games and preserved the same user experience
Could run Ethereum tokens & smart-contracts at hundreds of TPS
Were mere months from production on mainnet—they’re here now
So I asked an expert if this stuff was real.
I asked him “can we just put this entire DeFi thing in a rollup?”
This was his response.
🙏Sponsor: Aave—earn high yields on deposits & borrow at the best possible rate!
When DeFi meets Rollup
Guest post by: Daniel Goldman, engineer, researcher, and writer at Offchain Labs.
Last year marked the emergence of two new, trendy, Ethereum buzzwords. On the application level, we got “DeFi” projects which leverage smart contracts to offer incarnations of traditional financial services with trustless (or at least trust minimized, or at the very least hopefully-one-day-trust-miminized) properties. In the parallel universe of scaling protocol design, researchers began making noises about Optimistic Rollup, a layer 2 construction which, if you’re to believe the L2 enthusiasts ( 👋), promises to be more than just a passing fad.
This year (2020 for those who’ve lost track), with a live and lively DeFi ecosystem taking shape, and rollups well on their way to hitting mainnet, a natural question arises: how shall the twain meet?
Can we use rollups to scale the DeFi ecosystem?
Although as one might expect, some new challenges arise.
Optimistic Rollups are a layer 2 sidechain construction which seeks to alleviate the burden on Ethereum’s main chain. The basic idea is that instead of validating all transactions on the rollup sidechain, the mainchain simply publishes them and “optimistically” assumes they’re valid unless explicitly challenged.
The core benefit to employing rollups is lower gas costs for users, which translates to more transactions per second (several hundred TPS at least) for the network as a whole. Cheaper transactions also means that certain applications that would otherwise be too gas intensive to even be possible, like privacy solutions that employ complex cryptography, now become feasible. Thus, while rollup itself doesn’t inherently offer privacy benefits, it’s a fitting substrate on which to build privacy preserving technology. Likewise, rollup doesn’t inherently increase transaction latency (speed), but gives a nice environment on which channels, which can offer virtually instant transactions, can be built.
The way Optimistic Rollups handle data gives the constructions some nice simplicity, especially relative to alternative layer 2 protocols. Crucially, this translates to UX for end users that could (and should!) feel nearly identical to that of using layer 1. Likewise, for developers and protocol designers, much of the tools and thought-models they are accustomed to will still be available, though as we’ll see, tackling some challenges around composability may require some additional work.
The User Perspective
From the perspective of a user, interacting with a dApp—DeFi or otherwise—on a rollup will feel nearly identical to using it were it on layer 1. Popular wallets like Metamask and the Burner wallet can be supported, as can block explorers to monitor rollup-chain activity.
The basic lifecycle of using a rolled-up dapp is as follows:
First, a user deposits some funds (“funds” could be Ether, ERC20s, ERC721s, etc.) onto a rollup chain; this first step mirrors the UX of many layer 1 dApps, in which the user must initially transfer funds into a contract before using it. At this point, a user can issue transactions on the application as they usually would; if the rollup chain is designed to prioritize censorship resistance, getting one’s transaction included doesn’t depend on any more trust, reputation, or goodwill—and doesn’t invite any more potential censorship or front-running—than publishing an L1 transaction.
When a user wants to bring their assets back to layer 1, they issue a special withdrawal transaction. Here we see a potential difference: recall that Optimistic Rollup’s security model depends on the ability for parties to issue challenges; thus, we need to allow a grace period for any parties monitoring the activity to (potentially) prove fraudulence. This means that once a withdrawal is requested, the user must wait before the funds are accessible again on layer 1; the economic security this mechanism gives is a function of both the amount of stake required to produce rollup blocks and the length of this waiting period (Ed Felten argues here that 3 hours is sufficient).
With that said, the hope/expectation is that users will rarely, if ever, have to actually wait through this grace period. Third parties can offer to purchase ownership of your pending withdrawal by sending you the equivalent value on layer 1, minus some fee, enabling you to access your funds without having to wait. Thus, as long as such liquidity providers are indeed available, and with an interface that abstracts the complexity away, even withdrawals will hit UX parity with layer 1.
📢 I’m told Offchain Labs is going to release a demo of Uniswap using rollup technology w/ MetaMask support next week! They call it Arbiswap. I expect this’ll be a bit like Unipig with some added magic. I intend to try it give my thoughts so stay tuned! – RSA
Okay, but is Optimistic Rollup really trustless? In short, yes.
Any user can use a rollup in strictly trustless fashion if they opt to, and if they don’t, their security guarantees are still strong.
To eliminate any trust-exposure, anyone (user or otherwise) can become a validator, letting them verify for themselves that nobody is trying to cheat, and prevent them from doing so if they are. This amounts to running some additional software that has to “look in” at least once every dispute period. For users not running validators, fraudulent transactions (theft of funds, say) are only possible if 100% of the validating parties are in on the crime and colluding with each other. In other words, as long as there is one honest validator out there—be it another user, an exchange, application developer, a block explorer, a wallet provider, or a pseudo-anonymous teenager in their basement—or, even if all parties are malicious, so long as they aren’t all colluding with other to collectively lie consistently, the whole rollup chain is safe from malfeasance. Once fraud is proven, the bad actors get their security deposit slashed, some portion of which is given to the fraud-provers; this incentivizes honest validation, and puts a price on trying to inconvenience other validators with deliberate dishonest actions.
The Developer Perspective
Shifting to the perspective of application creators, we happily find that much of the developer experience of building and deploying rolled-up dApps will also feel fairly familiar; developer tools and libraries like truffle, web3, and ethers.js can be reappropriated for development in the rollup context. Additionally, contracts deployed to a rollup chain can still be written in Solidity, with only a few restrictions.
The biggest difference, then, in designing and reasoning about rolled-up applications has to do with questions of composability, something particularly relevant to DeFi apps.
The Composability Challenge
One of the more celebrated—and occasionally alarming—features of DeFi applications is their ability to compose with each other, directly and permissionlessly integrating fellow financial services. This radical interconnectivity effectively comes “for free” for Ethereum contracts on layer 1, with the downside, of course, being the scaling bottleneck. As we partition activity into separate layer 2 environments, interoperability across different layer 2 chains, while not lost, becomes more of a challenge.
To steal an analogy: if layer 1 apps are housemates, apps on separate rollup chains are friends living in different houses in the same neighborhood. I.e., their living quarters are less crowded, but now, communicating and making plans isn’t as simple as meeting in their common space.
Consider the example of PoolTogether, a no-loss lottery DeFi application. PoolTogether’s contracts manage the random lottery winner selection and dispersion of funds; the funds themselves consist of interest generated by Compound, a distinct (and pre-existing) application; and the asset itself (for one of its pools) is Dai, issued by a separate contract still. This interconnectedness is all seamless with the three of them living together on layer 1.
But what if all three contracts were on separate rollup chains?
Migrating assets like DAI from one rollup to another is no hurdle, and looks very similar to moving between regular L1 contracts. Buying a PoolTogether lottery ticket, however, entails using PoolTogether to deposit assets onto Compound, which, if PoolTogether and Compound are on separate chains, isn’t possible with one simple transaction. The PoolTogether rollup needs a new strategy to access and “listen” for updates on the Compound rollup. In some other cases, we can imagine that two contracts may both want the power to talk to the other bidirectionally; or perhaps in some cases, we may only require one side to get occasional, periodic “updates” from another.
The rollup-communication toolset here is analogous to the methods for communication across Layer 1 blockchains, or across different shards in the context of a system like Eth2. In short, there are many different approaches fit for different use cases, each with their own levels of technical complexity and/or UX tradeoffs, depending on specific needs. The technical details are out of scope here, but the UX tradeoffs tend to involve things like asking users to wait longer to get their transactions confirmed and/or publishing multiple transactions to get their one desired action accomplished.
To tortuously overextend the analogy: should the friends migrate from house to house? Shout at each other out of their windows? Relay messages via some intermediate, common house? Chat directly with each other digitally (which is fast, but requires more advanced telephonic technology)?
There are many possibilities, but suffice it to say that communicating across different rollups won’t ever be as simple as chatting face to face.
Worth noting—cross-rollup communication is still easier…
Nicely enough, cross-shard and cross-rollup communication are both easier than communication across two arbitrary chains in at least one way: they have a common frame of reference—the beacon chain for ETH 2.0 and the underlying L1 for rollups.
In the alternative extreme, we can imagine a situation where we put a whole bunch of applications—all of DeFi, say, on one giant rollup chain. Here, the complications of cross-rollup interoperability vanish; Compound and PoolTogether can speak to each other on layer 2 as freely as they would on layer 1.
The only problem with this vision is it undercuts the very scalability gains we sought after to begin with. Layer 2’s scalability comes in large part from partitioning and localizing work that would otherwise have to be performed globally; a single, busy rollup becomes harder to validate, and brings us closer to the problem we sought to avoid. In other words, we don’t want to move out of one overcrowded house only to overcrowd a new one.
Perhaps, then, the ideal scenario lies somewhere in between: applications which benefit from (or require), composability with each other can choose to move in together on a common rollup chain, while communicating with other chains via the appropriate means as needed.
(Above) Apps may cluster into rollup districts based on their need to maintain for close communication ties—the same ways populations tend to cluster in regions and cities
Ultimately, a key value proposition of layer 2 is the permissionless experimentation that can take place; applications and users can opt in to local environments based on the services and interactions they anticipate they’ll need, giving them access to new features and lower fees while alleviating broader network congestion.
As far as layer 2 constructions go, Optimistic Rollups are far and away the top contender for delivering these benefits while preserving much of the core UX users have come to expect. The questions around facilitating interoperability are important considerations at this stage, as scaling solutions become usable and we approach the next phase in evolution of decentralized finance.
Daniel Goldman is a Software Engineer, researcher, and writer at Offchain Labs.
Review: what benefits can rollups bring to DeFi protocols?
Consider: do rollups give us early insight into what Eth2 sharding will be like?
Go Bankless. $12 / mo. Includes archive access, Inner Circle & Deals—(pay w/ crypto)
🙏Thanks to our sponsor: Aave Protocol
Aave protocol is a decentralized, open-source, and non-custodial money market protocol to earn interest on deposits and borrow assets. It also features access to Flash Loans, an innovative DeFi building block for developers to build self liquidations, collateral swaps, and more! Check it out here.
New to the Bankless program? Start here.
Not financial or tax advice. This newsletter is strictly educational and is not investment advice or a solicitation to buy or sell any assets or to make any financial decisions. This newsletter is not tax advice. Talk to your accountant. Do your own research.
Disclosure. From time-to-time I may add links in this newsletter to products I use. I may receive commission if you make a purchase through one of these links. I’ll always disclose when this is the case.