Matic goes to the Great Reddit Scaling Bake-Off

9 min read

The Matic team has put together a Proof-of-Concept for the Reddit Scaling Bake-Off. We think Matic is the most apt solution for the scaling requirements of Reddit, keeping in mind it’s current and future needs.

We believe that the Matic Layer 2 platform is the most complete solution out there in terms of the features and fits right in with what Reddit requires:

  • Security via Plasma predicates on Ethereum: Reliable exits to Ethereum (Proof-of-Stake based decentralized multi-operator Plasma construction which mitigates mass exit occurrence)
  • Composability (EVM Support), 
  • Extremely high scalability with each sidechain (multiple sidechains in future, hence suitable for the scale of Reddit) 
  • Ability to add custom smart contract features (via Ethereum Plasma predicates) for future product innovation

TL;DR: The Matic sidechain processed 3mn transactions over 12 hours with a total gas fees of USD 3.52 as part of the Great Reddit Scaling Bake-Off PoC.

The PoC used a few addresses only for the purpose of the demo, and the total throughput with millions of user addresses can go up to 7200 TPS per sidechain.

The PoC touches upon various aspects of the solution required – scalability that will need to meet Reddit’s requirements over time (more sub-reddits using Community Points), faster transaction times, inexpensive minting of Community Points, decentralization, accessible developer tooling, use of meta-transactions to pay for gas on behalf of users, open source code, extensibility, ability to exit back to Ethereum, if needed and more.

What is Matic?

Matic Network is a Layer 2 scaling solution for Ethereum that provides hybrid Proof-of-Stake and Plasma-enabled sidechains. We just released version 1 of our mainnet in May 2020 – https://blog.matic.network/the-matic-network-mainnet-is-now-live/.

Matic implements an account-based variant of MoreVP (More Viable Plasma), with support for custom Plasma predicates. The Plasma framework with predicates is used to guarantee the security of assets and specific smart contracts using Plasma predicates, while arbitrary smart contracts are secured by a Proof-of-Stake network, with validators staking Matic tokens on Ethereum. Matic sidechains are essentially EVM-enabled chains and are conducive to ready deployment of Solidity smart contracts, essentially making it an easy tool for Ethereum developers to use it for scaling their dApps/Protocols.

We are submitting the following:

Tradeoffs:

  • Block time on the Matic sidechain is ~2 seconds. This provides partial finality. Validators of the chain submit a state snapshot/checkpoint of the sidechain state to Ethereum every ~30 minutes. This helps in proving transaction inclusion of any transaction on the Matic sidechain on Ethereum after a period of ~30 minutes, assuming data is available.
  • Data availability is based on 2/3+1 BFT majority on the Matic Heimdall chain by validators who stake Matic tokens on the staking smart contracts on Ethereum, and are incentivized to do so. Matic can be thought of a Proof-of-Stake based multi-operator Plasma which mitigates the possible requirement of a mass exit to a great extent.
  • Do note that a mass exit is not possible as long as >2/3 of Matic validators are honest – there is a crypto-economic cost associated to violating this condition in terms of the MATIC token stake locked in Matic staking contracts that can be slashed for misbehavior. We think this is an acceptable tradeoff for Reddit.
  • Reddit will need to run a watcher node to watch transactions on the Matic sidechain on behalf of their users. We believe this is an acceptable tradeoff to have. Any one else can also run the watcher node on behalf of Reddit users including the Matic foundation, if required.
  • The withdrawal period for our Plasma MoreVP is 7 days currently. There is an issue of mass exits with the Plasma framework, but we believe increasing the withdrawal delay by way of configuration mitigates the issue to a large extent. This essentially means tokens can be withdrawn securely to Ethereum, although in the worst case, that would entail a longer time delay.

Future:

  • Multiple sidechains are planned to be implemented in the future to increase throughput. It can be the case that multiple future subreddit contracts could be deployed in different chains (partitioning deployment by subreddits) to ensure growth in Reddit transaction volume.
  • Research is in active progress to verify state transitions on sidechain with zero knowledge cryptographic approaches instead of current challenge mechanism.

We are happy to say we meet all of the Reddit challenge requirements. Here is a checklist that we have made for the challenge requirements – https://www.notion.so/maticnetwork/Reddit-bakeoff-checklist-b7a5252171ba48d49c5cc816ffd4a0c7.

Requirements from Reddit:

Scaling. This PoC should scale to the numbers below with minimal costs (both on & off-chain). There should also be a clear path to supporting hundreds of millions of users.

  • Over a 12 hour period, our scaling PoC was able to handle: 3,000,000 (3mn transactions):
    • 1,000,000 point claims (minting & distributing points)
    • 1,000,000 subscriptions and 1,000,000 burns
    • 1,000,000 transfers

This was on one sidechain. In the future, there will be multiple sidechains added.

Decentralization. Solutions should not depend on any single third-party provider. We prefer solutions that do not depend on specific entities such as Reddit or another provider, and solutions with no single point of control or failure in off-chain components, but recognize there are numerous trade-offs to consider

Data availability on the Matic sidechains are based on 2/3+1 BFT majority on the Matic Heimdall chain by validators who stake Matic tokens on the staking smart contracts on Ethereum, and are incentivized to do so. The Plasma framework with predicates is used to guarantee the security of assets and specific smart contracts using Plasma predicates – this allows trustless exit from Matic sidechains in the worst case scenario if the Matic sidechain goes down.

Usability. Scaling solutions should have a simple end user experience.

Most wallets such as PortisTorusFortmaticMetamask and others already have support for the Matic mainnet sidechain

Users shouldn’t have to maintain any extra state/proofs, regularly monitor activity, keep track of extra keys, or sign anything other than their normal transactions.

Reddit will need to run a watcher node to watch transactions on the Matic sidechain on behalf of their users. We believe this is an acceptable tradeoff to have. Any one else can also run the watcher node on behalf of Reddit users including the Matic foundation, if required.

Running a watcher node will have the following requirements as that of a sentry node – https://docs.matic.today/docs/validate/technical-requirements/.

Transactions complete in a reasonable amount of time (seconds or minutes, not hours or days)

Block time on the Matic sidechain is ~2 seconds.

Free to use for end users (no gas fees, or fixed/minimal fees that Reddit can pay on their behalf)

Very cheap transactions. The Reddit PoC consisting of 3,000,000 transactions (1mn minting, 1mn transfers, 1m subscriptions and burns) cost around ~US$ 3.5 to run. Reddit can easily pay this by using meta-transactions on behalf of users.

Bonus points: Users should be able to view their balances & transactions via a blockchain explorer-style interface

Matic has a beautiful block explorer – https://explorer.matic.network/ – and third-party explorer support is increasing as time progresses.

Exiting is fast & simple

Exiting is fast and immediate using a fast-exit liquidity mechanism in lieu of fees. Users interested in exiting to Ethereum instantly can exit via a fast-exit liquidity contract mechanism, that Reddit or other interested parties can run. You can refer https://github.com/maticnetwork/reddit-poc/blob/master/docs/withdraw.md for more details.

Here is an example of this fast-exit contract – https://github.com/maticnetwork/fast-exits.

Interoperability. Compatibility with third party apps (wallets/contracts/etc) is necessary.

Scaling solutions should be extensible and allow third parties to build on top of it

  • Account-based Plasma MoreVP implementation, with Plasma predicates support is present to enable more expressive, custom fraud proofs, if required
    • Reddit smart contracts can be modified in the future and appropriate fraud proofs via predicates can be written to ensure changes can be done later

APIs should be well documented and stable

Documentation should be clear and complete

Third-party permissionless integrations should be possible & straightforward

Simple is better. Learning an uncommon or proprietary language should not be necessary. Advanced knowledge of mathematics, cryptography, or L2 scaling should not be required. Compatibility with common utilities & toolchains is expected.

  • EVM compatible interface – web3js and other web3 library support is present
  • Standard Solidity support to enable existing smart contracts to be deployed without major rework
  • EVM compatibility results in support for all Ethereum developer and user tooling
    • Most wallets such as PortisTorusFortmaticMetamask and others already have support for the Matic mainnet sidechain
    • Most libraries readily usable on Matic
    • Compatibility with common utilities & toolchains
    • Third-party permissionless integrations
    • HSM and hardware wallet support

Security. Users have full ownership & control of their points.

Balances and transactions cannot be forged, manipulated, or blocked by Reddit or anyone else

Users should own their points and be able to get on-chain ERC20 tokens without permission from anyone else

Points should be recoverable to on-chain ERC20 tokens even if all third-parties involved go offline

  • Tokens can be withdrawn to Ethereum in case the Matic sidechain goes down by way of our Plasma MoreVP mechanism
  • The withdrawal period for our Plasma MoreVP is 7 days currently. There is an issue of mass exits with the Plasma framework, but we believe increasing the withdrawal delay by way of configuration mitigates the issue to a large extent. This essentially means tokens can be withdrawn securely to Ethereum, although in the worst case, that would entail a longer time delay.
  • Do note that a mass exit is possible only in the case when >1/3 of Matic validators behave maliciously – there is a crypto-economic cost associated to that in terms of the stake locked in Matic staking contracts. At the time of writing, >$14.5 mn worth of Matic tokens have been staked and this number is expected to only increase going forward. We think this is an acceptable tradeoff for Reddit.

A public, third-party review attesting to the soundness of the design should be available

Bonus points: Public, third-party implementation review available or in progress

  • Plasma contracts – audited by 1 third-party auditor
  • Staking contracts – audited by 2 third-party auditors
  • Heimdall and Bor – audited by 1 third-party auditor

All audit reports are available on request.

Fully open-source solutions are strongly preferred

All code is open source – https://github.com/maticnetwork

Important repos:

We are excited to see what’s in store! Boo yah 🙂


Connect with us

Website | GitHub | Twitter | Telegram | Reddit | YouTube