Celer is a layer-2 scaling platform pioneering the technology of state channel network and hybrid roll-up. Ethereum is our home and we have a proven track record to contribute to its scalability. We propose Celer’s State Channel solution as a great fit for Reddit’s Community Points because:
- It fits the ask with the right tradeoffs: Apps built using Celer have almost the exact same usage pattern like the Community Point. In addition, we believe for Reddit’s specific use cases, State Channel Network provides the right tradeoffs in a complex layer-2 space.
- It is built for and battle-tested in the production environment: these apps, such as Arcade Win, Daub Cash, Solitaire Win, Bust-A-Move RMT have close to 1 million users from 85 different countries for close to a year with no downtime for State Channel nodes in H1 2020.
- UX is priority #1: newly onboarded users are using Celer layer-2 on Ethereum with the milli-second level UI interaction response and they are happy to rate UX 4.5+ stars in App Store without feeling any “blockchain slowness”.
In the following sections, we talk about how we have already built uses cases that are almost identical to Reddit’s requirements, why we believe state channel offers the right tradeoffs for the use cases and the performance benchmarks that show 4000 transactions per second and 9ms latency with just a single state channel node with 200MB memory usage. Finally, we also discuss the concept of Layer-2 LEGO to have multiple different layer-2 techniques working together to address all current and future use cases seamlessly.
Use Cases Walkthrough
In this section, we walk through four use cases specified in the challenge: mint & distribute Community Points (CP), CP transfer, auto subscription and CP burn. For each, we discuss the user flow of how apps are doing it today and underlying technical solutions. For more general explanations of how state channels work, check out generalized state channel walkthrough article, and more technically, the specification, detailed walkthrough and our Devcon V talk .
💰Mint and Distribute Community Points
Celer supports this exact use case in CelerX gaming platform today. CelerX is a mobile eSport platform where users can pay ETH or supported ERC-20s to enter skill-based real money game tournaments and win prizes.
When a user onboards a game, he will be automatically created an Ethereum wallet. At the same time, 100 Game Token (ERC-20 used for free practice tournaments) will be minted and distributed to this user through Celer’s State Channel Network. When users use up all Game Tokens, new Game Tokens can be redeemed. Different game developers can use CelerX SDK to have different GT in their ecosystems.
How much is it actually used today in production? Our active users perform about 30K Game Token mint&distribute per day and we are comfortably handling 150K such operations in the 5 day period mentioned by Reddit team. However, this is far from the actual limit of the software. Performance benchmarks are in the next section.
It is straightforward to swap the “Game Token” to “Community Point” and different “game developers” to “subreddits” in the above description. It’s frictionless for users and indeed, 90% of our users do not even realize that they are using blockchain and only think we use an interesting way to back up their accounts (use iCloud or write down 12 words somewhere).
Next, we dig deeper into some specific aspects of the solution in an FAQ style.
Isn’t the case that a user has to have on-chain ETH to open a channel for Community Points? Not really. Celer’s state channel network has a built-in functionality called promised channel open. This gives the possibility to have a mutually signed commitment between Off-chain Service Providers and users (Reddit or subreddit owners) to act as a promise to mint and distribute a certain amount of tokens to a user’s channel on layer-1. Therefore, it acts as a token mint in layer-2.
Does this mean that users have to store additional states or may lose their Community Points? Luckily no. Users and service providers (e.g. Reddit or subreddit owners) can store their states in State Guardian Network (SGN) by paying a fee. State Guardian Network is a decentralized watchtower solution that solves many of the state availability issues in traditional simple payment networks such as Lightning and Raiden.
If a user is offline, will his CPs be exposed to attacks? Nope again. This is what SGN is built for so that even when the user is offline, a decentralized SGN looks out for the user’s state. Other layer-2 solutions like Plasma or Rollups also have to have similar “watchtower” to monitor layer-2 state commits and transactions on users’ behalf and the involved cost in the worst-case malicious scenario is very similar.
In the state channel networks, users need to connect to some channel nodes in the network. So who acts as a user’s counterparty node? This will be the subreddit owner or Reddit itself in the beginning. This offers great horizontal scalability: each subreddit can host a cluster of state channel nodes in an independently scalable fashion with strong user proximity and connect to other subreddits in the channel network if common community points can be used cross certain subreddits.
💰Mint and Distribute Community Points
P2P token transfer is really the bread and butter of the state channel network. To show a use case that is in production: when two users in CelerX platform enter a 1v1 match between each other, what happens underlying is that they send a layer-2 boolean conditional payment to each other conditionally depending on the result of the game. This condition will resolve to true or false and the corresponding layer-2 payment will be established or canceled automatically off-chain after the result of the game is determined off-chain. The conditional payment is a particularly powerful construct of generalized state channel network and we will discuss more in the subscription use case. Simple CP transfer completes across the network with 1.5 Round Trip Time (RTT) end-to-end network latency in the order of milliseconds.
Does the recipient need to be online to receive the payment? Not necessary. Celer’s state channel network has the unique capability to set Delegated Recipients to receive payment when a user is offline. The delegated recipients, in this case, can trivially be the subreddit hosts or Reddit itself in the very beginning. It is also important to note that Delegated Recipients can only sign state proof on users’ behalf and cannot actually withdraw the fund from the channel on-chain. In addition, to ensure that there is no possibility to have any state availability attack, the sender’s protocol ensures that the delegate put these mutually signed states to SGN so that when a user comes back online, he can retrieve the most recent state.
How much is it used today in production? We are processing about 80K game payments in Game Token per day. Same as before, this is far from the system limit. Benchmarks will be discussed later.
🔥Community Points Burn
Community Points Burn is also a use case that we already implemented in production. In games built using Celer, there is a concept of Loyalty Point (ERC-20, like Game Token). Users receive Loyalty Points by competing in tournaments. Users can also use loyalty points to redeem items of real value (like Celer T-shirt). This redeeming process is precisely the token burn use case required by Reddit.
This is implemented by simply sending the token back to the layer-2 minter. In our case, it is sent back to the game developers’ Celer nodes and in the case of Reddit, it will be sent back to the subreddit owners’ nodes.
But wait, how is the token burnt if it is sent back to the minter on layer-2? In other words, would it be possible for a minter to just withdraw these tokens on-chain and send it to whoever he likes? Rest Assured. For the case of minted Community Points, the minter can act as counterparty to send out and relay points transfers, however, he is just a delegate recipient (see above discussion) of a token minting pool address. The best he can try on-chain is to withdraw the token back to the pool but cannot actually get a hold of token on-chain.
📅 Subscription Auto Payment
This is not yet live in production, but we actually have a feature coming up that uses the exact same usage pattern. To implement this use case, we use a powerful primitive of generalized state channel called Conditional Payment. To explain what a conditional payment is, let’s look at an example. When Alice sends a conditional payment with X CP to a subreddit CP minter the X CP won’t be immediately burnt but is in a “committed” state with a conditional dependency that will be resolved later. The condition can be literally anything that you can verify and get result on-chain, for example, subscription states of this subreddit and the timestamp. The final amount that Alice burnt can fall in the range between 0 to X and is determined by evaluating the outcome of the conditional dependency using any arbitrary function. In this very concrete use case, Alice can send a relatively large amount of CP as conditional payment and the resolution of the conditional payment will automatically update as the time passes by. Note that this process does not need to have any other layer-1 or layer-2 interaction so that is purely automatic.
Sending a payment that conditionally depends on the outcome of an on-chain verifiable state (off-chain or on-chain) is equivalent to sending funds to a smart contract application in layer-1 and this is one of the key differences between Celer generalized state channel solution and other simple payment channel network solutions.
Why State Channel Network Provides the Right Tradeoffs for Reddit’s Use Cases?
With so many different great layer-2 solutions, identifying a fitting solution is about identifying the right tradeoff for the specific use cases. Celer as a platform contains different techniques like State Channel Network and Hybrid Rollup to cover the entire layer-2 tradeoff space. We previously discussed different solutions’ tradeoffs. After applying these general principles to this specific case, we choose to not go to the Celer rollup solution and believe that Celer’s State Channel offer is the best fit.
Reddit’s use cases primarily concern token movement-related operations with certain flexibility requirements and it seems from the current requirements, things like “Defi + complicated yield mining based on Community Token” are not in the scope yet. Even when more complex use cases do come into the picture, it is still helpful to have a highly performant, low-cost, and flexible enough token operation core.
In this section, we take a first-principle approach to analyze the asymptotic fundamentals instead of fixated on a galaxy of possible system-level optimizations. We believe State Channel Network offers the following fundamental advantages comparing to other layer-2 scaling techniques for Reddit’s specific use cases.
⚡️Web 2.0-like interactiveness via 100X lower latency
Real-time and interactive UX is not optional in today’s consumer application world. Today’s Internet applications optimize latency to the level of milliseconds with well-studied results such as every additional 100ms latency on page load can drop Amazon sales by 1%.
When Community Token is widely used, we would imagine it is on a lot of users’ critical interaction paths. However, layer-2 techniques such as Plasma, zk Rollup, and Optimistic Rollup (collectively commit chains), though good for throughput (high TPS), fail when tested against this latency requirement. Let’s have a break down for commit chains’ thick latency profile:
- Internet latency to send out transactions to gateway/block producer. This is in the milliseconds.
- The latency for block producer to pack up a block with a batch of transactions. This is often in the seconds if not tens of seconds to control the layer-1 cost. However, for zk-Rollup this seems to be significantly longer due to proof computing.
- The latency for the layer-1 blockchain to confirm the rollup block. This is in the tens of seconds if not minutes.
- For non-zk rollups and Plasma, the actual finality latency (one can be sure that a transaction actually happened) is on the scale of hours to days.
Even not accounting for the finality latency, that is if a client is “heavy” enough to store, compute and verify the additional state transitions themselves (which breaks the challenge’s requirements), the latency for a transaction to reach layer-1-level security is in the tens of seconds and easily minutes under layer-1 congestion.
State Channel Network, however, offers two orders of magnitudes lower latency and gives users smoothest experience. The underlying reason for that is the so-called “instant finality”. When a user sends out a transaction in State Channel Network, all latency involved is a 1.5–3 Round Trip Time (worst-case in hundreds of milliseconds) to the counterparty to receive the mutually signed and updated state proof. Once this proof is obtained, this transaction is “final” as in there is no possibility to revert or reorg this transaction. We want to highlight that this is not a system engineering difference, but an asymptotic advantage for State Channel solutions.
💪Simple horizontal throughput scalability with maximal decentralization
In terms of throughput requirements, Celer’s State Channel also offers fundamental advantages. The key difference here is that State Channel Network offers a simple scale-out solution for the Reddit Community Point use cases. To add more subreddits supporting community tokens and therefore more users, it is as simple as spinning-up new Celer State Channel nodes. Each node will serve users in the “proximity” and cross different subreddits if tokens can be shared, they can be connected simply via some “backbone” links as a single and interoperable network. This offers close to linear scaling-out capacity as the number of users grows. There will be no layer-2 or layer-1 congestion.
On the contrary, all layer-2 commit chain approaches (e.g. Plasma, zk Rollup, and Optimistic Rollup) rely on a logical singleton to order transaction, compute state transition and finally batch succinct transaction summaries (proof or state root+calldata) to the layer-1 blockchain. This means that as more and more users onboard the logical singleton, there will be even congestion on layer-2 let alone the inherent congestion on layer-1. To alleviate such congestion, a simple approach is to split one commit chain into multiple commit chains in the fashion similar to layer-1 sharding. However, cross-chain communication will then pose a significant challenge with much more complicated interaction beyond the acceptable requirement of the use case.
💵 Lower transaction cost
State Channel also offers fundamentally lower transaction cost comparing to other layer-2 scaling solutions.
First, on the storage side, the amount of storage required in State Channel system is linear to the number of users in the system and has nothing to do with the number of transactions or interactions. In addition, there is no layer-1 storage required during the transaction process (send CP and burn CP). This is because state channel nodes and SGN only need to store the latest state for each node instead of the full transaction history. On the contrary, the commit-chain approaches require storage capacity to scale up with the number of transactions. What’s worse, even when transactions are happening purely in layer-2, layer-1 storage resources are also consumed to store the validity proof or state root.
Second, on the compute side, state channel requires less compute resources for off-chain transactions due to the fact that no state update needs to be computed or checked by a duplicated set of parties or waiting for any blocks. State updates are only computed and agreed upon between counterparties.
📝Flexible conditional payment primitive
State Channel like any other layer-2 technique, does not cover the full spectrum of tradeoff plane. The biggest tradeoff is that it is trading off performance and cost with the supported application patterns. If it is a use case such as minting and transferring NFT tokens (e.g. CryptoKitty)where the involved users concurrently interacting in a session is arbitrary and changing at any given time with arbitrarily unique assets, State Channel is not the best solution.
However, we do believe with Reddit’s specific use cases concentrating on token management and transfer, State Channel Network is a great fit with enough flexibility to go beyond just simple token transfers. Celer’s generalized state channel differs from simple payment channel networks (such as Raiden and Lightning) in the sense that it supports conditional payment to implement much more flexible functionalities and logics such as auto subscription with an underlying generalized payment network.
Celer Network’s node software is highly optimized and production-grade: it requires less than 10MB minimal memory and can support 1,000 clients on one t2.micro instance with 1CPU, 1G memory. The node software is also hyper scalable with support of multi-node clustering via solutions like k8s and parallel database backend via solutions like Cockroach DB.
All of the use cases mentioned in Reddit Bakeoff essentially can reduce to token transfer operations. So we focus our test on this specific benchmark. As we discussed previously Celer’s state channel can scale horizontally, we use a single-node setup with a single database backend instance for the ease of reproducing the benchmarking results through our end-to-end test.
As shown in the performance benchmark demo, with this setup, Celer Node can achieve 4177 transactions per second and an average transaction latency of 9ms with a peak memory usage of less than 200MB. We want to note that our node software has the capability to extend a single node to a decentralized cluster of nodes plus a parallel database access backend. Celer Node software can achieve more than 30,000 transactions per second with 11ms latency per transaction on a single logical node built by a 9-server cluster.
In terms of transaction cost, the only protocol cost is on storing user’s state to State Guardian Network. Each user’s state proof is around 200Bytes no matter how many transactions a user sends as the state constantly gets updated to the newest state instead of appending new states. Therefore, it is just a subscription model for a storage slot on the State Guardian Network. The pricing of state storage is dynamic and as of the initial launch of the SGN, the price to store states for 100K users for one full year is around $0.7.
Final Notes on the “Layer-2 LEGO”
Layer-2 is a complex space but it is also a composable one. We believe the best solution is not to choose any single layer-2 scaling technique but compose multiple techniques together as a wholistic solution. Analyzing the Reddit team’s requirements, we believe a combination of solutions working together might offer the best tradeoff for all current and future envisioned use cases. We provide an interesting thought experiment on how to compose different techniques together.
State Channel has the capability to not only run on layer-1 blockchains but also run on layer-2 commit chains like optimistic rollups. Therefore, we can imagine a system where the entire “on-chain” operations (e.g. exit of state channel and actual instantiation of channels) are all based on layer-2 smart contracts on optimistic rollup chains. This gives the flexibility to build very complex use cases like Community Token liquidity pool on rollups. At the same time, when it comes to real-time interaction, token distribution and token transfer, state channel network operating on top of a layer-2 rollup chain will take the load and give end-users the smoothest user experience possible.
We believe this is the most exciting future for Layer-2 scaling on Ethereum.
Questions and Discussions?
We have set up a dedicated email address to receive questions related to the Reddit Bakeoff: firstname.lastname@example.org
We also invite the community to ask questions in the following channels to get the fastest technical responses: