<?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 Andrew Thompson on Medium]]></title>
        <description><![CDATA[Stories by Andrew Thompson on Medium]]></description>
        <link>https://medium.com/@potsdamnhacker?source=rss-691abb98b3ba------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KncTMRKL_Lgx9e1mpch-cQ.jpeg</url>
            <title>Stories by Andrew Thompson on Medium</title>
            <link>https://medium.com/@potsdamnhacker?source=rss-691abb98b3ba------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 21:58:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@potsdamnhacker/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[Why blockchain is a terrible idea for applications]]></title>
            <link>https://medium.com/hackernoon/why-blockchain-is-a-terrible-idea-for-applications-8393d44f6cab?source=rss-691abb98b3ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/8393d44f6cab</guid>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Andrew Thompson]]></dc:creator>
            <pubDate>Thu, 25 Oct 2018 14:56:26 GMT</pubDate>
            <atom:updated>2018-11-10T21:39:01.446Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0FBJxJiUYg1hLl6pcJN37A.jpeg" /></figure><h3>Why Blockchain is a Terrible Idea for Applications</h3><h3>Here we go again</h3><p>Much like when the .com bubble burst, the cryptocurrency/blockchain market is headed towards an extinction event. There’s a reckoning to come and even companies with good ideas will discover issues during project execution. It turns out it’s a lot easier to describe in a whitepaper your plan to replace AWS, AirBnB or Uber with your blockchain project than actually pulling it off. These are difficult markets to attack and showing up to the fight with inferior UX, a fraction of the user-base, and the one shining “advantage” of decentralization won’t be enough.</p><h4>Why blockchains aren’t suitable for almost all projects</h4><p>Blockchains are not suitable for almost all projects; they’re slower, more complicated to develop applications for, and there are many security issues. In addition, decentralized applications running on the blockchain are out of your control — updates or changes require consensus.</p><p>All of which results in a minimum viable product that’s a lot harder to build or much more insecure. The upshot of this is the blockchain version of anything is either going to take significantly more effort to build or the team will have to cut corners that should not have been cut to get to a MVP faster.</p><h4>Using a blockchain, but not decentralized</h4><p>Some projects address blockchain shortcomings by using databases to store data (e.g., CryptoKitties, Bee Token). So, for example, a small amount of data goes onto a blockchain, but the majority is stored in a database (stored off-chain) with references back to the blockchain.</p><p>This hybrid approach may solve some problems, but others appear. What happens if the server goes offline or you lose the database? Also, anytime databases are leveraged, core centralized problems return: databases can be attacked, data stored in the database can be changed, or get compromised.</p><p>If 90% of data is stored off-chain in a database what have you really built and why have you built it on the blockchain?</p><p>The only thing you’ve done is tie your data to a public ledger and verify a link from the blockchain to the database existed at a certain point. But what‘s the benefit besides creating a digital notary about when something was added and evidence that something hasn’t been tampered with since? We can’t use that information to figure out any meaning at that point in time as it’s usually a one-way-hash of the data stored elsewhere.</p><p>Similarly, many projects use IPFS with a cluster of distributed nodes to host the data rather than keep it on the blockchain. This on the face of it feels decentralized, but there’s often no thought put in to the economics or incentive around keeping these nodes online. If the data is only “distributed” among a handful of participants, it’s really not a significant improvement over just using a centralized database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aNZ2qgWGupN4hNadUfgcaw.jpeg" /></figure><h3>Blockchain burdened by extra work</h3><p>If transaction speed is critical to your application’s success then you should think databases, not blockchains.</p><p>Some blockchains claim they can perform up to 500,000 tx/sec and while this speed may be fast compared to other blockchains, it’s slow compared to a database running on just a single machine (not a cluster). For example, a big SQL server is going to eat those numbers for lunch and will crush the capacity of Bitcoin, Ethereum or whatever blockchain network.</p><p>Even if future blockchains do increase in speed, fundamentally it is highly unlikely it will ever be faster than a database because it needs to do extra work. Most ‘classic’ blockchains combine two distinct activities together: mining and transaction processing.</p><p>Bitcoin is the best example; once you have enough transactions you start mining that block, and then need to solve the associated challenge to prove you’ve expended the requisite effort to “secure” the block. Requiring this proof of work ensures that the blockchain is proof against a minority party (in terms of compute power) derailing the consensus rules. Regardless of the blockchain, when mining is coupled with transaction processing the system can only go as fast as mining permits.</p><p>Other blockchain architectures elect or designate block producers so they decouple the Sybil attack countermeasures from the act of producing a block. This leads to faster block production rates, but there’s still a lot of work every consumer of that block has to do; signature validation, merkle tree checking, verifying hashes, etc. If you skip any of these steps for efficiency’s sake you’re open to being fed false or altered information, which will corrupt your view of the distributed ledger.</p><p>With 40 years of database research, compared to approximately ten for blockchains, databases will be faster for the foreseeable future.</p><p>To successfully design a blockchain-powered system that can actually be called decentralized it’s crucial to very carefully consider what you store on-chain and what you can <strong>avoid</strong> storing on-chain. At Helium we really want to let the device owners store their own information however they want and just use the blockchain as a routing and settlement layer for tracking gateway identity. Devices simply indicate their identity and we use prefix routing on their identifier to route the packet to the right place. We don’t store information about the actual device on-chain. The fastest blockchain transactions are the ones you don’t make.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kGzodCZd8DuKkjSA8OZQnA.jpeg" /></figure><h3>Loss of control</h3><p>Fundamentally when you put something on the blockchain that means you’re effectively releasing control. Are you willing to give up control to become truly decentralized? If so, you need to prepare for a number of questionable uses of the system. You don’t get to say I’m banning that user. Or I’m deploying a new version of the software to fix a bug. If you’re not willing, then why choose to use a blockchain?</p><p>If you are truly committed to a decentralized system, depending on the type of governance, to take action buy in is typically required from the majority of participants. This can take time and be cumbersome. As an example, we’ve seen contention over the Bitcoin 1 MB block size. The issue turned into a huge, very polarized debate and ended up with Bitcoin Cash becoming a fork. Technical decisions get weaponized as political ones.</p><p>In Bitcoin, for miners to vote they need to put a small amount of information in a piece of an unused block as a voting mechanism. Lots of chains recognize this as an issue and look to improve it with better on chain governance. However, now you have to solve a distributed voting problem with weak identities. If you choose to let only the miners vote then you disenfranchise the users and the network becomes run for-and-by miners.</p><p>Finally, another governance model is “whatever the development team says”. Indeed, this is often the early model used, somewhat by necessity (blockchains are software, they don’t launch bug-free). However, if you don’t have a plan or the desire to move beyond this eventually you’ll hit a point where you’re disenfranchising your users and they’ll push back.</p><blockquote>Bitcoin has over 70 chain forks and probably several hundred codebase forks. This reflects not only Bitcoin’s popularity but also the fact that it has a fair miner and developer-centric governance.</blockquote><p>When users don’t feel their needs are being met, there are several ways they can push back: they can refuse to update their software, they can fork the codebase or they can jump ship to something else that meets their needs better. None of these are desirable from the project creator’s standpoint so you should try to forestall them by making sure the users feel like their concerns and needs are being considered.</p><p>Bitcoin has over 70 chain forks and probably several hundred codebase forks. This reflects not only Bitcoin’s popularity but also the fact that it has a fair miner and developer-centric governance. An even more extreme example is Monero, Monero is a fork of Bytecoin, but it has completely obliterated Bytecoin in terms of market share because the community fork was more focused on features that users wanted to see and that the community did not trust the original developers of Bytecoin.</p><p>At Helium, this loss of control was actually something we wanted. Nobody wants to trust their information to a third party or have hardware they paid for stop working if a company goes out of business or on an “<a href="https://ourincrediblejourney.tumblr.com/about/">incredible journey</a>”. We very intentionally designed a system that flipped the normal IoT ownership rules on their head to put the customer back in charge of their information and devices while still building a seamless global network. To that end, we needed a network that enabled devices that don’t trust each other to still collaborate safely. This is the killer feature of blockchains, they allow untrusted consensus to be built and systems to be resilient if any members of the community depart. We want to enable other companies and users to build their own gateways, implement their own end-nodes, their own wallet, their own consensus implementation, etc. We think the value of an “always on, everywhere” IoT network far outweighs the advantages of a single-vendor, proprietary network. After enabling the creation of that network, a profitable business model can be derived by providing services around that open ecosystem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sv2Gwx4iD7qFweQ17adGiQ.jpeg" /></figure><h3>Increased complexity</h3><p>What makes building blockchain applications complicated is you’re forced to use a less expressive way to write business logic for applications that need to run in an untrusted context.</p><blockquote>There’s hundreds of millions of ETH locked up in smart contracts because of various programming errors.</blockquote><h4>Fuzzy business logic</h4><p>To write blockchain applications you often need to work with something like a smart contract; and while the smart contract language will give you certain primitives, they may not be ones you’re familiar with. Solidity has all kinds of gotchas, trips, and traps. Mistype one character and your smart contract is vulnerable. There’s hundreds of millions of ETH locked up in smart contracts because of various programming errors.</p><p>In general, it’s not clear the industry is very good at writing smart contracts, and the support and tooling for writing them well is still a very fast moving area. With traditional legal contracts, contract disputes have ways to be resolved. A smart contract, almost by definition, cannot be wrong because “code is law”. However, if there’s an error in a smart contract, unlike with a regular contract, you can’t take a dispute to a court to decide intent vs implementation. If we can’t write regular software without bugs, we should be cautious about delegating final decisions to immutable code that we can’t fix or revert if an error is found later.</p><p>Implementing your business logic with these constraints can be very tricky. Smart contracts also usually cost tokens or “gas” to run and store data on the chain, so you have to be extremely careful how often you execute your code and how much storage it uses. At one point it was estimated storing 1Gb on the Ethereum blockchain would cost about 1 million dollars.</p><p>Even if you’re able to implement your business logic compactly and safely in a smart contract, now you have the problem of upgrading it. Often the solution is to have a shim contract that calls into the latest version of your “real” code. In fact, whole smart contract “operating systems” are emerging to give you access to smart contracts implementing common tasks. While this sounds great, we’ve seen several cases where a failure in a fundamental contract like this has been catastrophic.</p><p>At Helium we’ve chosen to avoid implementing smart contracts for now. Happily, our blockchain doesn’t require general purpose compute to be useful. We plan to implement some of the more useful smart contract patterns (Hash Time Locked Commitments, Multisig transactions, etc). If smart contract languages, runtimes, and tooling improve we’ll definitely revisit that decision, but for now we feel that it’s safer to provide a set of well-tested, predefined transaction types that deliver the features we anticipate needing.</p><h4>Running without trust</h4><p>One of the biggest challenges running in an untrusted context is how do I generate a random number in a smart contract? It’s actually very hard because if that random number is at all important to the execution of that smart contract, the miner is going to see it before anybody else. So with that prior knowledge, it’s possible they can take unfair advantage of the system including front-running the transaction.</p><p>How do you build these systems when effectively all your business logic is out there for everyone to see? Imagine building an application and anyone can look at the source code and state of the system at any time. Let’s say you’re running a public lottery on the blockchain; everybody pays in, whoever draws the random number gets paid. If you run the lottery server, and you’re honest (or regulated by the state gaming commission) it’s easy. As soon as everyone is running the lottery server how do you make that work without being exploited or front-run?</p><p>If you’re running code on a smart contract, which is effectively where you put your business logic for a distributed application (dApp), you have to figure out how to keep that secret from the people running the smart contract as part of the mining process so they don’t have privileged information. You need to consider what happens if a miner is looking for these kinds of transactions or smart contract executions. There are already examples of bad actors with privileged positions using knowledge of incoming transactions to take advantage of the system.</p><p>At Helium we are very interested in preventing the miner censoring transactions they don’t like or front-running them when it’s profitable. To that end, the consensus protocol we’ve chosen to implement, HoneyBadgerBFT, is a censorship <em>resistant </em>consensus protocol. It makes use of threshold encryption to ensure that miners have a harder time ignoring valid transactions they don’t want to include (because the transaction fee is too low, or because it might dilute their power or position) and we’re investigating ways to strengthen those properties further.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IkPXAy0qxFzImxhpoqa8HA.jpeg" /></figure><h3>Security</h3><p>Once you put information on a permissionless blockchain, everyone can see it. Some users may have some special local knowledge, eg. a decryption key, that can allow them to access private information in a public blockchain but, in general, what one user of the blockchain sees, everyone sees. This can make some things that are simple in the centralized model much harder when it’s done in a decentralized way on a public, permissionless blockchain. If a miner can use transaction information to predict the outcome of a smart contract, they can front-run that transaction by delaying the user’s transaction and putting a transaction they crafted to exploit their advance knowledge ahead of it in the blockchain. Imagine a miner seeing a large buy/sell order transaction come in on a decentralized exchange where they can use that advance knowledge to their advantage by buying/dumping right before the big trade is processed.</p><blockquote>The immutability of the ledger can be a double-edged sword and you need carefully consider what you want to store and how you want to store it because there’s no undo button.</blockquote><p>In general the stakes for putting information into a blockchain are much higher; once you put it in, you can’t take it back out. This means that even if you think what you’re doing today is secure you also have to think about what that information could mean in the future if a private key is lost or your security scheme is broken. The immutability of the ledger can be a double-edged sword and you need carefully consider what you want to store and how you want to store it because there’s no undo button.</p><h3>And still we chose a blockchain</h3><p>At Helium we knew a blockchain was a critical component to build a wireless network that was truly decentralized. To learn why we chose to build our own blockchain despite knowing the formidable challenges read my blog post <a href="https://blog.helium.com/introducing-the-helium-blockchain-dc2f8997083c">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mn09S7-36U5go-s2UlTZ1A.png" /></figure><figure><a href="http://www.helium.com/"><img alt="" src="https://cdn-images-1.medium.com/max/871/1*paiBV-xskzmx0RqBc1TO6Q.png" /></a></figure><figure><a href="http://whitepaper.helium.com/"><img alt="" src="https://cdn-images-1.medium.com/max/871/1*KfWl9J_Cjinis9Odf_mx3A.png" /></a></figure><figure><a href="https://t.me/helium_network"><img alt="" src="https://cdn-images-1.medium.com/max/871/1*O2rbqG2kGjEXWVGN2WS0HA.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8393d44f6cab" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/why-blockchain-is-a-terrible-idea-for-applications-8393d44f6cab">Why blockchain is a terrible idea for applications</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[Building a truly decentralized system with a distributed key generator]]></title>
            <link>https://medium.com/hackernoon/building-a-truly-decentralized-system-with-a-distributed-key-generator-1cfe13af55e7?source=rss-691abb98b3ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cfe13af55e7</guid>
            <category><![CDATA[key-generator]]></category>
            <category><![CDATA[distributed-key-generator]]></category>
            <category><![CDATA[bitcoin]]></category>
            <dc:creator><![CDATA[Andrew Thompson]]></dc:creator>
            <pubDate>Fri, 10 Aug 2018 06:01:01 GMT</pubDate>
            <atom:updated>2018-08-10T15:25:12.221Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r7917C5gzvWWBmA_n-MahA.png" /></figure><p>Any system that still requires a trusted entity to hold secrets is by nature not decentralized and suffers from a number of weaknesses including: single point of failure, susceptibility to Denial of Service attacks and, worst of all, having the secret stolen.</p><p>When we set out to build a new wireless network for machines at Helium, we had a number of design goals, key among them was to be truly decentralized in nature (other goals included permissionless, byzantine fault tolerance, useful proof of work/identity, high confirmed transaction rate, and transactions being censor resistant. For more details see the Helium <a href="http://whitepaper.helium.com/">whitepaper</a>).</p><p>Since centralized organizations dictate network cost and coverage, we decided a decentralized approach would be an effective way to provide broad, affordable wireless coverage for low power devices over long distances.</p><p>To build our decentralized machine network we chose to reward our community to provide wireless network coverage by hosting gateways.</p><p>To ensure community members provide valid coverage we created a new proof of work system we call Proof of Coverage. Proof of Coverage is the first proof protocol that leverages radio waves to validate network coverage and uses it to achieve consensus on a physical blockchain.</p><p>Community members providing coverage with gateways are rewarded with Helium tokens through mining and transaction fees from users of the network.</p><p>For a gateway to mine it needs to belong to the consensus group. Gateways can be elected to a consensus group by earning a score based on providing legitimate wireless coverage.</p><p>In Helium, this consensus group is temporarily assigned the task of running the consensus protocol to accept transactions and create blocks. The Helium consensus protocol needs to use threshold encryption for two tasks: to agree on transactions for the next block without censoring them and to provide a ‘<a href="https://eprint.iacr.org/2000/034.pdf">common coin</a>’ to break deadlocks in agreement . These kinds of threshold cryptosystems require a key to be shared between all members of the consensus group. Obviously a single party knowing the complete key is a big security hole, so that‘s why we needed to build a distributed key generator.</p><p>A <a href="https://eprint.iacr.org/2012/377.pdf">distributed key generator</a> is a way for a group of nodes to collectively agree on a public/private key pair <em>without</em> any single party knowing the private key (everyone knows the public key). This is actually very hard to achieve, but it relies on the fact that <a href="https://en.wikipedia.org/wiki/Lagrange_polynomial">lagrange interpolated shares</a> are homomorphic (in that operations can be performed on shares even without knowing the full value). For example, you can add A{share1}+B{share1} to get C{share1} that you can add to someone else’s C{share2} to get the <em>full</em> value of C (assuming A and B were split into 2 shares each).</p><p>I wanted to explain how a DKG works over <a href="https://en.wikipedia.org/wiki/Pairing-based_cryptography">pairing based keys</a> in a way that should be understandable to a non-technical audience. I’ve played with a few metaphors, but the one that comes closest to how it actually works is based on pin-tumbler locks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sQMhh7aG1Y4DxbXtc8i9hA.jpeg" /></figure><p>A pin tumbler lock works by the key pushing several ‘key pins’ to the right height such that the shear line between the key pin and the driver pin lines up with the shear line between the part of the lock that rotates (the core), and the part of the lock that is fixed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*20tDWHdQdq9Xs4rk6WSmEw.png" /></figure><p>When the correct key is inserted, all the pins line up so the shear line is clear and the core can rotate. If even one pin is wrong the lock won’t open.</p><p>Imagine with me, if you will, that I design a lock (with the corresponding key). I know how deep each cut for each pin on the key needs to be, but nobody else does. I give all my peers a share of the key pin information such that T+1 (T+1 is the <em>threshold</em> number of shares you need to reconstruct the original data) shares of the key pin information are enough to make a key that opens the lock. This is called <a href="https://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing">secret sharing</a>.</p><p>Now, this is fine if everyone trusts me to not leak my knowledge of the key. However, it is not sufficient if we want the property that <em>nobody</em> should know what the key looks like, and this is where a <em>distributed</em> key generator comes in.</p><p>In addition to ‘normal’ pin-tumbler locks, locks exist with a ‘cross key’ where the key has several blades, each one with a corresponding set of pin tumblers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*deLaVA_foqwWtm0u3CAGYQ.png" /><figcaption>‘Cross Key’ Keys require two sets of combination blades</figcaption></figure><p>Now, imagine the key had N blades (where N is the number of people you are generating the key with). Each member generates the pin tumbler configuration for <em>their</em> blade and shares it as described above. Then once everyone has shared their blade and received their share of the other blades we now have a lock that <em>nobody</em> knows how to open, but T+1 members can combine their shares to construct a key to unlock it. This is distributed key generation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZeY0chwmCIgc2Yv-JQgAxQ.png" /><figcaption>Blades combining to form a new key</figcaption></figure><p>In normal usage the full key is not usually recovered, rather holders of the key shares work together to perform operations in a <a href="https://en.wikipedia.org/wiki/Threshold_cryptosystem">threshold cryptosystem</a> (eg. T+1 of N are required to participate in signing a message or T+1 of N parties are required to participate in decrypting a message).</p><p>Building a distributed key generator is hard but necessary work to achieve a more secure system, but these challenges excite the team knowing we’re building the world’s first decentralized machine network.</p><p>To follow progress of our dkg work, check out our <a href="https://github.com/helium/erlang-dkg">github repo</a>.</p><figure><a href="https://t.me/helium_network"><img alt="" src="https://cdn-images-1.medium.com/max/610/1*fgCQWsakNXfBUVgwfvnSfg.png" /></a></figure><figure><a href="http://www.helium.com/"><img alt="" src="https://cdn-images-1.medium.com/max/610/1*AG902TeF2RCJiXgzN6Mo0Q.png" /></a></figure><figure><a href="http://whitepaper.helium.com/"><img alt="" src="https://cdn-images-1.medium.com/max/610/1*VPqg41pBgmw5zRJDuQUO2A.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cfe13af55e7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/building-a-truly-decentralized-system-with-a-distributed-key-generator-1cfe13af55e7">Building a truly decentralized system with a distributed key generator</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[Introducing the Helium Blockchain]]></title>
            <link>https://medium.com/helium-blog/introducing-the-helium-blockchain-dc2f8997083c?source=rss-691abb98b3ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc2f8997083c</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Andrew Thompson]]></dc:creator>
            <pubDate>Thu, 10 May 2018 19:40:16 GMT</pubDate>
            <atom:updated>2019-06-03T22:38:49.514Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GBhvYehyZ-VuR_9qn9hqvQ.png" /></figure><p>The Internet we have today dates back a long, long time. Back in the days when the <strong>ARPANet </strong>was designed, which eventually became the Internet, there were only a handful of sites participating, mostly Universities. In those days, when the early services that underpin the internet like BGP, DNS, and SMTP were designed, the designers assumed that the operators of those services would operate in good faith. The community was small and everyone knew everyone else, or at least knew where to find them.</p><p>As the years passed, more and more people gained access to the Internet and the strong identity and responsibility around using and operating services began to erode. Today many critical internet services rely on simple access control to secure them from attack and much effort is expended in the resulting arms-race between people trying to profit from attacking the Internet and those trying to defend it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tRlhw_ovOME7n8mSLOVrMA.png" /></figure><h3>The challenges of a centralized trust model for IoT</h3><p>Fast forward to today, and with the IoT, we’re trying to extend the Internet, with all its naive trust in the network, to tiny devices with little RAM and a very thin pipe back to the internet. The big problem of Internet security doesn’t fit well on a microcontroller.</p><p>One way of solving this is to introduce a trusted party that the devices look to for instructions and relay all their traffic through. By necessity these systems are a centralization point, everyone has to agree to use them, or they have to be federated. IoT’s track record on federation at this point is abysmal. Almost every IoT system to date requires customers to delegate trust to a service offered by the vendor. Additionally, in many of these systems, the gateway device (that bridges the wireless protocol and the internet protocol) also occupies a trusted position, or at least is not an open-access routing device (meaning it only works for devices using the same trusted party).</p><p>This is fine, but it’s not how the internet works. The internet, for all its flaws, is still a decentralized system. You can operate on the Internet with very little dependence on a trusted party. Your laptop works fine at home on a Comcast Internet connection and it works fine when you hotspot with your AT&amp;T phone. Your laptop doesn’t care, or need to care, how it’s connected to the internet. IoT devices today are not like this. They might speak the same wireless protocol (unlikely), but two products from two different vendors are very unlikely to interoperate. Additionally, if your neighbor has the same IoT device as you do, your device won’t use his gateway if the cat pulls the plug out of yours, nor vice versa. This is not an Internet of Things, it’s something else.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tRlhw_ovOME7n8mSLOVrMA.png" /></figure><h3>Rethinking the Internet of Things</h3><p>Helium was founded with the idea that an internet of Things, that was publically accessible and ubiquitous, should exist as a public commodity. Unfortunately, even we fell into the trap of centralizing around a trusted party, namely ourselves. While we were never entirely comfortable with the idea, it was difficult envisioning how an alternative could work.</p><p>About a year ago, we had a deep re-think about what we were offering and how it differed from what we wanted to offer: <strong>a crowd-sourced network of open-access gateways that users could depend on and gateway operators could be rewarded for maintaining</strong>. We also wanted to let users operate their own infrastructure (or use ours, if they trusted us). How do you build a trustless IoT network, though?</p><p>At the time blockchains had come back into vogue and we had many joking discussions about merging blockchains and IoT. Finally, though, we had a really interesting insight; <strong>what if we could replace Bitcoin-style Proof-of-Work (PoW) with something useful and relevant to the IoT.</strong></p><p>Fundamentally, Bitcoin-style proof of work is about defeating Sybil attacks. A Sybil attack is when a single actor creates many sock puppet accounts and exploits majority rule voting to overrule the true majority of actors. Proof of Work uses the fact that a CPU/GPU/ASIC can only be solving one puzzle at a time; solving several puzzles at once would reduce the speed of the computation. This means that a miner can realistically only be mining on behalf of one identity at a time. This allows proof of work style blockchains to defeat the Sybil attack strategy because mining on top of the block the miner thinks is the tip of the chain is an activity not interchangeable with mining on top of another block, or mining under another identity.</p><p>This effectively means that Bitcoin and other proof-of-work style blockchains rely on the fundamental <a href="https://en.wikipedia.org/wiki/Limits_of_computation"><strong>limits of computation</strong></a> (although our own technological limitations get in the way first) to construct an unforgable identity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tRlhw_ovOME7n8mSLOVrMA.png" /></figure><h3>Defining the first blockchain proof-of-work for wireless</h3><p>The challenge we posed ourselves is what does a equivalent to proof-of-work look like in the world of radio? In radio there are several fundamental limits: RF energy propagates at a maximum speed (the speed of light), it dissipates over distance (inverse square law), and it emits from a point source (antenna location). Happily these limits are well understood and improvements in technology are unlikely to change them, unlike computationally bounded proofs of work where a new ASIC can make hardware obsolete overnight.</p><p>Initially we wanted to build a network around an ERC20 token, but several requirements made that very difficult. First, ERC20 tokens are, pretty much by design, pre-mined. We’d have to build a smart contract to pay out mining rewards from a pre-mined pool. Writing secure smart contracts is still far from a solved problem and the stakes are high. Second, storage on the Ethereum blockchain is extremely expensive, so we’d have to store a lot of things off-chain, which defeats the purpose of building a decentralized system. Finally, <strong>Ethereum is slow</strong>, on the order of 5 to 7 transactions per second across the entire Ethereum network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_NJfqRL20zJgZUxgp5pFfA.png" /><figcaption>The Helium Gateway includes a Software Defined Radio (SDR) allowing it to listen on many channels simultaneously and determine a highly accurate timestamp of when transmissions were recieved.</figcaption></figure><p>After a lot of thinking, false starts and whiteboarding, we’ve come up with a way to turn our gateway’s access to radio equipment and location into a proof of coverage suitable for use as an identity. Essentially Helium gateways assert their location (according to their GPS coordinate) and other Helium gateways routinely challenge these gateways to prove their location. Knowing where, when, and how strongly a signal was received allows us to verify the transmitter location. Over time, with enough successful responses to these challenges, the gateways can create a strong identity with an associated trust score that we can use to defeat Sybil attacks. Because a gateway is anchored in space, and only a single gateway can occupy a point in space (we don’t allow two gateways to claim the same location), these identities are also unique.</p><h4>What about Consensus?</h4><p>Now that we’ve addressed the Sybil attack problem we need to return to consensus. In proof-of-work style consensus (also called Nakamoto consensus) because the proof of work is probabilistic (at any point in time the next bitcoin block is 10 minutes out, even if it’s been 10 minutes since the last block) it’s fine to have a ‘first seen block wins’ approach. Once you have a deterministic proof of identity you no longer want to just wait for the first proof seen, because proofs now have relative value outside of their order of arrival. In Helium’s blockchain we rank the proofs in order of how much they tell us about the network and the trustworthiness of the reporter.</p><p>An additional aspect to consider is because our proofs now have value, they all tell us something about the network, we don’t want to discard proofs that didn’t win. This means that simple Nakamoto consensus is not suitable. We explored using Ethereum style uncle blocks and, while that did work, it added a significant amount of complexity and overhead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_L-Ntu72oNCY798KurosQA.png" /></figure><p>Another aspect we considered was to make certain kinds of transactions “free” — as in free of transaction fees. This is important if you want to account per-packet because not only do we want to keep a trace that the packet was sent on the blockchain (for proof of location/transmission of the transmitter), but we also want to enable a “pay as you go” settlement scheme, rather than a pre-pay or pay-in-arrears settlement scheme. This requires the ability to have a transaction per packet (or at least a transaction every N packets).</p><p>Miners in a blockchain system are not your friend, they cooperate as long as it is in their interest to do so. Typically they will do the bare minimum, bend or break the rules, censor transactions, etc as long as they can still get paid. This is why most blockchains have transaction fees, they’re the bribe to incent the miner to include the transaction in the block. However, this is in direct conflict with the desire to provide microtransactions for packet transport. So, struggling with both the issues of discarding useful proofs and providing transaction-fee-free microtransactions, we discarded our Ethereum-style blockchain approach and went back to the drawing board.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tRlhw_ovOME7n8mSLOVrMA.png" /></figure><h3>Choosing a hybrid consensus model for speed and scalability</h3><p>One interesting approach we found was ByzCoin, which used Nakamoto-style consensus to bootstrap a Practical Byzantine Fault Tolerant (PBFT) consensus system. This type of system has the advantage of <strong>not only being resilient to Sybil attacks, but also confirming transactions at a very high rate which is critical for scalability</strong>. One big problem with Nakamoto consensus is you tie the proof of identity to the confirmation of transactions. Even worse, because Nakamoto consensus is not very tolerant of netsplits or chain forks, if a fork occurs eventually it will be resolved simply by deleting the losing fork. This means that if you’re on the wrong side of a network partition, or if you’re connected to a malicious peer on the blockchain, your transaction might look like it has been added to the chain (even with several blocks on top), but there’s no guarantee that a longer chain doesn’t exist elsewhere that will appear later and supercede it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*jVKMMJXgXY9m7mmcO9RfLQ.jpeg" /><figcaption>The HoneyBadger consensus model is both asynchronous and censorship-resistant.</figcaption></figure><p>These so called hybrid consensus models, like ByzCoin are very interesting, and are on the cutting edge of blockchain research. After researching ByzCoin we also found another paper with the amazing name of “<strong>HoneyBadgerBFT</strong>”. HoneyBadger is really interesting as it has two rare properties: it is asynchronous and it is censorship-resistant. Asynchronous means that it can tolerate arbitrary delays on messages being delivered. This is helpful for us as we expect gateways to be spread around the world with varying qualities of backhaul. Asynchronous systems are also less susceptible to Denial of Service (DoS) attacks where you cause a system to crash by flooding it with traffic.</p><p>With censorship resistance as long as one member of the consensus group is honest, and a user submits their transaction to that honest node, the transaction will eventually be accepted. HoneyBadger manages this with clever use of threshold encryption and as a result it’s very difficult for miners to ignore transactions they don’t want to include in the next block.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/130/1*rsHwclW2fJpcYZnhcsGwrQ.png" /></figure><h3>Designing the Helium Blockchain</h3><p>So, Helium’s hybrid blockchain system looks like this: Every ‘epoch’, the best N proofs of coverage from the last epoch, are used to elect the members of the HoneyBadger consensus for the next epoch. The elected members then run a distributed key generator to bootstrap their threshold encryption keys and then launch into the HoneyBadger consensus protocol.</p><p>The HoneyBadger consensus protocol, in brief, looks like this:</p><p>Each member accepts transactions until they have at least B transactions in their queue. Each member then selects B/N from the first B transactions in the queue. It then encrypts them with the threshold public key and gossips that encrypted data around. Once N — f, where f is the failure threshold, members have all shared their proposed transactions, they are all threshold decrypted, at which point it is too late to censor them.</p><p>The transactions are deduplicated, invalid ones are removed, and they’re combined into a new block. This block then has a threshold signature applied to it. Members trying to censor transactions will end up with a different block than honest nodes and thus their signature shares won’t be valid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FcnZZDlr59t5YHyVjkeOYw.png" /></figure><p>Thus, with all this work, <strong>Helium has designed a blockchain around a self-verifying network of gateways that provides message provenance, microtransactions, and open access to anyone.</strong></p><p>Our proof of work replacement is useful, indeed valuable, as it is a historical record of the state of the network as well as a very recent view of its current status. Users can consult the blockchain to see where coverage is in near real-time and what is costs, gateway operators can see where business opportunities for more or cheaper gateways are, etc. This coverage in real time also has the benefit of delivering geolocation capabilities without the need of expensive and battery consuming GPS.</p><p>We believe the Helium blockchain enables a purpose-built decentralized machine network, and solves the centralized trust problem that has plagued the industry and stalled its growth.</p><p>Join our Telegram chat at <a href="http://t.me/helium_network">http://t.me/helium_network</a> or visit <a href="http://www.helium.com/">helium.com</a> to learn more.</p><figure><a href="http://t.me/helium_network"><img alt="" src="https://cdn-images-1.medium.com/max/610/1*fgCQWsakNXfBUVgwfvnSfg.png" /></a></figure><figure><a href="http://www.helium.com/"><img alt="" src="https://cdn-images-1.medium.com/max/610/1*AG902TeF2RCJiXgzN6Mo0Q.png" /></a></figure><figure><a href="https://s3-us-west-2.amazonaws.com/helium-media/whitepaper.pdf"><img alt="" src="https://cdn-images-1.medium.com/max/610/1*VPqg41pBgmw5zRJDuQUO2A.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc2f8997083c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/helium-blog/introducing-the-helium-blockchain-dc2f8997083c">Introducing the Helium Blockchain</a> was originally published in <a href="https://medium.com/helium-blog">The Helium Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bullet-proofing Helium’s embedded C code with Erlang QuickCheck.]]></title>
            <link>https://medium.com/@potsdamnhacker/quickcheck-and-the-deep-firmware-278f77cd2342?source=rss-691abb98b3ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/278f77cd2342</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[internet-of-things]]></category>
            <category><![CDATA[erlang]]></category>
            <dc:creator><![CDATA[Andrew Thompson]]></dc:creator>
            <pubDate>Wed, 06 Jan 2016 23:44:35 GMT</pubDate>
            <atom:updated>2016-01-12T14:34:05.210Z</atom:updated>
            <content:encoded><![CDATA[<p>At <a href="http://www.helium.com/">Helium</a> we build and manage end-to-end, smart sensing systems for various industrial and enterprise verticals. This means we have code spanning all the way from embedded device firmware to Web interfaces, and a bunch in-between. One of the challenges on the embedded side of the system is that testing can be harder because of the constraints of embedded programming. Have you ever had a cable modem or access point need to be rebooted for no reason? Yeah, this is one of the reasons why. I’m going to talk a little about how we at Helium want our devices in the field to ‘just work’ and avoid the ‘just reboot it’ approach to troubleshooting.</p><p>I was recently chasing some stack corruption issues in some of our firmware that was adjacent to one of the data structures the firmware uses; basically a circular buffer. I wondered if the scenario I was testing was related to a bug in that datastructure, so I decided to reach for a tool I’d never used before; <a href="http://www.quviq.com/products/quickcheck-for-c/">Erlang QuickCheck for C</a> (or EQC-C for short).</p><p>Quickcheck, for those unfamiliar, is a property-based testing tool. There are clones for it in several different languages these days, but it originated in Haskell (which we also <a href="https://www.youtube.com/watch?v=T2wi0ZUOHfM">use at Helium</a>). <a href="http://www.quviq.com/">QuviQ</a> offers a commercial version for Erlang that provides a number of additional powerful features, one of them being EQC-C.</p><p>We’ve had a QuickCheck licence for a while, and we’ve used it to great effect in testing our Erlang-based, internal infrastructure and even black-box testing our firmware (that’s a blog post for another time). I had seen John Hughes talk about EQC-C but never had the chance to use it. This stack corruption issue was driving me nuts, however, so I decided it was time to try it out.</p><p>So, today I will be covering how you can QuickCheck C code. I won’t however, be using the code from our firmware. Instead, I will be showing you some EQC-C on some open source C datastructures that make for a cleaner and more interesting example (the circular buffer in the firmware turned out to be bug-free). Specifically, I will be testing the hashmap implementation from the open source video game remake I contribute to, <a href="https://github.com/omf2097/openomf">OpenOMF</a> (incidentally, we did use this hashmap for libhelium as well).</p><h4>Code to test</h4><p>First of all, let’s take a look at the API we’ll be testing:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/092beb3ff7d88f7cca28331e02d1e7bd/href">https://medium.com/media/092beb3ff7d88f7cca28331e02d1e7bd/href</a></iframe><p>As you can see, it is pretty straightforward. You can <strong>create</strong>, <strong>put</strong>, <strong>delete</strong>, <strong>iterate</strong> and <strong>clear</strong> the hashmap. So, how do we go about actually testing this? It turns out, EQC-C works by compiling your C code in some magical way that allows the C API to be wrapped in an Erlang module which then lets you write a regular EQC test to, well, test it.</p><h4>Bridging the Erlang/C divide</h4><p>The magic all begins with the <strong>eqc_c:start()</strong> function. In this case, it goes like this (at the Erlang REPL):</p><pre>1&gt; eqc_c:start(hashmap, [{c_src, “hashmap.c”},<br>                         {cppflags, “-I ../../include/ -std=c99”},       <br>                         {cflags,”-lm”},<br>                         {additional_files, [“iterator.c”]}]).<br>Starting Quviq QuickCheck version 1.36.1<br> (compiled at {{2015,9,8},{9,10,49}})<br>Licence for Helium reserved until {{2016,1,6},{8,59,18}}<br>ok<br>2&gt;</pre><p>There’s a bunch going on here, but basicially we tell it the C file we want to compile, set up some include paths, make sure we link it against the math library and also link in iterator.c, because the hashmap supports iteration.</p><p>Now, magically, we have a hashmap Erlang module that implements the C API:</p><pre>2&gt; hashmap:&lt;tab&gt;<br>...<br>hashmap_clear/1 hashmap_create/2<br>hashmap_create_with_allocator/3 hashmap_del/3<br>hashmap_delete/2 hashmap_free/1<br>hashmap_get/5 hashmap_idel/2<br>hashmap_iget/4 hashmap_iput/4<br>hashmap_iter_begin/2 hashmap_iter_next/1<br>hashmap_put/5 hashmap_reserved/1<br>hashmap_sdel/2 hashmap_sget/4<br>hashmap_size/1 hashmap_sput/4<br>...</pre><p>There’s actually a lot of other functions in this module, too. EQC-C has an option to only generate functions for the definitions in the C file, not the prototypes, but we will need some of the functions from iterator.c later, so we have to generate a bunch of extra functions.</p><h4>Taking it for a spin</h4><p>Now, we can actually use this as an Erlang module from the REPL, although it is a tad cumbersome because we need to use EQC-C’s C pointers:</p><pre>2&gt; rr(&quot;hashmap.hrl&quot;).[allocator_t,div_t,hashmap_node_t,hashmap_pair_t,hashmap_t,<br> iterator_t,ldiv_t,lldiv_t]<br>3&gt; HM = eqc_c:alloc({struct, hashmap_t}).<br>{ptr,{struct,hashmap_t},20516928}<br>4&gt; hashmap:hashmap_create(HM, 6).<br>ok<br>5&gt; hashmap:hashmap_put(HM, eqc_c:create_string(&quot;hello&quot;), 5, eqc_c:create_string(&quot;world&quot;), 5).<br>{ptr,void,20517648}</pre><p>So, there’s actually quite a bit going on here. First we read in the record definitions EQC-C generated from the structs it saw when compiling. Next, we actually allocate memory for one of those structures using eqc_c:alloc(). That returns a {ptr, …}, which is actually a handle for a C pointer. We can then use that pointer to call hashmap_create() to actually initialize a hashmap. Once we have initialized the hashmap, we can store something in it using hashmap_put(). To do so, we use an EQC-C helper function called create_string() which allocates a char* and initializes it to the string you provide it. hashmap_put also requires we specify the length of the parameters we pass (because it doesn’t assume the keys and values are null terminated), so we pass 5 in both cases. Once we do the put, we get back a pointer to the hashmap element we just created, just like the C API promises.</p><p>Now, to get something back <em>out</em> of the hashmap, it gets a little more complicated. Let’s look at the signature for hashmap_put again:</p><pre>int hashmap_get(hashmap *hm, const void *key, unsigned int keylen, void **val, unsigned int *vallen);</pre><p>So, it takes a void** and an unsigned int* pointer where it will fill in the address of the value for that key and its size. This is a little trickier to work with, and it took me a while to figure it out, but here’s how you do it:</p><pre>6&gt; Val = eqc_c:alloc({ptr, unsigned_char}).<br>{ptr,{ptr,unsigned_char},10064640}<br>7&gt; ValLen = eqc_c:alloc(unsigned_int).<br>{ptr,unsigned_int,10064672}<br>8&gt; Res = hashmap:hashmap_get(HM, eqc_c:create_string(&quot;hello&quot;), 5, Val, ValLen).<br>0</pre><p>Ok, so we allocated a unsigned char** pointer and an unsigned int* pointer and passed them to the <strong>hashmap_get().</strong> The get returned 0, which is the success return code, so we ‘got’ something, but how do we look at it? EQC-C provides ways to read through a pointer (as well as cast pointers), so lets see what we got back:</p><pre>9&gt; Len = eqc_c:deref(ValLen).<br>5<br>10&gt; eqc_c:read_array(eqc_c:deref(Val), Len).<br>&quot;world&quot;</pre><p>There we go, it works! What happens if we try with a missing key?</p><pre>13&gt; f(Len).<br>ok<br>14&gt; hashmap:hashmap_get(HM, eqc_c:create_string(&quot;nothere&quot;), 7, Val, ValLen).<br>1<br>15&gt; Len = eqc_c:deref(ValLen).<br>0</pre><p>Well, the return code from <strong>get()</strong> is now 1, which means the lookup failed, and the length pointer now holds 0, as expected.</p><h4>Let’s write a property!</h4><p>So, this is all well and good, but how is this any better than a glorified FFI? Truth be told it really isn’t (aside from providing some nice isolation so segfaults don’t kill the Erlang VM), EQC-C is just a tool to let you unleash the power of Erlang QuickCheck on your C code, which is what this is all leading up to.</p><p>One of the tools in QuickCheck is called eqc_statem, the documentation describes it as such:</p><blockquote>This module provides functions for testing operations with side-effects, which are specified via an abstract state machine.</blockquote><p>Which is basically true. eqc_statem is a way to statefully test some component by generating ‘commands’ against that component and checking that your invariants hold. ‘Regular’ quickcheck is more about checking invariants for a particular function (does it work for all sorted arrays and fail for all unsorted arrays, etc). Most QuickCheck implementations are mostly about that simpler form of testing, but eqc_statem lets you test much more complicated systems at whatever granularity you want. You can test a whole system adheres to some invariants for some inputs, or in this case, you can test something smaller, like a datastructure.</p><p>eqc_statem works by defining callbacks for commands, generators for arguments for those commands, preconditions for those commands (if it is valid to generate this command at this point), postconditions where you test your invariants and ‘next state’ where you update your model’s state to reflect the changes the command made to the system under test.</p><p>Let’s take a look at what we would define for hashmap_create, the obvious starting point:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1494f39df271688795b9b737777f8c83/href">https://medium.com/media/1494f39df271688795b9b737777f8c83/href</a></iframe><p>So, we actually need to define a model state, so we have something to test our C code against. The state we need for this is actually very simple, it just holds a pointer to the hashmap, the size we created the hashmap with and an empty Erlang list that we will use to model the hashmap’s behaviour.</p><p>Our precondition simply says “only generate a hashmap if the hashmap in the the state is undefined”. This effectively forces EQC to generate this as the first command in any test. For the argument generator, we generate a number between 4 and 10 as the ‘size’ of the hashmap.</p><p>Then we have the actual create command itself, we allocate a hashmap_t, as before, and then we create a hashmap and return the pointer. The _next function simply updates our state by storing the pointer in the model’s state. Finally, because we don’t really have any invariants to test here, there’s no postcondition.</p><p>Now that we’ve seen a command modeled, let’s put it together with the boilerplate to make a QuickCheck property you can actually run:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e33b9cf43c3af3f4a93345c4d55720bc/href">https://medium.com/media/e33b9cf43c3af3f4a93345c4d55720bc/href</a></iframe><p>The only really interesting thing that’s new here is the property. It is saying “for all sets of generated commands, running the commands should not violate any invariants”. Because we don’t really have any invariants, it isn’t very interesting yet, but we can run it anyway:</p><pre>1&gt; c(hashmap_eqc).<br>{ok,hashmap_eqc}<br>2&gt; eqc:quickcheck(hashmap_eqc:prop_correct()).<br>Starting Quviq QuickCheck version 1.36.1<br> (compiled at {{2015,9,8},{9,10,49}})<br>Licence for Helium reserved until {{2016,1,6},{8,59,18}}<br>……………………………………………………………………………………….<br>OK, passed 100 tests</pre><pre>100% {hashmap_eqc,hashmap_create,1}<br>true</pre><p>So, we ran 100 tests, they all passed and the command we ran was hashmap_create 100% of the time. Not very interesting. Let’s model some more of the API.</p><h4>Putting it on the line</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/64c4ebcd148ffbd001509b0e0feeb7ea/href">https://medium.com/media/64c4ebcd148ffbd001509b0e0feeb7ea/href</a></iframe><p>Now that we are modeling <strong>put()</strong> it’s starting to get interesting. The precondition to put is that we have a hashmap created, so the hashmap element of the model state can’t be undefined. That is pretty straightforward. Next, using the argument generator, we’re generating 3 arguments; the pointer to the hashmap, the key and the value. We want to generate keys that don’t already appear in the hashmap, so we use the <strong>SUCHTHAT</strong> macro to say we want a non-empty list of char()s that are not already in the list of keys in the model state and that the value should also not be empty.</p><p>The actual command function, <strong>hashmap_put</strong>, takes those generated arguments and actually does the put, as we’ve seen before. I’m being careful to clean up after myself now though so we don’t leak memory. The return value from the command is the return value from the actual C function <strong>hashmap_put</strong> (although in this case we don’t use it).</p><p>Finally, the next function prepends the {Key, Value} tuple to our list that we are using to model the state of the hashmap.</p><p>If we go ahead and add that to what we had before (along with the relevant export directives) we see something like this:</p><pre>eqc:quickcheck(hashmap_eqc:prop_correct()).<br>……………………………………………………………………………………….<br>OK, passed 100 tests</pre><pre>91.7% {hashmap_eqc,hashmap_put,3}<br>8.3% {hashmap_eqc,hashmap_create,1}<br>true</pre><p>Because we can only call <strong>hashmap_create</strong> if there isn’t already a hashmap, the hashmap_put now dominates the distribution of the commands generated. We still don’t have any postconditions to check our invariants, so everything passes. So lets add something we can actually test, like <strong>get()</strong>.</p><h4>Getting serious</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65f2a4ca96cd0f7316657cb1f04a52a4/href">https://medium.com/media/65f2a4ca96cd0f7316657cb1f04a52a4/href</a></iframe><p>Ok, there is a lot more going on here, let’s break it down.</p><p>We have seen this precondition before. Nothing too interesting. Our argument generator has 2 clauses, one for when we have keys in the hashmap, and one for when we don’t. When we DO have keys in the hashmap we pick one of the keys out of the model we know we’ve stored, but we also have a chance to generate keys that may NOT appear in the hashmap, so we can test failed lookups as well. When the hashmap is empty, we just try with a random key.</p><p>The actual command function, again, is similar to what we did on the REPL earlier. From the command function, we return a 3 tuple containing the result of the C function, the value of the returned length, and the value returned from the hashmap lookup (or undefined, if the length was 0).</p><p>Now, finally, we have a postcondition. The postcondition says that if the key was expected to be in the hashmap, the return code should be 0 and the value read out of the hashmap should be the same as we had stored in the model. If the key is NOT in the hashmap, we expect the return code to be 1 and the returned length to be 0.</p><p>If we put that together with what we had before and run it, well, everything still passes. I guess the hashmap does the basics well.</p><h4>Forgetting things</h4><p>Let’s model clear() next, it will be easy:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5bd0e76c185ac403f7ad8a39e2dec393/href">https://medium.com/media/5bd0e76c185ac403f7ad8a39e2dec393/href</a></iframe><p>Super simple - all we do is call clear and set our model to have the empty list as the model for the map. This means that any lookups AFTER a clear is done should return nothing. Again, as expected, if we update the test, everything passes. Let’s do delete:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b09eb94b262488f11b41dbc5f13208e5/href">https://medium.com/media/b09eb94b262488f11b41dbc5f13208e5/href</a></iframe><p>The argument generator here is similar to the one for <strong>get()</strong>. If the map isn’t empty we pick a key from the map or a random key; if the map is empty we generate a random key. The command is straightforward, the postcondition just checks if the return code is 0 if the key was in the hashmap, and 1 if it was not, and the _next function deletes the key we deleted from our model.</p><p>Lets put all this together and run 1000 tests:</p><pre>eqc:quickcheck(eqc:numtests(1000, hashmap_eqc:prop_correct())).<br>……………………………………………………………………………………….(x10)………………………………………………………………………………<br>OK, passed 1000 tests</pre><pre>23.94% {hashmap_eqc,hashmap_get,2}<br>23.62% {hashmap_eqc,hashmap_delete,2}<br>23.24% {hashmap_eqc,hashmap_put,3}<br>23.10% {hashmap_eqc,hashmap_clear,1}<br>6.10% {hashmap_eqc,hashmap_create,1}<br>true</pre><h4>Taking a walk through a hashmap</h4><p>Everything still passes and we’re generating a good mix of operations against the hashmap. What else can we test? The two interesting functions remaining are both of the iteration functions, <strong>hashmap_iter_begin</strong> and <strong>hashmap_delete</strong> (which takes an iterator). Let’s use the iterator to dump the state of the hash and compare every key in there to our model:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d2232c607719af81fdf18b8f745a268/href">https://medium.com/media/6d2232c607719af81fdf18b8f745a268/href</a></iframe><p>So, we actually needed a helper function here to walk the iterator until we hit NULL, which indicates the end of the hash. We are also making use of <strong>cast_ptr</strong> here to cast the void pointers we get back from <strong>iter_next()</strong> into the relevant types so we can extract the key/value pairs. Once we hit NULL, we return the accumulated list of 2-tuples and use that as the return from our command function. The postcondition compares if the sorted model list matches the sorted list we dumped from the hashmap.</p><h4>Pigeon hole problem</h4><p>However, even with all that ingenuity we still have no failures. What if we intentionally try to orphan values by overwriting existing keys? It would look a little something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7498047483df029c4484bd04659a9a3/href">https://medium.com/media/a7498047483df029c4484bd04659a9a3/href</a></iframe><p>So, we generate a key and value pair to <strong>put()</strong> that intentionally generates the key as one of the keys already in the hashmap, and the generated value must NOT already be present in the hashmap. This will give us a good way to see what happens when we ‘update’ a key in the hashmap.</p><p>Let’s run it and see what happens:</p><pre>10&gt; eqc:quickcheck(eqc:numtests(1000, hashmap_eqc:prop_correct())).<br>..Failed! After 3 tests.<br>[{set,{var,1},{call,hashmap_eqc,hashmap_create,”\n”}},<br> {set,{var,2},{call,hashmap_eqc,hashmap_get,[{var,1},”±”]}},<br> {set,{var,3},{call,hashmap_eqc,hashmap_compare,[{var,1}]}},<br> {set,{var,4},{call,hashmap_eqc,hashmap_get,[{var,1},”õ”]}},<br> {set,{var,5},{call,hashmap_eqc,hashmap_compare,[{var,1}]}},<br> {set,{var,6},{call,hashmap_eqc,hashmap_delete,[{var,1},”\””]}},<br> {set,{var,7},{call,hashmap_eqc,hashmap_compare,[{var,1}]}},<br> {set,{var,8},{call,hashmap_eqc,hashmap_compare,[{var,1}]}},<br> {set,{var,9},{call,hashmap_eqc,hashmap_clear,[{var,1}]}},<br> {set,{var,10},{call,hashmap_eqc,hashmap_clear,[{var,1}]}},<br> {set,{var,11},{call,hashmap_eqc,hashmap_put,[{var,1},”y”,”T”]}},<br> {set,{var,12},{call,hashmap_eqc,hashmap_replace,[{var,1},”y”,”j”]}},<br> {set,{var,13},{call,hashmap_eqc,hashmap_compare,[{var,1}]}},<br> {set,{var,14},{call,hashmap_eqc,hashmap_get,[{var,1},[155]]}},<br> {set,{var,15},{call,hashmap_eqc,hashmap_clear,[{var,1}]}},<br> {set,{var,16},{call,hashmap_eqc,hashmap_put,[{var,1},”º”,”r”]}},<br> {set,{var,17},{call,hashmap_eqc,hashmap_compare,[{var,1}]}},<br> {set,{var,18},{call,hashmap_eqc,hashmap_put,[{var,1},”Ý”,”ä”]}}]</pre><pre>hashmap_eqc:hashmap_create(10) -&gt; {ptr, {struct, hashmap_t}, 18817040}<br>hashmap_eqc:hashmap_get({ptr, {struct, hashmap_t}, 18817040}, “±”) -&gt;<br> {1, 0, undefined}<br>hashmap_eqc:hashmap_compare({ptr, {struct, hashmap_t}, 18817040}) -&gt; []<br>hashmap_eqc:hashmap_get({ptr, {struct, hashmap_t}, 18817040}, “õ”) -&gt;<br> {1, 0, undefined}<br>hashmap_eqc:hashmap_compare({ptr, {struct, hashmap_t}, 18817040}) -&gt; []<br>hashmap_eqc:hashmap_delete({ptr, {struct, hashmap_t}, 18817040}, “\””) -&gt; 1<br>hashmap_eqc:hashmap_compare({ptr, {struct, hashmap_t}, 18817040}) -&gt; []<br>hashmap_eqc:hashmap_compare({ptr, {struct, hashmap_t}, 18817040}) -&gt; []<br>hashmap_eqc:hashmap_clear({ptr, {struct, hashmap_t}, 18817040}) -&gt; ok<br>hashmap_eqc:hashmap_clear({ptr, {struct, hashmap_t}, 18817040}) -&gt; ok<br>hashmap_eqc:hashmap_put({ptr, {struct, hashmap_t}, 18817040}, “y”, “T”) -&gt;<br> {ptr, void, 18825440}<br>hashmap_eqc:hashmap_replace({ptr, {struct, hashmap_t}, 18817040}, “y”, “j”) -&gt;<br> {ptr, void, 18825552}<br>hashmap_eqc:hashmap_compare({ptr, {struct, hashmap_t}, 18817040}) -&gt;<br> [{“y”, “T”}, {“y”, “j”}]</pre><pre>Reason:<br> Post-condition failed:<br> {hash_mismatch, [{“y”, “j”}], [{“y”, “T”}, {“y”, “j”}]}<br>{postcondition,{hash_mismatch,[{“y”,”j”}],[{“y”,”T”},{“y”,”j”}]}} /= ok<br>false</pre><p>Yes! A counterexample! We’ve found a bug. We expected the hashmap to contain [{“y”, “j”}] but it actually contained [{“y”, “T”}, {“y”, “j”}], we had 2 values for the “y” key. This is a bug (at least in how we choose to define the semantics of this hashmap). If we go look at the <a href="https://github.com/omf2097/openomf/blob/4eca9e4e4c606121678beb79a9fa7988e12e1eed/src/utils/hashmap.c#L140-L162">hashmap_put()</a> function implementation, we see that it doesn’t clear out any previous value under that key. I reported this to the author and he made <a href="https://github.com/omf2097/openomf/commit/a941e52f6e524ab15323366dfa40014fd8adf6aa">this commit</a> to fix it and test for this scenario, lets try it:</p><pre>3&gt; eqc:check(hashmap_eqc:prop_correct()).<br>OK, passed the test.<br>true</pre><p>eqc:check() will re-run the last counterexample for the given property, so once you find a failure, you can test only that failure until you’ve fixed it. Bug squashed. Let’s run some more tests to be sure…</p><pre>hashmap_eqc:hashmap_create(9) -&gt; {ptr, {struct, hashmap_t}, 89178928}<br>hashmap_eqc:hashmap_delete({ptr, {struct, hashmap_t}, 89178928}, [159, 166, 202]) -&gt; 1<br>hashmap_eqc:hashmap_delete({ptr, {struct, hashmap_t}, 89178928}, [1]) -&gt; 1<br>hashmap_eqc:hashmap_put({ptr, {struct, hashmap_t}, 89178928}, [19], “{²”) -&gt;<br> {ptr, void, 89183696}<br>hashmap_eqc:hashmap_iter_delete({ptr, {struct, hashmap_t}, 89178928}, [28, 92, 116]) -&gt; 1<br>hashmap_eqc:hashmap_clear({ptr, {struct, hashmap_t}, 89178928}) -&gt; ok<br>hashmap_eqc:hashmap_iter_delete({ptr, {struct, hashmap_t}, 89178928}, “È”) -&gt; 1<br>hashmap_eqc:hashmap_clear({ptr, {struct, hashmap_t}, 89178928}) -&gt; ok<br>hashmap_eqc:hashmap_put({ptr, {struct, hashmap_t}, 89178928}, “;”, “OÀO”) -&gt;<br> {ptr, void, 89184336}<br>hashmap_eqc:hashmap_replace({ptr, {struct, hashmap_t}, 89178928}, “;”, “´S”) -&gt;<br> {ptr, void, 89184576}<br>hashmap_eqc:hashmap_put({ptr, {struct, hashmap_t}, 89178928}, [3, 208], “ðE”) -&gt;<br> {ptr, void, 89184992}<br>hashmap_eqc:hashmap_get({ptr, {struct, hashmap_t}, 89178928}, [142, 227, 49]) -&gt;<br> {1, 0, undefined}<br>hashmap_eqc:hashmap_compare({ptr, {struct, hashmap_t}, 89178928}) -&gt;<br> [{“;”, [180, 83, 0]}, {[3, 208], “ðE”}]</pre><pre>Reason:<br> Post-condition failed:<br> {hash_mismatch, [{[3, 208], “ðE”}, {“;”, “´S”}],<br> [{[3, 208], “ðE”}, {“;”, [180, 83, 0]}]}<br>{postcondition,{hash_mismatch,[{[3,208],”ðE”},{“;”,”´S”}],<br> [{[3,208],”ðE”},{“;”,[180,83,0]}]}} /= ok<br>false<br>5&gt; [180, 83].<br>“´S”</pre><p>Oh, so now a value has a random null byte appended.. what? It turns out the fix just reallocs the value, but doesn’t reset the value length, so we’re reading past the length of the value into undefined memory. That’s bad. I pushed a <a href="https://github.com/omf2097/openomf/commit/ebfc123caf4dd9a4300e86a48606670a8313d0fa">fix to the fix.</a></p><h4>Deletes, one more time</h4><p>There’s not much more interesting to test. The weird flavors of put/get are just ones that auto cast the type for you. The only interesting function left is really hashmap_delete() which is what you use to delete while you’re iterating over the hashmap. Let’s model that command.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/579d6fe408bfba89142e856ff4e6aafa/href">https://medium.com/media/579d6fe408bfba89142e856ff4e6aafa/href</a></iframe><p>So, again, we generate a key like we did for put and del, but this time we iterate the hash until we find that key and then we pass the iterator at that point to hashmap_delete. In the postcondition we check the return value was as-expected, existant keys should return 0, non-existant keys should return 1 (if we fall of the end of the iterator, we try to delete the iterator anyway). The next_state function deletes the key from the map.</p><p>Lets put that all together and run it now:</p><pre>OK, passed 1000 tests</pre><pre>15.28% {hashmap_eqc,hashmap_compare,1}<br>15.13% {hashmap_eqc,hashmap_iter_delete,2}<br>14.99% {hashmap_eqc,hashmap_get,2}<br>14.97% {hashmap_eqc,hashmap_clear,1}<br>14.92% {hashmap_eqc,hashmap_delete,2}<br>14.49% {hashmap_eqc,hashmap_put,3}<br>5.63% {hashmap_eqc,hashmap_create,1}<br>4.59% {hashmap_eqc,hashmap_replace,3}<br>true</pre><h4>Checking for leaks</h4><p>Well, I guess that works as expected, too. What about checking for memory leaks? EQC-C has a cool way to run the generated C program under a wrapper command, lets try that. Just add</p><pre>{exec_command_line, fun(Exe) -&gt; {os:find_executable(&quot;valgrind&quot;), [&quot;--leak-check=full&quot;, Exe]} end}</pre><p>To the end of the eqc_c:start parameter list to run the command under valgrind. Lets do a nice long run, too, like 15 minutes:</p><pre>eqc:quickcheck(eqc:testing_time(900, hashmap_eqc:prop_correct())).</pre><pre>==23954== Invalid read of size 8<br>==23954== at 0x41F52D: hashmap_delete (hashmap.c:461)<br>==23954== by 0x41387A: __eqc_c_wrapper_hashmap_delete (__eqc_tmp145296883325291_wrapper.c:3574)<br>==23954== by 0x4253ED: __eqc_c_interpreter_loop (eqc_c_lib.c:620)<br>==23954== by 0x42556F: __eqc_c_interpreter (eqc_c_lib.c:639)<br>==23954== by 0x41C39B: main (__eqc_tmp145296883325291_wrapper.c:5970)<br>==23954== Address 0x6bb0cf8 is 8 bytes before a block of size 2,048 alloc’d<br>==23954== at 0x4C28C10: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)<br>==23954== by 0x41C752: hashmap_create_with_allocator (hashmap.c:59)<br>==23954== by 0x41C8AB: hashmap_create (hashmap.c:81)<br>==23954== by 0x4135A2: __eqc_c_wrapper_hashmap_create (__eqc_tmp145296883325291_wrapper.c:3537)<br>==23954== by 0x4253ED: __eqc_c_interpreter_loop (eqc_c_lib.c:620)<br>==23954== by 0x42556F: __eqc_c_interpreter (eqc_c_lib.c:639)<br>==23954== by 0x41C39B: main (__eqc_tmp145296883325291_wrapper.c:5970)</pre><pre>Time limit reached: 900.0 seconds.</pre><pre>OK, passed 39965 tests</pre><pre>14.9205% {hashmap_eqc,hashmap_put,3}<br>14.8869% {hashmap_eqc,hashmap_get,2}<br>14.8748% {hashmap_eqc,hashmap_clear,1}<br>14.8599% {hashmap_eqc,hashmap_compare,1}<br>14.8477% {hashmap_eqc,hashmap_delete,2}<br>14.8462% {hashmap_eqc,hashmap_iter_delete,2}<br>6.0068% {hashmap_eqc,hashmap_create,1}<br>4.7573% {hashmap_eqc,hashmap_replace,3}<br>true<br>3&gt;<br>User switch command<br> → q<br>==22494== [../src/utils]<br>==22494== HEAP SUMMARY:<br>==22494== in use at exit: 0 bytes in 0 blocks<br>==22494== total heap usage: 1,244,999 allocs, 1,244,999 frees, 105,542,040 bytes allocated<br>==22494==<br>==22494== All heap blocks were freed — no leaks are possible<br>==22494==<br>==22494== For counts of detected and suppressed errors, rerun with: -v<br>==22494== ERROR SUMMARY: 62690 errors from 1 contexts (suppressed: 0 from 0)</pre><p>Uh oh, invalid read of size 8 in hashmap_delete, what is causing that? Turns out passing an ‘ended’ iterator to hashmap_delete causes an invalid read. We can <a href="https://github.com/omf2097/openomf/commit/32d93f0c09e901a33f79a95462ebd0730a28dc51">fix that</a> pretty easily, and then the run is clean.</p><p>Now, other than doing a lot of allocations/frees (which is expected), everything looks good. This is why I was so careful to clean up after all my allocations earlier. I wanted to be able to check if the datastructure had any leaks in it.</p><h4>Looking for bad behavior &amp; checking coverage</h4><p>What about checking for C undefined behaviour, or if there’s any buffer overruns on the stack? We can add these to the cflags for eqc_c start:</p><pre>-fsanitize=undefined -fno-sanitize-recover -fstack-protector-strong</pre><p>This will cause the program to abort on undefined behaviour and also install red zones between things on the stack so overruns will cause an unmapped page fault and crash the program. We can also get some numbers on how many times each line is being hit using these cflags:</p><pre>-fprofile-arcs -ftest-coverage</pre><p>One more run:</p><pre>Time limit reached: 900.0 seconds.</pre><pre>OK, passed 37209 tests</pre><pre>14.9676% {hashmap_eqc,hashmap_clear,1}<br>14.9604% {hashmap_eqc,hashmap_compare,1}<br>14.8948% {hashmap_eqc,hashmap_iter_delete,2}<br>14.8553% {hashmap_eqc,hashmap_get,2}<br>14.8513% {hashmap_eqc,hashmap_delete,2}<br>14.7747% {hashmap_eqc,hashmap_put,3}<br>5.9534% {hashmap_eqc,hashmap_create,1}<br>4.7425% {hashmap_eqc,hashmap_replace,3}<br>true<br>4&gt;<br>User switch command<br> → q<br>^andrew@macbookpro:: ==27754== [../src/utils]<br>==27754== HEAP SUMMARY:<br>==27754== in use at exit: 72,704 bytes in 1 blocks<br>==27754== total heap usage: 1,107,152 allocs, 1,107,151 frees, 97,994,853 bytes allocated<br>==27754==<br>==27754== LEAK SUMMARY:<br>==27754== definitely lost: 0 bytes in 0 blocks<br>==27754== indirectly lost: 0 bytes in 0 blocks<br>==27754== possibly lost: 0 bytes in 0 blocks<br>==27754== still reachable: 72,704 bytes in 1 blocks<br>==27754== suppressed: 0 bytes in 0 blocks<br>==27754== Reachable blocks (those to which a pointer was found) are not shown.<br>==27754== To see them, rerun with: — leak-check=full — show-leak-kinds=all<br>==27754==<br>==27754== For counts of detected and suppressed errors, rerun with: -v<br>==27754== ERROR SUMMARY: 59201 errors from 1 contexts (suppressed: 0 from 0)</pre><p>And let’s look at the coverage:</p><pre>$ gcov hashmap.c<br>File ‘hashmap.c’<br>Lines executed:89.25% of 186<br>Creating ‘hashmap.c.gcov’</pre><p><a href="https://gist.github.com/Vagabond/f4d44f376b22bb169c4c">Here’s the report</a>. Lines are prefixed by the # of times they’re called. Lines with no code are prefixed by dashes and unreachable lines are prefixed by #####. The only unreached lines I’m actually worried about are 346 and 368. 346 is reachable if you do silly things with iterators (like double iterate, delete with one iterator and try to delete with the second). 368 is, I think, dead code.</p><h4>End of the road</h4><p>Here’s the <a href="https://gist.github.com/Vagabond/04508270fa6f81dbba19">final EQC test</a>. The real beauty of this is that unlike a regular test suite, you can have it run millions of generated tests. In fact, I usually don’t consider an EQC test done unless it has passed a million iterations at least. I’ve often found crazy bugs after 750,000 tests that turned out to be legitimate and the kind of bug that if you saw it happen in production you’d ascribe to cosmic rays flipping bits or something. Once you teach EQC about the system under test, it can test that system endlessly. You don’t have to spend a lot of time thinking about really evil edge cases to turn into unit tests, EQC uses the basic knowledge about the system to find those edge cases for you.</p><p>If you’re interested in more information, <a href="http://quviq.com/">QuviQ’</a>s site has a lot more information, documentation, case studies, blog posts and videos. You can also download EQC-mini, which has similar features to the Haskell QuickCheck (no eqc_statem or EQC-C). You can also look into recent Helium hire, Scott Vokes’ <a href="https://github.com/silentbicycle/theft">theft</a>, which is like QuickCheck in C, or Helium veteran Reid Draper’s <a href="https://github.com/clojure/test.check">test.check</a> for Clojure. There’s also probably a QuickCheck clone for your favorite language, too.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=278f77cd2342" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>