Subjectivity in Oracles
ETHCC 4 · July 2021 · 25:50
Brenda Loya examines the subjectivity involved in choosing data and settlement prices for financial contracts. She explains why an oracle’s structure and definition of truth have security consequences, using examples from traditional finance and DeFi.
Speakers
Topics
From ETHCC 4, hosted by Ethereum France.
Transcript
awesome so hi everybody i'm brenda i'm with teller and we're in oracle and ethereum but before that i used to produce and publish economic statistics for the us government like the producer price index and employment numbers things like that and i used to do also a lot of the methodology research behind it so it's basically like defining you know how we come up with those numbers and how we make sure these numbers actually reflect the us economy and that way you know we can put out all the information so people can determine whether or not they can use those numbers to make decisions now with heller i basically do just one
portion of it we just publish the data on chain we're in oracle and what i've noticed a lot is that with so many backgrounds coming together on to blockchain and building all of this new industry there's a very old problem that's becoming a new problem in new technology and that's basically how you define what data to need do you need and how you basically settle different types of derivatives or bets however you guys want to call them um and that's what this talks about it's basically like going back and looking like how you should look at your oracles versus how you should also determine and define your data and um sorry i have some but
the blockchain how many of you guys are developers okay so i have a good chunk of devs um how many of you guys uh have been into space for a while hi so everybody knows how blockchains work right so they work exactly like vegas right have you guys been to vegas no jesus okay one perfect have you ever heard the the saying what happens in vegans stays in vegas yeah okay so for those of you um what that basically means is that whatever happens in vegas it's a pot nobody knows about it except that environment and blockchains work very similarly
basically what happens in the blockchain stays on the blockchain unless you know you get a millennial that goes to vegas and post everything on youtube and that's basically what oracles are oh i'm sorry so that's what we do we just make sure that what happens in one space gets it's known in another space we expand communication we expand use cases within the blockchain we make use cases a lot more interesting than just what's going on on chain and that's basically why we exist and with that i'm going to go through a very quick example of like how we are used and we are used for much more i think eventually we will be
for more than just bets but for right now let's just go through this example let's assume that this smart contract is very secure gone through its audit and then alice and bob are going to bet whether or not the price of bitcoin is going to be above or below 30k when i did this slide alice won i don't know about today i haven't checked the price but basically what you need is a price fee it's an oracle and a data source right and if it all goes well the right price gets in and everything goes perfect but there are two very distinct attack vectors here when it comes to the data putting that
on chain one is how the oracle reaches consensus and how they make sure that your data is secure and not manipulated within the oracle and how it reaches consensus and then there's a second portion of it which is actually what data they actually put in there and where they get it from and that i was saying like in the very later statistics i used to do more of a i created i do some research but then i also published it right now oracle's only publish your data as a user you are way you know you know better than nobody or anybody what you need for your contract to settle for your contract needs in terms of data so oracle's you actually tell
them hey go get get this data and where to get it so it's super important that you actually um go and define it um and we'll talk about it in a little bit but first we're going to talk about how when you're defining your data you're going to get there you also need to choose your oracle and make sure that it is secure oracles just like blockchains have the same challenges the scalability trilemma does not disappear for us we're not going to be faster than the blockchain if you need something to settle within seconds and you're on ethereum you're you should probably use another blockchain that's not going to work when oracles reach consensus on layer one there is no way they're going to be
faster than that so for starters look at that and you're also going to have to make a determination where your pareto equilibrium lies between your security and decentralization that you want versus how fast you want it and that you're going to have to look into your oracle and then the data source you're going to be using but that still applies to our goals in terms of oracle's you're going to have basically these type of flavors we have all sorts of different designs but you're going to go from centralized to decentralized centralized is the easiest oracle you can use is great for mvps it's great for for something that you
just need to get out the door on hackathon or something along those lines the biggest name in that is currently it's provable before they used to be oraclized and they're very easy to use npm install and great you know but they're also very centralized and the biggest downfall on that is that it is way easier to manipulate a centralized source than it is a decentralized source but for an mvp is great it gets you up and running and then you know you're off to something and then you have like a multi-sig uh design where you can have like multiple parties actually submit data to your contract and you know that kind of decentralizes a little bit more then you have the multi-stick with our
single relayer which actually makes it a little bit more centralized because now all of them are just submitting one science or transaction onto on chain um and then you know that kind of centralizes the the structure of it then you have y listers and i've have like poa and depos because you could kind of sort of relate oracles to how blockchains work but anyway your whitelister is basically somebody says you know these addresses can actually submit data and you have to go through them to make sure that they can on your um on your protocol and then there you have a decentralized protocol it's going to be probably a lot slower but it should be open and one way that
you can determine like whether or not i think one easy way that you can really determine something is centralized or not is if the team was to go away either walk away go to bahamas or just die tomorrow will i still get data on my contract will that be you know will i still be able to get that data feed and if you can honestly say yes like awesome then that is decentralized none of us are thinking like what happens with i mean i hope that they're safe lumen and vitalik right but honestly if they go away they walk away we can all still use ethereum nothing stops you know we don't call
them for support it's like hey i can't get this no like that doesn't happen that's decentralized so the same type of test applies to oracles with that going back to the data source so now that you know you're experts on oracles and how to sort of gauge where they fall within this centralization and decentralization range you are you have to go back and look into your protocol and what do you need for it because you're telling you're the boss you're telling the oracles what to go get for you and that is a very very difficult thing to do to be honest it's something that even the bureau the majority of them
probably the budget goes to research like how do we make this data based on whatever data we have available how can we approximate the population in the best way possible because you're using a model i mean you're just trying to get there in the best most efficient way but that is a very hard way thing to do when we are talking about the um so that in itself is the non-oracle problem of bringing data on chain and that falls on us or the users to determine what they need um but some of the things that you should keep always in mind is how appropriate your data is you know is this really what i need and that is
is going to vary from case to case whether you're doing a derivatives protocol or you're doing um what i said insurance sort of protocol if you're doing you know that might be slower faster how easy is it to manipulate the data sources that you're providing or how easy is it for them to disappear if you're paying if you're asking for a paid service how is it he said to for that api to go away um if you're just asking for one specific api how hard is it to does it like you're never gonna get the data i mean i mean it's pretty cheap i think um and availability like how fast is that api is it really as sensitive as you need it to be
because if you're asking for you know milliseconds fast data and your source is not that fast it's not going to happen and it's not going to happen the oracle's not going to be able to get it they're not going to be able to reach consensus as fast as you need it to and that those are just at least the beginning of things that you should look at before you even start thinking like okay how am i going to make sure that somebody doesn't come into my protocol and use this stuff as a vector attack because it is cheaper to do this than to actually pay out their bet and with that some of the things that you can do at least for pricing information is you know take a meeting across venues
like make sure you use more than one source that is the biggest thing do not use one source only that is the easiest way to attack your network and you're only as decentralized as your least decentralized vector in within your protocol if you look at it and be honest with yourself you're like this is a major risk major point of attack that's when you have to go back to how can i make this better volume weighted i mean evaluated and time weighted those two things they take time so just like we talk about ethereum and bitcoin like how much would it cost to attack them for an hour it gets more expensive so if you do this a an attack on your actual data source it's gonna be harder and way more
expensive so even that just helps you already um another thing that you can do which is a little bit less conventional um at least in the space right now it's just providing a data you know i just want the price of bitcoin if you don't have to be from one specific source it could be that opens it up to being like that price can come from a peer-to-peer network and come from anywhere and you will still get a price feed it just makes it more open now that you know you have to determine what you need and how exact you need to be but if you want the price of bitcoin from coinbase api at 8 a.m that's going to be very easy to attack and if that's the only way you can
settle your contract you better have a you know like a backup way of how to actually con settle it if it doesn't get there if you get negative data zeros you know whatever and then another thing that you know it's mitigate the risk for edge cases and that really has to go back to your own design of your protocol um for teller we do we do two types of tests we do for you know once you do your smart contracts you do function text test you know functions work requires works and then we have we go back and actually think about like okay how are our users do this you know how how are they going to break this because you know that that user that is like
you swear he's listening to it it's so intuitive a baby could do it but then you have that you want to use her that goes and uses it and like oh man i don't know how they broke it but you have to go back sit down and we call them end-to-end tests and we just try and figure out how our people are going to break our contract and you know in terms of security i was talking to a security person yesterday they're like well you know what you really need to do is sit down and think like how would i attack my own contract how would i take advantage of it and then once you're done with those tests or when you with those scenarios then you can actually you know you're never gonna completely get rid of risk i mean it's code bottom line there's
no code without bugs i mean i think you know that's what we have now we have upgradable contracts we have ways to go about it but anyway you go back you determine what these cases would be and that will help you also like determine your data source determine your structure and making sure that your users are actually safe and once you determine this you have a whole definition that you can actually give to your oracle because they when they reach consensus the way that they're going to know whether or not they provided you the right data is going to be based on that definition and anything that we like for example if they're slashing or like if if the numbers can be disputed because they were bad numbers or whatever
they need to know what to reference and they're going to reference that definition in that data source to actually be able to come up with a consensus on it so um in terms of what to do um um i think it's it's for a protocol before i was in teller our very first startup was actually derivatives and we use more than one source of data because you know sometimes an api is down sometimes uh the actual resource is down and because of that we realize that like in production especially like that happens on main
end and that gives you a lot of headaches like that cannot happen when you're securing millions of dollars on your protocol so you have to have backup plans and i think one of the easiest way to do this is to just use several oracles there's an um an eip proposed already for that um to use some sort of standard so that you can switch back and forth between oracle's or just add more um and that you know it's it's something that is super useful because for somebody to actually dive into the architecture of two different oracles that were completely different it's gonna be one really hard technically and then two is gonna make it super expensive for them to actually break two if you're
using the median of three let's say then it is to break one like if they find a vulnerability in one then they can actually attack your protocol if it's if the cost of doing that is actually lower than what they aim to lose or gain right um and then also always you know what can you do within your protocol structure if you get bad data if you get a zero if you get negative numbers what happens because apis are apis you don't control them if they're testing something if they're testing an upgrade they're upgrading their api now it's going to have extra zeros and all of a sudden you have a flash crash that didn't exist or a flash you know increase that like
it didn't happen but it was just the api you know was bad and it's still going to be a valid query because you told the oracle to go get this data from that api so it's still valid that's what it said but it's not what's expected and it's not correct and you just want to make sure that you have some sort of levers to like manage that you know you never like i said risk is there but you can do a delay you can do a freeze you can once you do a freeze you can go through a world and and make sure that you get your protocol back up and running and it doesn't just get pulled down like because of some very very quick attack um and then because once you have your data defined
you can actually go back to your goals like is it fast enough you know how how much does it cost to break it um can it really secure what i have on my protocol and um you know then you have to like the liveness which is just basically like will it still survive and will i still get my data whether or not the team is there um but those things you determine like once you have your data like then and if defined then you can say like this these oracles fit this model or are similar to what i need they can actually sustain it then you know you go back to that to the drawing board and and that's that's pretty much it like choose the right architecture use more than one
oracle use more than one data source decentralize your architecture in terms of how you get the data and minimize the attack vector to it and just protect your your users right now the block there's the entire space it's a tiny industry compared to like those cemented industries that are already out there the financial sector is huge compared to to what we have right now and the last thing we want is to have regulators come down on us because we don't or because they perceive that we're just trying to defraud people when we're just trying to do something better and we can just keep our users safe i think that will keep regulators
away from us at least for a little bit until we can grow the industry into actually being something that can be here for a long time um and that's it for my presentation but thank you [Applause] any questions hi thanks for the talk um you mentioned something about the oracle standard that was kind of being discussed could you expand on that yes um basically we it's uh it's called the the atom as alliance of decentralized oracles and we formed it about
two years ago or about a year and a half ago it's been a while we just keep going in and out of it but like we're basically just trying to come up with a standard where we all provide or submit or output data in a very similar way so that the users can just basically go from one to another right now i think we have settled on byte data and it's 23.72 do you guys remember the number no anyway um it's it's it is on the ethereum get um bitcoin github uh we already submitted it
uh we're still working on it i think we dropped the first one we went back to the drawing board we're back at it now and that's basically because as the industry grows and the amount of money that is being secured growth we understand that there is a need for people to just have options yeah thank you um have you looked into more privacy preserving or other data everything here is public data which many people can access like price feeds and stuff what about any private like i know data about a person or something else
which is which is not available as much have you thought about like privacy preserving type oracle so on private data i mean um i think everybody is working on the privacy it's very expensive to do anything private on on chain we haven't really gone into that because i think a lot of the things that we do especially for and because we were so focused on price data we wanted to be as transparent but yes i have i'm actually like thinking about the privacy of the data which then can be analyzed by an oracle and then published whatever this typical example kyc is this user a legit person and you don't want to put this on chain right so oracles could do something but then
because it's not public you need to share it with multiple oracles like that's i think the the challenge i see that if we have anything which is about people itself or information which is not published to the world how can we bridge this gap from private data to some at the station on chain i think it would at least for us like the attestation it happens on chain when you can it could be i think encrypted right but if like three like right now the way that we reach consensus is three out of five um and it could be a way like if at least three out of five or three of whatever submit the same encrypted data then you could assume that it is correct
i don't know but we have not really looked into privacy data or of the data and bridging that at this point so if anybody has any ideas you know happy to talk about it or yeah sorry this might be sound like a question too much up in the clouds but uh how do you think that ai will affect um oracles and maybe up in the stratosphere how do you think that ai could actually uh help decentralize data retrieving in a in a consensus-based way um that's a good question i mean
a lot of though and i can only speak for teller because i know that other oracles work differently but what you do to collect the data outside of uh when you actually reach consensus on chain i mean you could do all sorts of aggregations and run a lot more like you could even do ai like trying to figure out other things but as long as when you get it on chain there is a consensus of how you got to that truth i think you could use pretty much anything you want even if it was ai to like depending on what models you're trying to determine or whatever but what really matters is on chain how are they reaching consensus and how you're making sure that they
that the reporters are providing valid data and if you can somehow reach you know if like i said like if it's three or f out of five so i'm getting the same hash and then there's like two random ones that you're like well why did they come up with this but it's difficult it depends what it is it can be difficult because you know if it's a string it's going to be very difficult if it's a number it's probably going to be the same hash it's like 10 is going to be the hash of 10. but if it's a string it's going to be more complex and that's something that you have to define and that's something that within the reporters or when you ask for the data you have to define like how you're going to decode it what it means um so but outside of the on-chain portion i
think off-chain you can use anything you want i mean as long as you can bring it to consensus on chain yeah thank you all right i think just remember what happens in paris we'll probably we'll probably end up in twitter actually in this conference so anyway thank you everybody have a good day bye you