Securely Connecting Smart Contracts to Off-Chain Data and Events by Sergey Nazarov (Devcon5)
Devcon·Fri, Oct 9, 2020, 12:00 AM
Speaker
Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on IPFS and more. https://archive.devcon.org/archive/watch/5/securely-connecting-smart-contracts-to-off-chain-data-and-events For smart contracts to achieve mass adoption, they need the ability to securely connect to external off-chain data and existing non-blockchain systems. The reliability with which smart contracts connect to key external systems determines their overall security. This critical security factor determines whether smart contracts will be used to secure the many forms of value beyond tokenization, such as prediction market outcomes, insurance payouts, trade finance, and more. In this talk, we’ll examine what makes a secure oracle mechanism reliable enough to be trusted by smart contracts for external data delivery, access web APIs, and off-chain payments. We’ll review the security risks and failure scenarios to avoid when using oracles and share how developers should set up methods to maximize success. We’ll examine how a decentralized network makes oracle mechanisms more secure, and how decentralization, combined with approaches like Trusted Execution Environments, can enable the highest level of security when connecting with external systems. Finally, we will show the design patterns which leading smart contracts use to remain reliable and provide high levels of overall security while connecting to external systems. Speaker(s): Sergey Nazarov Skill level: Beginner Track: Security Keywords: chainlink, off-chain, general Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum Learn more about devcon: https://www.devcon.org/ Learn more about ethereum: https://ethereum.org/ Devcon is the Ethereum conference for developers, researchers, thinkers, and makers. Devcon 5 was held in Osaka, Japan on Oct 8 - 11, 2019. Devcon is organized and presented by the Ethereum Foundation, with the support of our sponsors. To find out more, please visit https://ethereum.foundation/
Transcript
hi everyone thanks thing to learn more about Oracle's and how they fit into smart contracts and and if they're iums overall future so I think the the first useful thing is for us to get some share context and to look look at the security problem that we're trying to solve and then look at the different ways in which that security problem can can be solved effectively so the nature of the problem is that smart contracts on great networks like aetherium can't connect with external data this is based on how they reach consensus about transactions how they verify verify the data in in in blocks and it isn't something that's likely to change it's it's an inherent problem of all decentralized infrastructure that seeks to package transactions into blocks because the miners set that you have doing that you don't want a specific miner responsible you don't want him having control over the ability to you know make your contract trigger from data or not trigger and you also can't have the entire miners set exposed to various arbitrary API s so this is this is known as the Oracle problem and it's the inability of layer 1 systems to interact with external data now the significance of this is is rather large the significance of this is is why we are currently mainly defined as an industry by tokens and we're defined as an industry by tokens because that's effectively what base layer 1 systems can do because they have it inherently built-in to incentivize mining and therefore allow their you know their base basic existence now the the reality is is that if you look at the the rest of the world and you look at all the digital agreements powering financial products in in various centralized forms the insurance industry the global trade trade finance industry all of these industries use some form of digital agreement and all of those forms of digital agreement require inputs inputs about what happened relative to the agreements terms so generally speaking we call these events and the ability for a contract to know about an event is the is the necessary point is the necessary for it to be written about that event so essentially the the significance of the limitation is with without the ability interact with events smart contracts would stay related to tokens which is only a small percentage of what our technology could be about so our industry could be about financial products insurance global trade if if we're able to solve this problem so historically how our industry has actually evolved is it's gone from a smaller set of capabilities for developers to a larger set of capabilities the first large shift in capabilities was from Bitcoin Multi signature as the only capability that anybody could build around in around you know 2011-12 and then in about 14 you had the first app coins as they were called these were protocols smart contracts where you had to bake up smart contract into each protocol then the protocol smart contracts got switched over to scriptable contracts and scriptable contracts is what aetherium deserves the vast majority of the credit for they've done a fantastic job of taking our space from these protocol contracts that took months to get launched to scriptable contracts which took days to launch and because they took days to launch we now have all these people launching massive high value systems based on this capability and as you can see a lot of those systems are pretty much exclusively focused on tokens because at the moment that's what scriptable capabilities allow what we think is that scriptable contracts together with external events is how our space moves into this entirely new stage of usefulness for for developers for users you know how we redefine our space to be about tokens and all the other types of digital agreements that that underpin you know very important global industries generally speaking this is the problem that we work on we focus on creating secure blockchain middleware that product is called chain link and it basically focuses on enabling the ability to get data into networks like aetherium get networks like aetherium to pay in other systems and interact with other environments as well as get them to do cross chain things we're ready live on main net it's all working and and the things that I'm going to be showing to you are live and working and usable by by us developers so generally speaking the the I think there's kind of two two key points and in this talk one one key point is how do you define the security of an Oracle so that you can rely on it to trigger your contract so that's that's a very important question and then the second question is once you rely on the security of an Oracle what can an Oracle really do for you right like okay I've arrived at a place where I can can assess and feel comfortable about the security of these of this Oracle mechanism which effectively makes up the second half of my contract because if my contract is about an event I have a piece of it about on change state and I have a piece of it about the event and both the unchanged state and the off trained event needs to be properly guaranteed from a technical point of view in order for the the smart contract to retain its unique property of reliability so the these are these are kind of the points I'm going to be speaking about and and elaborating on what what it is that that what makes a secure call and what a secure Oracle can do to expand what developers in our space could build to create all these other various types of usefulness and and valuable contracts generally speaking our approach to all of this is the ability to provide decentralization for the Oracle mechanism by having multiple independent node operators validate the accuracy of Oracle Oracle reports we do this through something called binding service agreements binding service agreements make an Oracle commit to delivering a certain quality of data or computation or our payments outcome and that commitment is both technically in cryptographically guaranteed and crypto economically guaranteed through things like staking the ability for all the binding service agreements that an Oracle a generates to be aggregated into a picture of that Oracle's overall reliability the application of something called defense-in-depth where we lay around multiple security approaches on top of decentralization such as trusted execution environments and zero knowledge proof and the fact that we do this with a large open-source community made up of some of the best academic researchers the best some of the best security auditors and and a large and growing group of developers that are excited about enabling this world of smart contracts beyond tokenization so it's usually useful to look at the problem or solving the the specific problem we're solving is the the problem of centralization and the capacity for an Oracle to fail because it's been it's been it's been it's been made unreliable by being attacked as a single point of failure generally speaking that the way to approach this is through the centralization just like the contract is secured through multiple node operators validating the the inputs and the validating the transactions that the block and the contract is made up of we have multiple Oracle's validating that an input is is indeed correctly validated and secure and reliable enough to trigger large amounts of value this is partly guaranteed by service agreement service agreements are not legal documents they are on chain commitments that are cryptographically and technically enforced to guarantee that an Oracle does deliver data and that if the Norrell doesn't deliver data there's there's immediate and inescapable penalties both to their their long term usefulness for other users an immediate loss of stake and and and and other negative factors generally speaking we see a world where just like you have right now extreme decentralization aetherium you should be able to have whatever degree of decentralization you'd like to have from the Oracle mechanism and also that'll probably lead to the centralization at the data source level such that you know the highest value hundreds of millions of dollar contracts you already see them thinking about all these things in more detail and you see them wondering why do I think an Oracle is secure how do I know that this data source won't be compromised how do I protect myself from a data source being compromised how do I protect myself from an Oracle being compromised these are the problems that our space is going to have to have an answer to if we want to if we wanted to move into this realm of events driven contracts so that's that's the very large focus that that that we have is solving the problem of how do you reliably provide guarantees that your Vince driven contract can have a billion dollars put into it and can be considered reliable reliable enough to move that million billion 100 million billion dollars in a matter of seconds which is the the real promise and value of our space so generally speaking the way this looks in practice is you know service agreements are made up of something called jobs jobs are basically function as a service of blocks of predefined computations that a node operator lists themselves as opting into do you interact with them as on a service agreement they commit to do this computation for you in this case the retrieval of price you select from a multitude of nodes we have I predict approaching 70 high quality nodes now and I think a quarter of them are securely reviewed in a two week process what a security interview at the end both creating civil resistance in an overview of their security infrastructure which we then present to users as well and generally speaking the goal is well the dis goal right what iswhat I shown you here has been achieved you if you want to compose a reliable Oracle network with multiple independent parties running that network and multiple independent data sources feeding your decentralized finance contract reliable data you can is now been achieved on may not it's been live for you know a number of months now without without any security issues likewise if you wanted to compose something like smart smart contract a smart contract for crop insurance the crop insurance would would learn about whether it would aggregate death or data about whether and it would then arrive at at a conclusion for that for that outcome and then also through through the set of Oracle's that we have be able to execute payments so it would be able to ingest inputs put outputs and these are the previous defy example in this example are what we're really trying to get the space to so that just just like you could write a token in a day you should be able to compose a high-quality externally connected contract in a day generally speaking what what all of this usage does and and this is one of the important nuances of how you would evaluate Oracle is generates a lot of data it generates massive amounts of data just like you have block explorers for a theorem contracts we have even more detailed block explorers for Qing link Oracle reports that define exactly what somebody did what they committed to do and whether they met their previous commitment you can you can find all this in a multitude of resources and I'll show you how to do that at the end of the talk for for a set of Oracle's Oracle networks that we call reference data networks so generally speaking that part of the goal here is how do I as a user effectively assess a node operator that I can then compose into greater and greater networks and such that if not the value of my contract grows I can compose greater and greater collections of node operators we enable this by floating provable information about their infrastructure how how they've been able to successfully fulfill their commitments and also what specific infrastructure they run on and also the capabilities they can give you through that infrastructure so so that's the thing that we've actually been seeing quite a bit of since since launching on main net we've been seeing quite a lot of adoption and in an additional usage not only in data delivery but in the ability for a chain link to connect smart contracts to all the different you know function as a service systems all the different computational environments other other than other than block chains which which gives smart contracts the capacity to securely use huge huge amounts of computing resources this is for example a diagram we released in in a post with Google describing how a theoretical architecture would look in in the case of using Google cloud platform for one of their specific services like bigquery and here here at Def Con there's been released by one of our users Foam you know great group of folks basically building an incentive serve as a service to generate valuable location data using token incentives and and here's how that architecture looks so just like you know just like we started out with data and we've started to enable a lot of define a lot of simpler arching contracts with data the next stage in in in all of this is actually expanding the definition of an Oracle beyond just something that provides data but something that actually provides access secure and provably secure access to all the different computational resources available outside of blockchains this includes random number generators it includes all the resources in cloud providers all the great pre-made services and functions as a service that you would want to use and the capacity to validate and prove that those computations were correctly executed on one server serving across across different services so I think the interesting thing that we've seen is the capacity to move beyond data and into data plus computation such that chain link becomes an off chain resource that developers can go to to compose whatever interactions they need to compose around their contract in in in in the world of all of Auld already existing high quality of chain computation that's out there another example of this is a recent announcement at the start of this conference about how chain link enables aetherium contracts to use Intel's trusted computing framework so Intel has spent a lot of time and effort and and we've been working with them to generate a good trust of computing framework that implements trusted execution environments as as something that can be used in layer 2 systems and the capacity to use layer 2 systems that use trusted execution environments as as an option computational resource that provides highly highly reliable highly scalable private computations while keeping a contract on chain is is right now due to the current limitations of launching contracts probably the way people are going to build high throughput high value applications that still have access to public network value right so on the one hand we want applications that exist in large public networks like aetherium that have access to that the user set to the network effect kind of value that that network has a accrued but at the same time we want a lot of functionality because we want to build more and more complex more and more valuable and useful contracts and the middle ground seems to be the capacity developer to use an auction computation environment to interact with all the different computations they need and then to prove back on chain that those computations that they performed were properly performed that the data was properly delivered for those computations and that that computation can't form a reliable part of that contract so that's that's kind of the expansion of of what we're starting to define chain-linked as what what a lot of this leads to is it leads us to a world where across environments we have chain link node operators that are servicing various different chains and they're accruing usage and that usage in various different environments is once again another source of proof it's a source of proof that there's you know five defy applications to insurance applications you know five gaming applications using this note operator and this note operator is able to successfully deliver data and randomness and and and various types of data to these users and that provides even greater surety so as a system like ours gets used you you start to accrue a lot more data about each individual note operator and that accrual of data provides even greater assurances so there there's kind of a network effect from usage that allows people to continually define greater degrees of their security and guarantees for users now one of the things that we've been using you know when it when at one of the Oracle networks that we've composed for the use of the ecosystem are these reference price reference data networks price reference data networks basically put data on chain they put data on chain for use mainly by D Phi projects and right now price reference data networks like like the one I I'm showing here powers all of the centralized finance well it except if somebody made a centralized Oracle and you took a big risk on that but you know that's that's their decision which I don't really advise so these price reference data networks that we've already made right now have grown to be the largest most secure most civil resistant we can definitively say that because we have the most note operators for example in this network with eath USD price we have seventeen and we're far ahead of schedule to reach the targeted twenty one we have multiple high quality data sources so not original exchanges but data aggregators that take on the the burden of making sure the data is correct and it's a civil resistant network because we've validated these node operators over the course of a two-week process and a final security interview and it's also you know security reviewed in many other forms like the ways that I showed you so even the note operators I showed you in the previous slide with all that detail are the ones that are powering a network like this so these reference data networks are actually very important as you can see you can dig into them we encourage you to go and and and and and look at them you can once again see exactly what they're doing and and this level of clarity is supposed to provide users a guarantee that the reference data on this network is reliable enough to trigger their hundreds of millions of dollars in value whereas any other type of reference data network or some centralized Oracle wouldn't have any of this information you wouldn't have any guarantees that this Oracle is committed to or has successfully performed its obligations previously we've we've had so much success so far doing this and it's it's been done so securely all over the past number of months that we've were basically committing to expand the amount of reference data networks these are the next seven reference data networks that we're going to be launching bitcoin dai USD c0x rep WB TC and and bat prices these prices and and feeds were chosen based on the needs of our users and customers they're meant to service systems like compound partially synthetics partially other systems that are going to be building their contracts and securing their value using these reference data networks these reference data networks are once again I mean they're provided free by us if somebody wants to add security to them we're going to be releasing information about how somebody could take reference data network with you know five or seven Oracle's and how they can add more Oracle's to that reference data network in case they start using it and they want to add more security on top of the initial security we paid for but we're we're very excited to be giving back to the community because the etherium community has done a huge amount for us and where we think that the capacity to have high quality data on chain and to make it extremely usable and rely is one of the key things that were kickstart defy and so right now we're committing to put these seven networks out because we know they're going to successfully service you know existing users and customers and beyond that we plan to launch many more in in that vein if you if you have a deep eye project if you have a need for a reference data price on chain we we want to support you and our goal as a company is actually to make our users succeed by giving them access to this reliable data so our chain link is basically here to enable smart contract developers to build any kind of externally connected or next-generation contract and if that's what you're doing you know we're very collaborative very helpful people we have a huge integration engineer and support engineering staff that that that is there to help you build these contracts and likewise even make a great reference data network possibly even even starting out for your use case but then getting used by other other dphi projects as well so thank you thank you very much and I'm looking forward to seeing you all at the conference thank you
Automatic transcript — names and jargon may be misspelled.