STARK-powered Data / 0xevolve
EthPrague 2023 · June 2023 · 21:24
0xevolve shows how validity proofs, and STARK proofs in particular, can be used to build a truly decentralized oracle network. The ETHPrague 2023 talk presents STARK-powered data as a way to bring offchain data onchain with cryptographic guarantees, applying zero-knowledge proof technology to the oracle problem.
Speakers
Topics
From EthPrague 2023, hosted by ETHPrague.
Transcript
so uh hello everyone um my name is uh Matia so I go by the the nickname as your evolve on Twitter um just a quick intro about myself um I was previously at maker Dao working on the Stark net core unit for basically the best year which I recently left to focus taking my whole time building pragma which is a decentralized Oracle solution built on Stark net natively and that will be extended to multi-chain the in the future so today I'm basically going to talk about how can you make an oracle that is actually provable meaning that you
remove a bunch of trust assumptions that current oracles have especially um how you aggregate the data so let's jump into it so first a little uh disclaimer about ZK proofs against validity proofs most people are often confusing and talking about the key proof when in reality most of the Roll-Ups and the tech is a validity proof and there are a few exceptions uh remarkably Aztec that really uses a ZK proof so they use the Privacy part of these proofs but what we care the most about actually is the succiness of this proof um and that's what we'll be leveraging
to build this um some yeah to remove all the trust assumptions in the Oracle system okay so now that this uh first disclaimer is done let's talk about the Oracle problem um so in Oracle as you most of you might know is a way for you to put off-chain data on chain and make sure that smart contracts are able to query and access that option data so it could be um mostly like financial data so liquidity data prices of assets or the book death and all kinds of data um and you could go even further and have these data feeds so more complex aggregation of data
um but yeah the question is how do you put this on a on chain without um sacrifying a few properties so the first one is the trustlessness you don't want that system to add a layer of trust assumption to your depth which might already have a few and especially like the smart contract risk um you want your Oracle to be unstoppable you don't want it to like stop at uh at some point and it's not providing any data or the dab anymore and you lead to a bunch of of pretty bad issues and finally you ideally you want this article to be transparent so you would want to know what's happening at that Network and not
um it being like your black box um which is like pretty much the case right now due to the current technology and the fact that everything is built as an off chain Network and actually we have a pretty good solution to the the three of these um properties and it's a it's a blockchain so um in the past there have been many experimentations you build these option networks but it's hard to have these three properties whereas blockchains give uh give you these properties out of the box um so it kind of makes sense when you think about it you have your Oracle Network built as a blockchain and we will see how uh Stark net Starks and a few other Cool Tools um make this
actually possible okay so let's first talk a bit about Cairo um if you're not familiar with Cairo Cairo is a programming language invented by star Square which is meant to make it easy for you to write programs that are actually provable so by approvable we mean that you um as a developer you write your program so it's a turing complete language you can write anything basically and then when this program is executed the generator trace a trace which you can send to some prover and the approver will be able to generate the Stark proof out of it it's um so Cairo stands for uh basically in their CPU it's
yeah so like for a bit of History before Cairo the star core team used to like ride this polynomials by hand to like for instance dydx or this kind of applications um but at some point they wanted to have something general and not having to restart from scratch every time they want to build some kind of new provable application and that's where uh Carol was born and it's now getting uh pretty mature with Carol one and uh a bunch of people using it and yeah so a good example like we we like to take is um so with Garrow you can write your program and you can actually do like a lot of computation in your
program if you're used to building the the an adap you know that you be careful about the computation you're doing you'll try a bunch of optimization and there are even things that smart contract developers right now do not think about because it's um it's not how solidity was designed the evm was designed but Cairo kind of change changes this whole Paradigm now you're able to write way more computationally intensive programs and it's fine because you're not going to be the one that run this program right in the end it's going to be the approver that runs this very expensive computation and then on ethereum when you sell the proof everyone just
verifies it and it's way way faster and cheaper um so how this is about a bit of context about Cairo you can select a very very powerful tool to like do very computationally intensive algorithms without losing any any trust in your system okay so now I'm going to talk a bit about uh storage proof uh bridging um so especially Herodotus which is like a stark net native company doing that so what do we mean by storage proof if you're familiar with like the cosmos ecosystem and IBC it's kind of a same ideas that you want some protocol that
is able to unshared a firm like right now it's it's quite charted you have this bunch of chains and you will have more and more chains as a time progresses so you want to really unchart the state and unify the state of all these Roll-Ups that exist or will exist in the future um a cool priority is that you will you actually with storage proof you get synchronous that I read between layers um you could you read some data from optimism on or like arbitrum on ethereum um and in the same in the synchronous Manner and that's very very powerful um one over very cool poverty is enabling historical data access um storage proof are actually when you
use storage proof you you decide a block number you just take a snapshot of a state at a certain block number and that makes it easy to let's say access stage from let's say you want to know what were the if balances of some accounts back in the DL hack you can do that um and you don't have to do any fancy magic it's just in the end it's just verifying some Mercury proof of the state tree of the block it combines a bunch of cryptographic Primitives snark Starks and MPC but I won't dive too much into details for this presentation we could really talk
about it for hours okay so let's um let's introduce a new um a new stack that uh Stark in the start net ecosystem we've been developing developing for a while it's called Madara uh yeah the the name is uh a lot of anime names in starknet you will uh quickly realize um but Madara is basically some equivalent I would say in some some way to the op stack it's a way for you to create um some your own start custom Stark net in in some way so it's still at the let's say proof of concept stage but it's have done quite a lot of progress
and now we're running ephemeral test Nets and getting a lot of of traction there um so Madara can be defined like this you have as the modular stack implies you have all these different layers and the most important here is the execution layer it's uh um it's where you have Cairo and you don't really want to put anything else here or you lose uh everything I've talked about in the beginning so the ability to write these provable programs the second thing is the settlement on Ice Cairo is compatible with Stark provers you could have so sharp right now is like the most optimized stock quiver run by stockware but they're um of approvers being developed in the
wild then the sequencing is handled by mother so Madara is built on substrate if you like familiar with Frontier or Moonbeam we kind of did the same thing so we took the Cairo VM and we put it into substrate so it's a stark net compatibility layer for um substrate and why substrate you you might ask and why not Cosmos SDK or rocket or let's say over sdks so it was mainly because of of rust like the whole starting ecosystem the VM the the blockifiers like component that handles the state transition logic is returned
in Rust so it was very straightforward and it took us only like four months to reach a quite usable state of Madera and it's very very performant we we really don't lose anything we keep the safety substrate it's also a battle tested software right it's uh it's been there for years and years securing billion dollar value is um in with substrate we're able to um to create this decentralized networks out of the box and that's uh very very nice especially that in the world we are in right now most sequencers are centralized right um but here you have a decentralized sequencing layer out of the box for free we didn't have to do anything uh it came about uh with substrate
then you could custom also choose your own data availability layer or even governance so there are a bunch of tools there but we won't dive too much into it okay so that the second thing yeah just uh so here is the QR code if you want to take a look at the Madara repo we already have I think around 50 contributors it's uh and like a bunch of people from different ecosystem contributing it's uh we're very glad to see that it took so much uh um traction and everything so yeah feel free to come and uh you'll be proud to be among the these amazing contributors okay so now that we have talked about the three ingredients the KERO VM
substrate so Madara and Herodotus we can actually combine these three things together to get verifiable data so let's uh see exactly how this combines together and you will see that it's actually pretty straightforward when you when you think about it okay so this is um basically the what we're developing at pragma which so we have some version is live on starknet mainnet for eight months now but we wanted to have higher frequency updates for Oracle and have the ability to make this data feed available cross chain and we came up with this design um basically it's a some kind of pool
based Oracle if you as a user you if you want to access some data you query Herodotus to get the storage proof uh sorry doctors will handle the proving and the verification of the storage proof and then you can just access the underlying data so the chain is the roll-up is basically a custom roller build with Madera just talked about and this heavily optimized for Herodotus so we are basically changing the storage layout the hashing functions and everything to make it as snark friendly as possible such that Herodotus has a I would say the best time generating these proofs and it's actually cheap to verify them that was very important
um yeah and it will eventually settle as an L3 on top of starknet so that we can basically settle way more often under layer 2 it's way cheaper we don't necessarily have to put data availability of chain and um yeah it's actually a pretty cool property um all right so what can you do with that why even above are there like any cool things that you can build with this that you just couldn't build before and the answer is actually yes um here I just listed so a bunch of new use cases that are don't don't exist in D5 or done with some off-chain infrastructure right now
um so mainly volatility oracles risk oracles Dynamic collateralized depth ratios um you could have like Dynamic fees Dynamics press Dynamic dips depth ceiling so in the end you have a bunch of parameters in a lot of D5 protocols that are just updated manually through like uh cumbersome governance processes and you you will find that in a lot of D5 protocols and it's fine I mean it's it's how it's done right now because we just don't have the tools to set these parameters in a dynamically because we wouldn't need complex models that take into account a lot of inputs and we just don't have the computation power to to run these complex models on chain so as
I said there are some people doing that of chain but again that's not really what we we want to achieve there and if you remember that's why we we have Cairo Cairo we're able to write these very complex things so you could write some volatility index we have a live on starknet non-chan yield curve we realize volatility these are things that yeah just didn't exist before and when you think about it just unlocks a new whole wave of new use cases um so we're trying to basically work with a few D5 protocols to see how this can be actually be used in production in a in the safest way possible okay so what uh what what next uh for
pragma um the main thing is a high caffeine that is being organized actually starting tomorrow so I know that if there are people here that um just finished the hackathon from um from from here from if Prague you can jump right away in another hackathon we have like around 80 000 of price pools with basically all the different Stark net projects and you can yeah you can just hike a bunch of cool things Madara for instance or basically anything experiment with Cairo One and with these new complex models so here's the QR code if you want to go on the hackathana website
then the next thing will be a demo that will do as talking at CC of this whole system running and finally the implied volatility feed so uh my co-founder Mateo gave a talk about the methodology that we use to compute implied volatility uh with this model and uh it will soon be live and by the borrowing a few amazing options protocol building on starknet so yeah that's uh that's what's coming next here are a few links if you want to to dive a bit deeper about everything and uh I guess I'll just take some questions now thank you
[Applause] are there any questions so I understand uh the proofs have to have some kind of input and how do you actually prove that the data taken from the exchanges that are used as the input to volatility calculation liquid adaptive cancellations all right it's done through the proof of Stack layer of substrate or some other way um the question is about like the security of
uh basically how do you make sure that the input data to the calculation that is then proven so it's correct yeah so there's a fair point here we didn't talk about how do we get like the raw data that we're using to compute these complex models um so right now like the raw data comes from um it's a permission manner so we have market makers and slide exchanges also people in the ecosystem like Argent equilibrium spatial never mind and a bunch of uh great people that run node so we have both first party data and third-party data that's actually very important we could dive uh into it as well but um yes we got these two things the idea is to like so when I have around uh 10 to 20 sources and the idea
is to have more and more sources and if you want to make this permissionless yes it would be some proof of stake mechanism so actually leveraging the default substrate proof of stake mechanism but uh customizing different ways to um ensure like some kind of crypto Economic Security for identified protocols consuming the data feeds so that's uh yeah that's a another field of research that we'll be taking to make this whole system permissionless but at first yeah at first it would be permission with actors just putting their reputation at stake and the more sources we have like this risk um goes down uh very uh very low I'll show you
foreign it seems like all of the applications were Financial in nature are there other fields where you plan to apply this technology yeah so right now we think that there is a big uh use case in the financial applications that we're really focusing on these Financial use cases um especially because there are a bunch of uh complex models like like hedge fund or trade file is just running on for years and decades even and we don't even have uh in uh in G5 yet so we thought that there is uh it was like the most important thing to tackle but then if we want we will make all of this permission less basically you'll be able to have any kind of data providers
coming and providing the data and people writing these models on top of the raw data um yeah so definitely in the future I will um there will be different uh data types but for now yeah mostly financially and earlier you said we only care about the succinctness of ZK proofs not necessarily the Privacy aspect do you think that's driven by let's say I won't call it a few I'll call it fear of Regulation or is it just that that's like a second order thing so uh yeah so actually uh playing yourself you have some kind of privacy because um these complex models uh if especially if we're trying to get these hedge fund models to run on chain uh sometimes it's
it's um these people just don't want these models to be transparent right so you need some kind of privacy there um and how it will work so in substrate there people have been doing work for quite some time on encrypted transactions so previously will be there it won't be at the proof level but it will be at the on the Chain itself that's again like a cool thing you get when you're building uh this network as a blockchain is that you you um yeah you benefit from all the research that has been done in the blockchain field and by all the substrate chains and everything so yeah it will be basically encrypting the the transactions themselves so that no one can just see what happened uh like how the data feeds look like and everything
but you can still consume it in uh in a trustless way so that's that's uh yeah thank you welcome foreign [Music] thank you very much [Applause] [Music] foreign