<?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[Stories by Yoav Weiss on Medium]]></title>
        <description><![CDATA[Stories by Yoav Weiss on Medium]]></description>
        <link>https://medium.com/@yoavw?source=rss-c0013a425528------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*C6Q1EJSPZuJ428ThOLwWAw.jpeg</url>
            <title>Stories by Yoav Weiss on Medium</title>
            <link>https://medium.com/@yoavw?source=rss-c0013a425528------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 10:02:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yoavw/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Optimistic time-travel]]></title>
            <link>https://medium.com/infinitism/optimistic-time-travel-6680567f1864?source=rss-c0013a425528------2</link>
            <guid isPermaLink="false">https://medium.com/p/6680567f1864</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[rollup]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Yoav Weiss]]></dc:creator>
            <pubDate>Sun, 20 Mar 2022 16:11:05 GMT</pubDate>
            <atom:updated>2022-03-23T03:07:05.918Z</atom:updated>
            <content:encoded><![CDATA[<h4>Cautious optimism— why security matters for fraud proofs</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M5BmOmzkwV-zX4Pg.jpg" /><figcaption>Wait a minute. Wait a minute Doc, are you telling me you built a <strong>time</strong> machine out of a DeLorean?”</figcaption></figure><p>In this post I am going to introduce two classes of attacks against optimistic rollups — time travel attacks, and reality distortion attacks. I will demonstrate these attacks using OVM 1, an obsolete implementation which Optimism has retired in November 2021.</p><p>The purpose of this post is to highlight the significance of fraud-proofs security research and to provide a frame of thinking when approaching fraud-proof bounties.</p><h3>Optimistic rollups and fraud proofs</h3><p><a href="https://ethereum.org/en/developers/docs/scaling/optimistic-rollups/">Optimistic rollups</a> scale Ethereum by using the L1 (a.k.a. Ethereum mainnet) network mostly for storage, doing the expensive computations elsewhere. It is assumed that the sequencer performs those computations correctly, because it locked a bond that it would forfeit if the results are incorrect.</p><p>If the sequencer submits a fraudulent state transition, an L1 fraud proof contract can be used to prove the fraud, undo the transition and slash the sequencer. A state transition is considered fraudulent if the submitted transactions, when applied to the previous state, do not result in the new state attested by the sequencer.</p><p>Upon a successful fraud proof the chain rolls back to its pre-fraud state, and then it gets rolled forward by replaying the same transactions in the same order, using the correct state.</p><p>Fraud proofs are tricky to implement. They involve simulating EVM execution with arbitrary state and inputs on EVM itself, and must always reach the same result as the L2 execution. They must not have corner cases where execution differs.</p><p>Optimism’s fraud proofs implementation in OVM-1 is described in a <a href="https://research.paradigm.xyz/optimism">great post</a> by Georgios Konstantopoulos. The technical sections of my post assume some familiarity with it.</p><h3>Motivation: time-traveling the blockchain</h3><p>In this section I’ll explain the implications of a malicious fraud proof, and how an attacker could use it to cause maximum damage and extract maximum value by carefully planned time-traveling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*4sEoyjE-hQeJkWGMzpTkiQ.png" /><figcaption>Great Scott!</figcaption></figure><p>Normally transactions are processed on L2, but when they are challenged by a fraud proof, they are reprocessed on L1 as part of the proof. To avoid fraud proof, these two flows must have identical results.</p><p>Time travel attacks work by creating transactions that modify the state in one way during normal L2 processing, and in another during the fraud proof. A retroactive state change during reprocessing could have a cascading effect on everything that happened afterwards. By selectively changing the past, we can change the present and the future.</p><p>OVM-1 had multiple vulnerabilities that could be used to inject a seemingly legitimate transaction through the sequencer, and then prove their resulting state as fraudulent on L1. This was made worse by the fraud-prover service <a href="https://github.com/ethereum-optimism/optimism-ts-services/blob/3cf3c11ee5a6b39eedd2b4f2895137e109f7970b/src/services/fraud-prover.service.ts">implementation</a> not attempting L1 simulation, and relying on L2 execution, so it failed to detect these transactions as fraudulent. As a result, an attacker could plant the transaction, wait up to 7 days — the fraud proof window — and roll the chain back to that point by producing an L1 fraud proof.</p><p>Here’s how Doc implements a basic <em>double-spending</em> attack:</p><ol><li>Send as much ETH as he can obtain to L2 before the attack, to Account_1.</li><li>Inject a fraudulent transaction as demonstrated below. The transaction moves the ETH to Account_2 when executed in L2, but reverts when simulated on L1 during a fraud proof (or vice versa, Account_1 and Account_2 could be inverted, depending on which of the exploits below is used — whether the revert happens on L2 or in the L1 simulation).</li><li>Withdraw the ETH from the account that has it, through <a href="https://www.optimism.io/apps/bridges"><em>Fast Bridges</em></a>. The canonical bridge would be of no use during the attack, because it is subject to the 7-day delay, but bridges such as <a href="https://app.hop.exchange/#/send?token=ETH">Hop</a>, <a href="https://connext.network/">Connext</a> and <a href="https://cbridge.celer.network/#/transfer">Celer</a>, are willing to take the risk and release funds to L1 without this delay. At this point, Doc’s funds are already safe on L1 (minus fees) before the attack has started.</li><li>Send another transaction using Account_1 (the account that no longer has the funds), attempting to send the same amount to L1 through the canonical bridge. This transaction should revert on L2 at this point, due to lack of funds.</li><li>Wait 6 days.</li><li>Submit a fraud proof, rolling the chain back by 6 days. At this point the chain’s state is 6 days behind, and users are unable to submit transactions through the sequencer because it is out of sync until it is fixed to submit the state root that matches the L1 simulation (changing the outcome of the fraudulent transaction). If the sequencer tries to come back up and roll the chain forward with the old state root, Doc will just keep re-slashing it and taking its bond.</li><li>Eventually the sequencer comes back online and replays the chain, with Doc’s first transaction resulting in the state root determined by the L1 simulation.</li><li>At this point, Doc has doubled his funds. The result of the transfer from Account_1 to Account_2 has changed, so the subsequent Fast Bridge<em> </em>transfers are reverted due to lack of funds. Doc has his original funds on L1, but the Fast Bridge transfers on L2 were retroactively reverted, so he also has the funds on L2. The Fast Bridges liquidity pools have been drained.</li><li>When the chain is replayed after the fix, the change in the outcome of the 1st transaction has a cascading effect, also changing the outcome of the 2nd transaction. Account_1 now has the funds, so the previously reverted transfer to the canonical bridge now succeeds.</li><li>A day later, the 7-day window is over, and the funds from the canonical bridge are released on L1. Doc has doubled his ETH on L1, successfully robbing the Fast Bridges.</li></ol><p>But Doc is greedy and wants more than 2X profit, so he proceeds to the bonus rounds:</p><ol><li>The chain traveled 6 days back in time, opening major arbitrage opportunities against current token prices. Just after the bridge withdrawal, Doc picks a high-volatility, high-volume token. Doc doesn’t send the 2nd transaction above (the one that sent the funds to the canonical bridge), and replaces it with a trade on Uniswap by Account_1, attempting the buy a large quantity of the token at the current price. The trade reverts due to lack of funds in Account_1.</li><li>During the next 6 days, Doc monitors the token price. If the token price is down, Doc does nothing, waits another day for the fraud window to expire, and starts the attack from scratch.</li><li>If the token price increases significantly during the 6 days, Doc sends another trade, attempting to sell the tokens at the current price. This trade reverts because doc doesn’t actually have the tokens.</li><li>Doc finally sends the fraud proof and waits for the sequencer to be fixed, and for the chain to be replayed with the altered state.</li><li>During replay, the 1st transaction’s result changes, starting the cascade effect. The 2nd transaction — buying the token 6 days ago, now succeeds because the funds are available in Account_1. Doc now has the tokens, and the token price on Uniswap goes up as a result of the trade. Many subsequent replayed trades made by other users during these 6 days revert because their limit no longer matches the token price on Uniswap. The last trades succeed when their price limit matches the new price created by Doc’s retroactive trade. The token finally reaches its current price. Then the 3rd transaction is replayed, selling Doc’s tokens at the current price.</li><li>Doc did much better than 2X. He double-spent his ETH but also used the double-spent funds to retroactively exploit a 6-day arbitrage, <em>frontrunning</em> all the other traders. Any further trades made by these users will probably fail as well, since their replayed transactions no longer match the assets they hold.</li><li>If Doc gets really greedy, he can create arbitrarily complex post-exploit sequences of transactions, attacking different DeFi protocols. For example, he could exploit arbitrage opportunities only in the first 3 days to amass a lot of ETH. Then he would use it to manipulate token prices, trigger liquidations in some collateralized protocols, and collect these liquidations. Doc would successfully frontrun everyone else because the liquidations happen 3 days in the past, and only Doc was there to take them.</li><li>Similarly, he exploits options protocols such as Synthetix by selectively buying options 6 days ago. With time-travel, the possibilities in DeFi seem endless.</li><li>Finally, instead of sending the proceeds to the canonical bridge, Doc pushes all the newly acquired ETH to Tornado Cash on L2 at the end of the conditional sequence, so that the addresses can’t be blacklisted by the bridge after the network is fixed.</li><li>When the network is back running, Doc slowly withdraws the ETH from Tornado and sends it to L1.</li></ol><p>This entire movie-plot attack would probably fail because the L1 contracts are still centrally upgradable, and the upgrade could fix the fraud proof contract rather than the sequencer, ensuring that the state remains intact during replay. Or the upgrade could temporarily disable fraud proofs and replay the chain with the same state.</p><p>However that’s not something the community should rely on. At some point the rollups will be decentralized, and rolling back the chain to undo an attack will become infeasible. We need fraud proofs to be reliable enough to never require centralized rollback to bail it out.</p><p>Having established why we should care, let’s move on to explore actual vulnerabilities.</p><h3>Two classes of vulnerabilities</h3><p>During my research, I focused on two kinds of vulnerabilities:</p><ol><li>Time-traveling attacks by an anonymous user.</li><li>Reality-distortion attacks by a malicious sequencer.</li></ol><p>In the next sections I will demonstrate attacks of both kinds.</p><h3>Time-traveling attacks by an anonymous user</h3><p>Proving fraud of a legitimate state transition enables chain reverts and time-traveling as explained above. This class of attacks is the riskiest, because it could be performed by any anonymous user on the network.</p><h4>The simplest one: storage gas cost differences</h4><p>OVM-1 consisted of an l2geth (for L2 execution) and a set of OVM contracts (for L1 simulation). One place where the two differ a lot is the state manager. For example, <a href="https://github.com/ethereum-optimism/optimism/blob/ed2ff66d014666cb27b363026a2ceb6c971cb647/packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_StateManager.sol">OVM_StateManager</a>.sol implements SSTORE/SLOAD for L1 in an <a href="https://github.com/ethereum-optimism/optimism/blob/ed2ff66d014666cb27b363026a2ceb6c971cb647/packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_StateManager.sol#L463">exotic way</a> which differs from the <a href="https://github.com/ethereum-optimism/optimism/blob/ed2ff66d014666cb27b363026a2ceb6c971cb647/l2geth/core/vm/ovm_state_manager.go#L121">L2 implementation</a>. Therefore, the gas behavior of any contract that uses storage will differ between L1 and L2. The same goes for other functions implemented in <a href="https://github.com/ethereum-optimism/optimism/blob/ed2ff66d014666cb27b363026a2ceb6c971cb647/l2geth/core/vm/ovm_state_manager.go">ovm_state_manager.go</a>.</p><p>This can be exploited by either accessing gasleft() directly, or by using a call with a gas limit that would cause an out-of-gas revert only on one of them.</p><p>This was my first fraud proof exploit, using this trivial contract:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2c630d229ca2799a6d95e704a6b9fd5/href">https://medium.com/media/f2c630d229ca2799a6d95e704a6b9fd5/href</a></iframe><p>The number emitted by this contract on L1 and on L2 differs due to the gas consumed when storing gas1. It also results in a different state root, due to a different number being stored in gas2.</p><p>To exploit it, I needed a fraud prover that would simulate the transaction on L1. Unfortunately, the <a href="https://github.com/ethereum-optimism/optimism-ts-services/blob/2fc4521af2efc20932f219d53973c9a68ff6e21d/src/services/fraud-prover.service.ts">fraud prover</a> in the repo compared the state root to the one reported by l2geth, and therefore wouldn’t trigger the L1 simulation. I <a href="https://gist.github.com/yoavw/bdf6d532b75ede6f60ca8404a7131335">patched</a> it to accept a FORCE_BAD_ROOT environment variable, making it “see” a different state root in the specified block number and attempting to prove it on L1. This patched prover is used in all the demos below.</p><p>The actual exploit:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0dea4e9eab1649e81d313019a64e920f/href">https://medium.com/media/0dea4e9eab1649e81d313019a64e920f/href</a></iframe><p>And the successful fraud proof output can be seen <a href="https://gist.github.com/yoavw/160d5dadb37fbd0d1ec04e69951edafd">here</a>. The <a href="https://gist.github.com/yoavw/160d5dadb37fbd0d1ec04e69951edafd#file-ovm_exploit0-log-L136-L138">marked section at the bottom</a> shows that it produced a different state root, and therefore the fraud proof was successful.</p><h4>Bypassing the whitelist deployer: non-contract attacks</h4><p>When I was researching OVM-1 fraud proofs, OVM was already live on mainnet as a Synthetix specific chain (see timeline below) but in a limited way. Optimism was smart to use layers of defense for the Synthetix chain and for the later <a href="https://medium.com/ethereum-optimism/mainnet-soft-launch-7cacc0143cd5">mainnet soft launch</a>. The first line of defense was a whitelist deployer, preventing unauthorized users from deploying contracts. Therefore the trivial exploit above wouldn’t work on mainnet. I decided to focus my research on breaking OVM without deploying contracts, in order to breach the first line of defense. This meant finding system contracts in which I could trigger a fraud proof through a normal (non-create) transaction.</p><p>The simplest one was against OVM’s innovative account abstraction. OVM replaced EOA with an <a href="https://github.com/ethereum-optimism/optimism/blob/ed2ff66d014666cb27b363026a2ceb6c971cb647/packages/contracts/contracts/optimistic-ethereum/OVM/accounts/OVM_ECDSAContractAccount.sol">ECDSA contract</a> emulating the behavior of an EOA. This was a fine implementation of account abstraction, but it also introduced a vulnerability.</p><p>Normally, when an EOA sends a transaction with less than the minimum gas, the transaction is not mined and the chain state is not affected. But with account abstraction, the minimum required gas is much higher, and if gas is between the L1 minimum and the L2 minimum, the revert happens on-chain. Any transaction that has enough gas to apply (~25000) but not enough to fully execute the ECDSA contract (539745 for a simple transaction with no data) ends up behaving differently on L1 and L2.</p><p>On L2, EVM catches it as a revert at the account level. Nonce is not increased, gas payment is not transferred. On L1, the fee transfer and nonce increase succeed, the actual call fails because that’s where the user-specified gas limit is applied by the fraud proof simulation.</p><p>Therefore, the L1 (fraud proof) state is changed, but in L2 the transaction had no effect so the L2 state root remained identical to the previous batch despite the chain progressing, something that should never occur.</p><p>The exploit was as simple as sending an empty transaction with gas limit 25000, then submitting a fraud proof:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f43111f6edbd304c3ca839f1494ce087/href">https://medium.com/media/f43111f6edbd304c3ca839f1494ce087/href</a></iframe><p>The successful fraud proof output is available <a href="https://gist.github.com/yoavw/9518419b5da00604cbba97325f28004c">here</a>.</p><h4>Bypassing gas protection: nested transactions</h4><p>In April 2021 I pulled the latest OVM version (tag v0.2.0) and saw that the non-contract, gas based exploits stopped working. That surprised me, because fixing the gas calculations in a single-round fraud proofs system seemed nearly impossible. A closer look revealed that the sequencer just started ignoring the user-specified gas limit and hardcoded it to 9000000, which eliminated a whole class of gas related attacks I previously implemented.</p><p>To fix my exploits, I needed them to work without relying on specifying my own gas limits. Luckily, account abstraction came to my aid again.</p><p>The ECDSA contract is normally called by the sequencer, but nothing stops it from being called by other contracts, or even by itself in a nested call. As long as the inner call includes the ECDSA signature of such EOA emulation, it can make a call from that account. This enables some fun transactions, such as a transaction that increments the nonce multiple times, or incrementing the nonces of multiple accounts within the same transaction.</p><p>As a side note, transaction-nesting also enabled creation of contracts from a secondary EOA during a fraud proof without going through the ovmCREATE checks, allowing the created contract to break out of the sandbox, whereas the same creation would fail on L2 due to the ovmCREATE checks. This attack is complex so we’ll stick to simpler ones in this post.</p><p>I used nesting to fix the above <em>ovm_exploit3.py</em>, crafting a multi-layer transaction involving multiple accounts. Given enough layers, one nonce will behave differently on L1 and L2:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c2e8a8e1020c866615baff1367b2e82f/href">https://medium.com/media/c2e8a8e1020c866615baff1367b2e82f/href</a></iframe><p>The successful (albeit long) fraud proof output is available <a href="https://gist.github.com/yoavw/3679ceadc8dd0ce1eef0bf8ed085fc69">here</a>.</p><p>I implemented a couple more exploits in the anonymous non-contract category, but hopefully the ones above make it sufficiently clear that single-round fraud proofs are hard to secure.</p><p>Any of these exploits could have been used for time-traveling attacks.</p><h3>Reality-distortion attack by a malicious sequencer</h3><p>An unprovable malicious state transition could alter the on-chain reality. If a legitimate transaction cannot be simulated, a malicious sequencer could abuse it to make an arbitrary state change, such as minting the entire L1 liquidity in the bridge to itself on L2 and starting a withdrawal to L1. This would only be exploitable as a rugpull by the sequencer operator, which is currently permissioned, but when the rollup is decentralized it could become a major issue.</p><h4>Unprovable fraud: abusing fraud-proof gas checks</h4><p>In the final stage of the fraud proof, the prover must call <a href="https://github.com/ethereum-optimism/optimism/blob/8d67991aba584c1703692ea46273ea8a1ef45f56/packages/contracts/contracts/optimistic-ethereum/OVM/verification/OVM_StateTransitioner.sol#L323">OVM_StateTransitioner.applyTransaction</a> to simulate the transaction. The state transitioner performs certain checks, such as <a href="https://github.com/ethereum-optimism/optimism/blob/8d67991aba584c1703692ea46273ea8a1ef45f56/packages/contracts/contracts/optimistic-ethereum/OVM/verification/OVM_StateTransitioner.sol#L340">this gas check</a>, causing it to revert if conditions are not met.</p><p>Furthermore, OVM_ExecutionManager.run called by OVM_StateTransitioner.applyTransaction actually calls the user transaction with <a href="https://github.com/ethereum-optimism/optimism/blob/8d67991aba584c1703692ea46273ea8a1ef45f56/packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_ExecutionManager.sol#L209">less gas</a> than the user-specified amount.</p><p>If a valid L2 transaction makes it impossible to complete applyTransaction on L1 without reverting, then the sequencer would be able to attest to an arbitrary state root. Everyone will be able to tell that it is wrong, but it will be impossible to prove it on chain and undo it. The sequencer could exploit this, minting itself any amount of L2 tokens and then sending them to L1 through the canonical bridge, effectively draining the bridge.</p><p>OVM tried to prevent this by <a href="https://github.com/ethereum-optimism/optimism/blob/8d67991aba584c1703692ea46273ea8a1ef45f56/packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_ExecutionManager.sol#L1696">limiting the gas</a>, but this limitation is applied too late, in OVM_ExecutionManager.run, so it doesn’t take calldata size into account. It is therefore possible to create a transaction that uses slightly less than the maximum gas but also has calldata padding, making it impossible to simulate on L1 due to mainnet block gas limit. The gas check during applyTransaction will always revert for such transaction because even if the L1 transaction started with gasleft() as high as the block gas limit, it still won’t satisfy <em>(gasleft() &gt;= 100000 + _transaction.gasLimit * 1032 / 1000)</em> due to the pre-incurred calldata cost.</p><p>An easy way to exploit this is to use the above nested-transaction exploit and specify a large padding value. I won’t repeat the nearly identical code (available <a href="https://gist.github.com/yoavw/3d36467216d7f798d6715f2d1e71a293">here</a> for completeness), but <a href="https://gist.github.com/yoavw/e14f4f7d940e3da649d3c742372f5fe5">here</a> is the failed fraud proof attempt. The important part in this output is the revert at the end: “<a href="https://gist.github.com/yoavw/e14f4f7d940e3da649d3c742372f5fe5#file-ovm_exploit8-log-L295"><em>Not enough gas to execute transaction deterministically.</em></a>” which makes it impossible to complete the fraud proof.</p><p>This class of vulnerabilities demonstrates an important point: If fraud proofs become too complex, they could make full decentralization too risky. A malicious sequencer could corrupt and rugpull the entire rollup if it can make an unprovable state transition.</p><p>Fraud proofs shouldn’t have less security checks than normal execution, but they also shouldn’t have more security checks. They must behave identically.</p><h3>Timeline: How I came to explore time travel</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*yBoZZJxiJ2pfglgl.JPG" /></figure><p>I’ve been fascinated with the idea of EVM fraud proofs since I first heard about them and realized the time-travel potential they carry if abused. I previously used fraud proofs in my own designs, e.g. <a href="https://github.com/opengsn/gsn/blob/f1e4cb6e73dcfc44fca95cb6f67ea630b8235d1b/packages/contracts/src/Penalizer.sol#L160">in GSN</a>, but applying fraud proofs to arbitrary code is a different level. Arbitrum <a href="https://www.youtube.com/watch?v=BpzrLOk4Zy0&amp;ab_channel=CITPPrinceton">pioneered</a> this idea in 2015, but full execution was not simulated on L1.</p><p>On 16 Jan 2021 Optimism <a href="https://medium.com/ethereum-optimism/mainnet-soft-launch-7cacc0143cd5">announced</a> the oncoming mainnet launch and I got curious about how they tackled the incredible complexity of single-round fraud proofs, so I just had to take a close look.</p><p>Optimism planned to go live on mainnet in April 2021, but then I realized that it was <a href="https://blog.synthetix.io/l2-mainnet-launch/">already on mainnet</a> with an app-specific chain for Synthetix, having more than $100M worth of SNX staked through its <a href="https://etherscan.io/address/0x045e507925d2e05d114534d0810a1abd94aca8d6/advanced#tokentxns">L2 bridge</a> shortly after its launch. This added some urgency to my curiosity. I spent the next two months full-time digging deep into the platform.</p><p>In the course of this research I found some vulnerabilities and implemented proof-of-concept exploits, such as the ones in this post.</p><p>Since there were already funds at risk, it was important to practice responsible disclosure. There was no Optimism bounty at the time (they have a <a href="https://immunefi.com/bounty/optimism/">great one</a> now), and I didn’t know the team so I wasn’t sure how to safely report the issues. Finally, in April 2021 Vitalik introduced me to the Optimism team (thanks!) and we had a long telegram chat followed by a zoom call to discuss the OVM security model. The team was very attentive and transparent, and I really enjoyed discussing fraud proofs security with like-minded researchers.</p><p>OVM-1 fraud proofs were disabled on mainnet, eliminating all the associated risks. To be enabled soon, in a much better form — Cannon!</p><p>I’d like to also use the opportunity to thank Optimism for the retroactive grant for my security research. Retroactive grants are a perfect fit for supporting research.</p><h3>Single-round vs. interactive fraud proofs</h3><p>Fraud proofs can be implemented in two ways: a single-round simulation or as an interactive verification game. The former is simpler to implement, but as shown above, has certain security and usability drawbacks.</p><p>In single-round proofs, the prover reconstructs the required subset of the last good state before the fraudulent transaction, proves it against the state root of the last good transaction, and then simulates the entire fraudulent transaction within a single transaction. Optimism implemented this approach in <a href="https://research.paradigm.xyz/optimism">OVM-1</a>.</p><p>In interactive proofs, the prover and the sequencer engage in a verification game, proving the execution. When they reach the point of disagreement — a single instruction where their results differ — they only need to simulate that instruction on-chain, using its inputs and comparing its output. Most of the verification happens off-chain, but with an on-chain mechanism to ensure timely participation of both parties. Arbitrum implemented this approach in AVM as described <a href="https://developer.offchainlabs.com/docs/inside_arbitrum">here</a>, and Optimism is implementing it in OVM-2 <a href="https://twitter.com/ben_chain/status/1488275950877872128?">using Cannon</a>.</p><p>Single-round proofs have a significantly larger attack surface. The contract’s state machine consists of the entire executed transaction, so the number of possible states is only bound by the number of possible execution flows in EVM. All the complexities and corner cases of EVM come into play. Interactive proofs, on the other hand, only simulate a single opcode, so the number of states is bound by the number of architecture opcodes and their possible inputs. Arbitrum’s <a href="https://github.com/OffchainLabs/arbitrum/blob/9483d8de5bb9ea4c4d4f71804a512976dd259493/packages/arb-bridge-eth/contracts/arch/OneStepProof.sol">OneStepProof.sol</a>, for example, only needed to prove 79 opcodes — probably small enough to achieve full test coverage of the state machine.</p><p>Single-round proofs also impose a limit on the gas used by a transaction, as it needs to be simulated inside another transaction. This introduces usability problems such has limiting contract size and not being able to perform certain EVM flows that are possible on L1. Optimism switching to interactive proofs in OVM-2 enabled EVM equivalence, which was impossible with OVM-1. This switch is the right design choice, for many reasons.</p><p><em>The exploits demonstrated in this post were implemented against OVM-1. At the time of writing this, there are no published unpatched OVM-2 vulnerabilities.</em></p><h3>Cannon: OVM-2 fault proofs</h3><p>Optimism recently <a href="https://medium.com/ethereum-optimism/cannon-cannon-cannon-introducing-cannon-4ce0d9245a03">announced Cannon</a>, the interactive fault proofs (formerly known as fraud proofs) implementation built by geohot.</p><p>I won’t fully explain it here, as Ben explains it far better than I could, but the general idea is not to have a separate EVM implementation at all, which was the root cause of all the vulnerabilities described in this posts. Instead, it interactively proves a subset of the MIPS instruction set, and compiles a subset of geth (aka minigeth) which implements the EVM state transition. Therefore, the EVM running in L2 (implemented in l2geth) should behave exactly like the EVM proven on L1.</p><p>Cannon uses a subset of the MIPS opcodes, needing to prove just <a href="https://github.com/ethereum-optimism/cannon/blob/24c78db43cf1d10e6d37d53e4ea63ecd40ba03e8/mipsevm/README#L7">55 opcodes</a> used by minigeth, making its state machine sufficiently small for full test coverage, effective fuzzing, and possibly formal verification.</p><p>The new architecture makes OVM-2 strictly better than OVM-1: EVM equivalence, minimal attack surface due to the switch to interactive proofs, and minimal differences from geth, reducing the risk of a difference between L1 and L2 execution environment.</p><p>The switch to interactive proofs requires researching new attack vectors. For example, the mechanism design and implementation for ensuring timely participation of both sides in the challenge game must be reviewed carefully.</p><p>Interestingly, Arbitrum has been working on their next-gen <a href="https://medium.com/offchainlabs/arbitrum-nitro-sneak-preview-44550d9054f5">Nitro</a> architecture for some time now, and it seems to work the same way: it removes AVM and compiles the geth state transition code to WASM (same architecture choice made by Truebit). The implementation is not available yet, but it seems that both projects will end up using similar proof systems eventually. I’m looking forward to exploring and comparing both.</p><h3>Bridges: a word of caution</h3><p>If fraud proofs are ever exploited on mainnet, the primary victim will probably be <a href="https://www.optimism.io/apps/bridges"><em>Fast Bridges</em></a>. The liquidity providers of these bridges effectively insure their users against attacks that abuse the fraud proofs system. It is therefore advised that these projects take some precautions to protect their liquidity:</p><ol><li>Limit the available liquidity to keep the risk bounded. For example, avoid “unlimited liquidity” as <a href="https://forum.makerdao.com/t/introducing-maker-wormhole/11550/1">proposed by MakerDAO</a>, minting unlimited DAI on L1. An attack like the ones demonstrated above could result in severe undercollateralization and put the protocol at risk. I hope the Wormhole team will consider enforcing limits on the L1 side.</li><li>Running a <strong>real</strong> fraud prover on the bridge oracles, fully attempting to fraud-prove any transaction on a mainnet fork. It’s more computationally expensive than just watching L2 state (as the OVM-1 fraud prover did) and requires doing this for all L2 transactions, not just the ones related to the bridge. But it would have prevented all the attacks above and any form of time-travel attack, as well as reality distortion attacks. The chain would have still rolled back or altered, but the bridges would be frozen immediately so no funds would be lost.</li><li>Consider fraud-proof insurance. Loss is provable on-chain, making on-chain insurance claims easy. Maybe projects like <a href="https://nexusmutual.io/">Nexus Mutual</a> could offer some assurance to liquidity providers.</li></ol><h3>The future of fraud proofs</h3><p>Optimistic rollups are converging on geth-based EVM implementations and interactive proofs of geth execution. Hopefully both <a href="https://medium.com/ethereum-optimism/cannon-cannon-cannon-introducing-cannon-4ce0d9245a03">Cannon</a> and <a href="https://medium.com/offchainlabs/arbitrum-nitro-sneak-preview-44550d9054f5">Nitro</a> will go live in the next few months. The attack surface will subsequently become smaller and easier to secure.</p><p><strong>Bounties</strong> will incentivize security research, not just on rollup bridges but also fraud proofs security. Optimism already started a <a href="https://immunefi.com/bounty/optimismcannon/">$50k bounty</a> for Cannon (which I hope they’ll eventually merge into their <a href="https://immunefi.com/bounty/optimism/">$2M bounty</a> when Cannon is merged into OVM-2) and Arbitrum has a <a href="https://immunefi.com/bounty/arbitrum/">$1M bounty</a> covering their fraud proofs as well. Have fun exploring time-travel and make money too!</p><p>As Optimistic rollups matures, it’ll become safer to increase the liquidity in <em>Fast Bridges</em>.</p><p>In a more distant future, maybe we will see optimistic rollups using multiple implementations of their fraud proofs to increase security. This is similar to Ethereum’s multi-client approach, where a bug in a single client is unlikely to lead to a consensus failure. The community could develop multiple implementations of L1 EVM provers, and rollups could opt to use a number of them after they are sufficiently tested. A failure in a single fraud proof implementation, while the other implementations consider the state transition to be valid, would result in the removal of the buggy implementation rather than an L2 chain revert. Finding a vulnerability that will work similarly against multiple fraud proof implementations will be much harder than attacking any single implementation.</p><h3>Conclusion</h3><p>This long post demonstrated why fraud proofs can be risky and how they could be exploited. It also discussed ways to mitigate the risk, and took a glimpse into the future of optimistic rollups.</p><p>My hope is to raise awareness and attract security research and resources, to ensure fraud proof safety and prevent risky time-traveling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3GlFW4e89pu3RH9b.jpg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6680567f1864" width="1" height="1" alt=""><hr><p><a href="https://medium.com/infinitism/optimistic-time-travel-6680567f1864">Optimistic time-travel</a> was originally published in <a href="https://medium.com/infinitism">Infinitism</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[United We Stand! (In a Trustless Way)]]></title>
            <link>https://medium.com/tabookey/united-we-stand-in-a-trustless-way-fd28ecf4126f?source=rss-c0013a425528------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd28ecf4126f</guid>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Yoav Weiss]]></dc:creator>
            <pubDate>Thu, 08 Aug 2019 07:33:05 GMT</pubDate>
            <atom:updated>2019-08-08T07:33:05.912Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>“the future is ours… if you can count!” — <a href="https://www.youtube.com/watch?v=tcc2ltIjNU0">Cyrus, 1979</a></blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Ftcc2ltIjNU0%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dtcc2ltIjNU0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Ftcc2ltIjNU0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/670bc2827c6a596c245940b4d129c36a/href">https://medium.com/media/670bc2827c6a596c245940b4d129c36a/href</a></iframe><h3>The story of the Gas Stations Network</h3><p>In early 2018 we encountered a problem. We wanted to onboard users who had no ETH to pay for gas. Little did we know back then, that this problem haunted many other projects. That got us started on a journey that got us to where we are today — launching GSN on mainnet.</p><p>We started developing our own solution, based on the idea of Meta-Transactions, like many other projects did. Place a relay between the user and the blockchain, let the relay pay for the user’s gas and deliver the transaction.</p><p>It solved the usability problem, but at a cost we weren’t willing to incur — having a single point of failure. A dapp is as decentralized as it’s most centralized component, so now it’s as fragile as a single host instead of being as robust as the entire blockchain.</p><h4>Decentralizing, the selfish way.</h4><p>Our next step was to design a private decentralized network of relays, increasing our dapp’s robustness by adding more relays with no centralized components. We would host relay nodes in different locations, different hosting providers (e.g. Amazon AWS, Google Cloud, Microsoft Azure). Our relays network would be as robust as the amount of money we’re willing to spend on maintaining more relays, although never as robust as the Ethereum blockchain itself.</p><p>Something still bothered us. There was still a single point of failure — us! Even if taking the relays network through a denial-of-service attack was no longer feasible, a powerful attacker could still take it down by attacking us, rather than our relays. A legal attack or a financial attack, for example, could force us to take all of the relays down and bring the network down, denying our users access to the dapp. Or someone could apply violence and force us to do this, at gunpoint.</p><p>We want something better for our users. Something… like the blockchain.</p><h4>Robust as the blockchain itself!</h4><p>What makes the blockchain robust? Why can it withstand censorship attacks better than anything else we know?</p><p>The answer is safety in numbers, and decentralization. No single person or entity operates the blockchain. There are way too many nodes to perform a DoS attack. There’s no single entity to threaten legally or hold at gunpoint. Taking a single dapp down requires taking all of them down.</p><p>Any new dapp attracts more traffic, driving an increase in the number of nodes. Therefore, the more dapps exist, the more robust each of them becomes.</p><p>In fact, the blockchain is better than robust. It is <a href="https://en.wikipedia.org/wiki/Antifragile">antifragile</a>! An attempt to take it down for the purpose of killing a single dapp would actually incentivize people to run more nodes and the blockchain would grow stronger as a result of the attack.</p><p>Then it dawned on us…</p><h4>United we stand, divided we fall!</h4><p>Projects that run a single relay are fragile. Projects that run a private network of relays are somewhat robust. But if all projects combined forces together, the network becomes <a href="https://en.wikipedia.org/wiki/Antifragile">antifragile</a>. No one will take us all down!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CS8lsVrL9NicsEg6LtXmBQ.png" /></figure><p>Inspired by <a href="https://www.youtube.com/watch?v=tcc2ltIjNU0">Cyrus</a>, we went to work. But as Cyrus teaches us, uniting everyone is tricky. Different and competing interests collide, and thus Cyrus has failed. Can we avoid that fate?</p><p><strong>YES WE CAN!</strong></p><p>We just need to find a way to build a trustless decentralized network of relays, incentivizing each participant to cooperate. Classic game theory style.</p><p>We designed and built a relay network whose robustness increases as more dapps join. Relays are incentivised to watch each other and slash non-cooperating relays, but cannot abuse this power. Participants don’t need to trust each other in order to work together. An attempt to flood the network will just increase the fees, making it more profitable to run more relays, increasing the robustness of the network. Antifragile.</p><p>As a community, we’re stronger together, as long as we can keep things trustless. By pooling our resources, we make gasless transactions as robust as the blockchain itself. Taking one project down requires bringing the entire network down.</p><p>How does it work? I explained it in <a href="https://medium.com/tabookey/1-800-ethereum-gas-stations-network-for-toll-free-transactions-4bbfc03a0a56">1–800-Ethereum</a> and in <a href="https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1613.md">EIP-1613</a>.</p><h4>No owner, no single point of failure.</h4><p>The RelayHub contract, the heart of GSN, is an autonomous and owner-less contract, and all participants are equal. No one, including us, could bring the network down.</p><p>Our next step was to make the GSN project itself robust, built to outlast us if needed. We formed the <strong>GSN alliance</strong>. An increasing number of projects and companies, committed to using GSN, running relays to increase the capacity (while guaranteeing service for themselves of course), and participating in the maintenance of the code base.</p><h4>…and we’re on!</h4><p>Today we are launching the Gas Stations Network on mainnet, as public infrastructure for the benefit of the Ethereum community. It will serve everyone, and not be controlled by any one entity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*zJpOIK-Fp2OjCeh_DQEw3g.png" /></figure><p>Special thanks to GSN alliance members, <a href="https://openzeppelin.com/">OpenZeppelin</a> who performed the GSN security audit and joined us in building and maintaining the code, to <a href="https://www.metacartel.org/">MetaCartel</a> for bringing everyone together and spreading the word, and to <a href="https://www.ethereum.org/">Ethereum Foundation</a> and <a href="https://consensys.net/">ConsenSys</a> who generously provided grants to help us get GSN to mainnet.</p><h4>Come aboard!</h4><p>Want to start using GSN in your dapp? Check our <a href="https://github.com/tabookey/tabookey-gasless">github</a> for examples, or try an existing integration from <a href="https://openzeppelin.com/">OpenZeppelin</a> or <a href="https://www.portis.io/">Portis</a>. Also find us at the <a href="https://t.me/joinchat/HXGtDkjG0CpHv87hfGpXCA">Gas Stations Network support group</a> in Telegram.</p><h4>What’s next?</h4><p>Now that GSN is available, we’re going to keep the momentum going:</p><ul><li>Keep improving the tools around GSN, with the help of our friends at <a href="https://openzeppelin.com/">OpenZeppelin</a> and other contributors.</li><li>Building great projects on top of GSN. We at <a href="https://www.tabookey.com/">TabooKey</a> are building a great product using GSN. We’re also excited to see teams like <a href="https://www.portis.io/">Portis</a> building dapps with great UX by utilizing GSN.</li><li>Extending GSN to support more complex use-cases. We’re working with our friends at <a href="https://makerdao.com/">MakerDAO</a> to make dapps even more accessible to everyone.</li><li>Decentralized Infrastructure Network — GSN is just the start! DIN will extend the idea of GSN beyond meta-transactions, using game theory to provide trustless access to the blockchain without having to run an Ethereum node. More on that in a future post.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd28ecf4126f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tabookey/united-we-stand-in-a-trustless-way-fd28ecf4126f">United We Stand! (In a Trustless Way)</a> was originally published in <a href="https://medium.com/tabookey">TabooKey</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[1–800-Ethereum: Gas Stations Network for Toll Free Transactions]]></title>
            <link>https://medium.com/tabookey/1-800-ethereum-gas-stations-network-for-toll-free-transactions-4bbfc03a0a56?source=rss-c0013a425528------2</link>
            <guid isPermaLink="false">https://medium.com/p/4bbfc03a0a56</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[crypto]]></category>
            <dc:creator><![CDATA[Yoav Weiss]]></dc:creator>
            <pubDate>Wed, 09 Jan 2019 19:15:36 GMT</pubDate>
            <atom:updated>2019-02-17T10:50:53.743Z</atom:updated>
            <content:encoded><![CDATA[<p><em>“The greatest victory is that which requires no battle</em>.” — Sun Tzu</p><p><a href="https://www.tabookey.com/">TabooKey</a> needed a trustless decentralized way of onboarding new users that don’t have ETH to pay for gas fees. To our frustration, we couldn’t find a solution that would give us both security and usability. Finally, by looking at the problem from a fresh angle, we had a eureka moment that allowed us to come up with a simpler, more decentralized and robust approach that provides a general purpose toll free interface for smart contracts. We’re sharing this so everyone who wants to create dapps with great user experiences can benefit!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*L0WhOdphzuJKQ16DRxEkSQ.jpeg" /></figure><h3><strong>The dapp onboarding paradox</strong></h3><p>Dapps gain value through network effect. The first users get little value, but value increases as more users join. However, users need to jump through hoops — go to an exchange, pass a KYC process and wait for approval, transfer money from their bank, buy ETH, install MetaMask, learn how to use it and transfer ETH to it, etc. All that, just to start using a dapp that offers little value at that point. Result: users are not coming and dapps are not taking off. Even Facebook offered little value to its first users, but at least it was easy to join and see if it catches on.</p><p>And there’s another paradox within that paradox. Interacting with a Decentralized App requires purchasing ETH at a Centralized exchange with a KYC process, which excludes the unbanked population. It goes against the spirit of blockchain and decentralization.</p><h3><strong>But wait, don’t existing meta-tx frameworks or proposals solve the problem?</strong></h3><p><strong>What are meta transactions?</strong></p><p>The idea of meta transactions isn’t new: Signing a transaction with a key that doesn’t own ETH, and then wrapping it with another transaction signed by a key that does own ETH, to pay for the gas. The recipient contract “peels” the outer transaction and uses the inner one.</p><p>There are currently two types of meta-tx solutions:</p><p><strong>Centralized relays</strong></p><p>Some dapps deploy a single, or a small number of relayers to mediate access to their contracts. Here lies another paradox, requiring a centralized relay (or a small number of relays) to use a decentralized app. Attack or malfunction of this relayer could result in censoring some or all transactions to the dapp. The relayer is a single point of failure. Corollary: <em>a dapp is as decentralized as its most centralized component.</em></p><p><strong>Decentralized relays</strong></p><p>An idea that keeps coming up is a decentralized network of relayers watching a secondary transactions-pool and acting as secondary miners. They all suffer from a synchronization problem: A relayer can only relay one transaction at a time, so each relayer picks the (same) most profitable transaction and relays it. Only one of them will succeed, and all others will get reverted and lose money, while the less profitable transactions are never “mined”. Attempts to solve this <a href="https://en.m.wikipedia.org/wiki/Thundering_herd_problem">Thundering Herd</a> problem involve using consensus protocols such as Proof of Work. As a result, etherless transactions need to be mined twice, and take much longer than normal transactions. Furthermore, the cost of running each relay increases, which in turn increases the transaction fees.</p><p>Another problem with the secondary transactions-pool approach is access from restricted/proxied networks (e.g. enterprise or government), or from mobile devices with limited background processing. P2P protocols are often blocked in such scenarios, and apps have to fall back to http.</p><p><strong>Can we solve these problems without becoming centralized?</strong></p><p>What if we could achieve decentralization without having to solve the Thundering Herd problem at all, while using only http? As Sun Tzu teaches us, <em>the greatest victory is that which requires no battle</em>.</p><p><strong>Key insights that led to the solution:</strong></p><ul><li>It’ll be easier to bootstrap dapp network effect if we subsidized interaction with the contract. Could dapps have a toll-free 800 number?</li><li>The person who signs the transaction doesn’t have to be the person paying for the gas. The dapp just needs a way to know who the real sender is.</li><li>To stay decentralized, all components have to be incentivized.</li><li>Transaction-pool based solutions lack synchronization. P2P solutions would require consensus, e.g. proof-of-work, which would make gasless transactions slower than regular transactions. Resorting to distributed consensus mechanisms comes from group-think we have in our blockchain community. It’s an overkill if we can achieve decentralization without it.</li><li>Clients in restricted network environments cannot reliably communicate with P2P networks. In order to scale quickly, we must use commonly supported protocols.</li><li>The sender is already motivated to get the transaction to the dapp, and is, therefore, most suitable to drive the process. How could we empower the sender to control the process?</li><li>Instead of a public pool of transactions, we can use a public pool of relayers and let the sender select one.</li><li>To put the sender in control, we need to give it a way to find a relay, negotiate its fee, verify its reliability, and send the transaction.</li><li>Relayers are like miners. They may act selfishly and abuse the system if it would increase their profits. The solution will only be robust if it doesn’t require trusting them.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V-wzyTZmodhEK7pCRWxm2A.png" /></figure><h3><strong>What is the Gas Stations Network?</strong></h3><p>Gas Stations Network is a decentralized and trustless way to add reverse-charge calls to smart contracts. The dapp takes care of paying for verified transactions, so users can start using the dapp immediately.</p><p>Depending on the business model of the dapp, it may charge the users through other means, such as credit cards, or it may sponsor the transactions while capturing value elsewhere.</p><h3><strong>What is the Gas Stations Network not?</strong></h3><p>It’s not an L2 solution. It just utilizes an L2 network to reliably deliver L1 etherless transactions.</p><p>It’s not a protocol modification and does not require a hard fork or even a soft fork. It is agnostic to L1 implementation and will continue to work unchanged as Ethereum evolves. Therefore, dapps can start using it immediately and the network will scale to accommodate it. There’s already a working GSN on the Ropsten test network.</p><h3><strong>How does it work?</strong></h3><p><strong>Gas stations</strong></p><p>The network consists of gas stations (relays), publishing their fees and URLs on the blockchain, accepting etherless transactions from users, filling them with gas by signing them, returning them to the user, relaying them to the blockchain and getting compensated for their effort. Gas stations and users don’t trust each other, which leads us to…</p><p><strong>Anchor of Trust</strong></p><p>A single open-source smart contract, RelayHub, acts as registrar for relays, mediates transactions between relays and dapp contracts, and emits events that help users find relays and assess their reputation. RelayHub holds small deposits from dapps and uses them to compensate relays for transactions accepted by dapps.</p><p>Relays are required to stake ETH in RelayHub when they register. The stake is used to prevent certain DoS or censorship attacks, described in the <a href="https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1613.md#attacks-and-mitigations">attacks section of EIP 1613</a>. Honest relays earn transaction fees, and provably dishonest relays lose their stake.</p><p>The entire interaction between a user and a relay is a short-lived http session. At the end of this http transaction the user gets a performance bond that keeps the relay honest, so the user knows that the transaction has been relayed without having to wait for mining to occur. A failed request can be detected immediately, and the user proceeds to the next relay. The network is censorship resistant as long as there is at least one honest relay.</p><p><strong>The user app</strong></p><p>From the user’s perspective, the app (web or mobile) transparently selects a relay and delivers the transaction to the blockchain. Behind the scenes, the app selects a relay using on-chain information about transaction fees and ongoing reputation, attempts to send the transaction through the selected relay, knows immediately whether the request was handled, or retries with the next relay. The immediate validation process enables fast iteration, so malfunctioning or malicious relays cannot cause long delays, and the transaction gets delivered in a timely manner.</p><p>The full technical details, attacks and mitigations, are beyond the scope of this post, and are available in <a href="https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1613.md">EIP 1613</a>.</p><h3><strong>How can my dapp use it?</strong></h3><p>The Gas Stations Network lets the dapp accept reverse charge calls and pay for transactions’ gas, supporting etherless users. The particular funding model depends on the business model of the dapp. Let’s demonstrate it through a couple of examples:</p><ul><li>SalesChain, a paid dapp, may wish to onboard etherless users and charge them through credit cards. In this case, our user, Joe, will sign in to SalesChain and buy gas credit using any supported method, e.g. PayPal. SalesChain will use the received funds to purchase ETH and deposit it in RelayHub to compensate relays. Joe will be allowed to make as many etherless transactions as he has credit for. Joe cannot exhaust SalesChain’s deposit since he’s limited to his own credit.</li><li>CryptoUnicorns, a fun social game, may wish to pay for its users, not charge them for it, and monetize them through other means such as in-app advertising or selling unicorn accessories. In this case, Joe will sign in, using uPort or other commonly used identity methods such as his Google or Facebook account. CryptoUnicorns will grant Joe tokens and allow him to make a certain amount of daily etherless transactions. If Joe tries to exhaust CryptoUnicors’ deposit, he will eventually lock himself out of the game by exhausting his own quota instead.</li><li>Joe works at Pineapple Unincorporated, a DAO that wishes to always pay for its known participants, funding the transactions from its revenues. In this case, Pineapple will accept requests only from Joe and his known peers, Alice and Bob, and not charge them in any way. If Joe abuses this trust and wastes Pineapple’s deposit for no good reason, Alice and Bob can vote him out, so he will no longer be able to send etherless transactions.</li></ul><p>The Gas Stations Network doesn’t impose any restrictions on how the dapp chooses to manage its funding. It just solves the UX problem, allows onboarding users quickly, and gives dapps the tools to manage its own accounting.</p><h3><strong>I want to try it! What do I need to do?</strong></h3><p>The change required in the dapp contract is minimal. It just needs to become aware of RelayHub, in order to accept or reject transactions, get the real sender, and maintain a small deposit of ETH for compensating relays.</p><p>Changes to the app are also minimal, as web3 is hooked to find and use relays instead of sending regular transactions. The hook can use MetaMask if installed or generate and use ephemeral keys.</p><p>We took a Metacoin sample, <a href="https://github.com/tabookey/webpack-box/blob/master/contracts/MetaCoin.sol">modified</a> it to support our relay network, and <a href="https://gsn.tabookey.com/metacoin/index.html">deployed</a> it to the Ropsten network. It uses our <a href="https://relay2.duckdns.org:8090/getaddr">deployed</a> <a href="https://atbk.duckdns.org:8090/getaddr">relays</a> to access the Ropsten <a href="https://ropsten.etherscan.io/address/0x1349584869a1c7b8dc8ae0e93d8c15f5bb3b4b87">RelayHub</a>. You can also take a look at some samples in the <a href="https://github.com/tabookey/tabookey-gasless">GSN repository</a>,</p><p>In our <a href="https://medium.com/tabookey/how-to-make-your-dapp-gasless-da15d4d3cacd">next</a> posts we’ll focus on the technical aspects of making an existing dapp use the Gas Stations Network.</p><h3><strong>Conclusion</strong></h3><p>Gas Stations Network solves one of Ethereum’s biggest UX challenges — onboarding users quickly and effortlessly, helping dapps scale quickly. It does so in a trustless and decentralized way, and without requiring any changes to how Ethereum works.</p><p>The network is intentionally designed to serve the community and not capture value. <a href="https://www.tabookey.com/">TabooKey</a> decided to publish it as <a href="https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1613.md">EIP 1613</a> and a <a href="https://github.com/tabookey/tabookey-gasless">free implementation</a>. The only way to profit from the network is to run a gas station (a relay server) and compete in the free market, based on transaction fee and reliability metrics. Once we deploy it on mainnet, we will not be in control of the network. As the number of dapps using the network increases, we expect the network to scale up with more relays joining to make a profit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4bbfc03a0a56" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tabookey/1-800-ethereum-gas-stations-network-for-toll-free-transactions-4bbfc03a0a56">1–800-Ethereum: Gas Stations Network for Toll Free Transactions</a> was originally published in <a href="https://medium.com/tabookey">TabooKey</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>