<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Plasma Group Blog - Medium]]></title>
        <description><![CDATA[Plasma research and development - Medium]]></description>
        <link>https://medium.com/plasma-group?source=rss----cf16016e9fa8---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Plasma Group Blog - Medium</title>
            <link>https://medium.com/plasma-group?source=rss----cf16016e9fa8---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 14:56:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/plasma-group" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Ethereum Smart Contracts in L2: Optimistic Rollup]]></title>
            <link>https://medium.com/plasma-group/ethereum-smart-contracts-in-l2-optimistic-rollup-2c1cef2ec537?source=rss----cf16016e9fa8---4</link>
            <guid isPermaLink="false">https://medium.com/p/2c1cef2ec537</guid>
            <category><![CDATA[plasma]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[rollup]]></category>
            <category><![CDATA[layer-2]]></category>
            <dc:creator><![CDATA[Karl Floersch]]></dc:creator>
            <pubDate>Fri, 06 Mar 2020 15:54:16 GMT</pubDate>
            <atom:updated>2019-11-02T00:23:22.309Z</atom:updated>
            <content:encoded><![CDATA[<p>This post outlines optimistic rollup: a construction which enables autonomous smart contracts on layer 2 (L2) using the <a href="https://medium.com/plasma-group/introducing-the-ovm-db253287af50">OVM</a>. The construction borrows heavily from both plasma and zkRollup designs, and builds on <a href="https://blog.ethereum.org/2014/09/17/scalability-part-1-building-top/">shadow chains</a> as described by Vitalik. <strong>This construction resembles plasma but trades off some scalability to enable running fully general (eg. Solidity) smart contracts in layer 2, secured by layer 1.</strong> Scalability is proportional to the bandwidth of data availability oracles which include Eth1, Eth2, or even <a href="https://ethresear.ch/t/bitcoin-cash-a-short-term-data-availability-layer-for-ethereum/5735">Bitcoin Cash or ETC</a> — providing a near term scalable EVM-like chain in layer 2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*qk6yWTozTxMfZXZILtvpAQ.png" /></figure><h3>Quick Overview</h3><p>Let’s start with some intuitions for how optimistic rollup works end to end on mainnet Ethereum, then dive in deep.</p><p>The following is a chronicle of the life of an optimistic rollup smart contract… named Fred:</p><ol><li>Developer writes a Solidity contract named Fred. Hello Fred!</li><li>Developer sends transaction off-chain to a bonded <strong>aggregator</strong> (a layer 2 block producer) which deploys the contract.<br> — Anyone with a bond may become an aggregator.<br> — There are multiple aggregators on the same chain.<br> — Fees are paid however the aggregator wants (account abstraction / meta transactions).<br> — Developer gets an instant guarantee that the transaction will be included or else the aggregator loses their bond.</li><li>Aggregator locally applies the transaction &amp; computes the new state root.</li><li>Aggregator submits an Ethereum transaction (paying gas) which contains the transaction &amp; state root (an optimistic rollup block).</li><li>If <strong>anyone</strong> downloads the block &amp; finds that it is invalid, they may prove the invalidity with verify_state_transition(prev_state, block, witness) which:<br> — Slashes the malicious aggregator &amp; any aggregator who built on top of the invalid block.<br> — Rewards the prover with a portion of the aggregator’s bond.</li><li>Fred the smart contract is safe, happy &amp; secure knowing her deployment transaction is now a part of every valid future optimistic rollup state. Plus Fred can be sent mainnet ERC20’s deposited into L2! Yay!</li></ol><p>That’s it! The behavior of users &amp; smart contracts should be very similar to what we see today on Ethereum mainnet, except, it scales! Now let’s explore how this whole thing is possible.</p><h3>Optimistic Rollup In Depth</h3><p>To begin let’s define what it means to create a permissionless smart contract platform like Ethereum. There are three properties we must satisfy to build one of these lovely state machines:</p><ol><li><strong>Available head state</strong> — Any relevant party can download the current head state.</li><li><strong>Valid head state </strong>— The head state is valid (eg. no invalid state transitions).</li><li><strong>Live head state</strong> — Any interested party can submit transactions which transition the head state.</li></ol><p>You’ll notice that Ethereum layer 1 satisfies these three properties because we believe 1) miners do not mine on unavailable blocks, 2) miners do not mine on invalid blocks<a href="https://eprint.iacr.org/2015/702.pdf">*</a>; and 3) not all miners will censor transactions. However, it doesn’t currently scale.</p><p>On the other hand, under some similar security assumptions, optimistic rollup can provide all three guarantees at scale. To understand the construction &amp; security assumptions we’ll go over each property we’d like to ensure individually.</p><h3>#1: Available head state</h3><p>Optimistic rollup uses classic rollup techniques (<a href="https://ethresear.ch/t/on-chain-scaling-to-potentially-500-tx-sec-through-mass-tx-validation/3477">outlined here</a>) to ensure data availability of the current state. The technique is simple — block producers (called aggregators) pass all blocks which include transactions &amp; state roots through calldata (ie. the input to an Ethereum function) on Ethereum mainnet. The calldata block is then merklized &amp; a single 32 byte state root is stored. For reference, calldata is 2,000 gas per 32 bytes while storage is 20,000 gas. Additionally, the gas cost of calldata will be reduced by almost 5x in the <a href="https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1679.md">Istanbul hard fork</a>.</p><p>Notably, we can use data availability oracles other than the Ethereum mainnet including <a href="https://ethresear.ch/t/bitcoin-cash-a-short-term-data-availability-layer-for-ethereum/5735">Bitcoin Cash</a> and Eth2. With Eth2 phase 1 all shards can serve as data availability oracles, scaling TPS linearly in the number of shards. This is enough throughput that we will hit other scalability bottlenecks before we run out of available data, for example state computation.</p><h4>Security Assumptions</h4><p>Here we assume honest majority on Ethereum mainnet. In addition, if we use Eth2, ETC, or Bitcoin Cash, we similarly inherit their honest majority assumptions.</p><blockquote>Under these assumptions, using a trusted availability oracle to publish all transactions we can ensure that anyone can compute the current head state, satisfying property #1.</blockquote><h3>#2: Valid head state</h3><p>The next property we need to ensure is a valid head state. In zkRollup we use zero-knowledge proofs to ensure validity. While this is a great solution in the long term, for now it is not possible to create efficient zkProofs for arbitrary state transitions. However, there’s still hope for a general purpose EVM-style state machine! We can use a cryptoeconomic validity game similar to plasma / truebit.</p><h4>Cryptoeconomic Validity Game</h4><p>At a high level the block submission &amp; validity game is as follows:</p><ol><li>Aggregators post a security deposit to start producing blocks.</li><li>Each block contains [<a href="https://github.com/ethereum/wiki/wiki/Sharding-FAQ#can-we-force-more-of-the-state-to-be-held-user-side-so-that-transactions-can-be-validated-without-requiring-validators-to-hold-all-state-data">access_list</a>, transactions, post_state_root].</li><li>All blocks are committed to a ROLLUP_CHAIN contract by a bonded aggregator on a first come first serve basis (or round robin if desired).</li><li><strong>Anyone</strong> may prove a block invalid, <strong>winning a portion of the aggregator’s security deposit</strong>.</li></ol><p>To prove a block invalid you must prove one of the three following properties:</p><pre>1. INVALID_BLOCK: The committed block is *invalid*. <br>   This is calculated with `is_valid_transition(prev_state, block, witness) =&gt; boolean`<br>2. SKIPPED_VALID_BLOCK: The committed block &quot;skipped&quot; a valid block.<br>3. INVALID_PARENT: The committed block&#39;s parent is invalid.</pre><p>These three state transition validity conditions can be visualized as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cv_RR7vxY0BW89QKr7mRsA.png" /></figure><p>There are a few interesting properties that fall out of this state validity game:</p><ol><li><strong>Pluggable validity checkers</strong>: We can define different validity checkers for is_valid_transition(…) allowing us to use different VMs to run smart contracts including EVM and WASM.</li><li><strong>Only one valid chain</strong>: Blocks are submitted to Ethereum which gives us a total ordering of transactions &amp; blocks. This enables us to deterministically decide the “head” block, and thereby require aggregators to prune invalid blocks before submitting a new block.</li><li><strong>Sharded validation</strong>: This validity game can be played out at an individual UTXO basis. Instead of invalidating full blocks, we partially invalidate them — similar to Plasma Cash. Note that this <strong>does not</strong> require proving all invalid transitions up front for a single block. Partial block invalidation means we can validate only UTXOs for contracts we care about to secure our state. To learn more about how UTXOs enable parallelism <a href="https://www.youtube.com/watch?v=-xoCoZGJ9AQ">check out this Cryptoeconomics.study video</a>!</li></ol><h4>A Note on Watchtowers</h4><p>One challenge to adoption of L2 has been the added complexity of <a href="https://blockonomi.com/watchtowers-bitcoin-lightning-network/">watchtowers</a>. Users contracting watchtowers adds yet another entity to manage to an already complex system. Thankfully, watchtowers are naturally incentivized by the optimistic rollup cryptoeconomic validity game! All data is available &amp; therefore anyone running a full node stands to gain the security bond of <strong>all</strong> aggregators who build on their invalid chain. This risk incentivizes aggregators to be watchtowers, validating the chain they are building on — mitigating the verifiers dilemma.</p><h4>A Note on Plasma</h4><p>Many plasma constructions also rely on cryptoeconomic validity games; however, in plasma autonomous smart contract state enforcement is impossible without zkProofs or a <a href="https://github.com/ethereum/research/wiki/A-note-on-data-availability-and-erasure-coding#what-is-the-data-availability-problem">fisherman’s game</a> during a data withholding attack (the data availability problem). Thankfully rollup gets around the data availability problem by posting the minimal information needed to compute state transitions on-chain. Still, plasma is critical if we want to scale up to transactions per second in the hundreds of thousands (and more) — a long term necessity but not a requirement in the medium term for many smart contracts.</p><h4>Security Assumptions</h4><ol><li>This cryptoeconomic validity game works with <strong>a single honest or even rational verifier</strong> assumption. We can say it is a “rational” verifier as opposed to “honest” because they may be economically incentivized with challenge games.</li><li>Additionally we assume the mainnet is <strong>live</strong>, meaning it is not censoring all incoming transactions attempting to prove invalidity. Note that the aggregator unbonding period is in some sense the liveness assumption on the mainnet (eg. if we require a 1 month unbonding period, then invalidity must be proven within that month to forfeit that bond).</li></ol><blockquote>Under these assumptions, all invalid blocks / state transitions will be discarded leaving us with a *single* valid head state, satisfying property #2.</blockquote><h3>#3: Live Head State</h3><p>The final property we must satisfy is liveness, often known as censorship resistance. The key insights which ensures this are:</p><ol><li>Anyone with a bond size above MINIMUM_BOND_SIZE may become an aggregator for the same rollup chain.</li><li>Because honest aggregators may prune invalid blocks, the chain <strong>does not halt</strong> in the event of an invalid block.</li></ol><p>With these two properties we’ve already got liveness! Honest aggregators may always submit blocks which fork around invalid blocks &amp; so even if there’s just one non-censoring aggregator your transaction will eventually get through — similar to mainnet.</p><h4>A Note on Liveness vs Instant Confirmations</h4><p>One property we really want is instant confirmations. This way we can give users sub-second feedback that their transaction will be processed. We can achieve this by designating short-lived aggregator monopolies on blocks. The downside is that it trades off censorship resistance because now a single party can censor for some period of time. Would love to hear about any research on this tradeoff!</p><h4>Security Assumptions</h4><p>With two security assumptions we get liveness:</p><ol><li>There exists a non-censoring aggregator.</li><li>Mainnet Ethereum is not censoring.</li></ol><blockquote>Under these assumptions, the optimistic rollup chain will be able to progress &amp; mutate the head state based on any valid user transactions, satisfying property #3.</blockquote><blockquote>Now all three properties are satisfied &amp; we’ve got a permissionless smart contract platform in Ethereum L2!</blockquote><h3>Scalability Metrics</h3><p>The following estimates are <strong>purely based on data availability</strong>. In practice other bottlenecks could be hit, one being state calculation. However, this does provide a useful upper bound.</p><h4><strong>ERC20 Transfers with ETH1 Data availability</strong></h4><p>Calculations are based on <a href="https://gist.github.com/karlfloersch/1bf6ab7871f41e3a5a921c0a007ad5c6">this little call-data calculation python script</a>.</p><p>Note that these ERC20 transfers are calldata optimized. Additionally note that the nice thing about Optimistic Rollup is we aren’t limited to ERC20 transfers!</p><p><strong>ECDSA Signature</strong><br>~100 TPS without EIP 2028<br>~450 TPS with EIP 2028 (coming in October 2019)</p><p><strong>BLS Signature / SNARK-ed Signatures</strong><br>~400 TPS without EIP 2028<br>~2000 TPS with EIP 2028 (coming in October 2019)</p><h4>With external availability oracles (eg. ETH2, Bitcoin Cash)</h4><p><strong><em>~linear in relation to the amount of throughput the availability oracle can handle.</em></strong></p><p><em>That’s a lot more than 2000 TPS!</em></p><h3>Optimistic Rollup vs Plasma</h3><p>Optimistic Rollup shares much in common with Plasma. Both use aggregators to commit to blocks on mainnet with a cryptoeconomic validity game ensuring safety. The sole divergence is whether or not we have an availability receipt ensuring block availability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XM9jBBbYE20kFC7PIngipA.png" /></figure><p>The similarities between the two solutions allows for lots of shared infrastructure &amp; code between the two constructions. In a mature layer 2 ecosystem it’s likely that we will see rollup, plasma, and state channels all working together in the same client (a smart wallet). Oh, have I mentioned the <a href="https://medium.com/plasma-group/introducing-the-ovm-db253287af50">OVM</a>? 😁</p><h3>Yay Optimistic Rollup 🎉</h3><p>Optimistic Rollup occupies a nice niche in the space of layer 2 constructions. It trades off some scalability for general purpose smart contracts, simplicity, &amp; security. Plus being able to run secure smart contracts means that it can even be used to adjudicate other layer 2 solutions like plasma and state channels!</p><blockquote>Call it “the layer 1 of layer 2s.”</blockquote><p>Anyway, enough research — time to implement a robust, comprehensive, and user friendly Ethereum layer 2! 😍</p><p><em>Special thanks to Vitalik Buterin for working through these ideas with me and for coming up with much of this.</em></p><p><em>Additionally, thank you Ben Jones for much of this and Jinglan Wang, Kevin Ho &amp; Jesse Walden for edits.</em></p><p><strong>Update</strong>: Shout out to the great and related work by John Adler in his article on Merged Consensus which can be compared to optimistic rollups — Check it out <a href="https://ethresear.ch/t/minimal-viable-merged-consensus/5617">here</a>! Plus <a href="https://ethresear.ch/t/multi-threaded-data-availability-on-eth-1/5899">this proposal</a> to improve Eth1’s ability to act as a data availability oracle — more tps!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c1cef2ec537" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plasma-group/ethereum-smart-contracts-in-l2-optimistic-rollup-2c1cef2ec537">Ethereum Smart Contracts in L2: Optimistic Rollup</a> was originally published in <a href="https://medium.com/plasma-group">Plasma Group Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[On To New Beginnings]]></title>
            <link>https://medium.com/plasma-group/on-to-new-beginnings-e9d76b170752?source=rss----cf16016e9fa8---4</link>
            <guid isPermaLink="false">https://medium.com/p/e9d76b170752</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Optimism]]></dc:creator>
            <pubDate>Thu, 09 Jan 2020 22:54:32 GMT</pubDate>
            <atom:updated>2020-01-09T23:08:22.304Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xrNcPprHo3nIWlC9VFzoVA.png" /></figure><p>Happy new year, all! This week marks the first anniversary of Plasma Group. It will also be the last. We will continue performing the highest leverage actions for the community that we can. This means we will be evolving.</p><p>We see Ethereum entering a new chapter, and we’re so proud to have been able to contribute to that progress. A year ago, scalability research felt like the most pressing need to us, so we threw everything we had into accelerating it. It is amazing to see the multitude of competent teams pushing production plasma into reality now. This shift from research to implementation means that our mission as a research organization must shift as well.</p><p>Scalability is still a priority — but another critical issue has become clear to us: <strong>the problem of funding and sustaining public goods</strong>. As we solidify our vision for our next steps, this issue weighs heavily on our minds. It played a large role in our year as a nonprofit releasing un-monetized content to the public domain.</p><p>For now, a concrete step we can take toward this goal is to re-seed our remaining runway. We will be donating the entirety of what we have left to Gitcoin. We believe Gitcoin is doing some of the most critical and underrated work not only in the blockchain space but also in the greater space of public goods.</p><p>Finally, we’d like to present to you our final research contribution as Plasma Group, reflect on a year of scalability progress, and share our outlook for the future.</p><p><strong>Optimistic Game Semantics</strong></p><p>Before we go, we have one last research contribution to pass on. This time, we are sharing our work on Optimistic Game Semantics, formerly known as the Optimistic Virtual Machine — a set of conceptual underpinnings which motivates the possibility of a single piece of software that can run many L2 constructions under a single, unified theory. For us, this represents a “culmination of generalizations” — from the dozens of plasma flavors to composable L2s, Optimistic Game Semantics shows how one day, all L2 constructions might build on the same foundation. In other words, even when the flavors vary, the ingredients are shared.</p><p>You can find the paper <a href="https://plasma.group/optimistic-game-semantics.pdf">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R2m5JT47_A9yzevbo0mang.png" /></figure><h3><strong>An Eventful Year…</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FnYbPt33gtwbU-hd" /></figure><p>The path was not always straight — not without the occasional red herring — but every misstep makes the way forward clearer, and overall we are thrilled with the progress that L2 has seen in the past year.</p><p>Some of Plasma Group’s own finest moments included:</p><ul><li>Creating the first ever <a href="https://medium.com/plasma-group/plasma-spec-9d98d0f2fccf">Plasma Cashflow</a> implementation</li><li>Opening the door for applications on plasma with our <a href="https://medium.com/plasma-group/towards-a-general-purpose-plasma-f1cc4d49c1f4?source=collection_home---6------4-----------------------">generalized plasma spec</a></li><li>Organizing the premier <a href="https://www.scalingethereum.org/">Scaling Ethereum</a> conference from which many research breakthroughs emerged for lots of teams</li><li>Coining Optimistic Rollup and demonstrating the viability of fully fledged smart contracts on L2 with our<a href="https://unipig.exchange/"> Unipig</a> demo</li></ul><h4><strong>The Future: Public Goods</strong></h4><p>After a year of progress, we are incredibly optimistic about the future of scalability. The biggest trend we see today is a shift towards implementation. Many hard problems have been solved, and viable, production-ready implementations are finally on the rise. Across the ecosystem, the efforts are too many to count.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*MJvmumemM7Dm1DSHx-BiDg.png" /><figcaption>Sleepy Kelvin</figcaption></figure><p>We’re eager to get to work on the next urgent problem facing the community we love. We still have a lot that we need to figure out! But we’re not done working for this community, so stay tuned — you’ll be hearing from us again very soon. It’s certainly not a problem we’ll be sleeping on.</p><p>Thank you all for a tremendous year.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a1p-BJq1Y1vwEPKC" /><figcaption>Xuanji Li, Alex Attar, Ben Jones, and Eva Beylin hacking away at ETH New York</figcaption></figure><p>Importantly, none of this was done in a vacuum! We have many people to thank and recognize for their contributions to both our work and the general L2 effort:</p><h3>Donors</h3><p><strong>Ethereum Foundation<br></strong>The EF has and continues to do incredible work for the ecosystem. They are a backbone of one of the greatest communities ever. We have benefited greatly from the resources that the EF has provided to us — the leadership of Aya, experienced words of wisdom from Albert, and the many brilliant folk who work at the EF whom we have had the opportunity to learn from.</p><p><a href="https://omisego.co/"><strong>OmiseGO</strong></a><strong><br></strong>OmiseGO was among our earliest supporters, and without them we wouldn’t have had the start that we did — not just their financial and moral support for Plasma Group, but also the groundwork they laid in manifesting and memeing plasma and their continued conviction in moving it forward. Audits on the first version of the OMG Plasma Framework, which took inspiration from Plasma Group’s [work on predicates], are nearly finished. It’s exciting to see our work being used in the wild, and it’s also a testament to OmiseGO’s commitment to the kind of cross-pollination that makes this space so special.</p><p><strong>Pandia Jiang, Founder — EDCON, Linktime, Unitimes<br></strong>Pandia was our very first donor. She has been a pillar in the global Ethereum community and a valuable resource to us — from making introductions to advising us on managing dynamics in a distributed team. We have benefited greatly from the community work she has done across borders and it was her faith in us that bootstrapped the team and propelled us into our very first testnet release of Plasma Cashflow. She has been a tireless advocate of decentralization and a great inspiration to our own mission.</p><p><a href="https://consensys.net/"><strong>Consensys</strong></a><strong><br></strong>As a fellow NYC based company, Consensys have been unbelievably supportive, warm and welcoming. They’ve lent us space, dev time, and constant encouragement. That a company could grow to such a scale without ever straying from the philosophy that contributing to the success of the whole doesn’t negate the success of the individual is really extraordinary.</p><p>Consensys has done so much legwork to bringing visibility and talent into ethereum and we thank them for that.</p><p><a href="https://gitcoin.co/"><strong>Gitcoin</strong></a><strong><br></strong>Gitcoin’s CLR grant rounds brought many people together to support Plasma Group and lots of other worthy projects. Those donations helped keep us going, but it’s not just the money: it’s a sense of community and a show of support. The validation that we received from seeing so many members of the community contribute was just as valuable as the money they gave. As leaders in exploring and executing novel strategies for sustainably funding public goods, we believe Gitcoin is doing critical work for the community that <em>every single person</em> benefits from.</p><p><a href="https://matic.network/"><strong>Matic</strong></a><strong><br></strong>Besides being our biggest CLR donor, Matic has been incredibly supportive of our work on predicates. They helped spread the word about our <a href="https://medium.com/matic-network/plasma-predicates-one-step-towards-generalized-plasma-b9b2aa458b4f">predicates framework </a>and included it in an implementation of their own. We’re so grateful for their contribution to the L2 scalability effort through their word on sidechains, and proud to have worked alongside such a fantastic team for the past year.</p><p><strong>Status<br></strong><a href="https://statusnetwork.com/">Status</a> was another one of our earliest backers. The support of a project that so embodies the open source ethos means a great deal to us. Status has never wavered from their commitment to individual sovereignty, freedom of expression, and open infrastructure. These values and the tools that put them into practice are exactly what we work so hard to build strong foundations for.</p><h3>Collaborators &amp; Contributors</h3><p><strong>Uniswap<br></strong>We’ve always loved the Uniswap team and their incredible style. It was a blast to collaborate with them on UniPig. We are so proud of our friends for the work they’ve done and the ethos they embody.</p><p><strong>Whiteblock<br></strong>We were fortunate enough to contract Whiteblock’s unbeatable team of fantastic engineers. Their incredible responsiveness and lightning grasp of the architecture earns a big gold star from us. We highly recommend Whiteblock to any blockchain team that wants access to some big brains.</p><p><strong>Abbey Titcomb<br></strong>Between gigs at a VC firm and Radicle, Abbey crushed heaps of research with us. Nobody throws a more powerful punch than Abbey. We miss having her firepower close to us, but we are all so lucky to have her as part of the community.</p><p><strong>Alex Attar<br></strong>We first got the opportunity to work with Alex at ETH Denver where he blasted through contracts for the first Generalized Plasma implementation with us. He has been an incredible friend to all of us, and we can only hope to match the level of support he has shown.</p><p><strong>Cryptoeconomics Lab<br></strong>Whether it’s the pure dev firepower of Syuhei, or Yuriko’s clean research and writing, we’ve been impressed time and time again by the brilliance of the members CEL team. We have thoroughly enjoyed working with them to hone our understanding of plasma and we have high hopes for their bright future.</p><p><strong>Dan Robinson<br></strong>The Karoke King and Poppin’ Polymath. We can’t believe that we had the stupendous fortune of having him as an advisor this past year. The breadth and depth of his knowledge astounds us every day.</p><p><strong>Eva Beylin<br></strong>We asked Eva to help organize the premier Scaling Ethereum conference. She ended up pulling the entire thing together in record time. Because of her deep expertise in crypto and her penchant for efficiency, many attendees stated it was the best conference they’d ever been to. We agree ❤</p><p><strong>Georgios Konstantopoulos<br></strong>Georgios the Greek Enigma has always been a source of invaluable feedback and inspiration for our research work. He doesn’t just hustle, he is Hustle itself and we aspire to get on his level.</p><p><strong>Megan Knab<br></strong>If anybody needs a crypto tax accountant or bookkeeper, Megan’s company <a href="https://veriledger.io/">Veriledger</a> will be your holy grail. We are thankful to Megan for subduing our tax and financial panic with ease, patience, and obvious expertise.</p><p><strong>Mikerah Quintyne Collins<br></strong>Mikerah was also critical to the success of the Scaling Ethereum conference, and she’s always been an inspiration to us with her grit, candor, and creativity. You can check out some of her awesome work on <a href="https://github.com/hashcloak/Meson">mixnets here</a>.</p><p><strong>Tas Dienes<br></strong>Thanks to our advisor Tas, we made far fewer boneheaded decisions than we would have otherwise. He’s been a rock of wisdom for us, and we are deeply grateful for his support.</p><p><strong>Meeseeking &amp; Other Anonymous Twitter Friends</strong><br>We’re not sure who you are, but every time you all tweet about our work, donate to our gitcoin grant, or encourage others to support us, the whole team gathers around one screen to read your words and we attack the day with renewed vigor.</p><p><strong>You<br></strong>Thank you for your support, for following our work, engaging with our posts, and giving us words of encouragement. Random acts of kindness and support have been critical to our motivation. Even the little likes and re-tweets on our posts have brightened our days significantly, as we’ve slogged through complicated research problems that sometimes felt insurmountable.</p><p>We hope that we can continue to earn your support. Cheers to the future!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y7QMrrceeotavIXQJ1H52g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9d76b170752" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plasma-group/on-to-new-beginnings-e9d76b170752">On To New Beginnings</a> was originally published in <a href="https://medium.com/plasma-group">Plasma Group Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The OVM ❤️s Your Scaling Solution: State Channel Edition]]></title>
            <link>https://medium.com/plasma-group/the-ovm-%EF%B8%8Fs-your-scaling-solution-state-channel-edition-ed13de56e249?source=rss----cf16016e9fa8---4</link>
            <guid isPermaLink="false">https://medium.com/p/ed13de56e249</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Will Meister]]></dc:creator>
            <pubDate>Wed, 21 Aug 2019 16:52:15 GMT</pubDate>
            <atom:updated>2020-01-13T18:49:02.182Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CASXvXmPNqCcQki8mW7D5w.png" /></figure><p>A little over a month ago, we <a href="https://medium.com/plasma-group/introducing-the-ovm-db253287af50">enthusiastically announced the OVM</a>, now known as <a href="https://plasma.group/optimistic-game-semantics.pdf">OGS</a>, a general-purpose layer 2 (L2) solution to scaling blockchains, while inheriting <em>all</em> of the security of the base chain (L1). This work, while extremely promising, was purely theoretical… <strong>until today!</strong></p><p>We’re excited to announce that the rubber has hit the road in the form of a proof-of-concept State Channel implementation on the OVM . This work demonstrates how State Channels can function seamlessly on the OVM and, if you’ll extrapolate with me a bit, shows how <strong>all L2 solutions can be built on the OVM for better standardization, security, and interoperability with less development effort.</strong></p><h3>Hold up. What’s the OVM again?</h3><p>The OVM is a general purpose framework for completely inheriting the benefits of the slow and costly base chain in cheap, light-speed L2 applications. Its differentiator is that it is blockchain-agnostic and L2-solution-agnostic, creating a standard that users, wallets, developers, etc. can follow to support many different L2 applications instead of a separate paradigm for each L2 approach.</p><p><strong>How does it do this?</strong> We’ll dive deeper in a bit, but like many proposed scaling solutions, the OVM only uses L1 for what L1 is good at: achieving immutable, unanimous consensus based on a clearly defined set of rules. The mental model I always go with is that L1 is the judge and jury, and it is far more efficient to use it to retroactively handle claims that the law has not been followed than to proactively oversee everything to ensure that the law is always followed.</p><h3>Ben Jones 🔮 on Twitter</h3><p>Key axiom of layer 2: &quot;Processing disputes for all unsuccessful transactions is cheaper than processing all successful transactions.&quot; You don&#39;t go to court to cash a check. You go to court when the check bounces.</p><p>The OVM takes this approach a step further, realizing that if all of these claims of bad behavior can be expressed in the same way, we can use the same justice system (L1 dispute contract) for <em>all</em> cases (L2 implementations).</p><h3>State Channels PoC Overview</h3><p><strong>What it is</strong></p><ol><li>An example that has the minimum functionality necessary to demonstrate that full-blown State Channels are possible on the OVM.</li><li>Code that optimistically evolves L1 state through mutual agreement in L2, completely agnostic of L1, in a way that is verifiable and disputable by participants, thereby completely inheriting L1 security.</li><li>One of the many scaling ideas that can be implemented on top of the generic OVM L2 client.</li></ol><p><strong>What it is not</strong></p><ol><li>Special-purpose code that only does State Channels.</li><li>A production-ready demo of State Channels, free of bugs and small cryptoeconomic holes.</li><li>Something that actually interacts with L1 (we will discuss here how this <em>would</em> happen and demonstrate how that part works in a later post).</li></ol><h3>High-level OVM Workflow</h3><p><strong>Enter L2:</strong> Lock funds (and/or state) into a dispute contract on L1, referencing the [L1] adjudication contract. In this case, we will reference a State Channel contract containing logic that defines what constitutes a valid exitable state. The State Channel contract, and presumably all OVM adjudication contracts, will depend on the dispute contract for standard exit request and exit dispute processing.</p><p><strong>Use L2:</strong> Interact efficiently in L2, completely inheriting L1 security.<br>Exchange light-speed updates of mutually-agreed-upon state in L2, following the rules specified in the L1 State Channel contract without actually interacting with it.</p><p><strong>Exit L2:</strong> Exit with a valid claim for which there are no valid challenges during the challenge period. For State Channels, this claim will be that the state being exited is valid, as defined by the L1 State Channel contract. In using the L2 State Channel, the parties necessarily collect proof capable of disputing invalid exit claims.</p><h3>Deep-dive into L2 with State Channels</h3><p><strong>L1 Adjudication Contract</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*oes5GbpjBJfIjeTsVlHnfA.png" /></figure><p>If we’re going to use L1 as judge and jury, we need to define a clear set of laws that it will use to make rulings on claims. This will include, at a minimum, defining valid exitable states. For State Channels, a valid exitable state can be defined in English as “The most recent mutually-signed state of a channel.”</p><p>To make this statement evaluable by a general purpose judge, a valid exit claim for party A to exit State Channel C, and update its L1 state to match the state of L2, contains two assertions:</p><ol><li>Message M with State S, for Channel C has been signed by all channel participants.</li><li>There exists no Message M’ for Channel C such that M’ has a higher nonce than M <em>and</em> M’ is signed by all channel participants.</li></ol><p>If such a claim is made, 2 possible scenarios can result:</p><ol><li>The claim is validated by the dispute period lapsing without a valid challenge.</li><li>The claim is invalidated during the dispute period if either of the following happen:<br> a) The L1 contract evaluates message M and determines that it is not signed by all participants of channel C.<br> b) The L1 contract receives, from any party, a message M’ that disproves the claim that such a message doesn’t.</li></ol><p>The logic to evaluate such claims must be present in the L1 contract. While this will not be demonstrated in this post, hopefully the reader is sufficiently convinced that Smart Contracts can be built to associate addresses with a channel ID, determine if specific addresses have signed a specific message, compare the nonceproperty of different messages, take action after a specified time delay, etc.</p><h3>L2 Interaction</h3><p>Alice and Bob have deposited funds into the L1 contract, successfully initiating a State Channel. Now what? The OVM leaves this part entirely up to them.</p><p><strong>Messages</strong><br>If Alice and Bob want to evolve the state of their initial deposits in L2, they’ll need to sign and exchange messages that fit the format that the L1 contract can verify and make sure not to break any of the rules set out in the L1 contract. Let’s say this is the message format (as described in our repo <a href="https://github.com/plasma-group/pigi/blob/master/packages/core/src/types/serialization/message.interface.ts#L8">here</a> and <a href="https://github.com/plasma-group/pigi/blob/master/packages/core/src/app/serialization/examples/simple-state-channel.ts#L61">here</a>):</p><pre>{<br>  &quot;channelId&quot;: &quot;1234567890&quot;, // L1 ID<br>  &quot;nonce&quot;: 1,                // The first message<br>  &quot;data&quot;: {<br>    &quot;addressBalance&quot;: {<br>      &quot;0x0a&quot;: 100,           // Alice&#39;s initial balance<br>      &quot;0x0b&quot;: 100            // Bob&#39;s initial balance<br>    }<br>  }<br>}</pre><p>If the messages exchanged do not follow this format, the L1 contract will not be able to interpret them, and they’ll be useless.</p><p><strong>Sending, Signing, and Countersigning</strong><br>Let’s say Alice is paying Bob 5 from her balance for some good or service. She can do this by simply signing and sending him the following message (logic <a href="https://github.com/plasma-group/pigi/blob/master/packages/core/src/app/ovm/examples/state-channel-client.ts#L57">here</a> in our repo):</p><pre>{<br>  &quot;channelId&quot;: &quot;1234567890&quot;,<br>  &quot;nonce&quot;: 2,      // Most recent message<br>  &quot;data&quot;: {<br>    &quot;addressBalance&quot;: {<br>      &quot;0x0a&quot;: 95,  // Alice -5<br>      &quot;0x0b&quot;: 105  // Bob +5<br>    }<br>  }<br>}</pre><p>If Bob accepts the message as valid, he will countersign this message and send it back to Alice (let’s ignore the scenario in which he doesn’t countersign a valid message for now because that is a solved problem in State Channels).</p><p>If the message is not valid, Bob will not sign it, and the previous state will continue to be the valid state.</p><p>They can continue to evolve the state by signing and exchanging messages in this fashion, increasing the nonce for every new message.</p><p><strong>Message Storage</strong><br>Just as the OVM doesn’t dictate how messages are exchanged, it doesn’t dictate what Alice and Bob need to store, but they know what information the L1 contract needs to process an exit and what they need to present to dispute any invalid exits that arise. As such, they’ll need to store the most recent countersigned message as well as any pending (meaning not countersigned) messages that either party has signed and sent.</p><p>If Alice or Bob want to exit, they will submit to the L1 contract the most recent countersigned message as the state they would like to exit. If either party tries to exit a previous state’s message, the other party will submit the most recent countersigned message as proof that the other message is invalid.</p><p>An example datastore for State Channel messages is <a href="https://github.com/plasma-group/pigi/blob/master/packages/core/src/types/ovm/db/state-channel-message-db.interface.ts#L9">here</a> within our repo (note that it extends the functionality in our base <a href="https://github.com/plasma-group/pigi/blob/master/packages/core/src/types/ovm/db/message-db.interface.ts#L4">MessageDB</a>).</p><h3>Exiting and Challenging Exits</h3><p>Each exit and exit challenge will not only need the data that the L1 adjudication contract needs to evaluate it but it will also need to be presented in a way that the general L1 dispute contract can understand.</p><p>👷<em>Here’s where we really learn how the OVM functions. Fasten your seatbelt.</em>👷</p><p>Let’s say that Alice wants to exit the State Channel after the above message with nonce 2. Here’s the structure of the <a href="https://github.com/plasma-group/pigi/blob/master/packages/core/src/app/ovm/examples/state-channel-client.ts#L131">State Channel Exit Claim</a> that she would send to the L1 adjudication contract. It won’t make much sense right now but will become much clearer as we walk through it below:</p><pre>{<br>  &quot;decider&quot;: AndDecider,<br>  &quot;input&quot;: {<br>    &quot;left&quot;: {<br>      &quot;decider&quot;: SignedByDecider,<br>      &quot;input&quot;: {<br>        &quot;publicKey&quot;: &quot;0x0b&quot;, // Bob&#39;s Address<br>        &quot;message&quot;: { // Most recent message<br>          &quot;channelId&quot;: &quot;1234567890&quot;,<br>          &quot;nonce&quot;: 2,<br>          &quot;data&quot;: {<br>            &quot;addressBalance&quot;: {<br>              &quot;0x0a&quot;: 95,<br>              &quot;0x0b&quot;: 105<br>            }<br>          }<br>        }<br>      }<br>    },<br>    &quot;leftWitness&quot;: {<br>      &quot;signature&quot;: &quot;0xbbbbbbbbbbbbbbb&quot; // Bob&#39;s msg signature<br>    },<br>    &quot;right&quot;: {<br>      &quot;decider&quot;: ForAllSuchThatDecider,<br>      &quot;input&quot;: {<br>        &quot;quantifier&quot;: SignedByQuantifier,<br>        &quot;quantifierParameters&quot;: {<br>          &quot;publicKey&quot;: &quot;0x0a&quot;, // Alice&#39;s address<br>          &quot;channelID&quot;: &quot;1234567890&quot; // Our Channel<br>        }<br>        &quot;propertyFactory&quot;: (message) =&gt; {<br>          return {<br>            &quot;decider&quot;: MessageNonceLessThanDecider,<br>            &quot;input&quot;: {<br>              &quot;messageWithNonce&quot;: deserializeBuffer(<br>                signedMessage,<br>                deserializeMessage,<br>                stateChannelMessageDeserializer<br>              ),<br>              &quot;lessThanThis&quot;: 3,<br>            },<br>          }<br>        }<br>      }<br>    },<br>    &quot;rightWitness&quot;: undefined<br>  }<br>}</pre><p><strong>I read this far so you could hit me with this gibberish?</strong><br>I can explain…</p><p>First, let’s go back to our State Channel exit claim definition above:</p><blockquote>1. Message M with State S, for Channel C has been signed by all channel participants.</blockquote><blockquote>2. There exists no Message M’ for Channel C such that M’ has a higher nonce than M and M’ is signed by all channel participants.</blockquote><p>If we disregard the funky format for a moment, we can see that Alice’s claim <em>sort of follows this claim structure</em>.</p><p>The first part lists something called a SignedByDecider, and while we don’t know what that means yet, we see it is listed right by Bob’s address, our most recent message, and Bob’s signature of our most recent message. We can see that this has all of the info necessary to prove that Bob signed the most recent state.</p><p>The second part is more intense, but we see a ForAllSuchThatDeciderthat we don’t fully understand, a SignedByQuantifierthat has Alice’s address and our Channel ID parameters, and a MessageNonceLessThanDecider right by lessThanThis: 3. If we just read parts of that in order, we see ForAll... SignedBy...Alice’s address and our Channel ID, MessageNonceLessThan...3. It’s a stretch, but maybe this is claiming that all messages Alice has signed for this channel have a nonce less than 3?</p><p>Lastly, these two parts are nested inside an AndDeciderblock. It has a left part and a right part, so maybe it means left <em>AND</em> right?</p><p><strong>The VM in OVM means Virtual Machine</strong></p><p>The OVM is a virtual machine, and virtual machines need to execute instructions to be useful. In order to do that, the OVM has to define a base interface for an instruction. Since the OVM is based entirely on claims and disputes of those claims, its instructions must all follow the form “decide whether or not input N is valid according to rule set S.”</p><p>In order to do this, the OVM has the concept of a Property. Properties consist of a Decider, which maps directly to a simple L1 smart contract capable of making very specific true/false decisions, and inputinto the decider to be evaluated. For instance, the <a href="https://github.com/plasma-group/pigi/blob/master/packages/core/src/app/ovm/deciders/and-decider.ts#L19">AndDecider</a> decides trueif and only if its input.leftproperty evaluates to true<em>AND</em> its input.rightproperty evaluates to true.</p><p>Deciders may also require a witness, which is proof associated with the input. For example, the <a href="https://github.com/plasma-group/pigi/blob/master/packages/core/src/app/ovm/deciders/signed-by-decider.ts#L25">SignedByDecider</a> decides if a message has been signed by a public key. Its input (the messageand the publicKey) defines what is being decided, and its witness (the signature) is the proof used to make the decision.</p><p>The last piece of the puzzle is Quantifiers (other simple L1 smart contracts). Quantifiers are able to list all applicable information, given a specific set of constraints. For example, the <a href="https://github.com/plasma-group/pigi/blob/master/packages/core/src/app/ovm/quantifiers/signed-by-quantifier.ts#L12">SignedByQuantifier</a> is able to list all messages signed by a given public key.</p><p>Above, you can see that the <a href="https://github.com/plasma-group/pigi/blob/master/packages/core/src/app/ovm/deciders/for-all-such-that-decider.ts#L24">ForAllSuchThatDecider</a> uses the SignedByQuantifierto get all messages signed by Alice for the channel in question. The ForAllSuchThatDecideralso takes a property factory function that it calls, passing in each result from its quantifier, to get all of the properties that it will evaluate*. As you might imagine, the ForAllSuchThatDeciderdecides trueif all of the properties it is evaluating evaluate to true.</p><p><strong>Putting it all together</strong><br>Alice’s exit claim demonstrates how these granular properties can be nested together to represent complex statements. We can also see that, just like with other VMs, assembling different permutations of a small set of granular instructions (deciders), we should be able to represent every claim possible.</p><p>Please have a look at our <a href="https://github.com/plasma-group/pigi/blob/master/packages/core/src/app/ovm/examples/state-channel-client.ts#L39">StateChannelClient</a> and associated <a href="https://github.com/plasma-group/pigi/blob/master/packages/core/test/app/ovm/examples/simple-state-channel.spec.ts#L436">tests</a> that demonstrate L2 message exchange, exit claim generation, disputing exit claims, and more!</p><p>*Note: PropertyFactoryfunctions work for this example, but they will not ultimately be used in the claim that is passed to the L1 contract because they cannot be generically represented. This is not a blocker, as it is easily solved by simply passing a Decider, and optionally a transformer to transform Quantifierresults, to the ForAllSuchThatDeciderto enumerate the Properties itself, but we’re looking into the best approach to use.</p><h3>Extrapolating</h3><p>Now we know how the OVM enables State Channels. I won’t yammer on about how the OVM supports other scaling solutions, leaving it as an exercise to the reader how L1 adjudication contracts and exit claims might be structured for these other implementations. One thing I will touch on, however, is how this approach provides other valuable benefits such as security, compatibility, and chain agnosticism.</p><p>In standardizing the L1 dispute contract that actually holds all L2 funds, the OVM will offer excellent security by providing a reusable, extensible, battle-tested contract analogous to the ERC-20 standard. This standardization, and the universal nature of OVM operations, will offer compatibility between otherwise disparate scaling solutions as a byproduct, allowing better wallet integration and UX. Lastly, despite the fact that we’re targeting Ethereum for initial implementation, I haven’t mentioned a specific L1 chain for a reason — the OVM should work on any L1 that supports smart contracts. Taking this a step further, with the OVM, the same scaling solution can be implemented on incompatible L1 chains and share almost all L2 code.</p><p>This is just the beginning; the future is bright for the OVM! Thank you for reading, and we look forward to sharing more progress along the way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed13de56e249" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plasma-group/the-ovm-%EF%B8%8Fs-your-scaling-solution-state-channel-edition-ed13de56e249">The OVM ❤️s Your Scaling Solution: State Channel Edition</a> was originally published in <a href="https://medium.com/plasma-group">Plasma Group Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing the OVM]]></title>
            <link>https://medium.com/plasma-group/introducing-the-ovm-db253287af50?source=rss----cf16016e9fa8---4</link>
            <guid isPermaLink="false">https://medium.com/p/db253287af50</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[plasma]]></category>
            <category><![CDATA[layer-2]]></category>
            <category><![CDATA[state-channels]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Optimism]]></dc:creator>
            <pubDate>Fri, 12 Jul 2019 19:11:53 GMT</pubDate>
            <atom:updated>2020-04-09T17:07:00.549Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*16LhECJnDCqDRXMwH97GAA.jpeg" /><figcaption>It’s basically just the Oracle Virtual Machine + Eclipse IDE *on the blockchain*. Java’s back baby.</figcaption></figure><blockquote><strong>Update:</strong> This article describes what we now call OGS or Optimistic Game Semantics. For an in-depth exploration of OGS check out <a href="https://plasma.group/optimistic-game-semantics.pdf">the paper</a>! For up-to-date information on the OVM, visit <a href="http://optimism.io/">Optimism.io</a> ❤️</blockquote><h3>Introducing the OVM</h3><h4>A Correct-by-Construction Approach to Layer 2</h4><p>In this post we describe the Optimistic Virtual Machine (OVM): a virtual machine designed to support all layer 2 (L2) protocols. Its generality comes from a reframing of L2 as an “optimistic” fork choice rule layered on top of Ethereum. The formalization borrows heavily from <a href="https://github.com/cbc-casper/cbc-casper-paper/blob/master/cbc-casper-paper-draft.pdf">CBC Casper research</a>, and describes <em>layer 2 as a direct extension to layer 1 consensus</em>. This implies a possible unification of all “layer 2 scalability” constructions (Lightning, Plasma, etc) under a single theory and virtual machine: the OVM.</p><p><strong>This post will:</strong></p><ol><li>Introduce the language of the OVM.</li><li>Describe how a class of L2 applications can be compiled end-to-end using a universal dispute contract.</li></ol><h3>Part 1: Describing L2 With a Unified Language</h3><p>Layer 1 (L1) gives us a trusted, but expensive, virtual machine (VM). Layer 2 provides an interface for efficiently using the expensive L1 VM — instead of transactions directly updating the L1 state, we use off-chain data to guarantee what <em>will</em> happen to L1 state. We call this guarantee an “optimistic decision.”</p><blockquote><strong>Three steps to making an optimistic decision:</strong></blockquote><blockquote>1. Look at L1, and figure out what could possibly happen in the future.<br>2. Look at off-chain messages and what they guarantee if used in L1.<br>3. Restrict our expectation of future L1 state based on those guarantees.</blockquote><p>We will soon describe this process as part of the OVM’s <a href="https://en.wikipedia.org/wiki/Transition_system">state transition function</a>. However, first let’s build intuition for what we mean by “restrict expectation of future L1 state” with a few key concepts.</p><h4>🔑 Concept 1: The Ethereum Futures Cone</h4><p>One can imagine future Ethereum states as an infinite expanse which contains everything that could ever happen to the blockchain. Every transaction that could be signed, every <a href="https://www.businessinsider.com/dao-hacked-ethereum-crashing-in-value-tens-of-millions-allegedly-stolen-2016-6">DAO that could be hacked</a> — all possible futures. To avoid cliché this post will not mention the word: “quantum.”</p><p>However, even in the face of infinite futures we can still <strong>restrict possible futures</strong> based on the Ethereum Virtual Machine’s rules. For example, in the EVM, if 5 ETH has been burned to the address 0x000…, we know that all future Ethereum blocks will still have 5 ETH burned. This parallels CBC’s future protocol states (great illustrations by Barnabé Monnot <a href="https://medium.com/@barnabe/partially-explained-casper-cbc-specs-86d055fd0628">here</a>!).</p><p>We can visualize the process of gradually restricting possible futures as an infinitely large “cone” of possibilities that shrinks every time we mine &amp; finalize a new block.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NX-HxmrKRG3v09JtCMT1pg.gif" /><figcaption>Animation of the Ethereum futures cone. If Alice Burns 5 ETH, she knows it’s burned in all possible future blocks.</figcaption></figure><blockquote>Note that in L1 all restrictions of possible future states are done by mining and forming consensus around (finalizing) a new block — a process which produces an irreversible state transition within the EVM.</blockquote><h4>🔑 Concept 2: Local Information</h4><p>L2 extends the consensus protocol with local information (eg. off-chain messages). For example, a signed channel update, or an inclusion proof for a plasma block.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T9FK0WnvmA4w7x-KlbVDhQ.gif" /><figcaption>Off-chain message passing… Vizzzualized!</figcaption></figure><p>The OVM uses this local information to make <em>optimistic decisions —</em>we call a new decision an OVM state transition. But first, the OVM must define assumptions which it uses to derive possible future Ethereum states.</p><h4>🔑 Concept 3: Local Assumptions</h4><p>OVM programs define assumptions which, based on local information, determines what Ethereum states are possible. This can be expressed as a function satisfies_assumptions(assumptions, ethereum_state, local_information) =&gt; true/false. If satisfies_assumptions(...) returns true then the ethereum_state is possible based on these particular assumptions, and our local_information.</p><p>In many L2 solutions, this takes the form of a “dispute liveness assumption.” For example, participants in a channel assume that they will dispute any malicious withdrawal. So, we return false for any Ethereum state which contains a malicious, undisputed withdrawal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CIUp9K3K3t7wtRTQaCSxMQ.png" /><figcaption>Two forks, one where `satisfies_assumptions(…)` returns true, the other in which it returns false based on the “dispute liveness assumption.”</figcaption></figure><h4>🔑 Concept 4: Optimistic Decisions</h4><p>With our local assumptions eliminating impossible futures, we may finally make “optimistic decisions” about the future. The following would be a common optimistic decision in a payment channel:</p><blockquote><strong>Optimistically Decide Balance (with our 3 step process defined above)</strong>:</blockquote><blockquote>1. Look at L1 and determine that Alice is in a payment channel with Bob.<br>2. Look at off-chain messages determine that: a) Alice has the highest signed nonce, sending her 5 ETH; b) Alice may withdraw her 5 ETH after a dispute period; and c) Alice can respond to any invalid withdrawals based on her “dispute liveness assumption.”<br>3. Restrict our expectation of future L1 state to ONLY states in which Alice has been sent 5 ETH.</blockquote><blockquote><strong>Alice may now optimistically decide she will eventually have *at least* 5 ETH in all future states of Ethereum.</strong> — without an on-chain transaction to boot!</blockquote><h4>The Last 🔑: The Optimistic Futures Cone</h4><p>Remember that the “Ethereum futures cone” was only restricted by finalizing blocks — an entirely retrospective process. In the last section we reviewed an optimistic approach which restricts futures based on <em>local</em> <em>information</em> and <em>local assumptions </em>about the future — a prospective process. These two approaches may be “layered” on top of one-another to get the best of both worlds: the security of blockchain consensus, plus the speed, efficiency, &amp; privacy of local message transfer.</p><p>We can visualize this hybrid process with a futures cone that not only restricts future Ethereum states after each block, but also restricts future states between blocks based on local information. Deciding on a new restriction is considered a “state transition” in the OVM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*txRaipmV1qaxFNRriluFLg.gif" /><figcaption>Alice’s Optimistic Futures Cone “narrows” when she receives new off-chain messages.</figcaption></figure><h4>A Unified Language</h4><p>The above concepts may be used as the basis of a shared language and execution model for layer 2. This includes:</p><p>- Zero Confirmation Transactions<br>- The Lightning Network<br>- Cross-shard state schemes<br>- Plasma, Channels, Truebit<br> …and more — all within a shared notation.</p><p>In part 2 of this post, we will expand upon this language and show how the correct-by-construction approach motivates a specific OVM runtime. Based on first-order logic, it supports existing L2 designs —including <a href="https://ethresear.ch/t/layer-2-state-schemes/5691">those for ETH2</a>.</p><p>But first, if you’re weird like us and want to see some fancy maths, the following is a formalization of the key concepts we just reviewed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x-eUpOkVmmVhXqm17z7ovw.png" /></figure><h3>A Step Further: Building an OVM Runtime</h3><p>Excited by the realization that L2 can be described in a unified language, we soon found ourselves asking: how do we make this useful? Can we create a generic L2 runtime environment, supporting different L2 designs?</p><p>It turns out, for a broad class of OVM programs, we can. The trick is to build a dispute contract which interprets the same mathematic expressions the OVM is based on. This enables a high-level language written in predicate logic.</p><h3>The Universal Dispute Contract</h3><p>To do this, we create an arbitration contract handling user-submitted “claims”–expressions which evaluate to true/false. For example, <strong>“the preimage to hash X does NOT exist.”</strong></p><p>Disputes involve counter-claims which logically contradict. For example, <strong>“the preimage to hash X DOES exist” </strong>would contradict the first claim. This generalizes L2 “challenges”: at the end of the day, all disputes are logical contradictions (they can’t both be true).</p><p>After a dispute timeout, the contract can decide true for an unchallenged claim. However, if a contradiction is shown, it needs to make a choice. The logic of decisions about true/false statements is called <a href="https://en.wikipedia.org/wiki/First-order_logic">predicate calculus</a>.</p><h3>Predicates 2.0</h3><p>In developing <a href="https://medium.com/plasma-group/towards-a-general-purpose-plasma-f1cc4d49c1f4">generalized plasma</a>, we realized that pluggable “predicate contracts” enabled custom optimistic execution. What we now understand is that a pluggable system of predicates isn’t generalized plasma — <em>it’s generalized layer 2</em>. In this light, a plasma contract is just a composition of predicates.</p><p>Predicate contracts are the logical “evaluators” — deciding true or false on inputs. Critically, they can decide based on other predicates. This means a small set of interacting predicates can arbitrate a vast number of L2 systems.</p><h4>Example Predicates</h4><p>Let’s go over some example predicates used in first-order logic.</p><p><strong>NOT</strong><br>This predicate performs a logical negation: NOT(aPredicate, anInput). It can be contradicted by claiming aPredicate(anInput).</p><p><strong>AND</strong><br>This predicate is the logical AND operator, taking the form AND(predicate1, input1, predicate2, input2) . It can be contradicted by either NOT(predicate1, input1) or NOT(predicate2, input2) .</p><p><strong>WITNESS_EXISTS</strong><br>This predicate claims some witness data exists: WITNESS_EXISTS(verifier, parameters) . It is a <a href="https://twitter.com/VitalikButerin/status/1046498306958995456">fundamental building block</a> blockchains give to L2 systems using a liveness assumption. It decides true only if it receives some witness such that verifier.verify(parameters, witness) returns true.</p><p><strong>UNIVERSAL_QUANTIFIER</strong><br>This predicate represents <a href="https://en.wikipedia.org/wiki/Universal_quantification">universal quantification</a> (“for all”) based on some <a href="https://en.wikipedia.org/wiki/Quantifier_(logic)">quantifier</a> (“such that”)— UNIVERSAL_QUANTIFIER(aQuantifier, aPredicate) . It contradicts with NOT(aPredicate, someInput) if and only if aQuantifier.quantify(someInput) returns true.</p><h4>Composing a State Channel</h4><p>A class of widely-understood layer 2 systems is state channels, so let’s compose a state channel with predicates. Withdrawing from a state channel is like claiming the following: <strong>“For all state updates with a higher nonce than this </strong><strong>withdrawn_update, there does not exist a unanimous signature by all channel participants.”</strong></p><p>To the universal dispute contract, then, we would claim the following:</p><p>UNIVERSAL_QUANTIFIER(HAS_HIGHER_NONCE_QUANTIFIER(withdrawn_update), NOT(WITNESS_EXISTS(VERIFY_MULTISIG, withdrawn_update.participants)))</p><p>For Math folks, this might look more familiar as the following expression:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jRo0ZyJ-vcEYcQ3Isa4THw.png" /></figure><p>Thus, state channels can be built by composing four simple predicates.</p><h3>An Optimistic Future</h3><p>With very few predicates, this universal dispute contract can arbitrate many L2 systems: plasma flavors, state channels, optimistic cross-shard state schemes, Truebit, and so on. The predicate runtime provides a shared platform for each approach — enabling improved developer tooling. It effectively <strong>cuts the work of L2 developers in half</strong> because the predicate expressions are interpreted both on-chain and off-chain.</p><p>Beyond the predicate runtime, the OVM has broader implications:</p><ol><li><strong>Communication</strong> — Mathematical models for previously bespoke concepts.</li><li><strong>Interoperability</strong> — Shared memory for all optimistic execution.</li><li><strong>Security</strong> — Formal proofs for L2 &amp; the predicate runtime.</li></ol><p>Stay tuned for our paper detailing the OVM and the predicate runtime. In the meantime, you can further satiate your appetite with <a href="https://hackmd.io/@aTTDQ4GiRVyyce6trnsfpg/S1yGmXVxB">early drafts of the contracts</a>.</p><p>Please tweet questions @plasma_group, or better yet join in the discussion at the <a href="https://plasma.build/">plasma.build forum</a>–onwards!</p><p><em>PG would like to thank the following individuals for their comments and edits on the structure of this post: V, Will Meister, &amp; Akhila Raju.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db253287af50" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plasma-group/introducing-the-ovm-db253287af50">Introducing the OVM</a> was originally published in <a href="https://medium.com/plasma-group">Plasma Group Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Plapps and Predicates: Understanding the Generalized Plasma Architecture]]></title>
            <link>https://medium.com/plasma-group/plapps-and-predicates-understanding-the-generalized-plasma-architecture-fc171b25741?source=rss----cf16016e9fa8---4</link>
            <guid isPermaLink="false">https://medium.com/p/fc171b25741</guid>
            <category><![CDATA[plasma]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Optimism]]></dc:creator>
            <pubDate>Mon, 25 Mar 2019 17:54:53 GMT</pubDate>
            <atom:updated>2019-03-25T18:39:34.724Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding the Generalized Plasma Architecture</h3><p>We recently published <a href="https://medium.com/plasma-group/towards-a-general-purpose-plasma-f1cc4d49c1f4">an article</a> that describes our new work on a more generalized plasma <a href="https://pigi.readthedocs.io/en/latest/src/specs/generalized-plasma-state.html">architecture</a>. <strong>This post goes into more detail about the architecture for those who are interested in how things work under the hood. </strong>We’ll go over how everything fits together at a high level, then we’ll jump into the <a href="https://github.com/plasma-group/research/tree/master/gen-plasma">sample implementation</a> in Python. You can scroll forward to the diagrams if you’re already very familiar with plasma.</p><h3>Introduction</h3><p>The main takeaways from our previous article are:</p><ol><li>It’s hard to keep up with plasma research: those who are familiar with plasma have likely heard of all the different plasma flavors. Each flavor has a different sent of tradeoffs, and keeping up with rapidly evolving research is a full time job.</li><li>Most developers just want simple and easy ways to scale their dapps. People want good tools and well documented libraries. They certainly don’t want to build entire blockchains from scratch to run a single app.</li></ol><p>So we set out to create a platform that makes it easy to build scalable blockchain applications without having to be a plasma expert. We ended up with a general purpose plasma chain you can build apps (or “plapps”) on. Sound weird yet? Plapp. Plaaapp. Plappp. Yup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*eNl1ZoHmVKH2PjsEvgjE2g.png" /><figcaption>Rick and Morty having trouble keeping up with plasma research.</figcaption></figure><h3>Layer 2: Claims about State</h3><p>The core idea behind “Layer 2” is that we can use data outside of a main blockchain (“off-chain data”) to provide guarantees about assets sitting on the main blockchain (“on-chain data”). For example, that off-chain data might give you the right to withdraw an asset held in an on-chain escrow contract on Ethereum. But the<em> ownership</em> of that asset changed hands without touching Ethereum.</p><p>Of course, the off-chain data isn’t useful unless it’s possible for something to eventually happen on the main blockchain. This is usually achieved by allowing users to submit “claims” about the off-chain data to an on-chain smart contract where the assets being claimed are held. This claim might be something like “I have this signed message that says I’m allowed to withdraw asset X.”</p><p>But what happens if after submitting the claim, the person making the aforementioned claim <em>also</em> sings a message sending asset X to <em>someone else</em>? This would invalidate the above withdrawal. To ensure that any such invalid withdrawals are unsuccessful, we add a dispute period to every claim. Anyone may challenge the claim before the end of the dispute period. Otherwise, the claim is considered valid. Simple enough!</p><p>Let’s quickly relate this back to plasma. Plasma chains consist of a series of blocks, and each block consists of a series of transactions. Whenever a new plasma chain block is created, a <a href="https://en.wikipedia.org/wiki/Commitment_scheme"><em>cryptographic commitment</em></a> to that block is published to the main chain. These commitments can be used to prove that something was inside that block. In our case, this commitment is a merkle root created from all state updates in the block.</p><p>The plasma smart contract on Ethereum records the order in which plasma blocks are committed by the operator, and prevents commitments from ever being overwritten. Thus, these block commitments give us a sense of time. When users want to make claims about something that happened on plasma chain, they have to also reference <em>when</em> that thing happened through the block number. For example, a user might say, “Here’s transaction X <em>in block Y</em> that gave me asset Z.” This extra time dimension is also important for disputes because you sometimes want to know whether something happened before or after something else!</p><h3>Abstract Offchaindataism</h3><p>So as we’ve just seen, Layer 2 is primarily about using some off-chain data to affect things sitting on-chain. So far, off-chain data has mostly been used to represent <em>ownership </em>— who owns what, and whether it changed hands.</p><p>Alice will deposit an asset into a smart contract on Ethereum and she will become the owner of that asset. She can then sign an off-chain message that transfers ownership of the asset to Bob. Bob can then withdraw the asset back on Ethereum by making a claim using that signed message.</p><p>We can also represent more complex things than ownership. Let’s say Alice deposits a CryptoKitty and signs a bunch of messages that change the kitty’s fur color. Just like in the example above, she can eventually make a claim on Ethereum about the kitty’s fur color using the last message she signed!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/113/1*pJjjAUcxYCNqPA3ghTEp3g.png" /></figure><p>Whether it’s changing the kitty’s fur color or eye color, the smart contract back on Ethereum needs to have a way of understanding these changes. Each new piece of functionality — or new type of “state transition” — requires a change to the logic followed by the plasma contract. In previous plasma specs, adding a feature like this meant that one would have to re-deploy the *entire* plasma contract and migrate everyone’s assets from the old plasma chain to the new one. This is not secure, scalable, or upgradeable.</p><h3>Predicates: Making Plasma Useful</h3><p>We ran into this upgradeability problem once we got far enough into our plasma chain design that we wanted to add new functionality. After some brainstorming, we realized there was an easy way to add new functionality without changing the main plasma chain contract.</p><p>All of the various scenarios we’ve talked about so far have something in common — the off chain data is always for the purpose of “disputing” incorrect on-chain claims. The dispute for a particular claim is basically just some proof that the state referenced in the claim is outdated. A dispute about ownership proves that the user making the claim later transferred ownership to someone else. A dispute about kitty fur color requires proving that the kitty’s fur color has been changed.</p><p>Our primary breakthrough was realizing that dispute conditions don’t need to be checked in the main smart contract. Instead, we could have other smart contracts implement a function that would tell us if the dispute was valid or not. We could add new functionality by creating a new contract that implemented the necessary logic for that functionality and then have our main contract reference the new one. We call these external contracts <strong>‘predicates’</strong>.</p><p>Now it was really easy to add new functionality, but we still needed a way to know <em>which</em> predicate to use for a particular state update. A claim about a kitty’s fur color can’t be disputed by a change in the kitty’s eye color. So how do we know which predicate to use?</p><p>Simple! We just add the requirement that the state update also says which predicate it’s subject to. Now the update message that changes a kitty’s fur color could be, “I’m making this kitty’s fur color blue and disputes can be handled by the predicate sitting at (0x123…)”</p><p>Since users can specify any predicate address they want, anyone can add new functionality to the plasma chain at any time by deploying a new predicate on Ethereum. There’s a little more to predicates than just handling disputes, but we’ll get into that later. What’s important is that predicates just have to implement a standard interface, defined in this next section.</p><h3>Predicates in Practice</h3><h4>State Objects</h4><p>Now let’s dive into the details of how this all works in practice. The building block of our plasma chain design is the ‘state object’. A state object is just a piece of data with two attributes:</p><ul><li>predicateAddress: The on-chain address that controls the object.</li><li>parameters: Some arbitrary blob of data that describes the object.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*jFqDRVlB10TFJ55-r10UVg.png" /><figcaption>Structure of a plasma state object.</figcaption></figure><p>State objects are effectively assets — a generalization of the concept of the non-fungible “coins” in Plasma Cash. Just like each unique coin had a coinID in Cash, each state object has a stateID .</p><p>That’s it! The stateIDs are assigned sequentially based on deposits into the plasma chain, but there aren’t any rules about what parameters or predicate can be. Each plasma block is a collection of “state updates,” which define new stateObjectss at particular stateIDs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*xEfgFOq6q5fuo2Lrj-AGrQ.png" /><figcaption>A state update committed at block 0: “Alice owns the state object with ID 0 at block 0”</figcaption></figure><p>Because we use a <a href="https://medium.com/plasma-group/plasma-spec-9d98d0f2fccf">range-based Cash variant</a>, stateUpdates are actually specified over ranges of stateObject IDs:</p><pre>stateUpdate = {<br>   start: uint,<br>   end: uint,<br>   plasmaBlockNumber: uint,<br>   stateObject: stateObject<br>}</pre><p>The plasma chain contract on Ethereum, where the operator submits plasma blockhashes, implements a verifyUpdate(update: stateUpdate, updateWitness:bytes[]) -&gt; bool which checks a Merkle inclusion proof (updateWitness) that the state update was indeed committed.</p><h4>The Predicate Interface</h4><p>Predicates need to implement a standard contract interface. Let’s go over those functions.</p><p>The most important thing thing the plasma contract does is determine the validity of state updates. Particularly, we need to prevent the operator (who has full control over blocks) from being able to “sneak in” a valid state update which has its stateObject.parameters.owner == operator — this would be theft!</p><p>To accomplish this, we introduce the concept of “state deprecation.” We say that the valid state for a given stateID is that of the earliest update which has not yet been “deprecated.” State deprecation is analogous to an <strong>Unspent</strong> Transaction Output becoming a <strong>Spent</strong> Transaction Output for UTXO blockchains.</p><p>This way, even if the operator sneaks in a later update where stateObject.parameters.owner == operator, an earlier update with stateObject.parameters.owner == alice will prevail, as only she can deprecate the state.</p><p>Thus, the most important function in the predicate defines the grounds by which its state may be deprecated:</p><pre>verifyDeprecation(stateID: uint, update: stateUpdate, deprecationWitness: bytes)</pre><p>verifyDeprecation returns true or false depending on whether the committed stateUpdate has been deprecated for a particular stateID. deprecationWitness is any arbitrary data that the predicate uses to check whether or not the stateObject has been deprecated. For example, by requiring that the deprecationWitness includes a valid signature from the update.stateObject.parameters.owner, we guarantee only the owner can approve a deprecation.</p><p>Remember, this function <strong>doesn’t actually do any deprecation</strong> as it regards to plasma’s exits games, disputes, and so on. Rather, the plasma contract <em>calls the function </em>when it needs to know whether a stateObject is deprecated to evaluate a dispute.</p><p>There are three other functions in the predicate interface — in order of importance, they are:</p><pre>finalizeExit(exit: bytes)</pre><p>When an exit is redeemed, the plasma contract sends any assets associated with the claim to the predicate address and then calls this function.</p><pre>canInitiateExit(stateUpdate: bytes, initiationWitness: bytes) -&gt; bool</pre><p>This function allows the predicate to restrict who may initiate a claim on the committed state. For example, an ownership predicate probably wants to restrict canInitiateExit to the owner of the asset.</p><pre>getAdditionalDisputePeriod(stateUpdate: bytes) -&gt; uint</pre><p>This function allows the predicate to increase the dispute period of a claim. We only really use this for complex predicates (e.g. atomic swaps) that might require a longer dispute resolution process. This function usually just returns 0.</p><h4>Predicates by Example: Ownership Predicate</h4><p>Everything is easier with examples, so let’s take a look at one. The simplest predicate is the ownership predicate. This state allows its current parameters.owner to exit at any time, or approve any state update.</p><p>The first step to creating our predicate is to design our state object. Luckily that’s pretty simple, the only data inside the object’s parameters is the address of the current owner. A state object using the ownership predicate might look like this:</p><pre>OwnedByAlice = {<br>  parameters: {<br>    owner: &#39;0xAliceAddress...&#39;,<br>  },<br>  predicate: &#39;0xOwnershipPredicateAddress...&#39;<br>}</pre><p>The most important function to implement is verifyDeprecated, which receives some arbitrary deprecationWitness. In the case of the ownership predicate, a valid deprecationWitness consists of:</p><ol><li>A signature from state.parameters.owner agreeing to a new stateUpdate.</li><li>A proof that the new stateUpdate was committed in a later plasma block.</li></ol><p>verifyDeprecated needs to check that these things are valid, which means checking a signature and a Merkle proof.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*SaRRQt2R5Qw7mHDaTdHGyQ.png" /><figcaption>Conditions for an ownership state to be deprecated.</figcaption></figure><p>Putting it all together, we see how the owner can deprecate its ownership state by approving a new update:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*i9HjxCuiullPd09WbpvNVA.png" /><figcaption>Single Ownership Predicate Flow. Alice sends stateID 0 to Bob, deprecating the update from block 0.</figcaption></figure><p>The remaining functions are pretty simple. canInitiateExit needs to check that the claimant is the owner, finalizeExit forwards the assets over to the owner, and getAdditionalDisputePeriod can return 0.</p><p>Here’s what that actually looks like in code! Below we’ve included a Python implementation of the simple ownership predicate. We wrote it in Python for simplicity, but it’s pretty easy to do in Solidity or Vyper as well.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/006b772109b960ea9c27d53599d48eae/href">https://medium.com/media/006b772109b960ea9c27d53599d48eae/href</a></iframe><p>As you can see, we’ve implemented the entire interface described above. Not too difficult :-).</p><p>And there we have it! A predicate that represents transferable ownership of an asset. Most of the logic here is identical to what was already being done in plasma contracts. We even managed to <a href="https://twitter.com/plasma_group/status/1097983085855965185">prototype the change</a> over the course of <a href="https://www.ethdenver.com/">ETHDenver</a>. It was mostly a matter of moving around code that we’d already written.</p><h3>Back to the Future</h3><p>This architecture is a significant step forward in our understanding of plasma. It is analogous to the jump from payment channels to generalized state channels–we are able to fit new features and functionalities in the plasma architecture without upgrading the plasma protocol itself.</p><p>Further, we believe the predicate design space presents a rich new area of research for plasma. It’s still early days, but some of the predicates we think are possible include:</p><ul><li>State channels</li><li>DEX predicates of various types</li><li><a href="https://ethresear.ch/t/plasma-cash-defragmentation-take-3">Defragmentation</a> predicates</li><li>Nested plasma (predicate is itself a plasma contract)</li><li><a href="https://rainbownet.work/RainbowNetwork.pdf">P2P options and CDP contracts</a></li></ul><p>However, it’s important to remember that predicates are not a panacea–they are still constrained within the plasma design space. More generalization is likely yet to be found. Nevertheless, predicates are very powerful, and seem useful for pretty much all plasma implementations–including those which are not based on Plasma Cash.</p><p>We think this represents an opportunity for standardization within the entire plasma ecosystem. Any plasma implementation which shares this state-deprecation architecture can share predicates and interoperate in new ways.</p><p>Layer 2 scaling solutions are all about using off-chain data to guarantee future on-chain state. Whether old state is deprecated through signatures (state channels), commitments (plasma), or something else, these tools are ultimately accomplishing the same thing. We hope that this advancement is a step towards a unified, shared language which encompasses all layer 2 solutions. We envision a future where wallets can connect to any layer 2 solution through utilizing a standard interface, rather than writing custom integration each time. All for interoperability, and interoperability for all!</p><h3>Resources</h3><p>Python simulation:<br><a href="https://github.com/plasma-group/research/tree/master/gen-plasma">https://github.com/plasma-group/research/tree/master/gen-plasma</a><br>Technical specification: <a href="https://pigi.readthedocs.io/en/latest/src/specs/generalized-plasma-state.html">https://pigi.readthedocs.io/en/latest/src/specs/generalized-plasma-state.html</a></p><p><strong>Join our Plasma Contributors telegram chat:</strong> <a href="https://t.me/plasmacontributors">https://t.me/plasmacontributors</a></p><h3>Our Thanks to:</h3><p>Alex Attar<br>Dan Robinson<br>Dan Tsui<br>Georgios Konstantopoulos<br>Jeff Coleman<br>Mark Tyneway<br>Matt Slipper<br>Vitalik Buterin<br>Xuanji Li</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc171b25741" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plasma-group/plapps-and-predicates-understanding-the-generalized-plasma-architecture-fc171b25741">Plapps and Predicates: Understanding the Generalized Plasma Architecture</a> was originally published in <a href="https://medium.com/plasma-group">Plasma Group Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Towards A General Purpose Plasma]]></title>
            <link>https://medium.com/plasma-group/towards-a-general-purpose-plasma-f1cc4d49c1f4?source=rss----cf16016e9fa8---4</link>
            <guid isPermaLink="false">https://medium.com/p/f1cc4d49c1f4</guid>
            <category><![CDATA[plasma]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[plapps]]></category>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Optimism]]></dc:creator>
            <pubDate>Thu, 28 Feb 2019 20:11:30 GMT</pubDate>
            <atom:updated>2019-02-28T17:20:10.994Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jC1YcTcvoq0AnoJXpO3A6w.png" /></figure><p><strong>TL;DR </strong><em>We created a general purpose plasma design that allows you to build a broad class of smart contracts on plasma. Reach out to learn how: </em><a href="https://t.me/plasmacontributors"><em>https://t.me/plasmacontributors</em></a></p><p>Imagine a world where every time you wanted to build a dapp, you had to build Ethereum from scratch… including the entire client, all of the networking, all of the data structures, and <em>everything else</em>.</p><p>Until now, that’s what plasma app development was like. Each deployed plasma chain was application-specific due to constraints in the old plasma architecture. Not upgradeable, not generalizable.</p><p>What we really needed was a way for people to build applications <em>on top</em> of a general-purpose plasma chain in the same way you build dapps on a general-purpose blockchain like Ethereum.</p><h3>Clap for the Plapps</h3><p>We’ve devised a new architecture for building <strong>plapps</strong> (plasma apps) on one generalized plasma chain. It establishes a clean separation between the plasma layer and the application layer.</p><p>Writing a new plapp is as simple as writing a special type of smart contract, called a <strong><em>predicate contract</em></strong>, and deploying it to Ethereum. Anyone can use your plapp by interacting with your predicate contract, and it all happens <em>on the plasma chain — </em>where it’s much, much cheaper.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fGGA5L5J028W5YgrUtrMmA.jpeg" /><figcaption>Yes we know “plapp” sounds weird.</figcaption></figure><p>Of course, these applications still live in the plasma design space. Plapps need to implement a standard predicate contract interface, and individual transactions must still fit within the ethereum gas limit.</p><p>In other words, plasma isn’t magical infinite Ethereum. However, most existing dapps (bounties, games, decentralized finance…) easily fulfill the above requirements. And, as a plapp, they get the benefits of plasma: low cost scalability, and frictionless onboarding — new users can join without ever touching Ethereum.</p><h3>Where We‘re At</h3><p>At ETH Denver, we used this new framework to create <em>bitcoin lightning contracts</em> in a predicate contract on our plasma chain:</p><h3>Plasma Group 🔮 on Twitter</h3><p>Check it out: We implemented payment channel contracts on plasma at ETH Denver. And it&#39;s not just any channel... it&#39;s a 🔮⚡️Bitcoin Lightning channel⚡️🔮! https://t.co/2LSnxVfOu9 @EthereumDenver</p><p>Since then, we built a <a href="https://github.com/plasma-group/research/tree/master/gen-plasma">python proof-of-concept</a> that demonstrates how things work under the hood.</p><p>We then <a href="https://github.com/plasma-group/plasma-core/tree/refactor-ts">upgraded our existing client code</a> to support plapps. It uses a new library we built that <a href="https://github.com/plasma-group/plasma-verifier">allows clients to run predicate contracts</a>.</p><h3>Where We’re Going</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*v-PkPMSPsCPyL9An_uO4_w.gif" /><figcaption>itsplappening.jpeg</figcaption></figure><p>Come build a plapp! We need your help. As we implement various parts of the architecture and distill our learnings into a detailed writeup, we need early adopters like you to help us understand your needs. We are building this for you, and we want to make it everything it can be.</p><p>We designed all of this with the goal of making plapp development as easy as possible, but implementation always teaches you something new. This understanding will allow us to build better tooling for developers.</p><p><strong>Build a plapp.</strong> Reach out to us on:</p><ul><li><a href="https://twitter.com/plasma_group">Twitter</a></li><li><a href="https://t.me/plasmacontributors">Telegram</a></li><li><a href="/service/mailto:projects@plasma.group">Email</a></li></ul><p>We’d love to hear from all of you. ❤</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1cc4d49c1f4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plasma-group/towards-a-general-purpose-plasma-f1cc4d49c1f4">Towards A General Purpose Plasma</a> was originally published in <a href="https://medium.com/plasma-group">Plasma Group Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Plasma Group’s Plasma Spec]]></title>
            <link>https://medium.com/plasma-group/plasma-spec-9d98d0f2fccf?source=rss----cf16016e9fa8---4</link>
            <guid isPermaLink="false">https://medium.com/p/9d98d0f2fccf</guid>
            <category><![CDATA[ethereum-blockchain]]></category>
            <category><![CDATA[plasma]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Optimism]]></dc:creator>
            <pubDate>Thu, 31 Jan 2019 19:52:33 GMT</pubDate>
            <atom:updated>2019-01-31T19:50:40.804Z</atom:updated>
            <content:encoded><![CDATA[<p><em>TLDR: We created a spec for a Plasma Cash variant and implemented it in Node.js and Vyper. This document covers the design specification, providing references to the implementation along the way. Our code supports deploying a new chain to testnet, an on-chain registry of other plasma chains and their block explorers, and transacting via a command-line wallet.</em></p><h3>Introduction</h3><p>The vision of a network of blockchains as a scalability solution has been spreading rapidly. A multi-chain approach for parallelizing transactions is a promising way to increasing throughput… unfortunately, it also imposes significant challenges:</p><ul><li>We don’t want to divide security, e.g. 100 chains with 1% of total security each.</li><li>Advanced solutions like sharding are promising, but not yet ready.</li></ul><p>We need a solution to scalability that:</p><ul><li>Provides similar levels of security to the Ethereum mainnet, without paying millions of dollars in mining fees.</li><li><strong>Can be implemented on Ethereum as it exists today.</strong></li></ul><p>We believe that the strongest candidate to meet these criteria is a network of chains, each secured to mainnet via the Plasma framework.</p><p>Plasma is a family of protocols which allow individuals to easily deploy high-throughput, secure blockchains. A smart contract on Ethereum’s main chain can ensure that users’ funds are secure, even if the “plasma chain” acts fully maliciously. This eliminates the need for a trusted pegging mechanism like that of sidechains. Plasma chains are non-custodial, allowing the prioritization of scalability without sacrificing security.</p><p>We envision a future with many Plasma chains, giving users choice over where they transact. So, along with releasing our plasma chain implementation, we have created a <a href="https://github.com/karlfloersch/plasma-contracts/blob/master/contracts/PlasmaRegistry.vy">PlasmaRegistry.vy</a>. The registry allows new chains to join the network by listing their IP/DNS address, a custom “name” string, and their contract address. The registry contract does the verifies trusted deployment, so users can be assured that any contract on that registry is safe to deposit into — <em>even if its operator is malicious</em>.</p><h3>Properties of our Plasma Chain Implementation</h3><p>This post specifies Plasma Group’s current protocol and implementation, which draws from recent developments within the research community.</p><p><strong>Our specification has the following properties:</strong></p><ul><li>Single transactions over large ranges of coins, solving the <a href="https://ethresear.ch/t/plasma-cash-was-a-transaction-format/4261">“fixed-denomination” problem</a> in Plasma Cash.</li><li>Block size which scales with the number of transactions, not the number of deposits.</li><li>Light client proofs which scale in the logarithm of the block size and linear in blocks since deposit, making the operator the system’s only (computational) bottleneck.</li><li>A simplified, optimistic exit procedure that allows exits to specify only the most recent transaction, instead of<a href="https://ethresear.ch/t/plasma-cash-plasma-with-much-less-per-user-data-checking/1298"> both a transaction and its parent</a>.</li><li>Interchain atomic swaps, which lay the groundwork for decentralized exchange protocols.</li><li>Unlimited deposit capacity.</li></ul><p><strong>Our implementation follows the above specification, providing the following:</strong></p><ul><li>A command line <a href="https://github.com/plasma-group/plasma-chain-operator">plasma chain operator</a> written in Javascript.</li><li>A <a href="https://github.com/plasma-group/plasma-core">plasma client implementation</a> written in Javascript with a command-line wallet.</li><li>A <a href="https://github.com/plasma-group/plasma-contracts">smart contract</a> supporting ETH and ERC20 tokens written in Vyper.</li><li>An integrated JSON RPC which allows clients to download and verify <a href="https://github.com/plasma-group/plasma-node">light client proofs</a> and transact.</li><li>A <a href="https://github.com/plasma-group/plasma-explorer">block explorer</a> hosted by the plasma operator.</li><li>A <a href="https://github.com/plasma-group/plasma-chain-operator">simulated client swarm</a> which generates transactions to load test.</li><li>A Plasma “registry” contract which lists a set of verified-as-safe contracts and operator IP addresses for users to explore.</li></ul><p>If you’re interested in checking out the protocol and the code implementation, you’ve come to the right place!</p><p><strong>However, a few disclaimers before we dig in:</strong></p><ul><li>Our plasma implementation is beta software currently only suitable for testnet use. <strong>There are surely critical bugs at this time.</strong></li><li>The main difference (explained below!) between this protocol and other Plasma implementations is the block structure: a Merkle <em>sum</em> tree. This has significant benefits, but adds complexity. Plasma is already complex in comparison to sidechains.</li><li>Code has yet to be audited or formally verified, and has not undergone any optimization.</li><li>While the operator is the only <em>computational</em> bottleneck, the primary performance limit today remains bandwidth. Custody proofs require downloads which are linear in the number of blocks. Our code is an improvement per block, but still linear. This <a href="https://ethresear.ch/t/rsa-accumulators-for-plasma-cash-history-reduction/3739">active</a> <a href="https://ethresear.ch/t/log-coins-sized-proofs-of-inclusion-and-exclusion-for-rsa-accumulators/3839/7">area</a> of <a href="https://ethresear.ch/t/plasma-prime-design-proposal/4222">research</a> is yet unready for implementation.</li><li>Though our safety mechanisms and exit games are both implemented and tested, we have not yet built an automated guard service, meaning challenges and responses must be manually constructed.</li></ul><p>With that out of the way, let’s jump in! The rest of this post will take comprehensive dive into our spec, where the code lives, and what it does.</p><h3>Table of Contents</h3><ol><li><a href="https://medium.com/p/9d98d0f2fccf#4d91">General Definitions and Data Structures</a><br>a. <a href="https://medium.com/p/9d98d0f2fccf#3d22">Coin ID Assignment</a><br>b. <a href="https://medium.com/p/9d98d0f2fccf#db53">Denominations</a></li><li><a href="https://medium.com/p/9d98d0f2fccf#2bda">Transactions over ranges of coins</a><br>a. <a href="https://medium.com/p/9d98d0f2fccf#b6ad">Transfers</a><br>b. <a href="https://medium.com/p/9d98d0f2fccf#ae5f">Typed and Untyped Bounds</a><br>c. <a href="https://medium.com/p/9d98d0f2fccf#012f">Multisends and Transfer/Transaction Atomicity</a><br>d. <a href="https://medium.com/p/9d98d0f2fccf#6f99">Serialization</a></li><li><a href="https://medium.com/p/9d98d0f2fccf#d8b0">Block Structure Specification</a><br>a. <a href="https://medium.com/p/9d98d0f2fccf#ac79">Sum Tree Node Specification</a><br>b. <a href="https://medium.com/p/9d98d0f2fccf#6122">Parent Calculation</a><br>c. <a href="https://medium.com/p/9d98d0f2fccf#6b7b">Calculating a Branch’s Range</a><br>d. <a href="https://medium.com/p/9d98d0f2fccf#c8c9">Parsing Transfers as Leaves</a><br>e. <a href="https://medium.com/p/9d98d0f2fccf#54db">Branch Validity and Implicit NoTx</a><br>f. <a href="https://medium.com/p/9d98d0f2fccf#762f">Atomic Multisends</a></li><li><a href="https://medium.com/p/9d98d0f2fccf#8c86">Proof Structure and Checking</a><br>a. <a href="https://medium.com/p/9d98d0f2fccf#e963">Proof Format</a><br>b. <a href="https://medium.com/p/9d98d0f2fccf#b697">Transaction Proofs</a><br>c. <a href="https://medium.com/p/9d98d0f2fccf#f3a8">Transfer Proofs</a><br>d. <a href="https://medium.com/p/9d98d0f2fccf#eb52">Proof Steps</a><br>e. <a href="https://medium.com/p/9d98d0f2fccf#9862">Snapshot Objects</a><br>f. <a href="https://medium.com/p/9d98d0f2fccf#8056">Deposit records</a><br>g. <a href="https://medium.com/p/9d98d0f2fccf#239c">TransactionProof Validity</a></li><li><a href="https://medium.com/p/9d98d0f2fccf#6eff">Contract and Exit Games</a><br>a. <a href="https://medium.com/p/9d98d0f2fccf#3b74">Keeping track of deposits and exits</a><br>b. <a href="https://medium.com/p/9d98d0f2fccf#bb29">Exit games’ relationship to vanilla Plasma Cash</a><br>c. <a href="https://medium.com/p/9d98d0f2fccf#a4d4">Blocknumber-specified transactions</a><br>d. <a href="https://medium.com/p/9d98d0f2fccf#a8f0">Per-coin transaction validity</a><br>e. <a href="https://medium.com/p/9d98d0f2fccf#600f">How the contract handles transaction checking</a><br>f. <a href="https://medium.com/p/9d98d0f2fccf#20c2">Challenges which immediately cancel exits</a><br>g. <a href="https://medium.com/p/9d98d0f2fccf#8de1">Optimistic exits and inclusion challenges</a><br>h. <a href="https://medium.com/p/9d98d0f2fccf#eb3a">Invalid History Challenges</a></li><li><a href="https://medium.com/p/9d98d0f2fccf#2078">The Future</a><br>a. <a href="https://medium.com/p/9d98d0f2fccf#487d">Missing pieces in implementation</a><br>b. <a href="https://medium.com/p/9d98d0f2fccf#c7f3">Missing pieces in the spec</a></li></ol><h3>Repos &amp; Architecture</h3><p><a href="https://github.com/plasma-group/">Our Github</a> offers all of our implementations under the MIT License:</p><ul><li><a href="https://github.com/plasma-group/plasma-chain-operator">plasma-chain-operator</a>: spin up your own plasma chain and deploy to testnet.</li><li><a href="https://github.com/plasma-group/plasma-core">plasma-core</a>: Core plasma client functionality —portable meat of the logic.</li><li><a href="https://github.com/plasma-group/plasma-node">plasma-node</a>: Node.js wrapper for plasma-core implementing a CLI</li><li><a href="https://github.com/plasma-group/plasma-js-lib">plasma-js-lib</a>: JS helper for building web applications integrating plasma transactions.</li><li><a href="https://github.com/plasma-group/plasma-contracts">plasma-contracts</a>: The PlasmaChain.vy and PlasmaRegistry.vy Vyper contracts.</li><li><a href="https://github.com/plasma-group/plasma-explorer">plasma-explorer</a>: A block explorer hosted by the operator.</li><li><a href="https://github.com/plasma-group/plasma-utils">plasma-utils</a>: Shared utilities for building on our plasma spec.</li><li><a href="https://github.com/plasma-group/plasma">plasma</a>: Integration testing for the above components.</li></ul><p>Here’s the architecture that plasma-core implements:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w6JoXXzW1QSYYxW0.png" /></figure><p>Here’s the architecture that plasma-chain-operator implements:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rUHFuhj_56LoFpPW.png" /></figure><h3>1. General Definitions and Data Structures</h3><p>This section will cover terminology and intuitions for the protocol’s components. These data structures are encoded and decoded by <em>plasma-utils</em>’ library <em>serialization</em>. The exact byte-per-byte binary representations of all data structures for each structure can be found in <a href="https://github.com/plasma-group/plasma-utils/tree/master/src/serialization/schemas">schemas</a>.</p><h4>Coin ID Assignment</h4><p>The base unit of any plasma asset is represented as a coin. Like in standard Plasma Cash, these coins are non-fungible, and we call the index of a coin its <em>coinID</em>, which is 16 bytes. They are assigned in order of deposit on a per-asset (ERC 20/ETH) basis. Notably, all assets in the chain share the same ID-space, even if they are different ERC20s or ETH. This means that transactions across all asset classes (which we refer to as the <em>tokenType</em> or <em>token</em>) share the same tree, providing maximum compression.</p><p>We achieve this by having the first 4 bytes refer to the <em>tokenType</em>of a coin, and the next 12 represent all possible coins of that specific <em>tokenType</em>.</p><p>For example: the 0th <em>tokenType</em> is always ETH, so the first ETH deposit will give spending rights for coin 0x00000000000000000000000000000000 to the depositer.</p><p>The total coins received per deposit is precisely (amount of token deposited)/(minimum token denomination) many.</p><p>For example: let’s say that tokenType 1 is DAI, the coin denomination is 0.1 DAI, and the first depositer sends 0.5 DAI. That means its tokenType == 1, so the first depositer will recieve the coinIDs from 0x00000001000000000000000000000000 up to and including coin 0x00000001000000000000000000000004.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*_BNsC7-z06ilTUYj-2dLAg.png" /><figcaption>coins all share the same ID-space</figcaption></figure><h4>Denominations</h4><p>In practice, denominations will be much lower than 0.1. Instead of storing denominations directly in the contract, it stores a decimalOffset mapping for each tokenType which represents the shift in decimal places between the amount of deposited ERC20 (or wei for ETH) and the number of received plasma coins. These calculations can be found in the depositERC20, depositETH, and finalizeExit functions in the <a href="https://github.com/plasma-group/plasma-contracts/blob/master/contracts/PlasmaChain.vy">smart contract</a></p><p><em>//Note: </em><em>decimalOfsets are hardcoded to 0 for this release, as we lack support in the client/operator code.</em></p><h3>2. Transactions over ranges of coins</h3><h4>Transfers</h4><p>A transaction consists of a specified block number and an array of Transfer objects, which describe the details of each range of the transaction. From the <a href="https://github.com/plasma-group/plasma-utils/blob/master/src/serialization/schemas/transfer.js">schema</a> in plasma-utils (lengths in bytes):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac8b288d41beb77a6d07be93eacdc193/href">https://medium.com/media/ac8b288d41beb77a6d07be93eacdc193/href</a></iframe><p>We can see that each Transfer in a Transaction specifies a tokenType, start, end, sender, and recipient.</p><h4>Typed and Untyped Bounds</h4><p>One thing to note above is that the start and end values are not 16 bytes, as coinIDs are, but rather 12. This should make sense in the context of the above sections on deposits. To get the actual coinIDs described by the transfer, we concatenate the token field’s 4 bytes to the left of start and end. We generally refer to the 12-byte versions as a transfer’s untypedStart and untypedEnd, with the concatenated version being called typedStart and typedEnd. These values are <a href="https://github.com/plasma-group/plasma-utils/blob/master/src/serialization/models/transfer.js">also exposed by the serializer</a>.</p><p>Another note: in any transfer the corresponding coinIDs are defined with start inclusive and end exclusive. That is, the exact coinIDs transferred are [typedStart, typedEnd). For example, the first 100 ETH coins can be sent with a Transfer with transfer.token = 0, transfer.start = 0, and transfer.end = 100. The second 100 would have transfer.start = 100 and transfer.end = 200.</p><h4>Multisends and Transfer/Transaction Atomicity</h4><p>The Transaction schema consists of a 4-byte block number (the transaction is only valid if included in that particular plasma block), and an <em>array</em> of Transfer objects. This means that a transaction can describe several transfers, which are either all atomically executed or not depending on the <em>entire transaction’s</em> inclusion and validity. This will form the basis for both decentralized exchange and <a href="https://ethresear.ch/t/plasma-cash-defragmentation-take-3/3737">defragmentation</a> in later releases.</p><h4>Serialization</h4><p>As exemplified above, plasma-utils implements a custom serialization library for data structures. Both the JSON RPC and the smart contract use the byte arrays as encoded by the serializer.</p><p>The encoding is quite simple, being the concatenation of each value fixed to the number of bytes defined by the schema.</p><p>For encoding which involve variable-sized arrays, such as Transaction objects which contain 1 or more Transfers, a single byte precedes for the number of elements. Tests for the serialization library can be found <a href="https://github.com/plasma-group/plasma-utils/blob/master/test/serialization/test-serialization.js">here</a>.</p><p>Currently, we have schemas for the following objects:</p><ul><li>Transfer</li><li>UnsignedTransaction</li><li>Signature</li><li>SignedTransaction</li><li>TransferProof</li><li>TransactionProof</li></ul><h3>3. Block Structure Specification</h3><p>One of the most important improvements Plasma Cash introduced was “light proofs.” Previously, plasma constructions required that users download the entire plasma chain to ensure safety of their funds. With Plasma Cash, they only have to download the branches of a Merkle tree relevant to their own funds.</p><p>This was accomplished by introducing a <em>new transaction validity condition</em>: transactions of a particular coinID are only valid at the coinIDth leaf in the Merkle tree. Thus, it is sufficient to download just that branch to be confident no <em>valid</em> transaction exists for that coin. The problem with this scheme is that transactions are “stuck” at this denomination: if you want to transact multiple coins, you need multiple transactions, one at each leaf.</p><p>Unfortunately, if we put the range-based transactions into branches of a regular Merkle tree, light proofs would become insecure. This is because having one branch does not guarantee that others don’t intersect:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rF68tR-5SdzlI5uY.png" /><figcaption>Leaves 4 and 6 both describe transactions over the range (3,4). Having one branch DOES NOT guarantee that the other doesn’t exist.</figcaption></figure><p>With a regular Merkle tree, the <em>only</em> way to guarantee no other branches intersect is to download them <em>all </em>and check. But that’s no longer a light proof!</p><p>At the heart of our plasma implementation is a <em>new block structure</em>, and an accompanying <em>new transaction validity condition</em>, which allows us to get light proofs for range-based transactions. The block structure is called a Merkle <em>sum</em> tree, where next to each hash is a sum value.</p><p>The new validity condition uses the sum values for a particular branch to compute a a start and end range. This calculation is specially crafted so that it is <strong>impossible</strong> <strong>for two branches’ computed ranges to overlap. </strong>A transfer is only valid if its own range is within that range, so this gets us back our light clients!</p><p>This section will specify the exact spec of the sum tree, what the range calculation actually is, and how we actually construct a tree which satisfies the range calculation. For a more detailed background and motivation on the research which led us to this spec, feel free check out <a href="https://ethresear.ch/t/plasma-cash-was-a-transaction-format/4261">this</a> post.</p><p>We have written two implementations of the plasma Merkle sum tree: one done in a <a href="https://github.com/plasma-group/plasma-operator/blob/master/src/block-manager/leveldb-sum-tree.js">database</a> for the operator, and another in-memory for testing <a href="https://github.com/plasma-group/plasma-utils/tree/master/src/sum-tree">in </a><a href="https://github.com/plasma-group/plasma-utils/tree/master/src/sum-tree">plasma-utils</a>.</p><h4>Sum Tree Node Specification</h4><p>Each node in the Merkle sum tree is 48 bytes, as follows:<br>[32 byte hash][16 byte sum]<br>It’s not a coincidence that the sum’s 16 bytes length is the same as a coinID!</p><p>We have two helper properties, .hash and .sum, which pull out these two parts. For example, for somenode = 0x1b2e79791f28c27ed669f257397e1deb3e522cf1f27024c161b619d276a25315ffffffffffffffffffffffffffffffff, we have<br>node.hash == 0x1b2e79791f28c27ed669f257397e1deb3e522cf1f27024c161b619d276a25315 and node.sum == 0xffffffffffffffffffffffffffffffff.</p><h4>Parent Calculation</h4><p>In a regular Merkle tree, we construct a binary tree of hash nodes, up to a single root node. Specifying the sum tree format is a simple matter of defining the parent(left, right) calculation function which accepts the two siblings as arguments. For example, a regular Merkle sum tree has:<br> parent = function (left, right) { return Sha3(left.concat(right)) } Where Sha3 is the hash function and concat appends the two values together.</p><p>To create a Merkle <em>sum</em> tree, the parent function must also concatenate the result of an addition operation on its children’s own .sum values:</p><pre>parent = function (left, right) { <br> return Sha3(left.concat(right)).concat(left.sum + right.sum) <br>}</pre><p>For example, we might have</p><pre>parent(0xabc…0001, 0xdef…0002) ===<br>hash(0xabc…0001.concat(0xdef…0002)).concat(0001 + 0002) ===<br>0x123…0003</pre><p>Note that the parent.hash is a commitment to each sibling.sum as well as the hashes: we hash the full 96 bytes of both.</p><h4>Calculating a Branch’s Range</h4><p>The reason we use a Merkle sum tree is because it allows us to calculate a specific range which a branch describes, and be 100% confident that no other valid, overlapping branches exist.</p><p>We calculate this range by adding up a leftSum and rightSum going up the branch. Initializing both to 0, at each parent calculation, if the inclusion proof specifies a sibling to the right, we take rightSum += right.sum, and if to the left, we add leftSum += left.sum.</p><p>Then, the range the branch describes is [leftSum, root.sum — rightSum). See the following example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tbtu6Mzpk-ObXHjd.png" /><figcaption>Merkle sum calculation for a branch.</figcaption></figure><p>In this example, branch 6’s valid range is [21+3, 36–5) == [24, 31). Notice that 31–24=7, which is the sum value for leaf 6! Similarly, branch 5’s valid range is [21, 36-(7+5)) == [21, 24). Notice that its end is the same as branch 6’s start!</p><p>If you play around with it, you’ll see that it’s impossible to construct a Merkle sum tree with two different branches covering the same range. At some level of the tree, the sum would have to be broken! Go ahead, try to “trick” leaf 5 or 6 by making another branch that intersects the range (4.5,6). Filling in only the ?s in grey boxes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/0*LL4h2OKGjW_kfmWo.png" /></figure><p>You’ll see it’s always impossible at some level of the tree:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/0*-h88VLvsb5Z8gQEz.png" /></figure><p>This is how we get light clients. We call the branch range bounds the implicitStart and implicitEnd, because they are calculated “implicitly” from the inclusion proof. We have a branch checker implemented in plasma-utils via calculateRootAndBounds() for testing and client-side proof checking:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc070b2fb34123b454120e02ee000e00/href">https://medium.com/media/bc070b2fb34123b454120e02ee000e00/href</a></iframe><p>as well as in Vyper for the smart contract via</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8868e2c6cdca11f3bdecdf3af957918b/href">https://medium.com/media/8868e2c6cdca11f3bdecdf3af957918b/href</a></iframe><p>Note that the ranges are <em>typed</em> starts and ends, the full 16 bytes.</p><h4>Parsing Transfers as Leaves</h4><p>In a regular Merkle tree, we construct the bottom layer of nodes by hashing the “leaves”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CJSl0_ZcnJ53-VxG.png" /></figure><p>In our case, we want the leaves to be the transactions. So, the hashing is straightforward, but we still need a .sum value for the tree’s bottom level.</p><p>Given some txA with a single transferA, what should the sum value be? It turns out, <em>not</em> just transferA.end — transferA.start. The reason for this is that it screws up branches’ ranges if the transfers are not touching. We need to “pad” the sum values to account for this gap, or the root.sum will be too small.</p><p>Interestingly, this is a non-deterministic choice because you can pad either the node to the right or left of the gap. We’ve chosen the following “left-aligned” scheme for parsing leaves into blocks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/0*YqGAq6DPh9MoYZML.png" /><figcaption>Transfer sum parsing</figcaption></figure><p>We call the bottommost .sum value the parsedSum for that branch, and the TransferProof schema includes a .parsedSum value which is used to reconstruct the bottom node.</p><h4>Branch Validity and Implicit NoTx</h4><p>Thus, the validity condition for a branch as checked by the smart contract is as follows: implicitStart &lt;= transfer.typedStart &lt; transfer.typedEnd &lt;= implicitEnd . Note that, in the original design of the sum tree in “Plasma Cashflow,” some leaves were filled with a special “NoTx” transaction to represent that ranges were not transacted. With this format, the coins which are not transacted are simply those in the ranges [implicitStart, transfer.typedStart) and [transfer.typedEnd, implicitEnd). The smart contract guarantees that no coins in these ranges can be used in any challenge or response to an exit.</p><h4>Atomic Multisends</h4><p>Often (to support transaction fees and exchange) transactions require multiple transfers to occur or not, atomically, to be valid. The effect is that a valid transaction needs to be included once for each of its .transfers — each with a valid sum in relation to that particular transfer.typedStart and .typedEnd. However, for each of these inclusions, it’s still the hash of the full UnsignedTransaction — NOT the individual Transfer— that is parsed to the bottom .hash.</p><h3>5. Proof Structure and Checking</h3><p>Unlike traditional blockchain systems, full plasma nodes don’t store every single transaction, they only ever need to store information relevant to assets they own. This means that the sender has to <em>prove</em> to the recipient that the sender actually owns the given range. A complete proof contains all the information sufficient to guaranteed that, if the Ethereum chain itself does not fork, tokens are redeemable on the main chain.</p><p>Proofs primarily consist of the inclusion and non-inclusion of transactions, which update the chain of custody for those coins. The inclusion roots must be checked against the block hashes submitted by the operator to the smart contract on the main chain. By tracing the chain of custody as verified in the proof scheme, from a token’s initial deposit into the contract through to the present, ability to redeem is guaranteed.</p><p>plasma-core follows a relatively simple methodology for verifying incoming transaction proofs. This section describes that methodology.</p><h4>Proof Format</h4><p>History proofs consist of a set of <em>deposit records</em> and long list of relevant Transactions with corresponding TransctionProofs.</p><p>plasma-utils <a href="https://github.com/plasma-group/plasma-utils/blob/13ab042d8962852cf8c1905727d616448923764d/src/sum-tree/plasma-sum-tree.js#L281">exposes</a> a static checkTransactionProof(transaction, transactionProof, root) method, which is used by plasma-core <a href="https://github.com/plasma-group/plasma-core/blob/3caa359681db62106ba703eb0fd99171ebb86365/src/services/proof/snapshot-manager.js#L117">here</a> via calls to the ProofService.</p><h4>Transaction Proofs</h4><p>A TransactionProof object contains all the necessary information to check the validity of a given Transaction. Namely, it is <a href="https://github.com/plasma-group/plasma-utils/blob/master/src/serialization/schemas/transaction-proof.js">simply</a> an array of TransferProof objects. As per the above section on atomic multisends, a given TransactionProof is valid if and only if all its TransferProofs are valid.</p><h4>Transfer Proofs</h4><p>TransferProofs contain all the necessary information required to recover the inclusion of a valid branch corresponding to the given Transfer in the Transaction at the correct block number. This constitutes:</p><ul><li>The actual nodes of the Merkle sum tree which represent the branch’s full `inclusionProof`</li><li>The index of the leaf to calculate the binary path traced by the branch</li><li>The parsed bottom .sum as described in the sum tree spec above</li><li>The signature for that particular sender.</li></ul><p>Right from the plasma-utils <a href="https://github.com/plasma-group/plasma-utils/blob/master/src/serialization/schemas/transfer-proof.js">schema</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/04774c378db02a9af54a350ca00cb4a1/href">https://medium.com/media/04774c378db02a9af54a350ca00cb4a1/href</a></iframe><p>Note that the inclusionProof is a variable-length array whose size depends on the depth of the tree.</p><h4>Proof Steps</h4><p>The core of the verification process involves applying each proof element to the current “verified” state, starting with the deposit. If any proof element doesn’t result in a valid state transition, we must reject the proof.</p><p>The process for applying each proof element is intuitive; we simply apply the transactions at each block as the contract’s custody rules dictate.</p><h4>Snapshot Objects</h4><p>The way in which we keep track of historically owned ranges is called a snapshot.<br>Quite simply, it represents the verified owner of a range at a block:</p><pre>{<br>  typedStart: Number,<br>  typedEnd: Number,<br>  block: Number,<br>  owner: address<br>}</pre><h4>Deposit records</h4><p>Every received range has to come from a corresponding deposit.<br>A deposit record consists of its token, start, end, depositer, and blockNumber.</p><p>For each deposit record, the verifier <em>must</em> double-check with Ethereum to verify that the claimed deposit did indeed occur, and that no exits have happened in the meantime.</p><p>If so, a verifiedSnapshots array is initialized to these deposits with each snapshot.owner being the depositer.</p><p>Next, we apply all given TransactionProofs, updating verifiedSnapshots accordingly. For each transaction and corresponding transactionProof, the verifier performs the following steps:</p><ol><li>Verify that the given proof element is valid. If not, throw an error.</li><li>For each transfer in the transaction, do the following:<br> a. “Split” any snapshots which were updated above at transfer.typedStart, transfer.typedEnd, implicitStart, and implicitEnd<br> b. Increment the .block number for all resulting verifiedSnapshots which have a block equalling transaction.blockNumber — 1<br> c. For each split snapshot which fell between transfer.start and transfer.end:<br> i. verify that snapshot.owner === transfer.from. If not, throw an error.<br> ii. set snapshot.owner = transfer.sender.</li></ol><p>The TransactionProofs must be applied in ascending blockNumber.</p><p>Once this operation has been recursively applied for all TransactionProofs, the client may check for herself which new coins she now owns, by searching for all elements in verifiedSnapshots with a blockNumber equalling the current plasma block, and the owner equalling her address.</p><h4>TransactionProof Validity</h4><p>The transaction validity check in step 1. above is equivalent to checking the smart contract’s validity condition. The basic validity check, based on the sum tree specification above, is as follows:</p><p>1. Check that the transaction encoding is well-formed.<br>2. For each transfer and corresponding transferProof:<br> a. Check that the signature resolves to its transfer.sender address<br> b. verify that the inclusionProof has a root equal to the root hash for that plasma block, with the binary path defined by the leafIndex<br> c. calculate the implicitStart and implicitEnd of the branch, and verify that implicitStart &lt;= transfer.start &lt; transfer.end &lt;= implicitEnd</p><h3>4. Contract and Exit Games</h3><p>Of course, the proof for a chain of custody isn’t useful unless it can also be passed to the main chain to keep funds secure. The mechanism which accepts proofs on-chain is the core of plasma’s security model, and it is called the “exit game.”</p><p>When a user wants to move their money off a plasma chain, they make an “exit”, which opens a dispute period. At the end of the dispute period, if there are no outstanding disputes, the money is sent from the plasma contract on the main chain to the exiter. During the dispute period, users may submit “challenges” which claim the money being exited isn’t rightfully owned by the person exiting. The proofs described above guarantee that a “response” to these challenges is always calculable.</p><p>The goal of the exit game is to keep money secured, even in the case of a maximally adversarial operator. Particularly, there are three main attacks which we must mitigate:</p><ul><li><strong>Data withholding:</strong> the operator may publish a root hash to the contract, but not tell anybody what the contents of the block are.</li><li><strong>Including a forged/invalid transaction</strong>: the operator may include a transaction in a block whose sender was not the previous recipient in the chain of custody.</li><li><strong>Censorship:</strong> after someone deposits their money, the operator may refuse to publish any transactions sending the money.</li></ul><p>In all of these cases, the challenge/response protocol of the exit game makes sure these behaviors do not allow theft, in at most 1 challenge followed by 1 response.</p><h4>Keeping track of deposits and exits</h4><p><strong>Deposits mapping</strong><br>Each time a new set of coins is deposited, the contract updates a mapping which each contain a deposit struct. From the contract:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/edd505da2967baed68250fdadc5fe223/href">https://medium.com/media/edd505da2967baed68250fdadc5fe223/href</a></iframe><p>Note that this struct contains neither the untypedEnd or tokenType for the deposit. That’s because the contract uses those values as the keys in a mapping of mappings. Accessing, for example, accessing the depositer of a given deposit looks like this: someDepositer: address = self.deposits[tokenType][untypedEnd].depositer</p><p>This choice saves a little gas, and also makes some of the code cleaner since we don’t need to store any sort of deposit ID to reference a deposit.</p><p><strong>Exitable ranges mapping</strong><br>In addition to adding self.deposits entries each time there’s a deposit, the contract needs to somehow keep track of historical exits to prevent multiple exits on the same range. This is a little trickier because exits do not occur in order like deposits, and it would be expensive to search through a list of exits.</p><p>Our contract implements a constant-sized solution, which instead stores a list of exitable ranges, updating the list as new exits occur. From the smart contract:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1218da47cd2f88b382080a613f24fcf3/href">https://medium.com/media/1218da47cd2f88b382080a613f24fcf3/href</a></iframe><p>Again, we use a double-nested mapping with keys tokenType and untypedEnd so that we may call self.exitable[tokenType][untpyedEnd].untypedStart to access the start of the range. Note that Vyper returns 0 for all unset mapping keys, so we need an isSet bool so that users may not “trick” the contract by passing an unset exitableRange.</p><p>The contract’s self.exitable ranges are split and deleted based on successful calls to finalizeExit via a helper function called removeFromExitable. Note that exits on a previously exited range do not even need to be challenged; they will never pass the checkRangeExitable test called in finalizeExit. You can find that code <a href="https://github.com/plasma-group/plasma-contracts/blob/068954a8584e4168daf38ebeaa3257ec08caa5aa/contracts/PlasmaChain.vy#L380">here</a>.</p><h4>Exit games’ relationship to vanilla Plasma Cash</h4><p>At heart, the exit games in our spec are very similar to the original Plasma Cash design. Exits are initiated with calls to the function</p><pre>beginExit(tokenType: uint256, blockNumber: uint256, untypedStart: uint256, untypedEnd: uint256) -&gt; uint256:</pre><p>To dispute an exit, all challenges specify a particular coinID called into question, and a Plasma Cash-style challenge game is carried out on that particular coin. Just a single coin needs to be proven invalid to cancel the entire exit.</p><p>Both exits and the two types of respondable challenges are given an exitID and challengeID which are assigned in order via an incrementing challengeNonce and exitNonce.</p><h4>Blocknumber-specified transactions</h4><p>In the original Plasma Cash spec, the exiter is required to specify both the exited transaction and its previous “parent” transaction to prevent the “in-flight” attack where the operator delays including a valid transaction and inserts an invalid one in the block between.</p><p>This poses a problem for our range-based schemes, because a transaction may have multiple parents. For example, if Alice sends (0, 50] to Carol, and Bob sends (50, 100] to Carol, Carol can now send (0, 100] to Dave. But, if Dave wants to exit that, both the (0, 50] and (50, 100] are parents.</p><p>Though specifying multiple parents is definitely doable, this specification would be gas-expensive and seemed more complex to implement. So, we opted for the simpler alternative, in which each transaction specifies the `block` its senders intend for it to go in and is invalidated if included in a different block. This solves the in-flight attack and means the contract does not need a transaction’s parents. For those interested in a formal writeup and safety proof for this scheme, it’s worth giving <a href="https://ethresear.ch/t/plasma-cash-with-smaller-exit-procedure-and-a-general-approach-to-safety-proofs/1942">this great post</a> a look.</p><h4>Per-coin transaction validity</h4><p>An unintuitive property of our exit games worth noting up front is that a certain transaction might be “valid” for some of the coins in its range, but not on others.</p><p>For example, imagine that Alice sends (0, 100] to Bob, who in turn sends (50, 100] to Carol. Carol <em>does not</em> need to verify that Alice was the rightful owner of the full (0, 100]. Carol only needs an assurance that Alice owned (50, 100] — the part of the custody chain which applies to her receipt. Though the transaction might in a sense be “invalid” if Alice didn’t own (0, 50], the smart contract <em>does not care about that</em> for the purposes of disputes around exits for the coins (50, 100]. So long as the received coins’ ownership is verified, the rest of the transactions don’t matter.</p><p>This is a very important requirement to preserve the size of light client proofs. If Carol had to check the full (0, 100], she might also have to check an overlapping parent of (0, 10000], and then all of its parents, and so on. This “cascading” effect could massively increase the size of proofs if transactions were very interdependent.</p><p>Note that this property also applies to atomic multisends which describe multiple ranges being swapped. If Alice trades 1 ETH for Bob’s 1 DAI, it is Alice’s responsibility to check that Bob owns the 1 Dai before signing. However, after, if Bob then sends the 1 ETH to Carol, Carol <strong>need not verify</strong> that Bob owned the 1 DAI, only that Alice owned the 1 ETH she sent to Bob. Alice incurred the risk, so Carol doesn’t have to.</p><p>From the standpoint of the smart contract, this property is a direct consequence of challenges always being submitted for a particular coinID within the exit.</p><h4>How the contract handles transaction checking</h4><p>Note that, to be used in exit games at all, Transactions must pass the TransactionProof check described in the proofs section above(valid signatures, branch bounds, etc). This check is performed at the contract level in the function</p><pre>def checkTransactionProofAndGetTypedTransfer(<br>   transactionEncoding: bytes[277],<br>   transactionProofEncoding: bytes[1749],<br>   transferIndex: int128<br> ) -&gt; (<br>   address, # transfer.to<br>   address, # transfer.from<br>   uint256, # transfer.start (typed)<br>   uint256, # transfer.end (typed)<br>   uint256 # transaction plasmaBlockNumber<br> ):</pre><p>An important note here is the transferIndex argument. Remember, a transaction may contain multiple transfers, and must be included once in the tree for each transfer. However, since challenges refer to a specific coinID, only a single transfer will be relevant. So, challengers and responders gives a transferIndex — whichever of the transfers relates to the coin being disputed. The check decodes and checks all the TransferProofs in the TransactionProof, and then checks inclusion for each with the function</p><pre>def checkTransferProofAndGetTypedBounds(<br> leafHash: bytes32,<br> blockNum: uint256,<br> transferProof: bytes[1749]<br>) -&gt; (uint256, uint256): # typedimplicitstart, typedimplicitEnd</pre><p>Once all TransferProofs are verified, the dispute-relevant values for the transferIndexth Transfer are returned to the exit game functions: namely the sender, recipient, typedStart, typedEnd, and plasmaBlockNumber.</p><p>With that out of the way, we can specify the full set of challenge/response games for exits.</p><h4>Challenges which immediately cancel exits</h4><p>Two kinds of challenges immediately cancel exits: those on spent coins and those on exits before the deposit occurred.</p><p><strong>Spent coin challenge</strong><br>This challenge is used to demonstrate that the exiter of a transaction already sent the coins to someone else.</p><pre><a href="http://twitter.com/public">@public</a><br>def challengeSpentCoin(<br> exitID: uint256,<br> coinID: uint256,<br> transferIndex: int128,<br> transactionEncoding: bytes[277],<br> transactionProofEncoding: bytes[1749],<br>):</pre><p>It uses checkTransactionProofAndGetTypedTransfer and then checks the following:</p><ol><li>The challenged coinID lies within the specified exit.</li><li>The challenged coinID lies within the typedStart and typedEnd of the transferIndexth element of transaction.transfers.</li><li>The plasmaBlockNumber of the challenge is greater than that of the exit.</li><li>The transfer.sender is the exiter.</li></ol><p>The introduction of atomic swaps does mean one thing: the spent coin challenge period must be strictly less than others, because of an edge case in which the operator withholds an atomic swap between two or more parties. In this case, those parties must exit their pre-swapped coins, forcing the operator to make a a spent coin challenge and reveal whether the swap was included or not. BUT, if we allowed the operator to do that at the last minute, it would make for be a race condition where the parties have no time to use the reveal to cancel other exits. Thus, the timeout is made shorter (1/2) than the regular challenge window, eliminating “last-minute response” attacks.</p><p><strong>Before deposit challenge</strong><br>This challenge is used to demonstrate that an exit comes from an earlier plasmaBlockNumber than that coin was actually deposited for.</p><pre><a href="http://twitter.com/public">@public</a><br>def challengeBeforeDeposit(<br> exitID: uint256,<br> coinID: uint256,<br> depositUntypedEnd: uint256<br>):</pre><p>The contract looks up self.deposits[self.exits[exitID].tokenType][depositUntypedEnd].precedingPlasmaBlockNumber and checks that it is later than the exit’s block number. If so, it cancels.</p><h4>Optimistic exits and inclusion challenges</h4><p>Our contract allows an exit to occur without doing any inclusion checks at all in the optimistic case. To allow this, any exit may be challenged directly via</p><pre><a href="http://twitter.com/public">@public</a><br>def challengeInclusion(exitID: uint256):</pre><p>To which the exiter must directly respond with either the transaction or deposit they are exiting from.</p><pre><a href="http://twitter.com/public">@public</a><br>def respondTransactionInclusion(<br> challengeID: uint256,<br> transferIndex: int128,<br> transactionEncoding: bytes[277],<br> transactionProofEncoding: bytes[1749],<br>):</pre><pre>...</pre><pre><a href="http://twitter.com/public">@public</a><br>def respondDepositInclusion(<br> challengeID: uint256,<br> depositEnd: uint256<br>):</pre><p>The second case allows users to get their money out if the operator censored all transactions after depositing.</p><p>Both responses cancel the challenge if:</p><ol><li>The deposit or transaction was indeed at the exit’s plasma block number.</li><li>The depositer or recipient is indeed the exiter.</li><li>The start and end of the exit were within the deposit or transfer’s start and end</li></ol><h4>Invalid History Challenges</h4><p>The most complex challenge-response game, for both vanilla Plasma Cash and this spec, is the case of history invalidity. This part of the protocol mitigates the attack in which the operator includes an forged “invalid” transaction whose sender is not the previous recipient. The solution is called an invalid history challenge: because the rightful owner has not yet spent their coins, they attest to this and challenge: “oh yeah, that coin is yours? Well it was mine earlier, and you can’t prove I ever spent it.”</p><p>Both invalid history challenges and responses can be either deposits or transactions.</p><p><strong>Challenging</strong></p><p>There are two ways to challenge depending on the current rightful owner:</p><pre><a href="http://twitter.com/public">@public</a><br>def challengeInvalidHistoryWithTransaction(<br> exitID: uint256,<br> coinID: uint256,<br> transferIndex: int128,<br> transactionEncoding: bytes[277],<br> transactionProofEncoding: bytes[1749]<br>):</pre><p>and</p><pre><a href="http://twitter.com/public">@public</a><br>def challengeInvalidHistoryWithDeposit(<br> exitID: uint256,<br> coinID: uint256,<br> depositUntypedEnd: uint256<br>):</pre><p>These both call a</p><pre><a href="http://twitter.com/private">@private</a><br>def challengeInvalidHistory(<br> exitID: uint256,<br> coinID: uint256,<br> claimant: address,<br> typedStart: uint256,<br> typedEnd: uint256,<br> blockNumber: uint256<br>):</pre><p>function which does the legwork of checking that the coinID is within the challenged exit, and that the blockNumber is earlier than the exit.</p><p><strong>Responding to invalid history challenges</strong></p><p>Of course, the invalid history challenge may be a grief, where really the challenger did spend their coin, and the chain of custody is indeed valid. We must allow this response. There are two kinds.</p><p>The first is to respond with a transaction showing the challenger’s spend:</p><pre><a href="http://twitter.com/public">@public</a><br>def respondInvalidHistoryTransaction(<br> challengeID: uint256,<br> transferIndex: int128,<br> transactionEncoding: bytes[277],<br> transactionProofEncoding: bytes[1749],<br>):</pre><p>The smart contract then performs the following checks:</p><ol><li>The transferIndexth Transfer in the transactionEncoding covers the challenged coinID.</li><li>The transferIndexth transfer.sender was indeed the claimant for that invalid history challenge.</li><li>The transaction’s plasma block number lies between the invalid history challenge and the exit.</li></ol><p>The other response is to show the challenge came before the coins were actually deposited — making the challenge invalid. This is similar to the challengeBeforeDeposit for exits themselves.</p><pre><a href="http://twitter.com/public">@public</a><br>def respondInvalidHistoryDeposit(<br> challengeID: uint256,<br> depositUntypedEnd: uint256<br>):</pre><p>In this case, there is no check on the sender being the challenge recipient, since the challenge was invalid. So the contract must simply check:</p><ol><li>The deposit covers the challenged coinID.</li><li>The deposit’s plasma block number lies between the challenge and the exit.</li></ol><p>If so, the exit is cancelled.</p><p>This concludes the complete exit game specification. With these building blocks, funds can be kept safe even in the case of a maximally malicious plasma chain.</p><h3>6. The Future</h3><p>Plasma Group is dedicated to the creation of an open plasma implementation for the greater Ethereum community. It’s our mission to push layer 2 scaling forward by exploring the full potential of the plasma framework. There’s certinaly much more to push forward! Here are some of the things we hope to work on next.</p><h4>Missing pieces in implementation</h4><p><strong>Automated Guarding</strong><br>While a good start, many improvements are needed to fulfill the true potential of Plasma, for this spec and beyond. Currently, the most glaring missing piece in our implementation is guarding, the automated process which submits challenges and responses on behalf of users. Thankfully, the exit games themselves are implemented and have been manually <a href="https://github.com/plasma-group/plasma-contracts/blob/master/test/test-plasma.js">tested</a>, so that client software can be updated after a chain is deployed. We felt this was sufficient for a testnet release, but is the most pressing addition the code needs.</p><p><strong>P2P History Proofs</strong></p><p>Currently, when a user recieves a transaction, they ask the operator and re-download the full proof. This introduces a massive increase in operator overhead. What should really happen is that the sender directly transmits their locally stored proof to the recipient, bypassing the operator and making it much cheaper to run a plasma chain.</p><p><strong>Defragmentation Strategies</strong><br>Since we support atomic swaps, our current spec is compatible with any defragmentation strategy without any upgrades to the contract. However, it remains to be seen what the right approach will be, especially since we require transactions to specify a Plasma block number. We hope the plasma community can build an extensible defragmentation abstraction library which allows operators and users to try out different approaches.</p><p><strong>Front-end wallet integration</strong><br>We have some designs for a front-end wallet, but currently the client only supports command-line transacting, with no support for trading different ERC20s. Having a nice UI to give to testnet users will be a major step up in terms of UX and accessibility.</p><p><strong>Operator fees</strong><br>Because we support atomic multisends, we can support transaction fees without any protocol modifications. However, we’ve not currently implemented anything for this testnet launch.</p><p><strong>Networked operator</strong><br>Something we’re not taking advantage of yet is that merkle tree construction is highly parallelizable. If the operator was deployed as a networked cluster, we could increase block size by constructing subtrees in parallel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/0*jHP1K2gdztKHsgxX.png" /><figcaption>Raspberry plasma, anyone?</figcaption></figure><p><strong>Code review</strong><br>It’s <strong>very likely</strong> that all of the client, contract, and operator implementations have critical bugs at this time. We’re hoping that part of this public launch will be an opportunity for external contributors to help point out many mistakes!</p><h4>Missing pieces in the spec</h4><p><strong>Succinct Proof Schemes</strong><br>As mentioned in the introduction, the most active area of Plasma research is a scheme to reduce the history proof size. P2P or not, an old (say, 1 year+) coin might have a significant amount of associated proof data, making transactions cumbersome. This is because the history proof contains, at minimum, one branch per block.</p><p>RSA accumulator constructions and STARKS/SNARKS which batch branch proofs over many blocks are currently the most likely candidates. Both would require protocol changes: for RSA (which also introduces a trusted setup), an entirely new validity condition must be added to the exit game. For the latter, the tree needs to be constructed using a SNARK/STARK friendly hashing algorithm, which has not been implemented in EVM.</p><p><strong>Mass Exit/Deposit Schemes<br></strong>If the operator does turn malicious, users must (eventually, no rush!) exit their funds. The concept of “mass exits”, in which many users consent to exiting together via a single on-chain transaction, would be a significant scalability increase. Ideally, the exit would be able to auto-deposit funds directly into a different plasma chain via a merkle root of balances. This would enable many users to switch chains, without individual balances ever being resolved on the main chain — a significant improvement in the “networkability” of multiple plasma chains.</p><p><strong>Multi-operator networks</strong><br>Though the operator cannot steal funds, they can censor transactions at will. One mitigation to this would be to replace the single-operator model with a set of operators, so that the existence of just a single honest operator is sufficient for clients to transact.</p><p><strong>Improved exit records</strong><br>Our exitable range construction allows for constant-sized checks on exited ranges. However, since each finalization updates this mapping, we will have a race condition if exits on the same range aren’t processed in ascending order. This is because the first exit’s finalization splits the range, changing the key to the self.exitable mapping and causing checkRangeExitable to fail for exits referencing the unsplit range. Those exits will revert and have to be re-submitted in the next Ethereum block. A gas-efficient alternative may exist, possibly using some sort of tree, queue, or some batchFinalizeExits method.</p><p><strong>State channels and scripting</strong><br>Recently, there’s been some great progress in the research community which suggests state channels and scripting with covenants are feasible on Plasma. Our current spec does not support either of these features, and will require a significant upgrade to the smart contract to support.</p><p>Together, we’ll build towards realizing the vision of a more decentralized future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d98d0f2fccf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plasma-group/plasma-spec-9d98d0f2fccf">Plasma Group’s Plasma Spec</a> was originally published in <a href="https://medium.com/plasma-group">Plasma Group Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Plasma Group]]></title>
            <link>https://medium.com/plasma-group/deployplasma-dd1cf0b2ab55?source=rss----cf16016e9fa8---4</link>
            <guid isPermaLink="false">https://medium.com/p/dd1cf0b2ab55</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[ethereum-blockchain]]></category>
            <category><![CDATA[plasma]]></category>
            <dc:creator><![CDATA[Optimism]]></dc:creator>
            <pubDate>Thu, 31 Jan 2019 19:51:55 GMT</pubDate>
            <atom:updated>2019-01-31T19:50:03.832Z</atom:updated>
            <content:encoded><![CDATA[<p><em>TLDR: We’ve created a simple way to deploy your own plasma chains.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VNi0VwR6Es6ubmZIf52Nsg.png" /><figcaption><a href="https://plasma.group/">plasma.group</a></figcaption></figure><p>Hello world! We are excited to announce a full service plasma toolbox for deploying, transacting on, building with, and developing on plasma chains.</p><p>This implementation set foot in the aftermath of devconIV. Though it’s an unaudited beta release, we hope it will lay the groundwork for a community-driven initiative to make plasma a tool for decentralization for everyone.</p><p>You can <a href="https://github.com/plasma-group/plasma-chain-operator">deploy your own plasma chain</a> from the command line or <a href="https://github.com/plasma-group/plasma-node">connect to a plasma chain that we’ve deployed</a> and send transactions via a command line wallet. This implementation is written in Javascript and Vyper, and includes a library of plasma utilities for those who want to build on top of it.</p><h3>About us</h3><p>Plasma Group is dedicated to the creation of an open plasma implementation for the greater Ethereum community. It’s our mission to push layer 2 scaling forward by exploring the full potential of the plasma framework. Together, we’ll build towards realizing the vision of a more decentralized future.</p><h3>Contributors</h3><p>No matter who you are, you can be a part of this community. Anyone can contribute, and we need your expertise to make this a success. Find a list of our repositories <a href="http://github.com/plasma-group">here</a>. Click through to each one to discover contributable issues.</p><h3>Donors</h3><p>We would like to give resounding thanks to our donors: <a href="https://omisego.network/">OmiseGO</a> and independent individuals within the OMG community, LinkTime, <a href="https://status.im/">Status</a>, <a href="https://consensys.net/">ConsenSys</a>, and <a href="https://gitcoin.co/">Gitcoin</a>. Thank you all so much for your contributions — we are so incredibly grateful.</p><h3>Relevant Links</h3><p><a href="https://medium.com/@plasma_group/plasma-spec-9d98d0f2fccf">Plasma Group Plasma spec </a><br><a href="https://github.com/plasma-group">Github</a><br><a href="https://twitter.com/plasma_group">Twitter</a><br><a href="https://plasma.group/">Website</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd1cf0b2ab55" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plasma-group/deployplasma-dd1cf0b2ab55">Introducing Plasma Group</a> was originally published in <a href="https://medium.com/plasma-group">Plasma Group Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>