<?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 François-René Rideau on Medium]]></title>
        <description><![CDATA[Stories by François-René Rideau on Medium]]></description>
        <link>https://medium.com/@phanaero?source=rss-bc914ed341b4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Exl-7z4cJf0Zo4vNWbIobA.jpeg</url>
            <title>Stories by François-René Rideau on Medium</title>
            <link>https://medium.com/@phanaero?source=rss-bc914ed341b4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 11:21:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@phanaero/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[Composing Contracts without Special Provisions — using Blockchain History]]></title>
            <link>https://medium.com/hackernoon/composing-contracts-without-special-provisions-using-blockchain-history-66b588e25891?source=rss-bc914ed341b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/66b588e25891</guid>
            <category><![CDATA[alacris]]></category>
            <category><![CDATA[composition]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[François-René Rideau]]></dc:creator>
            <pubDate>Fri, 26 Apr 2019 20:55:42 GMT</pubDate>
            <atom:updated>2019-05-03T12:48:40.945Z</atom:updated>
            <content:encoded><![CDATA[<h3>Composing Contracts without Special Provisions — using Blockchain History</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*SsG6YYKiJQVLixfsYWlVZA.jpeg" /></figure><p>One feature I sorely miss in most existing blockchains is the ability to verify the <em>history</em> of the blockchain from within its contract language. Why so? Because this feature when present enables easy composition of contracts, without the contracts being composed having to offer a dedicated API to facilitate such composition, such as the awkward “allowances” of ERC20 contracts.</p><p>Indeed, thanks to access to blockchain history, it is possible to compose not just contracts that weren’t designed to be composed, but even contracts involving other parties who are not directly involved in the larger composition — whether you don’t want to involve them, or they refuse to make your life easy. It is even possible to compose contracts in a private way where no one needs know the details of the composed contract except its direct participants.</p><p>Let’s assume that someone wrote some cool contract to manage interesting assets, say cute lizards that scale, <a href="https://medium.com/alacris/cryptoscalies-cute-lizards-at-scale-5ac34e6cc2af">Cryptoscalies</a>, and someone else wrote another cool contract so your Cryptoscalies can wear T-shirts. Now let’s assume I want to sign a sponsorship contract with you, whereby I will pay you so that your famous lizard Scaly Cardassian shall wear a “Vote for Borg” T-shirt for the next month. One issue, though: neither the Cryptoscalies contract, nor the T-shirt contract, have any provision that can facilitate any such arrangement. Some other obligations may even prevent you from relinquishing control of your Cryptoscalies, even temporarily, to a contract we might otherwise have written to implement the arrangement. How can we implement this sponsorship contract still?</p><p>With access to the history, we can write a contract with the following terms: “if an event is posted before the start of the month whereby your lizard dons the T-shirt, and no event is posted thereafter and until the end of the month, that causes the T-shirt to be removed or covered — then I shall pay you the convened sponsorship reward, which until then is escrowed in this composition contract.” I can imagine other conditions in a sponsorship contract, but let’s focus on how we would resolve any potential dispute on whether or not you did fulfill this part of our deal.</p><p>As long as we both agree on the outcome, we can simply sign a common settlement that assigns the escrowed funds to the deserving party. But what if we disagree? What if I somehow refuse to pay you though you did your part? Or, what if you demand payment even though you didn’t? How will the matter be resolved? How can a fair judge, automatically implemented by a “smart contract” on the blockchain consensus, adjudicate between our conflicting claims? Is there a way to resolve the issue without having to trust, pay and wait for a third party who’d act as arbiter?</p><p>All you have to do is prove to the consensus that you posted the T-shirt donning event before the beginning of the month, and didn’t post any contrary event until after the end of the month. Let’s assume that the blockchain gives access from each block to the entire event history as a Merkle trie, and gives direct access to a few hours worth of previous blocks from its contract scripting language. Then, to prove that your lizard did wear the T-shirt, you can tell the judge to look at a given recent block, and exhibit as evidence a Merkle proof that some transaction was posted that indeed represents the lizard wearing the T-shirt — with this evidence, you have a case, without it, you are thrown out of court. Now, proving that you did do something is easy, but you cannot so easily convince the judge that you did <em>not</em> post a contrary transaction whereby the lizard removes the T-shirt: for that, the judge would have to look back at each and every transaction between the donning of the T-shirt and the expiration date of the contract — and that definitely will not scale. What you can do, though, is challenge <em>me</em> to show any such transaction, if it exists as I claim it does. If I can show that indeed your lizard removed the T-shirt, by similarly exhibiting a recent block and a Merkle proof of inclusion from it, then you failed your contract and the judge will adjudicate in my favor. However, if I cannot provide such a counter-argument within my deadline, then the judge will adjudicate in your favor.</p><p>Using a field of mathematics known as <em>Game Semantics</em>, any formula quantified over the history of the blockchain can be transformed into such a “verification game,” and thereby be used in a contract. This enables the composition of arbitrary activities that were not otherwise designed to be composed.</p><p>Furthermore, these kinds of contracts can be kept private: the terms can be hidden from the public by only publishing a salted hash of these terms when initially signing the contract and escrowing collateral funds on the blockchain. Only in case of a dispute will the terms of the contracts have to be revealed. Actually, only one single clause of the contract has to be revealed, even though the contract can be very large and contain many clauses. The claimants can choose the simplest clause to argue, for instance the presence of brown M&amp;Ms in a contractually required bowl. Or they can pick whichever clause will maximize the damages they will be awarded, if the damages may vary with the clause.</p><p>To go one step further towards privacy, even the arguments themselves can be obscured using recursive zkSNARKs: all that bystanders would then see would be you and I sending O(1) proofs that remain impossible to decode by anyone not privy to our agreement. Yet all these bystanders, as well as the “judge” made of the “smart contract” and the blockchain consensus, will be able to check which one of us won this trial fairly and was adjudicated the escrowed funds. Actually, even the outcome of the trial can itself be kept private, using techniques pioneered by ZCash or MimbleWimble. All the public will then see is that some dispute happened, which was resolved according to objective justice, though no one but the parties involved will know either the topic of the dispute, or its conclusion.</p><p>And to achieve this composition of contracts, all we need from a blockchain is the ability to verify historical events — and of course, for suitable events to be emitted that we can reason about. To this end, we need the blockchain’s contract scripting language to give us access to recent block hash <em>and</em> we need each hash to commit to a trie of all past events. Interestingly, Ethereum only does the former. We can still achieve the latter, but to that end, <a href="https://github.com/amiller/ethereum-blockhashes">some contract</a> must maintain this trie and be called regularly to update it, and that’s a major hassle. If instead block miners maintained the trie, their cost at each block would only be logarithmic in the depth of the trie — just a few tens of hashes to carry — because nodes don’t need to remember the entire history to update these hashes, just the spine of the trie. As for remembering history, users will each be responsible for remembering the fragments of it that they care about.</p><p>Of course, the applications of this technology are not limited just to dressing cute lizards in T-shirts. They can be used to compose arbitrary contracts and create elaborate decentralized applications.</p><p>At <a href="https://alacris.io/">Alacris.io</a>, we are using the above technique among many others to build an operating system for decentralized applications. The applications we will enable will include atomic swaps between arbitrary financial products, elaborate financial contracts, scaling solutions based on side-chains, and much more. And we are hoping to convince blockchain implementers to actively support this history verification feature that will let us to compose decentralized applications in ways easier not harder than what Ethereum currently allows.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66b588e25891" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/composing-contracts-without-special-provisions-using-blockchain-history-66b588e25891">Composing Contracts without Special Provisions — using Blockchain History</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Composing Contracts without Special Provisions — using Blockchain History]]></title>
            <link>https://medium.com/alacris/composing-contracts-without-special-provisions-using-blockchain-history-9fcef0129518?source=rss-bc914ed341b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fcef0129518</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[composition]]></category>
            <category><![CDATA[alacris]]></category>
            <dc:creator><![CDATA[François-René Rideau]]></dc:creator>
            <pubDate>Fri, 26 Apr 2019 20:06:43 GMT</pubDate>
            <atom:updated>2019-05-03T12:42:16.371Z</atom:updated>
            <content:encoded><![CDATA[<h3>Composing Contracts without Special Provisions — using Blockchain History</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*SsG6YYKiJQVLixfsYWlVZA.jpeg" /></figure><p>One feature I sorely miss in most existing blockchains is the ability to verify the <em>history</em> of the blockchain from within its contract language. Why so? Because this feature when present enables easy composition of contracts, without the contracts being composed having to offer a dedicated API to facilitate such composition, such as the awkward “allowances” of ERC20 contracts.</p><p>Indeed, thanks to access to blockchain history, it is possible to compose not just contracts that weren’t designed to be composed, but even contracts involving other parties who are not directly involved in the larger composition — whether you don’t want to involve them, or they refuse to make your life easy. It is even possible to compose contracts in a private way where no one needs know the details of the composed contract except its direct participants.</p><p>Let’s assume that someone wrote some cool contract to manage interesting assets, say cute lizards that scale, <a href="https://medium.com/alacris/cryptoscalies-cute-lizards-at-scale-5ac34e6cc2af">Cryptoscalies</a>, and someone else wrote another cool contract so your Cryptoscalies can wear T-shirts. Now let’s assume I want to sign a sponsorship contract with you, whereby I will pay you so that your famous lizard Scaly Cardassian shall wear a “Vote for Borg” T-shirt for the next month. One issue, though: neither the Cryptoscalies contract, nor the T-shirt contract, have any provision that can facilitate any such arrangement. Some other obligations may even prevent you from relinquishing control of your Cryptoscalies, even temporarily, to a contract we might otherwise have written to implement the arrangement. How can we implement this sponsorship contract still?</p><p>With access to the history, we can write a contract with the following terms: “if an event is posted before the start of the month whereby your lizard dons the T-shirt, and no event is posted thereafter and until the end of the month, that causes the T-shirt to be removed or covered — then I shall pay you the convened sponsorship reward, which until then is escrowed in this composition contract.” I can imagine other conditions in a sponsorship contract, but let’s focus on how we would resolve any potential dispute on whether or not you did fulfill this part of our deal.</p><p>As long as we both agree on the outcome, we can simply sign a common settlement that assigns the escrowed funds to the deserving party. But what if we disagree? What if I somehow refuse to pay you though you did your part? Or, what if you demand payment even though you didn’t? How will the matter be resolved? How can a fair judge, automatically implemented by a “smart contract” on the blockchain consensus, adjudicate between our conflicting claims? Is there a way to resolve the issue without having to trust, pay and wait for a third party who’d act as arbiter?</p><p>All you have to do is prove to the consensus that you posted the T-shirt donning event before the beginning of the month, and didn’t post any contrary event until after the end of the month. Let’s assume that the blockchain gives access from each block to the entire event history as a Merkle trie, and gives direct access to a few hours worth of previous blocks from its contract scripting language. Then, to prove that your lizard did wear the T-shirt, you can tell the judge to look at a given recent block, and exhibit as evidence a Merkle proof that some transaction was posted that indeed represents the lizard wearing the T-shirt — with this evidence, you have a case, without it, you are thrown out of court. Now, proving that you did do something is easy, but you cannot so easily convince the judge that you did <em>not</em> post a contrary transaction whereby the lizard removes the T-shirt: for that, the judge would have to look back at each and every transaction between the donning of the T-shirt and the expiration date of the contract — and that definitely will not scale. What you can do, though, is challenge <em>me</em> to show any such transaction, if it exists as I claim it does. If I can show that indeed your lizard removed the T-shirt, by similarly exhibiting a recent block and a Merkle proof of inclusion from it, then you failed your contract and the judge will adjudicate in my favor. However, if I cannot provide such a counter-argument within my deadline, then the judge will adjudicate in your favor.</p><p>Using a field of mathematics known as <em>Game Semantics</em>, any formula quantified over the history of the blockchain can be transformed into such a “verification game,” and thereby be used in a contract. This enables the composition of arbitrary activities that were not otherwise designed to be composed.</p><p>Furthermore, these kinds of contracts can be kept private: the terms can be hidden from the public by only publishing a salted hash of these terms when initially signing the contract and escrowing collateral funds on the blockchain. Only in case of a dispute will the terms of the contracts have to be revealed. Actually, only one single clause of the contract has to be revealed, even though the contract can be very large and contain many clauses. The claimants can choose the simplest clause to argue, for instance the presence of brown M&amp;Ms in a contractually required bowl. Or they can pick whichever clause will maximize the damages they will be awarded, if the damages may vary with the clause.</p><p>To go one step further towards privacy, even the arguments themselves can be obscured using recursive zkSNARKs: all that bystanders would then see would be you and I sending O(1) proofs that remain impossible to decode by anyone not privy to our agreement. Yet all these bystanders, as well as the “judge” made of the “smart contract” and the blockchain consensus, will be able to check which one of us won this trial fairly and was adjudicated the escrowed funds. Actually, even the outcome of the trial can itself be kept private, using techniques pioneered by ZCash or MimbleWimble. All the public will then see is that some dispute happened, which was resolved according to objective justice, though no one but the parties involved will know either the topic of the dispute, or its conclusion.</p><p>And to achieve this composition of contracts, all we need from a blockchain is the ability to verify historical events — and of course, for suitable events to be emitted that we can reason about. To this end, we need the blockchain’s contract scripting language to give us access to recent block hash <em>and</em> we need each hash to commit to a trie of all past events. Interestingly, Ethereum only does the former. We can still achieve the latter, but to that end, <a href="https://github.com/amiller/ethereum-blockhashes">some contract</a> must maintain this trie and be called regularly to update it, and that’s a major hassle. If instead block miners maintained the trie, their cost at each block would only be logarithmic in the depth of the trie — just a few tens of hashes to carry — because nodes don’t need to remember the entire history to update these hashes, just the spine of the trie. As for remembering history, users will each be responsible for remembering the fragments of it that they care about.</p><p>Of course, the applications of this technology are not limited just to dressing cute lizards in T-shirts. They can be used to compose arbitrary contracts and create elaborate decentralized applications.</p><p>At <a href="https://alacris.io/">Alacris.io</a>, we are using the above technique among many others to build an operating system for decentralized applications. The applications we will enable will include atomic swaps between arbitrary financial products, elaborate financial contracts, scaling solutions based on side-chains, and much more. And we are hoping to convince blockchain implementers to actively support this history verification feature that will let us to compose decentralized applications in ways easier not harder than what Ethereum currently allows.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fcef0129518" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alacris/composing-contracts-without-special-provisions-using-blockchain-history-9fcef0129518">Composing Contracts without Special Provisions — using Blockchain History</a> was originally published in <a href="https://medium.com/alacris">Alacris</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Developing for the Blockchain is Hard Part 2: Computing Proper Collateral]]></title>
            <link>https://medium.com/alacris/why-developing-for-the-blockchain-is-hard-part-2-computing-proper-collateral-4014ca612e63?source=rss-bc914ed341b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/4014ca612e63</guid>
            <category><![CDATA[verification-game]]></category>
            <category><![CDATA[collateral-bond]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[François-René Rideau]]></dc:creator>
            <pubDate>Thu, 28 Mar 2019 21:07:14 GMT</pubDate>
            <atom:updated>2019-03-28T21:07:14.416Z</atom:updated>
            <content:encoded><![CDATA[<p>Many proposed blockchain solutions use verification games, whether informally as in TrueBit and Plasma, or formally as in <a href="https://alacris.io/">Alacris.io</a>. In these systems, an important challenge is for the contract to be able to assess whether participants are putting down sufficient collateral to accompany their claims; and this assessment crucially depends on having a good model for the price of gas.</p><h3>My Name is Bond, Collateral Bond</h3><p>In a system based on verification games, participants make <em>claims</em> that others may disprove if they are invalid. Each step of the verification game (or “smart lawsuit”) happens by invoking the “smart contract” on the blockchain with parameters detailing the claim (making a “smart legal argument”). If no one successfully counters the claim with a <em>counter-claim</em> within its <em>challenge period</em>, then the claim is considered validated. To punish those who make spurious claims and reward those that prove their claims invalid, participants who make a claim must accompany it with the deposit of a proper collateral. The claimant is <em>bonded</em> and the collateral is his <em>bond</em>, that will be released back to the claimant if the claim is validated, or to the counter-claimant if the claim is invalidated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*6CXCHa8UlBdYZ6oR" /><figcaption>Don’t misbehave or bounty hunters will come for you and collect your bond.</figcaption></figure><p>In the normal use pattern, an honest participant making a valid claim only ends up paying the price of making the claim, and pays nothing for proving it correct. It is the dishonest participants, making invalid claims or counter-claims, who end up paying by losing their collateral. This “bad guy pays” property makes verification games cheap and attractive. The downside is that the challenge period is a pain for users when it’s too long, and a security issue when it’s too short. However, there is also a crucial difficulty in <em>computing the proper collateral</em> to deposit: it must be small enough not to be an unbearable burden to the honest participants, but large enough to discourage the dishonest claimants and reward their counter-claimants, by covering any gas paid by the counter-claimant.</p><p>If there is no collateral, or if the collateral is too low, a bad actor could “troll” or “grief” an honest party with a large number of frivolous lawsuits. The honest defendant might have to spend a lot of money in gas for “smart court fees,” and might be pushed into making exploitable mistakes, revealing information that enables attacks (such as a DoS attacks based on location information), giving up in rage, or going bankrupt. Collateral amounts should be high enough to discourage bad behavior and to award honest participants damage reparations that cover all the cost of litigation: gas costs of getting the transactions in, operational costs of running and securing computers in redundant data centers, insurance cost to deal with the risk and volatility associated with other costs, moral cost of it all.</p><p>On the other hand, collateral amounts should be low enough that honest parties of modest means can afford to defend themselves — although one way around this problem is to allow them to sell their claims to a richer party who has time, money and computer resources enough to afford taking the litigation to its conclusion. Another solution would be borrowing funds to use as collateral, but it cannot be implemented purely on the blockchain. If bad actors could even temporarily cause the contract to require overly high collateral bonds, they could possibly prevent the other parties from defending themselves.</p><h3>Estimating the Gas Price</h3><p>The main thing that the bond must cover is “smart court fees” for the other party should the current claimant be the losing party. These fees are transaction fees required for the other party to publish their arguments on the blockchain.</p><p>In the case of Ethereum, the cost is proportional to the price of gas, which is not fixed in ETH, but floats depending on supply and demand and market manipulation by unsavory miners and transaction posters. Note, however, that the issue is not specific to Ethereum; it is an essential issue of any blockchain. A limited supply of transaction space is a necessary limitation of any public blockchain, because block verification is massively decentralized, which means that block data must fit in the limited network and cpu bandwidth of those who partake in the verification network. Given this limited supply, the economic value of gas (being a fixed fraction of that transaction space) will naturally vary with the demand, in a way that is largely independent from the value of the tokens themselves; therefore the only economically rational way to ration this supply is by letting the relative price of gas vs tokens float. A fixed price would cause artificial scarcity when it’s higher than the free market equilibrium, and long waiting lines when it’s lower.</p><p>Thus, transaction fees will float, and the structure of the contract can only tell you how much you have to pay compared to some floating base price. For the smart contract to ensure that claimants post sufficient fees to support their claim, it must therefore be able to compare those fees to some multiple of an appropriate estimate of the gas price or other base price.</p><p>It is therefore important for high-level verification-based contracts to be able to predict the price of gas in the near future, the next few hours or days, however long the longest smart lawsuit may take, which can be statically determined from the number of quantifier alternations in the contract clauses times the duration of one challenge period. The prediction does not have to be very accurate, but it must be a strict upper bound on the price of gas in that window, even accounting for unusual volatility in the market and deliberate market manipulation by some sizeable minority of accomplices among consensus miners.</p><p>One formula might consist in observing the price of gas over the last few days of fully confirmed transactions; in each block discard the 33% (by gas limit) most expensive transactions and keep the remaining high price; then discard the 33% (by block) most expensive of those prices, keep the remaining high price, but assume it may shoot up five times (or some other multiple of) the volatility observed among the prices not discarded; further multiply by eight, and use that as a gas price basis. The exact formula will have to be devised by someone with expertise in economic or actuarial modelling — the point being that the formula must reliably overestimate how much gas honest people may have to pay to defend themselves, yet not by such a large factor that it becomes unaffordable.</p><p>When using a short term contract that itself expires in a few days, the signatories can agree on the price prediction and include it as an explicit parameter during the creation of the contract. A limit to one complaint per participant, or per pair of participant, as applicable, can also put a cap on how much trouble a dishonest participant can wreak if the prediction becomes too low. But what about long term contracts that may manage assets over many weeks, months, or even years, while the gas price may vary wildly? Whatever formula is used will have to be quite elaborate, and will therefore be too expensive for the low-level contract to recompute every time it is invoked. Unless somehow the blockchain’s low-level contract VM itself supports predicting gas according to this exact same formula. Yet, like all computations, the formula for gas prediction can be verified using our usual interactive proof techniques, so updates to the gas price estimate can be made as claims against the contract, and could be included as part of other claims that are part of the distributed application’s regular operations.</p><h3>A Protocol to Maintain the Gas Price Estimate</h3><p>If the distributed application includes side-chains, the side-chain operators may update the price estimate, possibly in conjunction with updates to the state of their side-chain. If there are no privileged parties in the long-running contract to regularly maintain the contract state, then some protocol part of the distributed application may designate whose responsibility it is (e.g. each participant in turn in some order) to update the gas price basis next time the previously registered estimate falls out of some safety range, say below 4 times or over 16 times the current price prediction. In some contracts, is also possible that their own selfish interest in other participants not making spurious claims against them will be incentive enough for some participants to spontaneously make claims to maintain the gas price basis within a safe range. An invalid claim will be verified invalid and rejected, and the wrongful claimant will lose their collateral as well as their operator privilege, if any, which should be enough to incentivize the party that denounces them — as long as the last previously confirmed prediction is still a valid upper bound on the gas price.</p><p>A further improvement on the protocol may involve building a futures market for gas price. Insurers will offer insurance against rise of the gas price, possibly available for use in verification games only. Users who wish to protect themselves from gas price fluctuations can then avoid the volatility, at a small premium. The mechanism used by MakerDAO to provide a stable coin indexed on the dollar, the DAI, can also be used to provide future GAS at fixed price in either USD or ETH. Insurers can also leverage the “gas refund” mechanism of Ethereum to buy gas in advance, though these refunds can only cover half of the gas of any given transaction.</p><p>There is a lot of complexity involved in such a protocol; to track gas price requires carefully watching a full node on the blockchain validation network. Therefore only professionals should partake in the protocol. But, there could be a common verifiable approximate gas price prediction contract on the blockchain, the estimates of which are shared by all contracts that rely on the same formula, as a public service. As part of developing the Alacris Operating System, we will make it possible for all DApps to use the gas price estimates maintained by our DApps, as well as other verifiable oracles for data about Ethereum and other blockchains.</p><p><em>This article is the second in an ongoing series titled “Why Developing for the Blockchain is Hard.” Keep an eye out for our next article about DoS Attacks.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4014ca612e63" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alacris/why-developing-for-the-blockchain-is-hard-part-2-computing-proper-collateral-4014ca612e63">Why Developing for the Blockchain is Hard Part 2: Computing Proper Collateral</a> was originally published in <a href="https://medium.com/alacris">Alacris</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Developing for the Blockchain is Hard Part 2: Computing Proper Collateral]]></title>
            <link>https://medium.com/hackernoon/why-developing-for-the-blockchain-is-hard-part-2-computing-proper-collateral-28bf1fa16966?source=rss-bc914ed341b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/28bf1fa16966</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[collateral-bond]]></category>
            <category><![CDATA[verification-game]]></category>
            <dc:creator><![CDATA[François-René Rideau]]></dc:creator>
            <pubDate>Thu, 14 Mar 2019 17:21:58 GMT</pubDate>
            <atom:updated>2019-03-14T21:04:08.168Z</atom:updated>
            <content:encoded><![CDATA[<p>Many proposed blockchain solutions use verification games, whether informally as in TrueBit and Plasma, or formally as in <a href="https://alacris.io/">Alacris.io</a>. In these systems, an important challenge is for the contract to be able to assess whether participants are putting down sufficient collateral to accompany their claims; and this assessment crucially depends on having a good model for the price of gas.</p><h3>My Name is Bond, Collateral Bond</h3><p>In a system based on verification games, participants make <em>claims</em> that others may disprove if they are invalid. Each step of the verification game (or “smart lawsuit”) happens by invoking the “smart contract” on the blockchain with parameters detailing the claim (making a “smart legal argument”). If no one successfully counters the claim with a <em>counter-claim</em> within its <em>challenge period</em>, then the claim is considered validated. To punish those who make spurious claims and reward those that prove their claims invalid, participants who make a claim must accompany it with the deposit of a proper collateral. The claimant is <em>bonded</em> and the collateral is his <em>bond</em>, that will be released back to the claimant if the claim is validated, or to the counter-claimant if the claim is invalidated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*6CXCHa8UlBdYZ6oR" /><figcaption>Don’t misbehave or bounty hunters will come for you and collect your bond.</figcaption></figure><p>In the normal use pattern, an honest participant making a valid claim only ends up paying the price of making the claim, and pays nothing for proving it correct. It is the dishonest participants, making invalid claims or counter-claims, who end up paying by losing their collateral. This “bad guy pays” property makes verification games cheap and attractive. The downside is that the challenge period is a pain for users when it’s too long, and a security issue when it’s too short. However, there is also a crucial difficulty in <em>computing the proper collateral</em> to deposit: it must be small enough not to be an unbearable burden to the honest participants, but large enough to discourage the dishonest claimants and reward their counter-claimants, by covering any gas paid by the counter-claimant.</p><p>If there is no collateral, or if the collateral is too low, a bad actor could “troll” or “grief” an honest party with a large number of frivolous lawsuits. The honest defendant might have to spend a lot of money in gas for “smart court fees,” and might be pushed into making exploitable mistakes, revealing information that enables attacks (such as a DoS attacks based on location information), giving up in rage, or going bankrupt. Collateral amounts should be high enough to discourage bad behavior and to award honest participants damage reparations that cover all the cost of litigation: gas costs of getting the transactions in, operational costs of running and securing computers in redundant data centers, insurance cost to deal with the risk and volatility associated with other costs, moral cost of it all.</p><p>On the other hand, collateral amounts should be low enough that honest parties of modest means can afford to defend themselves — although one way around this problem is to allow them to sell their claims to a richer party who has time, money and computer resources enough to afford taking the litigation to its conclusion. Another solution would be borrowing funds to use as collateral, but it cannot be implemented purely on the blockchain. If bad actors could even temporarily cause the contract to require overly high collateral bonds, they could possibly prevent the other parties from defending themselves.</p><h3>Estimating the Gas Price</h3><p>The main thing that the bond must cover is “smart court fees” for the other party should the current claimant be the losing party. These fees are transaction fees required for the other party to publish their arguments on the blockchain.</p><p>In the case of Ethereum, the cost is proportional to the price of gas, which is not fixed in ETH, but floats depending on supply and demand and market manipulation by unsavory miners and transaction posters. Note, however, that the issue is not specific to Ethereum; it is an essential issue of any blockchain. A limited supply of transaction space is a necessary limitation of any public blockchain, because block verification is massively decentralized, which means that block data must fit in the limited network and cpu bandwidth of those who partake in the verification network. Given this limited supply, the economic value of gas (being a fixed fraction of that transaction space) will naturally vary with the demand, in a way that is largely independent from the value of the tokens themselves; therefore the only economically rational way to ration this supply is by letting the relative price of gas vs tokens float. A fixed price would cause artificial scarcity when it’s higher than the free market equilibrium, and long waiting lines when it’s lower.</p><p>Thus, transaction fees will float, and the structure of the contract can only tell you how much you have to pay compared to some floating base price. For the smart contract to ensure that claimants post sufficient fees to support their claim, it must therefore be able to compare those fees to some multiple of an appropriate estimate of the gas price or other base price.</p><p>It is therefore important for high-level verification-based contracts to be able to predict the price of gas in the near future, the next few hours or days, however long the longest smart lawsuit may take, which can be statically determined from the number of quantifier alternations in the contract clauses times the duration of one challenge period. The prediction does not have to be very accurate, but it must be a strict upper bound on the price of gas in that window, even accounting for unusual volatility in the market and deliberate market manipulation by some sizeable minority of accomplices among consensus miners.</p><p>One formula might consist in observing the price of gas over the last few days of fully confirmed transactions; in each block discard the 33% (by gas limit) most expensive transactions and keep the remaining high price; then discard the 33% (by block) most expensive of those prices, keep the remaining high price, but assume it may shoot up five times (or some other multiple of) the volatility observed among the prices not discarded; further multiply by eight, and use that as a gas price basis. The exact formula will have to be devised by someone with expertise in economic or actuarial modelling — the point being that the formula must reliably overestimate how much gas honest people may have to pay to defend themselves, yet not by such a large factor that it becomes unaffordable.</p><p>When using a short term contract that itself expires in a few days, the signatories can agree on the price prediction and include it as an explicit parameter during the creation of the contract. A limit to one complaint per participant, or per pair of participant, as applicable, can also put a cap on how much trouble a dishonest participant can wreak if the prediction becomes too low. But what about long term contracts that may manage assets over many weeks, months, or even years, while the gas price may vary wildly? Whatever formula is used will have to be quite elaborate, and will therefore be too expensive for the low-level contract to recompute every time it is invoked. Unless somehow the blockchain’s low-level contract VM itself supports predicting gas according to this exact same formula. Yet, like all computations, the formula for gas prediction can be verified using our usual interactive proof techniques, so updates to the gas price estimate can be made as claims against the contract, and could be included as part of other claims that are part of the distributed application’s regular operations.</p><h3>A Protocol to Maintain the Gas Price Estimate</h3><p>If the distributed application includes side-chains, the side-chain operators may update the price estimate, possibly in conjunction with updates to the state of their side-chain. If there are no privileged parties in the long-running contract to regularly maintain the contract state, then some protocol part of the distributed application may designate whose responsibility it is (e.g. each participant in turn in some order) to update the gas price basis next time the previously registered estimate falls out of some safety range, say below 4 times or over 16 times the current price prediction. In some contracts, is also possible that their own selfish interest in other participants not making spurious claims against them will be incentive enough for some participants to spontaneously make claims to maintain the gas price basis within a safe range. An invalid claim will be verified invalid and rejected, and the wrongful claimant will lose their collateral as well as their operator privilege, if any, which should be enough to incentivize the party that denounces them — as long as the last previously confirmed prediction is still a valid upper bound on the gas price.</p><p>A further improvement on the protocol may involve building a futures market for gas price. Insurers will offer insurance against rise of the gas price, possibly available for use in verification games only. Users who wish to protect themselves from gas price fluctuations can then avoid the volatility, at a small premium. The mechanism used by MakerDAO to provide a stable coin indexed on the dollar, the DAI, can also be used to provide future GAS at fixed price in either USD or ETH. Insurers can also leverage the “gas refund” mechanism of Ethereum to buy gas in advance, though these refunds can only cover half of the gas of any given transaction.</p><p>There is a lot of complexity involved in such a protocol; to track gas price requires carefully watching a full node on the blockchain validation network. Therefore only professionals should partake in the protocol. But, there could be a common verifiable approximate gas price prediction contract on the blockchain, the estimates of which are shared by all contracts that rely on the same formula, as a public service. As part of developing the Alacris Operating System, we will make it possible for all DApps to use the gas price estimates maintained by our DApps, as well as other verifiable oracles for data about Ethereum and other blockchains.</p><p><em>This article is the second in an ongoing series titled “Why Developing for the Blockchain is Hard.” Keep an eye out for our next article about DoS Attacks.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28bf1fa16966" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/why-developing-for-the-blockchain-is-hard-part-2-computing-proper-collateral-28bf1fa16966">Why Developing for the Blockchain is Hard Part 2: Computing Proper Collateral</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Developing for the Blockchain is Hard — Part 1: Posting Transactions]]></title>
            <link>https://medium.com/alacris/why-developing-for-the-blockchain-is-hard-part-1-posting-transactions-31b5db9b6122?source=rss-bc914ed341b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/31b5db9b6122</guid>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[François-René Rideau]]></dc:creator>
            <pubDate>Thu, 14 Mar 2019 16:47:15 GMT</pubDate>
            <atom:updated>2019-03-14T16:48:33.822Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why Developing for the Blockchain is Hard — Part 1: Posting Transactions</h3><p>We at <a href="https://alacris.io/">Alacris.io</a> want application developers to be able to spend their time focusing on the high-level design of their applications, in terms of economic interactions between multiple parties. We want to save them from having to deal with the complexity of issues like posting a transaction.</p><p>Wait, some will say: Posting a transaction is complex? Isn’t there already a function to call for that? Well, yes and no. There is already a function that works well enough for the simple case of manual payments; but that function fails badly and is wholly unsuitable for use in the more elaborate cases that matter to a distributed application backed by a smart contract.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*k1OCQDARvFuJqeY1.jpg" /><figcaption>When the simplest device (a Turing Machine) is already extremely complex…</figcaption></figure><h3>Existing Functions to Post Transactions are Lacking</h3><p>Sure, you will find functions to create and post transactions in the Ethereum JSON-RPC API, or the equivalent libraries for Go, Javascript, Python, Rust or your favorite language. But calling one of these functions does not and cannot guarantee that the transaction will go through. What if your application crashes in the middle of the interaction? What if your Ethereum node client crashes? What if you are victim of a network outage? What if you fail to use a high enough GAS limit, or use a high enough GAS price? What if your transaction loses the race to another transaction that you posted, or to a transaction posted by someone else using the same contract? What if your transaction makes it into a block, but that block gets reversed by a heavier uncle? What if any of the above happens, not by an unfortunate accident, but out of a deliberate attack by an enemy?</p><p>In all these cases, the simple answer is “after ten, thirty or sixty minutes, check whether the transaction went through, and if not try again.” And as long as you’re just a human sending payment and you’re in no great hurry, that’s probably a good enough answer. All you need is for your “wallet” to warn you that the transaction failed, and to offer you to try again with updated parameters at the press of a button. The merchant or trading partner on the other side will usually wait patiently for the payment to go through before they do anything, anyway. And so the existing function is good enough to implement a wallet.</p><p>Now, to write an application that is not merely a payment wallet, you need more than that. In a typical “smart contract”, one or multiple parties each posts a large bond that they will stand to lose should they fail to post the transactions that they contractually promised to post within a tight deadline. Is your “post transaction” function good enough to use in such a smart contract? If it works 99% of the time, that means that every hundred times someone will lose their large bond. Is that good enough for you? If the function works 99.9999% of the time, it will still fail once in a million calls. If it is to be used a billion times a year, that is still quite a number of discontent users each losing a significant amount of money. And yet, 99.9999% “six nines” reliability is already considered not easy to achieve in practice. Can you actually make this function that reliable, or even better? How many nines of reliability can you afford to have? And how many can you not afford not to have? When your function eventually fails because the world conspires against you, then what? Remember that in writing the function, you are not just fighting accidental odds of failure: you’re fighting deliberate attempts to thwart you by bad actors who will sign a contract with you just so they can prevent you from posting your transaction and collect part of your bond as reparations. Even if they can’t collect reparations from making you fail, enemies and vandals may want to see you lose even when they can’t directly benefit; and elaborate gangsters might threaten to make you fail to hold your bond hostage, blackmail you and ransom you. Will your function remain as reliable as you need it to be in that adversarial environment?</p><h3>What a Proper Post Transaction API would do</h3><p>The existing “post transaction” function is not at all a functional API usable by distributed applications beside simple wallets. The entire purpose of a functional API is to make it possible to write automated programs that will call the API, let it do its magic, and not have to deal with the details below that level of abstraction. A proper “post transaction” function will ensure that the transaction WILL go through, despite all the potential issues within the control of the program: It will include a good algorithmic model to follow the progress of the transaction in the network. It will handle persistence of data so the application survives a crash. It will maintain multiple application replicas over multiple data centers so that the application cannot “just” be thwarted by an enemy doing a DDoS. If needed, it will route all relevant communications through virtual circuits and/or mix networks so that enemies cannot easily locate the contract-using machine and attack it. It will automatically recompute nonces to adjust to race conditions. It will use some informed model-based strategy to watch the network and dynamically adjust what gas price to use, so as to resist block-buying attacks by partaking in a suitable auction for transaction space (and block-buying attacks are not just theoretical attacks, but things that have actually happened in the past: consider the case of the Fomo3D contract: <a href="https://medium.com/coinmonks/how-the-winner-got-fomo3d-prize-a-detailed-explanation-b30a69b7813f">1</a>, <a href="https://medium.com/coinmonks/the-buy-a-block-attack-c0ce845475d7">2</a>, <a href="https://motherboard.vice.com/en_us/article/7xq38d/fomo3d-winner-clogged-ethereum-blockchain">3</a>). All in all, a proper “post transaction” function will patiently nurse a pool of desired transactions until each of them is eventually posted and confirmed on the blockchain, once and only once, in a suitable order.</p><p>What if some issues outside the control of the program still crop up and prevent the transaction from being posted? Then the “post transaction” function will send suitable alerts, before it is too late. The program calling the function has the option of handling some of these alerts; but ultimately, whatever alerts are left unhandled will reach some human watchman on call. It is the role of the Blockchain Operating System to take over at this point, as the application developer doesn’t even have access to the entire context necessary to handle these complex issues. Is the application deployed on a cell phone? The user to alert is the cell phone owner, using cell phone alerts. Is the application deployed on a redundant network spanning three data centers across different continents? The user to alert may be a professional System Reliability Engineer on call. Users may be using a proprietary alert system that just did not exist when the application was written, and yet the application will indirectly make use of it, because alerts are part of the abstraction offered by the Operating System, rather than features of the application itself. What alert mechanism is used will depend on the deployment configuration for the application. It is not the responsibility of the application developer, who not only cannot know all the existing deployment situations, but by definition cannot predict the deployment situations that will only be invented in the future. Letting the application developer access the details of the deployment and handle the emergency situations would actually be big security concern that goes against all good practices for software security.</p><p>Now, what when an application fails? The human on call will have to take it over from there. And unless you’re a large corporation or wealthy individual affording a software operations engineer as technical support, that human on call will be you. Then, a <em>great</em> functional API will make it easy for that human on call to assess the situation and take appropriate action:</p><ul><li>plugging some cable back before retrying, retrying using a backup network connection,</li><li>calling a friend who will post the transaction for him over a different network,</li><li>using different parameters with more gas or a higher gas price,</li><li>dropping the transaction and losing the bond because posting the transaction would cost more than the bond is worth after all,</li><li>still posting the transaction and losing more in gas than the transaction is worth, because the failure to post would reward the bad guys, or would cause a loss of trust and future business from other users,</li><li>use some alternate execution path or mitigation game foreseen in the smart contract,</li><li>accept a settlement offer from the other party, rather than have a smart judge rule against you, etc.</li></ul><p>Many failure and recovery modes are possible, and in general it is not the responsibility of the calling function to painfully handle recovery strategies that involve global state way beyond the scope of said function. Rather, the Blockchain Operating System shall automatically deduce these monitoring interactions from the regular structure of the calling program.</p><p>However, before he may take any action at all, the human must be able to understand what is going on, what transaction is being held up, what value is at stake. It is therefore essential that the Operating System offers to the human the ability to inspect the structure of the calling program. The User Interface should make it possible for the user to inspect the current state of the program being interrupted. This is the reason why the program usually cannot be written as “just” simple function calls in Python, Go, Javascript or any such “blub” language: the program has to be written in a suitable Domain Specific Language (DSL), compiled by a metaprogram that has access to the entire program structure, rather than merely to local calls (though the program could be built from a metaprogram written in a blub language, in the style of Google TensorFlow, or from a metaprogram targeting the blub language). Writing distributed applications in suitable DSL also means that these applications can be made modular, where common modules can be reused and composed into larger applications, when written properly. By contrast, writing these applications by hand into a procedural language would lead to all the abstractions leaking and making the resulting program unsuitable for modular composition.</p><h3>Towards a Blockchain Operating System</h3><p>In conclusion, something as deceptively simple-looking as “posting a transaction” justifies that distributed applications should not be written using existing APIs, or using any API whatsoever expressed as function calls in any existing language. Rather, it should be written in a Domain Specific Language designed for the purpose of writing such applications, running on top of a “Blockchain Operating System” that will not only provide robust abstraction and enforce security practices, but also help humans handle emergency situations, depending on their specific deployment configuration. And posting a transaction is only one of a multitude of aspects of a distributed application, each of which has to be handled properly. At Alacris, we believe that these aspects are better implemented well once by infrastructure specialists then shared between all applications, rather than implemented many times by each application developer stepping out of his regular role and possibly out of his skills. That is why we at <a href="https://alacris.io/">Alacris.io</a> are building a Blockchain Operating System, that will manage these aspects for the application developers.</p><p><em>This article is the first in an ongoing series titled “Why Blockchain is Hard.” A new article will be released every three weeks. Keep an eye out for our next article “Computing a Proper Collateral.”</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31b5db9b6122" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alacris/why-developing-for-the-blockchain-is-hard-part-1-posting-transactions-31b5db9b6122">Why Developing for the Blockchain is Hard — Part 1: Posting Transactions</a> was originally published in <a href="https://medium.com/alacris">Alacris</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Developing for the Blockchain is Hard — Part 1: Posting Transactions]]></title>
            <link>https://medium.com/hackernoon/why-developing-for-the-blockchain-is-hard-part-1-posting-transactions-dde21c025c65?source=rss-bc914ed341b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/dde21c025c65</guid>
            <category><![CDATA[operating-systems]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[posting-transactions]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[blockchain-developer]]></category>
            <dc:creator><![CDATA[François-René Rideau]]></dc:creator>
            <pubDate>Tue, 08 Jan 2019 21:44:49 GMT</pubDate>
            <atom:updated>2019-02-20T21:52:38.229Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Why Developing for the Blockchain is Hard — Part 1: Posting Transactions</strong></h3><p>We at <a href="https://alacris.io/">Alacris.io</a> want application developers to be able to spend their time focusing on the high-level design of their applications, in terms of economic interactions between multiple parties. We want to save them from having to deal with the complexity of issues like posting a transaction.</p><p>Wait, some will say: Posting a transaction is complex? Isn’t there already a function to call for that? Well, yes and no. There is already a function that works well enough for the simple case of manual payments; but that function fails badly and is wholly unsuitable for use in the more elaborate cases that matter to a distributed application backed by a smart contract.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*k1OCQDARvFuJqeY1.jpg" /><figcaption>When the simplest device (a Turing Machine) is already extremely complex…</figcaption></figure><h3>Existing Functions to Post Transactions are Lacking</h3><p>Sure, you will find functions to create and post transactions in the Ethereum JSON-RPC API, or the equivalent libraries for Go, Javascript, Python, Rust or your favorite language. But calling one of these functions does not and cannot guarantee that the transaction will go through. What if your application crashes in the middle of the interaction? What if your Ethereum node client crashes? What if you are victim of a network outage? What if you fail to use a high enough GAS limit, or use a high enough GAS price? What if your transaction loses the race to another transaction that you posted, or to a transaction posted by someone else using the same contract? What if your transaction makes it into a block, but that block gets reversed by a heavier uncle? What if any of the above happens, not by an unfortunate accident, but out of a deliberate attack by an enemy?</p><p>In all these cases, the simple answer is “after ten, thirty or sixty minutes, check whether the transaction went through, and if not try again.” And as long as you’re just a human sending payment and you’re in no great hurry, that’s probably a good enough answer. All you need is for your “wallet” to warn you that the transaction failed, and to offer you to try again with updated parameters at the press of a button. The merchant or trading partner on the other side will usually wait patiently for the payment to go through before they do anything, anyway. And so the existing function is good enough to implement a wallet.</p><p>Now, to write an application that is not merely a payment wallet, you need more than that. In a typical “smart contract”, one or multiple parties each posts a large bond that they will stand to lose should they fail to post the transactions that they contractually promised to post within a tight deadline. Is your “post transaction” function good enough to use in such a smart contract? If it works 99% of the time, that means that every hundred times someone will lose their large bond. Is that good enough for you? If the function works 99.9999% of the time, it will still fail once in a million calls. If it is to be used a billion times a year, that is still quite a number of discontent users each losing a significant amount of money. And yet, 99.9999% “six nines” reliability is already considered not easy to achieve in practice. Can you actually make this function that reliable, or even better? How many nines of reliability can you afford to have? And how many can you not afford not to have? When your function eventually fails because the world conspires against you, then what? Remember that in writing the function, you are not just fighting accidental odds of failure: you’re fighting deliberate attempts to thwart you by bad actors who will sign a contract with you just so they can prevent you from posting your transaction and collect part of your bond as reparations. Even if they can’t collect reparations from making you fail, enemies and vandals may want to see you lose even when they can’t directly benefit; and elaborate gangsters might threaten to make you fail to hold your bond hostage, blackmail you and ransom you. Will your function remain as reliable as you need it to be in that adversarial environment?</p><h3>What a Proper Post Transaction API would do</h3><p>The existing “post transaction” function is not at all a functional API usable by distributed applications beside simple wallets. The entire purpose of a functional API is to make it possible to write automated programs that will call the API, let it do its magic, and not have to deal with the details below that level of abstraction. A proper “post transaction” function will ensure that the transaction WILL go through, despite all the potential issues within the control of the program: It will include a good algorithmic model to follow the progress of the transaction in the network. It will handle persistence of data so the application survives a crash. It will maintain multiple application replicas over multiple data centers so that the application cannot “just” be thwarted by an enemy doing a DDoS. If needed, it will route all relevant communications through virtual circuits and/or mix networks so that enemies cannot easily locate the contract-using machine and attack it. It will automatically recompute nonces to adjust to race conditions. It will use some informed model-based strategy to watch the network and dynamically adjust what gas price to use, so as to resist block-buying attacks by partaking in a suitable auction for transaction space (and block-buying attacks are not just theoretical attacks, but things that have actually happened in the past: consider the case of the Fomo3D contract: <a href="https://medium.com/coinmonks/how-the-winner-got-fomo3d-prize-a-detailed-explanation-b30a69b7813f">1</a>, <a href="https://medium.com/coinmonks/the-buy-a-block-attack-c0ce845475d7">2</a>, <a href="https://motherboard.vice.com/en_us/article/7xq38d/fomo3d-winner-clogged-ethereum-blockchain">3</a>). All in all, a proper “post transaction” function will patiently nurse a pool of desired transactions until each of them is eventually posted and confirmed on the blockchain, once and only once, in a suitable order.</p><p>What if some issues outside the control of the program still crop up and prevent the transaction from being posted? Then the “post transaction” function will send suitable alerts, before it is too late. The program calling the function has the option of handling some of these alerts; but ultimately, whatever alerts are left unhandled will reach some human watchman on call. It is the role of the Blockchain Operating System to take over at this point, as the application developer doesn’t even have access to the entire context necessary to handle these complex issues. Is the application deployed on a cell phone? The user to alert is the cell phone owner, using cell phone alerts. Is the application deployed on a redundant network spanning three data centers across different continents? The user to alert may be a professional System Reliability Engineer on call. Users may be using a proprietary alert system that just did not exist when the application was written, and yet the application will indirectly make use of it, because alerts are part of the abstraction offered by the Operating System, rather than features of the application itself. What alert mechanism is used will depend on the deployment configuration for the application. It is not the responsibility of the application developer, who not only cannot know all the existing deployment situations, but by definition cannot predict the deployment situations that will only be invented in the future. Letting the application developer access the details of the deployment and handle the emergency situations would actually be big security concern that goes against all good practices for software security.</p><p>Now, what when an application fails? The human on call will have to take it over from there. And unless you’re a large corporation or wealthy individual affording a software operations engineer as technical support, that human on call will be you. Then, a <em>great</em> functional API will make it easy for that human on call to assess the situation and take appropriate action:</p><ul><li>plugging some cable back before retrying, retrying using a backup network connection,</li><li>calling a friend who will post the transaction for him over a different network,</li><li>using different parameters with more gas or a higher gas price,</li><li>dropping the transaction and losing the bond because posting the transaction would cost more than the bond is worth after all,</li><li>still posting the transaction and losing more in gas than the transaction is worth, because the failure to post would reward the bad guys, or would cause a loss of trust and future business from other users,</li><li>use some alternate execution path or mitigation game foreseen in the smart contract,</li><li>accept a settlement offer from the other party, rather than have a smart judge rule against you, etc.</li></ul><p>Many failure and recovery modes are possible, and in general it is not the responsibility of the calling function to painfully handle recovery strategies that involve global state way beyond the scope of said function. Rather, the Blockchain Operating System shall automatically deduce these monitoring interactions from the regular structure of the calling program.</p><p>However, before he may take any action at all, the human must be able to understand what is going on, what transaction is being held up, what value is at stake. It is therefore essential that the Operating System offers to the human the ability to inspect the structure of the calling program. The User Interface should make it possible for the user to inspect the current state of the program being interrupted. This is the reason why the program usually cannot be written as “just” simple function calls in Python, Go, Javascript or any such “blub” language: the program has to be written in a suitable Domain Specific Language (DSL), compiled by a metaprogram that has access to the entire program structure, rather than merely to local calls (though the program could be built from a metaprogram written in a blub language, in the style of Google TensorFlow, or from a metaprogram targeting the blub language). Writing distributed applications in suitable DSL also means that these applications can be made modular, where common modules can be reused and composed into larger applications, when written properly. By contrast, writing these applications by hand into a procedural language would lead to all the abstractions leaking and making the resulting program unsuitable for modular composition.</p><h3>Towards a Blockchain Operating System</h3><p>In conclusion, something as deceptively simple-looking as “posting a transaction” justifies that distributed applications should not be written using existing APIs, or using any API whatsoever expressed as function calls in any existing language. Rather, it should be written in a Domain Specific Language designed for the purpose of writing such applications, running on top of a “Blockchain Operating System” that will not only provide robust abstraction and enforce security practices, but also help humans handle emergency situations, depending on their specific deployment configuration. And posting a transaction is only one of a multitude of aspects of a distributed application, each of which has to be handled properly. At Alacris, we believe that these aspects are better implemented well once by infrastructure specialists then shared between all applications, rather than implemented many times by each application developer stepping out of his regular role and possibly out of his skills. That is why we at <a href="https://alacris.io/">Alacris.io</a> are building a Blockchain Operating System, that will manage these aspects for the application developers.</p><p><em>This article is the first in an ongoing series titled “Why Blockchain is Hard.” A new article will be released every three weeks. Keep an eye out for our next article “Computing a Proper Collateral.”</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dde21c025c65" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/why-developing-for-the-blockchain-is-hard-part-1-posting-transactions-dde21c025c65">Why Developing for the Blockchain is Hard — Part 1: Posting Transactions</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What do Formal Methods actually Guarantee?]]></title>
            <link>https://medium.com/alacris/what-do-formal-methods-actually-guarantee-d94ae8802be2?source=rss-bc914ed341b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/d94ae8802be2</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[ocaml]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[formal-methods]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[François-René Rideau]]></dc:creator>
            <pubDate>Sun, 21 Oct 2018 04:20:08 GMT</pubDate>
            <atom:updated>2018-10-23T19:35:44.623Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*gZw2EKOIK5ntPiij33BDyw.jpeg" /></figure><p>There is a lot of misunderstanding about what formal methods can do — their powers — and what they cannot do — their limitations. Those who are mistaken about one side of the argument, exaggerating it or downplaying the other, or are simply too aware of one side yet insufficiently aware of the other, may end up being overly skeptical of formal methods or overly enthusiastic about them. In this short essay I’ll try to make both cases clear, and thus explain the value proposition of formal methods without falling into easily rejected claims.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*UPQd_cyi7wXPIzY2CezxYQ.jpeg" /></figure><p><strong>Limitation: </strong>Formal methods are not a magic powder that you can sprinkle over your code to make it correct.<br><strong>Power: </strong>Formal methods are a structural backbone around which you can develop more robust code.</p><p><strong>Limitation:</strong> Formal methods are only <em>methods</em>. To have useful results at all, you still need to apply them, correctly, to the right problems.<br><strong>Power: </strong>When applied correctly, formal methods can eliminate not only single actual bugs, but entire <em>classes</em> of potential bugs and attacks, that your model can express are absent.</p><p><strong>Limitation: </strong>Formal methods won’t prevent bugs on aspects of your code that you haven’t formalized (yet).<br><strong>Power: </strong>Formal methods can ensure the <em>non regression</em> of your code with respect to those classes of defects you have formalized. Unlike other methods, they provide a ratchet that ensures progress even as the code evolves.</p><p><strong>Limitation: </strong>Formal methods can’t eliminate bugs and prevent attacks that go <em>below</em> the model you use (e.g. <a href="https://meltdownattack.com/">SPECTRE attack</a>).<br><strong>Power: </strong>Formal methods allow you to reason at one high level of abstraction and transport your results to a lower level of abstraction, provided you also prove <em>full abstraction</em>.</p><p><strong>Limitation: </strong>Formal methods cannot be used to prove “everything” correct. There are always more things you could reason about.<br><strong>Power: </strong>While there are infinite further issues, previous issues are finite and those that can be solved can be fully solved with finite effort.</p><p><strong>Limitation: </strong>Formal methods suppose your domain is well-defined and limited enough to be specifiable, and that you actually understand it enough to specify it.<br><strong>Power: </strong>Formal methods are a discipline that when to stick to them, will naturally lead you to your understanding your domain better.</p><p><strong>Limitation: </strong>Formal methods cost a lot in terms of time and talent. They cost even more as you explore new spaces that require reasoning infrastructure.<br><strong>Power: </strong>In many applications where millions of dollars worth of assets, or even lives, are at stake, it can be even more expensive <em>not</em> to use formal methods.</p><p><strong>Limitation: </strong>Not everyone can use formal methods.<br><strong>Power: </strong>A large fraction of developers <em>can</em> be trained to use formal methods. As for those who really can’t, they are probably a liability when it comes to safety-critical code.</p><p><strong>Limitation: </strong>Formal methods can only prove formal guarantees, and only based on a lot of formal assumptions (axioms). And they cannot establish the informal guarantees that matter to humans.<br><strong>Power: </strong>Formal methods help you make explicit what your assumptions and your guarantees are and ruthlessly eliminate any flaw between the assumptions and guarantees.</p><p><strong>Limitation: </strong>Formal methods won’t save you from having to make a lot of assumptions about the vast amount of software and hardware that you depend on under your system.<br><strong>Power: </strong>Formal methods will prevent the multiplication of <em>implicit</em> assumptions you don’t know about, don’t track, and don’t check as your system evolves, that may once have been true yet will cause catastrophic errors when they stop being valid (see <a href="https://hownot2code.com/2016/09/02/a-space-error-370-million-for-an-integer-overflow/">Ariane V</a>).</p><p><strong>Limitation: </strong>Just because it’s true doesn’t mean it’s provable. There are correct programs that formal methods can’t prove correct.<br><strong>Power: </strong>You claim a program is correct, but how do you <em>know</em> it? If you don’t have at least an informal proof of it, then you don’t actually know it by any stretch of imagination — thus you shouldn’t deploy the program in a setting where safety matters. And if you do have that informal proof, making that informal proof formal is not only possible, but doable and useful. In the process you may uncover a lot of actual bugs that would cost you dearly if you skipped the formalization. Formal methods are not magic, but neither are informal methods.</p><p><strong>Limitation: </strong>Even for the things you <em>can</em> prove, often you can’t <em>afford</em> to prove them.<br><strong>Power: </strong>You can use formal methods strategically: study what kind of serious or catastrophic issues similar projects have had that are worth eliminating, and build your model accordingly.</p><p><strong>Limitation: </strong>Formal methods can’t prove the correctness of a system that isn’t correct to begin with.<br><strong>Power: </strong>Formal methods help you identify flaws in your reasoning, find bugs and attacks you hadn’t thought of, abandon false solutions and pursue actual solutions.</p><p>We at <a href="https://alacris.io/">Alacris.io</a> believe that software professionals and executives tend to vastly underestimate the value of formal methods — that, as the name indicates, are not mere products you can use but processes you can enact. This is especially true in the domain of cryptocurrency dApps, where contracts can’t be fixed after they are launched: a lot of people have lost up to hundreds of millions of dollars belonging to themselves or to their customers due to software bugs that a modicum of formal methods could have caught — if not necessarily the first time around, at least the subsequent times.</p><p>Happily, there is a small but growing number of serious projects to improve smart contracts using formal methods, some of which have already borne valuable fruits. However, we at <a href="https://alacris.io/">Alacris.io</a> think that the existing efforts though useful remain desperately low-level with respect to the problem of building dApps. That is why we are working on providing better solutions that will help build the massively scaled dApps of tomorrow — and not just their smart contracts — in a way that is correct by construction. But this will be a topic for future articles.</p><p>Until we publish our next article, we invite you to share your thoughts and continue the conversation on Telegram at <a href="https://t.me/alacrisio">https://t.me/alacrisio.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d94ae8802be2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alacris/what-do-formal-methods-actually-guarantee-d94ae8802be2">What do Formal Methods actually Guarantee?</a> was originally published in <a href="https://medium.com/alacris">Alacris</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CryptoScalies: Cute Lizards at Scale]]></title>
            <link>https://medium.com/alacris/cryptoscalies-cute-lizards-at-scale-5ac34e6cc2af?source=rss-bc914ed341b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ac34e6cc2af</guid>
            <category><![CDATA[scaling]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[sidechains]]></category>
            <category><![CDATA[ocaml]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[François-René Rideau]]></dc:creator>
            <pubDate>Sun, 21 Oct 2018 02:48:31 GMT</pubDate>
            <atom:updated>2018-10-21T04:14:14.142Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rdcMxclbfXK2w1UW-WylIA.png" /></figure><p>In our previous article, <a href="https://medium.com/alacris/scaling-your-dapps-with-alacris-io-e7ab53f5b864">Scaling your dApps with Alacris.io</a>, we gave a technical overview of the <a href="https://alacris.io/">Alacris.io</a> architecture. In this article, we will examine how our “Blockchain Layer 2 Operating System” will open new business opportunities as it enables distributed applications (dApps) to scale securely. To illustrate the capabilities of Alacris, we will consider everyone’s favorite dApp of the day: trading non-fungible assets with pseudo-random characteristics derived from a “genome,” visualized graphically as cute animals. In other words, <a href="https://www.cryptokitties.co/">CryptoKitties</a> and its many spin-offs. Of course, this frivolous example will only be a fun device to examine issues that crop up in all dApps, including more serious ones like a decentralized exchange (DEX), or an on-chain car-rental service.</p><p>Despite CryptoKitties’ popularity, one thing that limits its usage is its reliance on an Ethereum transaction to generate each new kitty. Since Ethereum can only handle about 15 transactions per second for all users in the entire world (that’s about 9 million a week for <em>everyone on Earth</em>), this proved to be a severe bottleneck at the height of CryptoKitties’ popularity, slowing all transactions on the network to a crawl.</p><p>What if we could scale this dApp so it could be used by hundreds of millions of users at a rate of thousands of transactions per second? What if this scaling could be achieved without jamming the Ethereum blockchain, yet with all transactions 100% backed by Ethereum tokens? The Alacris.io architecture enables a variant of this dApp that scales beyond what on-chain designs allow.</p><p>Let’s call this variant <em>CryptoScalies</em>. This time the cute animals are lizards, with scales, at scale. Of course, since the Alacris.io architecture isn’t fully implemented yet, this will be a thought experiment — but one that hopefully clarifies the goal we are working towards.</p><p>CryptoScalies can be written as a series of “layer 3” applications on top of Alacris.io, defining a new asset class and ways to use it, and automatically benefiting from the scalability and security of the Alacris.io network of side-chains. Because CryptoScalies scale, users can breed and trade them as fast as they’d like. Side-chains also serve as marketplaces where users can publish sale listings and purchase offers for CryptoScalies, or even conduct auctions. But thanks to scaling, there is more to CryptoScalies than breeding and trading. Users can also organize play dates for their CryptoScalies so they can socialize and practice cooperative activities or competitive sports. Did you know that CryptoScalies enjoy improvisational jazz? That they love playing tennis doubles and team tournaments?</p><h3>Scaling with Side-Chains</h3><p>Breeding and trading CryptoScalies, having them play together or against each other, etc., are all made possible through <em>side-chains</em>: auditable sequences of transactions that help dApps scale by being kept off the main-chain, each managed by an <em>operator</em> that acts as intermediary between millions of users. Side-chain operators can be brokers, auctioneers, matchmakers, tournament organizers, or play other intermediary roles for all activities involving CryptoScalies. Users put each of their assets under the temporary and revocable care of a side-chain operator. Side-chain operators will then receive orders from users as to how they want to trade CryptoScalies, or how they want their CryptoScalies to interact with others, and under what specific conditions they are ready to transact.</p><p>Side-chain operators can orchestrate all these interactions with <em>high throughput</em> and <em>low latency</em> because they are authorized by users to do so independently of the main-chain consensus. They do update the main-chain, but only with a very short cryptographic summary of large batches of activity, from which each constituent action can be succinctly proven. Amortizing this small on-chain transaction over a large number of users makes side-chain interaction extremely cheap.</p><p>These characteristics mean that dApps on Alacris.io can <em>scale</em>. Side-chains are a generic solution to scaling all kinds of dApps: take our basic dApp for fast payment, and extend it with additional operations to handle your new assets and transactions.</p><h3>Interactions between CryptoScalies</h3><p>Thanks to side-chains, CryptoScalies can not only reproduce and change owners, but interact with each other, in a matter of milliseconds. <em>These interactions would not be possible without scaling</em>, as enabled by our side-chains. We will demonstrate two kinds of ways that side-chains can help scale activities between users: first, cooperative activities, illustrated with improvisational jazz and payment channels; and second, competitive activities, illustrated with a tennis match, but also auctions and exchanges.</p><p>In a cooperative activity, like musical improvisation, where the interests of all participants are already aligned, and the number of participants is relatively small (say a few dozens at most), it is better and faster for these participants to conduct their operations directly among each other without a referee. The side-chain will thus help them setup a shared interaction channel, where participants can conduct all their operations among each other off-chain, using multiparty signatures to validate the progress of their interaction and only posting to the side-chain (and indirectly to the main-chain) the final result of their interaction, if any. A well-known particular case for such a setup is payment channels in the style of the Bitcoin Lightning Network, or more generally state channels. Using Alacris.io allows these channels to scale further as a layer 3 solution than they can on Bitcoin or Ethereum as a layer 2 solution: it can be hundreds of times cheaper to create such channels as layer 3 on a side-chain than it takes to create a single channel as a layer 2 solution directly on the main-chain; and the latency to full confirmation is only marginally slower, as they propagate from users to the side-chain to the main-chain.</p><p>In a competitive activity like a tennis match or tournament, the interests of participants are locally opposed to each other; the side-chain operator can then act as a neutral referee who will ensure interactions are fair without sacrificing latency. Typically, the game mechanics involves users each making strategic choices or contributing to random seeds and publishing a digest of their choices in a first phase. In a second phase they reveal their verifiable choices, leaving no way to cheat, except trying to time out rather than lose explicitly. With a neutral referee, those who fail to reveal their choices in a timely fashion lose their match by default and get excluded from their tournaments. Low-stake tournaments can have long timeouts, whereas high-stake tournaments will require players to remain constantly connected. Repeat offenders may also get excluded from all further activities unless they pay a suitable penalty to fully compensate victims and show their atonement. More generally, users who fail to complete their part of the protocol are increasingly penalized as their misbehavior repeats and/or as the stakes get higher. In financial transactions, they may have to pay interest or rent on the assets immobilized by the other parties during their lack of response, taken out of the collateral bond that was posted. On the other hand, in higher trust settings, when friends play for fun, acquaintances play with low stakes, or business partners interact in repeat business, they may nominate a referee among themselves, or rent a trusted yet affordable one, who can serve them as a faster, layer 3 solution. Users can thus achieve higher speed and lower transaction fees without sacrificing the security of transactions being ultimately backed by the blockchain.</p><p>In all of these cases, the Alacris.io architecture can help create new applications not otherwise possible, using side-chains to enforce verifiable computations.</p><h3>Holding Side-Chain Operators Accountable</h3><p>Side-chains can be a great resource if their operators are indeed honest and competent. But why should anyone trust these operators? For the very same reason that you might trust anyone else — because side-chain operators are motivated by the profits from behaving honestly and will be held accountable if they don’t. Side-chain operators are competing on a free market and will lose their customers if they don’t offer the best value for their customers in terms of service and price.</p><p>We have designed the Alacris.io protocol so that a side-chain operator can only lose money by acting maliciously, while their honest behavior will earn them business, and in turn, profits from fees.</p><p>Real-time auditing of a side-chain operator’s behavior ensures that there is a limit to how much damage they can do before they are caught — at which point they forfeit the bond that they posted as collateral. If that limit is small enough compared to the bond, it will not be in their interest to cheat at all. There is still the case of the incompetent side-chain operator getting hacked by those who might profit at the expense of both the operator and the users; but even in this case, the limits on possible damage mean that the risk is insurable — and on-chain or off-chain means are available to make honest users whole. We also expect hacks to be rare because Alacris.io will provide code with enough proof of correctness that it will not be the weakest link in the security defenses, as well as guidelines and training to deploy our code securely.</p><p>A side-chain operator’s track record can be established because its public keys provide a long-term pseudonymous identity. If a side-chain operator has been providing great service, they will be very recognizable. If a side-chain operator behaves dishonestly, they will have to create a new identity, post another bond, and build a reputation from scratch, just to be able to cheat again. Moreover, the Alacris.io architecture allows for people and institutions that already have a reputable identity to become side-chain operators that are recognizable and therefore, more likely to be a preferred side-chain operator. Based on this identity and reputation, some may even be able to purchase insurance so that users would be fully compensated even if the side-chain operator were to fail or get hacked, improving their trustworthiness to users. Users will thus have a wide range of side-chains to choose from, depending on their trust network and risk profile.</p><p>The last aspect of accountability that ensure that there will indeed be a free market in side-chains is that users can individually repudiate<em> </em>an unsatisfactory side-chain operator — any user can at any point unilaterally extract their assets from their side-chain’s custody by appealing to the main-chain contract.</p><p>Reasons to leave may include:</p><ul><li>The side-chain operator could be incompetent or dishonest.</li><li>The side-chain operator’s servers could be destroyed or captured.</li><li>The powers-that-be in a country where the side-chain is operated could prohibit the operator from handling further transactions.</li><li>The side-chain operator could increase their fee schedule beyond what the user is willing to pay.</li><li>Network disruption could make it impossible or impractical for the user to communicate with the side-chain operator.</li><li>A spokesperson for the side-chain operator made disparaging comments about the user’s favorite celebrity.</li></ul><p>Ultimately, any user’s reasons are their own, whether wise or frivolous.</p><p>Whatever the case, users can move all of their assets to another side-chain, with no justification required, and even without active cooperation from their original side-chain’s operator. In the Alacris.io architecture, this is guaranteed by the <em>smart contract</em> that binds the side-chain to the main-chain. Users can post transactions on the main-chain that the contract forces the side-chain operator to process. Users can even post transactions on the side-chain of another operator who will batch such transactions on the main-chain. Thus, mass exits from a side-chain can scale when that side-chain suddenly becomes unpopular — whether because of a fee hike, a scandal, or cheating.</p><p>This <em>right to exit</em> possessed by every user ensures free competition among side-chain operators. But what if all side-chain operators hike their fees at the same time? The <em>right to enter</em> ensures that anyone can become a side-chain operator, even <em>you</em>, dear reader, if you believe that you could provide a cheaper, better service to yourself, your friends, and other “victims of the system,” and still swim in gold (or even merely break even). It’s a free market out there, and we expect competition to keep prices down and service quality up.</p><h3>Verifiable Computations</h3><p>The main technical challenge in holding side-chain operators accountable is, how can you audit a side-chain operator’s behavior, in real-time, and verify that they are indeed honest? That’s where the Alacris.io architecture brings new answers.</p><p>Consider the verification of arbitrary computations, such as interactions between CryptoScalies. The Alacris.io architecture makes this verification efficient by shifting most of the work out of the blockchain consensus where computations are expensive, into the computers of individual users and side-chain operators for whom it is cheap. The network doesn’t run the computations, it only <em>verifies</em> them. The interactions will be specified in the Alacris.io programming language, which will allow for extraction of all components of the system: the software that partakes in the protocol, the software that computes the results, the software that produces a proof that the result is correct, the software that checks the proof that the result is correct, the software that argues the proof before the consensus (if required), etc. Application programmers will be able to write the software once and be confident that all these moving parts fit snugly with each other, and that the overall system is fast, robust and secure.</p><p>There remains the issue of making transaction data available for audit. Repudiable side-chain operators are required to constantly maintain a suitably indexed journal of all their activities on a side-chain. Then they must constantly publish this journal to a S<em>hared Knowledge Base</em>, that makes the data available to verifiers and serves as an oracle to make this data availability known to the main-chain. The Alacris.io contract on the main-chain then relays the public status of the data. Side-chain operators partake in the court registry and watch each other; they risk their own money if another side-chain operator starts lying, and an adversary would have to capture a majority of side-chain operators to take over the system.</p><p>In the end, side-chain operators leave behind an audit trail — the very state of their side-chain — and the transactions they facilitate are only considered confirmed after the trail itself is validated. This leaves precious little space for a side-chain operator to cheat in any way without getting caught and losing big. Whether they match users on an exchange, preside over auctions, arbitrate a tennis match, facilitate payments, or conduct any kind of activity, this activity can all be audited and verified. The only leeway they have is in denying or delaying service to some users while processing other users faster. Quality of service is not verifiable by the court system, but it is measurable by the users who can compare how well they are treated by various side-chain operators, and decide to which side-chains to bring their business and at what price.</p><h3>Confirmation, Fast and Slow</h3><p>Transactions go through many stages, and which stage you consider “confirmed” depends on how much you trust other participants with respect to the transaction amounts at stake.</p><ol><li>If a close friend or an otherwise reputable person promises to send you money to pay their share of a restaurant bill, you can probably take them at their word even before they complete the transaction, and cover their meal without waiting for the payment to clear two hours later. For somewhat larger bills from less trusted people who are nevertheless well-identified and solvent, you can also probably take their word, and escalate the situation if they don’t pay you in a timely manner: first, follow up casually, and if all else fails, take them to small claims court. In all these cases, you don’t need a side-chain to authorize an immediate transaction; still a side-chain can bring you lower transaction fees, and also peace of mind as the payment goes through the various stages of confirmation — especially in the border cases where you might not have been so sure about the trustworthiness of the other person.</li><li>If you fully trust that the side-chain operator is not colluding with a customer because it’s a big, known financial institution and the amount is small enough, you may serve that customer as soon as the side-chain operator sends confirmation of the transaction, which takes a fraction of a second.</li><li>If the payments you receive are suitably insured (at a small premium) or if you reasonably trust the side-chain operator not to cheat on the transaction you are receiving, then you may serve the customer as soon as a quorum of the Shared Knowledge Base agrees that the transaction looks good, which typically takes a few seconds.</li><li>If you have no reason whatsoever to trust either the customer or their side-chain operator, or if the transaction is large enough that you should take extra precautions anyway, then you should definitely wait for the consensus to fully confirm the transaction, which may take one hour, or even several hours, depending on the side-chain operator configuration.</li></ol><p>There are all kinds of transactions, and a large number of them fit into Cases 2 and 3 above, at which point the Alacris.io system will make them fast when they would otherwise have been slow. Other transactions, such as in Case 4, are actually made somewhat slower than by directly using the main-chain, but are still cheaper using a side-chain, because you share with thousands of other users the cost of registering transactions with the distributed consensus. Notably, most casual payments can be transacted quickly as in Case 3: Small payments in stores up to a few thousand dollars using a reputable side-chain operator such as an established financial institution. As for playing tournaments between CryptoScalies through a reputable side-chain, it can also be considered fast for most purposes; but don’t go spending or gambling away all your earnings before they are fully confirmed (or do it using the same side-chain).</p><p>In conclusion, Alacris.io can help you develop dApps that <em>scale</em>, in a <em>safe</em> way. The volume of transactions can be large. The cost of transactions will be low. The effective latency of transactions will be low in a wide variety of cases and the security of the system will be much better than if you had to rebuild the same system from scratch using lower-level tools than those that Alacris.io offers.</p><p>If you enjoyed reading the article or would like to follow along with our progress, we invite you to share your thoughts and continue the conversation on Telegram at <a href="https://t.me/LegicashCommunity">https://t.me/</a>alacrisio.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ac34e6cc2af" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alacris/cryptoscalies-cute-lizards-at-scale-5ac34e6cc2af">CryptoScalies: Cute Lizards at Scale</a> was originally published in <a href="https://medium.com/alacris">Alacris</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scaling your dApps with Alacris.io]]></title>
            <link>https://medium.com/alacris/scaling-your-dapps-with-alacris-io-e7ab53f5b864?source=rss-bc914ed341b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7ab53f5b864</guid>
            <category><![CDATA[ocaml]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[scaling]]></category>
            <dc:creator><![CDATA[François-René Rideau]]></dc:creator>
            <pubDate>Sat, 20 Oct 2018 05:19:37 GMT</pubDate>
            <atom:updated>2018-10-21T03:48:09.588Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X8k2mgt9hrzKVJbP4SJTAA.png" /></figure><p>You may have heard how we at <a href="https://alacris.io/">Alacris.io</a> are working to scale cryptocurrency payments. And these days, who isn’t? But our technology isn’t just about payments — it’s a general approach to developing dApps that are robust as well as scale. Payments are just the first step, necessary for any dApp that involves cryptocurrency. In the future, our platform will support non-custodial exchanges and cross-chain payments, state channels and arbitrary layer 3 contracts. And on that platform, <em>you</em> will be able to build your own secure, scalable dApps.</p><p>This article provides a technical overview of the “Blockchain Layer 2 Operating System” that we are building. It is intended for an audience that can understand and appreciate the technical concepts that underlie our architecture. The article article purposefully avoids going to any depth into the implementation of our ideas, to focus on their essence. If you are interested in the fine details of our code, contact us so we can disclose to you our source code in advance of an official public release. We will also publish more detailed articles as time permits on various more specific aspects of our architecture.</p><h3>Technical Summary</h3><p>First, let’s summarize our technical offering before we explain it further.</p><p>At <a href="https://alacris.io/">Alacris.io</a>, our approach to designing dApps is that they do as little work as possible on the main chain used as consensus, and as much as possible off-chain. Alacris.io is agnostic to the main chain being deployed. For practical purpose, the main chain is currently Ethereum. The only requirement for the main chain is its ability to securely express the rich smart contracts of Alacris.io. Using the main chain is strictly limited to making final settlements and to keeping everyone’s interests aligned via smart contracts where participants post bonds to serve as collateral. This way, regular transactions can scale without being limited by the necessarily high latency, low value, and high cost of the main chain consensus.</p><p>Auditable off-chain work happens on one or several <em>side-chains</em>. Unlike earlier side-chain proposals, the Alacris.io design is unique in that users do not have to trust the side-chain operators. Instead, the side-chains are bound to the rules of the dApp protocol by a <em>smart contract</em> on the main chain and their operators are held accountable by the threat of losing both their bond and their business if they fail. Our smart contracts use formal logic so that we can precisely describe the role and responsibilities of each participant in the dApp protocol. Abuse claims can then be verified using <em>interactive proofs</em> while a S<em>hared Knowledge Base </em>ensures that side-chain operators continually publish the complete, well-formed state of their side-chain, thus ensuring that anyone can partake in these proofs.</p><p>That’s quite a mouthful of a technical summary, so now let’s recapitulate in detail.</p><h3>Game Theory and Smart Law</h3><p>At Alacris.io, we think about software first and foremost in terms of distributed applications that involve multiple actors with distinct and possibly divergent interests. Studying interactions from the point of view of whether the interests of actors are aligned or opposed is the domain of <em>game theory</em>. This is a scientific topic at the intersection of Economics, Mathematics, and Military Science, familiar to all you information security professionals out there.</p><p>The technology that ensures that computerized actors’ interests converge and remain aligned is called <em>“smart law”</em> — where “smart” denotes automation, not intelligence, and “law” is an analogy to human law, not a substitute to it. This smart law can take the form of <em>smart statutes</em>, whereby they are rules baked into the interaction protocol itself that applies to all participants, or of <em>smart contracts</em>, wherein the rules are defined as an add-on to the protocol, that only applies to those participants who opt in. The protocol can therefore be seen as a <em>court system</em>, that prevents and resolves disputes between participants by enforcing property rights and contracts. In this, our vision is very similar to that of <a href="https://truebit.io/">TrueBit</a> or <a href="https://plasma.io/">Plasma</a>.</p><p>On the other hand, our vision challenges a common view of contracts as a means to conduct arbitrary computations on the blockchain. Instead we understand that computation on the main chain is inherently more expensive than outside the main chain. For example, computing on Ethereum is currently a <strong>million times</strong> more expensive than on the cloud, and there is reason to believe that it will always be much more expensive. In human terms, resolving conflicts in a federal court system is much more expensive and risky than resolving them in local courts, or even better, settling conflicts out of court, or better yet, avoiding conflict altogether. In smart contracts as in human contracts, going to court should never be plan A; rather, it is a last resort if the other party fails to comply with the agreed-upon contract and also refuses to settle out of court. A strong contract makes it very clear who is responsible for what, and what are the consequences for each party if they fail to do their part. And while there is always uncertainty as to how human courts will interpret a human contract when things break down, a smart contract can be written in such that there is no leeway for misinterpretation.</p><p>The goal of a contract is therefore to set excruciatingly clear parameters and consequences, such that the interests of all involved are aligned towards participating in the protocol as intended. Even so, the contract can only guarantee that offenders will be penalized and victims compensated. It cannot magically make someone else do something that they won’t or can’t do. Therefore, users should carefully choose partners, even if the contract ensures protection. Engaging with the wrong person will waste your time and immobilize your resources, even if the court grants you reparations in the end. Meanwhile the thing you wanted done won’t have happened and you may have to find someone else to do it for you. All this is true of both smart contracts and human contracts.</p><p>Alacris.io uses smart contracts as means to <em>verify</em> arbitrary computations on the blockchain; it doesn’t seek to <em>run</em> arbitrary computations on-chain, as the Plasma paper purports to do. In our <em>operating system</em>, actual computations are run on private computers off-chain; only the minimum necessary involves the blockchains. Even the verification, by a smart contracts, of whether a computation was or wasn’t executed properly, only happens when the failing party refuses to settle, and the aggrieved party posts a complaint. The good news is that this verification does not require a “Turing equivalent” language to specify on-chain contracts. There is no need for unlimited recursion, and the “deepest” necessary computations only involves checking Merkle proofs. When a suitable contract-checking language is devised and its effectiveness is demonstrated on an altcoin, chances are good that it will become a universal standard, and that it will even be adopted by Bitcoin. This means our technology will remain relevant even in the odd chance that Bitcoin maximalists are proven right in the future and other cryptocurrencies fade away.</p><h3>Game Semantics and the Logic of Blockchain</h3><p>Smart contracts are written in terms of mathematical logic. Each clause in the contract is a formula typically of the form <em>∀x P(x) → (∃ y Q(x,y)) ∨ S(x) </em>where one party makes a claim <em>P</em> based on a “witness” <em>x</em>, and challenges the other party to come up with a response <em>Q</em> based on an opposing witness y, or else the other party is penalized according to sanction <em>S</em>. <em>P</em> and <em>Q</em> are written as logical statements that the “judge” can check. <em>S</em> is an action that the judge can pronounce and enforce as their sentence. The process of making a claim and then challenging the other party to respond is an <em>interactive proof</em>. The other party has limited time to respond (typically two hours), but if they don’t respond in time, or make a less-than-optimal response, anyone else can propose an better response. Thus, as long as at least one vigilant person has access to the blockchain, malicious actors cannot get away with fraudulent claims. An interactive proof can take as many steps as there are challenge steps, which is bounded by the number of alternations between ∀ and ∃ in the formula. While there can potentially be a lot of them, techniques such as Skolemization can help bring this number down.</p><p>The branch of mathematics that deals with seeing logical formulas as verification games that yield interactive proofs is called <a href="https://en.wikipedia.org/wiki/Game_semantics">game semantics</a> (not to be confused with “game theory,” as discussed above). There is even an approach to logic that takes game semantics as its starting point and defines the logical connectors and quantifiers in terms of existing games, rather than trying to identify games that correspond to pre-existing logical frameworks. That approach is called <a href="https://en.wikipedia.org/wiki/Computability_logic">computability logic</a>. We believe that the best level of abstraction for specifying the logic of a dApp is a variant of computability logic. The primitive operations of that logic are the usual arithmetic and cryptographic functions, and its logical connectors are those that can be argued through interactive proof games.</p><p>Alacris.io will grow a domain-specific language with which dApp developers can use mathematical precision in defining the logic underlying their dApp. Our operating system will then consistently extract all the executable parts of a dApp from their specification in the logic, including:</p><ul><li>Mathematical proofs that the dApp makes sense from the viewpoint of game theory and indeed binds participants to do what each other think they should.</li><li>Code for each of the participants to act within the agreed-upon constraints, in a robust way, despite sometimes unreliable hardware, and despite a systematically adversarial network.</li><li>The “smart contract” code in the main chain’s virtual machine (e.g. EVM for Ethereum), that will serve as referee in case of a “smart lawsuit”.</li><li>The on-chain strategies for the “smart lawyers” of each party to play the interactive proof games when a “smart lawsuit” takes place.</li><li>The off-chain strategies for the “smart lawyers” of each party to avoid “smart lawsuits,” to negotiate cheaper off-chain settlements whenever it makes sense, and to explain to users their rights and responsibilities under the contract.</li><li>Continuous tests in a test network, that comprehensively exemplify how predictable attack scenarios are effectively prevented. It’s not enough to prove the code correct, it must be clear to all participants that the system will function as anticipated.</li></ul><p>All the above are as many moving parts that must fit precisely together. The smallest discrepancy between any of these aspects means that the dApp is broken, and may result in massive financial losses for its users. Smart contracts in particular cannot be revised after they are executed, even to fix bugs, so it is particularly important to get them perfectly right the first time around. If even the top dApp specialists have <a href="https://blog.comae.io/the-280m-ethereums-bug-f28e5de43513">lost $280M due to a bug in a 400 line contract</a>, what chance do mere mortals like us have at writing non-trivial contracts tens or hundreds of times larger without a fatal bug? We need tools that can prevent such bugs during development. And Alacris is building these tools.</p><p>Alacris.io uses the Coq proof assistant as the foundational tool on which to develop our dApps. As of October 2018, our demo is written in a mostly pure functional style in OCaml and Solidity. Once the design is stable, we’ll translate as much of it as possible into Coq and then we’ll generate the OCaml and Solidity (or EVM) code from Coq in a way that can be proven correct. We thus differ from TrueBit and Plasma in that even though their authors understand the basic principle of game semantics, they don’t take advantage of the power of formal methods to automatically weave together all the moving parts of a dApp so they tightly fit together.</p><h3>The Shared Knowledge Base</h3><p>Enforcement of side-chain rules depends on publishing a concise cryptographic summary of side-chain activity, known as a “Merkle root hash,” and adjudicating disputes based on cryptographic proofs based on this summary of side-chain participants’ behavior. Constructing these proofs requires full knowledge of all side-chain activity, so it’s necessary for all participants to have access to a canonical view of side-chains at all times.</p><p>The challenge faced by all smart contract systems in which an open set of users can join or leave the contract, is that in order to audit the behavior of a side-chain operator, all the side-chain data must be publicly available. If a side-chain operator could illicitly update the state of their side-chain by posting the content address of that state without showing the actual content, they could post invalid content that credits them and Sybil identities with unearned tokens, and no one could prove them wrong before they make off with the funds. This is what the Plasma paper calls a “block withholding attack.”</p><p>Current attempts at developing Plasma prototypes involve a variety of “exit games” to mitigate such an attack: if and when the side-chain operator withholds data, users exit en masse to the main chain, using a protocol meant to prevent double spending. But ultimately, if such an attack is possible at all, then it becomes impossible to conduct interactive validity proofs in bounded time. The “exit games” allow honest users who carefully watch the chain to get their money out of the contract, but will cause the entire main chain to grind to a halt if the side-chain was trying to scale beyond what the main chain could handle. The fees would become exorbitantly high, and users with small accounts, those not connected during the mass exit, or those who fail to exit before the timeout, etc., may all lose their money to the malevolent side-chain operator, or have their money held hostage for a long duration.</p><p>The solution we offer is to prevent such attacks using a S<em>hared Knowledge Base:</em> a network of servers, called registrars, that guarantee that the data is indeed both well-formed and publicly available in its entirety. This allows users and third-party verifiers to check that the data is valid and raise any disputes in court before state updates are confirmed. In the analogy between smart law and human law, this Shared Knowledge Base is a <em>smart court registry</em>: parties are required to register all the relevant data with the registry before it may be used as a title claim or otherwise as evidence in a smart lawsuit. In traditional smart contract parlance, the Shared Knowledge Base can also be seen as an <em>oracle</em> <em>for data availability</em>: an <em>oracle</em> is a way for the blockchain consensus to verify facts about the world outside the consensus itself. What this particular oracle establishes, is that the data is indeed available for verification by third-parties: the registrars, for a small fee, will accept data from the side-chains, check that the data is indeed all present and well-formed, sign off on the data, and allow anyone to review the data. As long as at least one honest registrar signs off on the data, a block withholding attack is impossible. Side-chains must obtain signatures from at least half of the registrars to be able to validate their state updates. An attacker must therefore capture 50% of registrars (by stake) to be able to break the system by either withholding blocks or denying validation.</p><p>The Shared Knowledge Base is a new component that comes with its own costs and benefits and its own guarantees and vulnerabilities. There are many challenges to building a secure Shared Knowledge Base. However, as compared to more general oracles trying to relay outside information, a Shared Knowledge Base is a more tractable problem: most oracles have potential issues both with participant honesty, and with reliability of their link to the outside world. This oracle only has to deal with the honesty part, whereas the reliably comes (comparatively) for free, since each registrar only has to report on a truth that it is making happen itself, i.e. making the data it has public, rather than on an outside truth about the world that it has to assess and measure. Ultimately, the honesty of court registrars can be reduced to the same problem as the honesty of validators for a cryptocurrency blockchain, a problem that, while not trivial, is considered solvable. The very same techniques used to secure a blockchain could be used to secure the Shared Knowledge Base. Yet, a Shared Knowledge Base is overall simpler and faster to achieve than a distributed consensus, since it only needs to build <em>shared knowledge </em>(information known by everyone), rather than the much more expensive <em>common knowledge</em> (information that everyone knows that everyone agrees upon). The parts of the protocol that do require a common knowledge will be resolved on the existing main chain (e.g. Ethereum) rather than on the new component that is the Shared Knowledge Base.</p><p>We’ll talk more in detail about the Shared Knowledge Base and how to properly use and implement it in a future article. For now, it is suffice to say that the Shared Knowledge Base is a key component of the Alacris.io architecture that allows it to scale safely, and is missing in rival proposals.</p><h3>Towards faster, cheaper, and safer dApps</h3><p>The Alacris.io architecture enables users to write dApps in a faster, cheaper, and safer way. By using side-chains, regular operations take a fraction of a second. Additional safety precautions require the use of the Shared Knowledge Base, which takes a few seconds. Complete safety still requires waiting for the consensus. But assuming the side-chain is honest, which is commonly the case since the side-chain is backed by a sizable bond, users can trust operations to be complete as fast as the side-chain can confirm them. What will make Alacris.io dApps safer than other dApps, though, is the use of formal methods, and the fact that they cover not just the contract strictly speaking, but also all the off-chain parts of the dApp that interact with the side-chain.</p><p>Anyone on the Internet can duplicate our code, which is largely free software, and start their own side-chain network, then use it to write applications as Layer 2 solutions. But for security reasons as well as for performance, it is better for them as well as for us to join forces, and enjoy the network effects — especially since the main risk for the capture of the Shared Knowledge Base is it being under-capitalized relative to the funds it is securing. Undercapitalization of a validator network is a potential issue for all solutions based on a side-chain — but our Shared Knowledge Base, unlike the validator networks of other side-chains, is <em>general purpose</em>: the same network can be used to ensure the integrity of any side-chain with any structure, not just the specific side-chain contract we will be developing. Developers of many side-chains can therefore pool their resources and capital into a common, more robust, validation network, where previous approaches were condemning them to each have its own separate validator network with a fraction of the total capitalization. To further increase these network effects, we will offer a way to write contracts as Layer 3 solutions on top of our network. Our general-purpose side-chain contract will itself allow the definition of contracts on the side-chains, so developers do not have to run their own side-chain network to deploy their scalable dApps. Our side-chains will sport a simple virtual machine (VM) that is designed to verify computations only, not to carry them out, and will include all the required cryptographic primitives (digests, signatures, merkle proofs, zk-SNARKs, encryption, etc.), with no unbounded recursion. Our VM will be able to deconstruct existing data structures without building new ones (beyond initial constants), and it will have subtraction or division of natural numbers without addition or multiplication. That VM will be usable as the backend of our logic specification language.</p><p>In our next article, we will describe an example application for our technology: CryptoScalies, or Cute Lizards at Scale. In the meantime, we invite you to share your thoughts and continue the conversation on Telegram at <a href="https://t.me/LegicashCommunity">https://t.me/</a>alacrisio.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7ab53f5b864" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alacris/scaling-your-dapps-with-alacris-io-e7ab53f5b864">Scaling your dApps with Alacris.io</a> was originally published in <a href="https://medium.com/alacris">Alacris</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What do Formal Methods actually Guarantee?]]></title>
            <link>https://medium.com/legi/what-do-formal-methods-actually-guarantee-c33e509de88f?source=rss-bc914ed341b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/c33e509de88f</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[formal-methods]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[ocaml]]></category>
            <dc:creator><![CDATA[François-René Rideau]]></dc:creator>
            <pubDate>Tue, 10 Jul 2018 13:46:23 GMT</pubDate>
            <atom:updated>2018-10-21T04:21:12.855Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*gZw2EKOIK5ntPiij33BDyw.jpeg" /></figure><p><em>A revised version of this article was published at </em><a href="https://medium.com/alacris/what-do-formal-methods-actually-guarantee-d94ae8802be2"><em>https://medium.com/alacris/what-do-formal-methods-actually-guarantee-d94ae8802be2</em></a></p><p>There is a lot of misunderstanding about what formal methods can do — their powers — and what they cannot do — their limitations. Those who are mistaken about one side of the argument, exaggerating it or downplaying the other, or are simply too aware of one side yet insufficiently aware of the other, may end up being overly skeptical of formal methods or overly enthusiastic about them. In this short essay I’ll try to make both cases clear, and thus explain the value proposition of formal methods without falling into easily rejected claims.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*UPQd_cyi7wXPIzY2CezxYQ.jpeg" /></figure><p><strong>Limitation: </strong>Formal methods are not a magic powder that you can sprinkle over your code to make it correct.<br><strong>Power: </strong>Formal methods are a structural backbone around which you can develop more robust code.</p><p><strong>Limitation:</strong> Formal methods are only <em>methods</em>. To have useful results at all, you still need to apply them, correctly, to the right problems.<br><strong>Power: </strong>When applied correctly, formal methods can eliminate not only single actual bugs, but entire <em>classes</em> of potential bugs and attacks, that your model can express are absent.</p><p><strong>Limitation: </strong>Formal methods won’t prevent bugs on aspects of your code that you haven’t formalized (yet).<br><strong>Power: </strong>Formal methods can ensure the <em>non regression</em> of your code with respect to those classes of defects you have formalized. Unlike other methods, they provide a ratchet that ensures progress even as the code evolves.</p><p><strong>Limitation: </strong>Formal methods can’t eliminate bugs and prevent attacks that go <em>below</em> the model you use (e.g. <a href="https://meltdownattack.com/">SPECTRE attack</a>).<br><strong>Power: </strong>Formal methods allow you to reason at one high level of abstraction and transport your results to a lower level of abstraction, provided you also prove <em>full abstraction</em>.</p><p><strong>Limitation: </strong>Formal methods cannot be used to prove “everything” correct. There are always more things you could reason about.<br><strong>Power: </strong>While there are infinite further issues, previous issues are finite and those that can be solved can be fully solved with finite effort.</p><p><strong>Limitation: </strong>Formal methods suppose your domain is well-defined and limited enough to be specifiable, and that you actually understand it enough to specify it.<br><strong>Power: </strong>Formal methods are a discipline that when to stick to them, will naturally lead you to your understanding your domain better.</p><p><strong>Limitation: </strong>Formal methods cost a lot in terms of time and talent. They cost even more as you explore new spaces that require reasoning infrastructure.<br><strong>Power: </strong>In many applications where millions of dollars worth of assets, or even lives, are at stake, it can be even more expensive <em>not</em> to use formal methods.</p><p><strong>Limitation: </strong>Not everyone can use formal methods.<br><strong>Power: </strong>A large fraction of developers <em>can</em> be trained to use formal methods. As for those who really can’t, they are probably a liability when it comes to safety-critical code.</p><p><strong>Limitation: </strong>Formal methods can only prove formal guarantees, and only based on a lot of formal assumptions (axioms). And they cannot establish the informal guarantees that matter to humans.<br><strong>Power: </strong>Formal methods help you make explicit what your assumptions and your guarantees are and ruthlessly eliminate any flaw between the assumptions and guarantees.</p><p><strong>Limitation: </strong>Formal methods won’t save you from having to make a lot of assumptions about the vast amount of software and hardware that you depend on under your system.<br><strong>Power: </strong>Formal methods will prevent the multiplication of <em>implicit</em> assumptions you don’t know about, don’t track, and don’t check as your system evolves, that may once have been true yet will cause catastrophic errors when they stop being valid (see <a href="https://hownot2code.com/2016/09/02/a-space-error-370-million-for-an-integer-overflow/">Ariane V</a>).</p><p><strong>Limitation: </strong>Just because it’s true doesn’t mean it’s provable. There are correct programs that formal methods can’t prove correct.<br><strong>Power: </strong>You shouldn’t deploy an program in a setting where safety matters unless you at least have an informal proof of safety. Then, making that informal proof formal is not only possible, but doable and useful. Formal methods are not magic, but neither are informal methods.</p><p><strong>Limitation: </strong>Even for the things you <em>can</em> prove, often you can’t <em>afford</em> to prove them.<br><strong>Power: </strong>You can use formal methods strategically: study what kind of serious or catastrophic issues similar projects have had that are worth eliminating, and build your model accordingly.</p><p><strong>Limitation: </strong>Formal methods can’t prove the correctness of a system that isn’t correct to begin with.<br><strong>Power: </strong>Formal methods help you identify flaws in your reasoning, find bugs and attacks you hadn’t thought of, abandon false solutions and pursue actual solutions.</p><p>We at Legicash believe that software professionals and executives tend to vastly underestimate the value of formal methods — that, as the name indicates, are not mere products you can use but processes you can enact. This is especially true in the domain of cryptocurrency dApps, where contracts can’t be fixed after they are launched: a lot of people have lost up to hundreds of millions of dollars belonging to themselves or to their customers due to software bugs that a modicum of formal methods could have caught — if not necessarily the first time around, at least the subsequent times.</p><p>Happily, there is a small but growing number of serious projects to improve smart contracts using formal methods, some of which have already borne valuable fruits. However, we at <a href="https://legi.cash/">Legicash</a> think that the existing efforts though useful remain desperately low-level with respect to the problem of building dApps. That is why we are working on providing better solutions that will help build the massively scaled dApps of tomorrow — and not just their smart contracts — in a way that is correct by construction. But this will be a topic for future articles.</p><p>Until we publish our next article, we invite you to share your thoughts and continue the conversation on Telegram at <a href="https://t.me/LegicashCommunity">https://t.me/LegicashCommunity</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c33e509de88f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/legi/what-do-formal-methods-actually-guarantee-c33e509de88f">What do Formal Methods actually Guarantee?</a> was originally published in <a href="https://medium.com/legi">Legicash</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>