Learnings from FOAM Location Developer Stack
ETHGlobal·Wed, Oct 9, 2019, 12:00 AM
The team from FOAM explains the FOAM Protocol and building a Consensus Driven Map of the World at a workshop at ETHNewYork. ETHNewYork was a hackathon organized by ETHGlobal and a team of hackers, developers and enthusiasts interested in building and creating in the ethereum ecosystem. ETHNewYork ethereum focused hackathon took place May 8-10, 2019 at New Lab at the Brooklyn Navy Yard. For more information visit https://ethnewyork.com/ and https://ethglobal.co/
Transcript
so I'm gonna present on foam which is a protocol for building a consensus driven map of the world and so really a foam protocol has like three main different elements and that's called the crypto spatial coordinate the spatial index visualizer and ultimately proof of location and so really like the starting point of the project was that there are no geospatial tools or standards for blockchain developers whatsoever so that's everything from how do we put geospatial information into a smart contract how do we visualize it and then how do we even verify it so that's kind of where we started from so currently we have a product that's live on the etherium a net it's called the foam map it's a token created registry for curating geospatial points of interest and kind of one of the first mechanisms of kind of trying to verify geospatial data on the blockchain and where we're going towards is something called proof of location and that's about actually verifying things that move around in the real world and with that we'd be using low-power radios and a time synchronization protocol so just back to basics foam is about bringing geospatial standards protocols and ultimately proof of location to the blockchain and so where we first started working on this project in about 2017 the first element we actually designed is something called the crypto spatial coordinate and so most people think that geolocation is already a solve problem today but in reality we have tons of different geo encoding standards there are things like postal addresses like so it'll say Times Square Manhattan New York latitude longitude and there are some like what three words which is proprietary solution which gives three words like rocky silver fund and that will represent a three by three square so they have basically a three word key for any place in the entire earth so this is for people that don't have postal addresses or they're in the desert or how to kind of do that but they're selling that solution to people like trains or mercedes-benz so it doesn't really cut it for a blockchain but we did find this one solution called the geo hash which is a really kind of elegant way of kind of making a really long latitude longitude into a short identifiers key and so what we did is take this open geohash standard and come up with a way for any smart contract just to claim a a geohash and out of that get a unique identifier which is a crypto spatial coordinate and this is kind of a smart contract making a claim on and off chain to a location it doesn't say that it's actually there but what this does is give a standardized way for smart contracts to encode locations so you don't have one using a street address than one using latitude longitude now they're not interoperable so this is kind of like the first starting point of just kind of brings some sort of standards about location into blockchain and so what that means is it's kind of the first step of introducing this new spatial dimension where contracts can start to claim addresses and you know from there we'll really see how do we actually verify if what they claim is true or not so this is actually the new lab the building we're sitting in now and for example if it claimed at the smart contract representing the new lab it would get this kind of unique identifier that you'd be able to drive its location from and you'll be able to derive it smart contract address and you'd be able to check it in the real world and on chain as well so as the first element of just encoding geospatial information from there we want to then be able to visualize it so from there we made the spatial index visualizer which is kind of like a visual blockchain Explorer and so there are currently no real general standards of building maps that are connected to the blockchain especially for developers so this is kind of the architecture of the spatial index visualizer it's a full stack web app and it uses everything from the top like uber deck GL tools map box SDK it's a react app with meta masks and you can interact with the blockchain via the front-end and then there's a back-end a B API written in Haskell it's running on kubernetes clusters and it can basically index the entire blockchain into a post sequel database and then from there this API feeds these events to the front-end so you kind of have this loop where you can interact from the web app with aetherium the backend can index it and feed those events back to the front so that you basically everything you then see on the map is actually a smart contract so this is the kind of architecture that powers the phone map today where every point you see is actually represents a smart contract on the blockchain and you can interact with it through that and it's powered by this back-end we've built an API and so while working on the spatial visualiser we came up with a lot of custom tools to support it and these are general purpose tools for aetherium developers they're not related to geospatial or blockchain and so the first is that we are functional programmers at foam were the largest contributors to the haskell web 3 library and when working on this project we made the pure script web 3 library so a pure script is a functional programming language that compiles to JavaScript but it's very much like Haskell with strongly typed language and secure so this is kind of what powers the front end of the application is this library that we maintain additionally we made a tool called clickbait this allows you to spin up a custom blockchain from a docker image really quickly and you can pre allocate balances to different accounts and import libraries already and we also developed something called chantrelle and this is written in pure script as an alternative to truffle truffle is one of the most popular deployment tools in e3 amande javascript but it's also comes a lot of pain points and so we made this as an alternative in our work so essentially at foam we have an entirely own aetherium stock that is kind of custom-made for us but available for anyone to use for their own purposes so instead of truffle you chantrelle instead of web 3GS we use pure script and instead of these test RPC modules we use these clickbait docker images and this makes it really really fast to spin up applications deploy things to the main net and in a really secure way so these are available for anyone to build on not even generally spatially but when it comes to the spatial index and the foam map we do host the foam developer portal so this is how you can get access to that API and get started either building your own applications with these tools or trying to basically do some analytics on what's happening on the map so that can be found at developer.android.com a map in their application and taiyo to a blockchain but where the foam token comes in is then how do we actually start to verify information and so what we start with is what we call static proof of location and so when we look at kind of open source mapping today there's a lot of problems and attacks so just recently it's we see here it says New York was renamed to do drop Alice and kind of like an anti-semitic job so somebody kind of vandalized OpenStreetMap and it nobody caught it and it got then basically pushed to snapchat and city bikes and street easy and basically everyone's mapped that day instead of New York it said Jutra police people in Pokemon go were going into OpenStreetMap and would add a volcano to Brooklyn and nobody would catch it and now there's Charizard everywhere in Brooklyn and try millions but there's also Ebers routing around volcanoes and fake rivers and so these are people kind of and even then with like ISP addresses there was like because of an error in the US military database for like every single stolen iPhone in South Africa at pinpoint at this guy's house and so detectives and police would be showing up all the time and like threatening him every day but it was just that the general isp assigned the geolocation for that town to his backyard so there's a lot of problems with kind of validating and verifying keeping this kind of data up-to-date already and if we want to think about a smart contract that will read this data it definitely should be verified and secure and so the solution that companies do today is companies like map box and Facebook they actually protect the map so you have these open source mappers building out these databases but then these companies have to run these algorithms and manually check it and pay a lot of people to do it so that they can make sure it's correct and then they sell it back to companies who want to use it like snap maps for example and so that's slightly problematic because you kind of have these gatekeepers of the data but it's especially problematic for any smart contract that then would have to pay these API fees to these entities that are kind of protecting the map so what we did is for the static perfect location is take this crypto spatial coordinate primitive and combine it with another in the blockchain space was as a token created registry and that's a way to kind of maintain a list of information and user token to curate it and in our case we want the list to actually be a map of location so the list is kind of rendered as a map and so in a token created registry there are candidates and these are new points that want to be on the map there are curators people who actually go through and potentially challenge those and then there's consumers which could be a human but more likely a smart contract like let's say a game we're running a scavenger hunt right now where you can win enough T's and there's a bot in the cloud that will read the map and trigger other smart contract events and issue NF T's as rewards and so this is kind of a fun graphic someone made in our community but it shows at the top when you want to add new locations you must stake a deposit that's kind of an anti-spam mechanism you still own your tokens but it's kind of backing the truthfulness of your claim if nobody does anything it will be added but if somebody challenges you they can stick against you and that kind of creates this reward pool where people can then vote on if it should say or not and that's kind of the real innovation here is that there's now an incentive to even check these points because there is this kind of like a latent bounty if you found an error and this is a little bit outdated but kind of shows the amount of points that have been added to the map so in this snapshot there was 8,000 I think it's closer to ten now and in about 4% we're actually challenged and a slightly less were then removed you can see somewhere like manually removed but ultimately a lot of the points are getting through and people are sticking tokens to them so this is also shows the amount of tokens that are staked in the phone map today across different contracts one signaling which I'll get to after so from when we launched in September to December to today people are actively basically adding data to this registry and this kind of shows the growth and ones uh I'll skip that for now and so we have a lot of challenges occurring as well and you can kind of like start to learn of how these actually creation markets perform in the real world though this is one of the first token created registries so a lot of assumptions need to be tested and kind of see how people behave and then we can kind of respond to them and make news so when this was this snapshot it showed that the highest challenge reason was the actual point was in the wrong location but since then the chart is actually different where the metadata has become the biggest reason and it's because people are getting more nitpicky to try to you know sneak in challenges and make people vote on their side to get the points this shows that points are either really challenged right away or old points that people are sifting through get challenged yeah stop there so that's about what's live today and we've learned a lot there's an active community of people either curating the map or debating how to enhance it there are a lot of governance parameters that can be triggered so people are kind of working through that and we see people also building now games on top of the map so the map is kind of a game but it's also very much a protocol meant to generate a verified list of points and then those points are to be used by other applications whether it's a game or something else but going forward we're working on dynamic proof location and this is on how do we come to consensus on where actually something is in the real world so the today the way that we kind of derive real-time location is through the GPS system and it works really great to figure out where you are but the satellites only send messages to earth they don't hear anything back from us so you can figure out where you are but the satellites don't know where you are there's no history of where you've been so it's very easy for you to change your GPS data before you send it to someone else and it's called spoofing and so it's a huge problem across supply chain IOT mobility like cars pokemons go but when we think about in a trustless web 3 economy if people want to accept location data to issue out a payment let's say you can't use GPS because it's impossible to know if it's a real or a fake GPS message because there's no origin and this is becoming a bigger and bigger problem like kind of the location market is suppressed companies like Pokemon go couldn't capitalize on revenue because too many people spoofed where they went and they wanted to partner with stores uber has lost tons of money trying to detect spoof errs who are making their trips last longer to ramp up the prices and we're seeing more and more kind of military-style interferences and attacks against GPS and there really is no alternative or backup but there's also no way today to actually verify your location in that way so in the kind of foam system what we want to build is something that is Byzantine fault tolerant completely independent of GPS trustless and permissionless and driven by punishments and rewards and the way that we do that is through synchronized clocks and triangulation low-power radio networks crypto economics and incentives and different consensus models for local and global and the kind of radios that we're looking out for this is a new class of radios called low-power wide area networks these radios have a very long battery life but can also go an extremely long range so unlike bluetooth etc so these are really interesting about something where you could not have an insane amount like bluetooth and still get decent coverage so the radio we're currently working on is called Laura and has up to like a 10 to 15 kilometer range and 10 year battery life in optimal conditions probably much less in like a dense urban city but this is a really exciting radio that also runs on the open is M band so you don't need a radio you don't need a license from the government to operate these radios you could run a business with these radios without a license and there are plenty of people kind of hosting these radios for free today so this is a snapshot in Sidney Zurich and these are people running them kind of for IOT DIY projects they have a sensor and a pond and they want to get that data to the cloud and people are running these low-power radios for free today and you look at other projects like go tena which is a consumer hardware device to be able to mesh network without internet and there's tons and tons of people hosting it now there's not much you can do with it but this kind of shows that there is an interest and demand from retail or normal people to actually use Hardware and participate in mesh networks kind of validating that there are people wanting to do this so in the foam system what we call these radios is own anchors so you would have them kind of being hosted by people who stake tokens and they would kind of find each other over radio and synchronize their clocks and once synchronized they form ozone and ozone is kind of maintaining a quorum on space and time and they're constantly synchronizing their clocks and broadcasting messages and if they unsink are kind of acting correctly the ideas they would lose their stake and the idea is that once this service is there customers can now generate proofs of where they've been in a way they never could before so applications can then define the logic and let's say it's an uber app the app would say to the driver for you to get paid at the end of this route you must produce seven receipts along the way and the only way those receipts could be made as if they were interacting with the zone so the zone is then basically keeping a quorum on time in space and can accept fees from customers that want to generate proofs so the system is meant to be trustless independent open hold people accountable and incentivized and so what we've been doing earlier this year has been building a kind of local test net so we can simulate this in the lab and we called it the Geo pickle this is what it looks like so it's a rack of like 40 raspberry PI's and so each rack of four I would represent a zone so a zone needs at least four zone anchors one for XYZ and a fourth for time and so here we have ten zones and what it allows us to do is simulate that they can you know hear each other half the time maybe they can hear each other 99% of the time you can simulate packets being dropped and so that we can actually run just locally this kind of simulations it's been really great to work on the time sink software and protocol through that this is kind of like a gif of showing like that you can see all the zones and they'll be running the time sync software and eventually they will synchronize which is great to see yeah I think I ran out of slides but what I wanted to say is that was the previous progress since then we've been working on the actual radios and a custom firmware for them and in parallel the kind of blockchain scaling architecture of a plasma architecture and so right now I'm 10 minutes up in our office because foam is based in the new lab here we're going to do our first demo of the radios running time sync over radio and then basically being able to exit their plasma chain and that uses 10 Derman consensus as well so yeah if you want to see it in action come up to our offices in 10 minutes and happy to take questions for now that's to verify that you were yeah so the way that like GPS even works is they all have atomic clocks and they synchronize their clocks and if you have synchronized messages and you can receive four of them you can run a time difference of arrival algorithm so if you know the location of all them and then you can basically trial a turret your location based on the difference of arrival so they all broadcast what time they sent it and then you see that they came in at slightly different times and so that's what your phone is doing when it's looking for the GPS messages it will try a lottery so that's why you need time synchronization and why it's really important to have them be fault tolerant because they have to always stay in sync up to like a nanosecond to make the location part accurate and so this just physics here will work the same and that these radios are synchronizing and they're broadcasting their messages so anyone listening can learn their location but the new value out here is that you can buy directional so you can talk back to the system and for like a small fee generate a receipt about yourself so it's more about humans or machines being able to generate what we call presence claims of where have they been by this kind of network of infrastructure being available so the phone map is on maintenance and launched a last September we're doing our first demo like the radio stuff on a tough night today any other questions so Kayla appear in the back he's a bum community member and he does some analytics so like the charts we saw but he also started a service called the foam daily digest so that like everyday tells you how many points were added how many challenges signals where the act of voting is and it's been pretty volatile so like last week there was like over 30 challenges at one time and like you know close to over 8 million took foam in the voting contract and it was like extremely active and then and there's like a hangover now and there's been no challenges and then there was like a week where there was like five points a day I think there's only been a few days in the history since we launched her there was zero points but so and then there'll be like a game that started on a Saturday and like the last three Saturdays there was 45 points added by like new users so it's been kind of volatile but it is slowly kind of tokens getting sucked off the market and into the registry there's no like preventing someone from writing about devil auto import points but I can't verify if anyone's done it or not but it's mostly people kind of like manually and they then they are really meticulous about it because if they mess up someone might challenge them and then then they're the minimum deposit is 50 phones so they it's ideas that have it be enough to be anti-spam and also should be enough that it's worth voting because if you have a too low voting the reward will be less than the gas yeah and then what we saw is people staked a ton so like they're like really proud of their point and put like 10,000 and then we see like a guy with a lot of foam will challenge them for 10,000 and then try and win the vote so it happened a few times and then the people like rally together and then like destroyed this Challenger and he lost like thirty challenges in a row I got the exact same time because he started them all at the same time and so like we're aware of like the perils of on chained voting but if they're it should eventually hit an equilibrium of every point had the minimum the challenges should only really be legitimate and kind of a lot of the challenges we saw are also people kind of even if they found a real error they would challenge it for the maximum amount to try to get but there was no requirement for the person to stake so much there anyway the idea is longer term it'll be a way to like visually rank points so if you want to be more visible you can put more at stake but yeah and so be awesome that we have a grant program available and bounties for this so if someone wants to like I think BOTS are pretty underexplored the NFT game that's running right now uses an ad robot in the cloud to listen to the API and trigger the minting of NF T's so it's definitely possible to make a bot though like take some what other database that's open source and like manually you have it add points or something it's kind of been like that you had to really see how it even works over some time and so now that that started to happen and there's been some controversies those conversations have just started and some community members have stepped up to like organize the calls and discussions no it's the same as voting this it's a gas basically so so there's like seven parameters that currently can be changed what would be expensive is to rewrite all brand-new smart contracts pay an auditor and then launch that but that's all we also have an upgrade path so it's possible one to like kind of target behavior off of kpi's by like if there's too many challenges make the challenge period last a month so there's enough time for people to vote if it foam goes up and value too much lower the minimum deposit things like that all right we have five more minutes any more questions yeah I mean so there's a lot we're currently exploring on making the parameters more intertwined so like for example a challenge to point addition ratio so like your challenge power ability could be like tied to how many points you've added but ultimately it's like a consensus driven map so it is comes down to subjective behavior and so the majority of foam users agreed that there is a volcano in Brooklyn and it's on the blockchain and nobody wants to pay enough money to challenge them all the others have to live with that fact ultimately the minority who was upset about it could also fork the code and leave behind the volcano yeah yeah well we're definitely seeing people like stress tests in folk we've had like three times now like a rogue challenger come in and then get burnt out and quit the community because like they ultimately like got defeated yeah so we have a API written in Haskell and we're running on kubernetes clusters and then it basically reads from aetherium yeah the metadata is an IP FS but then it has this back-end database and indexer and it goes into a post sequel GIS database or whatever spatially Kure database and then I can just send read WebSockets back to the front end and so from the front end it's just like seeing normal data and just renders it on mapped like in the same way any map box application does and then this kind of structure can be you know used for it can like index anything from it doesn't have to index just the TCR could index crypto kiddies with geospatial addresses in them yeah I think we're gonna go do a demo now in our office so thanks everyone for stopping by [Applause]
Automatic transcript — names and jargon may be misspelled.