Stateless Oracles - a novel way of delivering data to EVM without touching the storage

EthereumZuri.ch 2023 · April 2023 · 28:37

Marcin Kazmierczak presents stateless oracles, a way of delivering data to the EVM without touching contract storage. He argues that a model built on meta transactions and a data availability architecture will change the oracle space, and explains how it works at EthereumZuri.ch 2023.

Speakers

Topics

From EthereumZuri.ch 2023, hosted by EthereumZuri.ch.

Transcript

foreign [Music] [Applause] okay I think you can hear us now hi guys thanks for having us in front you mean okay so thanks for having us so my name is Marcin and I'm a CEO of redstone and also co-founder of e4so which is a conference in the hackathon in Warsaw Poland and I'm Jacob the the founder of redstone but also the technical background so I'll be dealing with the boring staff and I let Mars into to

introduce you the topic yeah so you always have to have someone that deals about the boring staff to create value right and then the other guy that is capable of presenting a little bit maybe so today we are going to talk about stateless oracles as we got introduced like oracles is this weird concept that many people think they understand but maybe on the surface level and there are many caveats when you dig into that that we will try to break it down so maybe to start so that we are no strangers we as Redstone last year raised uh seven million dollars as our seed run from notable web free investors is just to show you that not only us the

builders but also investors see value in opening up the Oracle market and Innovation over there our product has been used on many hackathons last year all together I think five prizes across five different hackathons where distributed using our technology one of them was lens score so using our Oracle we aggregate data from lens protocol about the score of a given Handler and then we can provide it to your smart contract so that you can create for example anti-bot or like a system for Rewards or anything similar to that which shows that finally Oracle deliver not only pricing data but it can

be any arbitrary number right we talk with developers like it's not like we close ourselves in the garage for half a year on year and then we come with the idea with the product at the end last year we participated 12 international events one of them was iforso like Stanis also and one of our supporters old friend with jakub from old days like in 2018 and 19 and all together right now we have 20 dedicated people apparently right now all of us are from Poland because over there we have good engineering ratio and also like pretty great talent so maybe let's start with a very simple

question what's an oracle so oracles for those that they know deliver various types of data on chain for smart contracts and dapps to visualize the flow on one hand you have various sources of data you have an Oracle and then you have various ecosystems that the data is delivered to so that dapps and smart contracts can utilize that data for their protocols right and right now the Oracle approach is fairly simple I would say so you just take the data you put it on chain with a heartbeat so an interval or a specific deviation and you update it regardless if anyone needs that or not so it's just

like outside of usage it's just updated depending on the specific variables that you put over there so we compare it right now to modems in 80s that apparently were quicker than nowadays oracles as it is on the market so we and mainly at Jacob in the very beginning had the idea okay we need to disrupt that space and create something that you can truly build the new Financial system on top of right because on that you cannot like any like a quick example ask any of your trotify guy to come over to D5 and tell them that the price feed is updated every 15 minutes he's going to look at you and say like eh really right so what are the problems why we

have such a market so because pushing data on chain is expensive it's non-scalable so if you introduce new data feeds or you update it like more frequently your costs grow exponentially so um you can offer unlimited feeds and the data is updated in very large intervals and in 2020 21 22 23 and as we go farther down the road we see that the multi-chain or multi-layer toward is going to be the one that will be existing in so it's not enough that you push data only to main editorium you have to push the same data to many ecosystems which creates huge costs right like the more ecosystems you have the higher cost it gives you in the end

so D5 potential right now is limited by oracles especially on for example recently launched zksync era that we are already present but many other increments cannot be that quick to launch at arbitroom polygon or also like a speed optimized layer ones like Avalanche or Phantom so now I will give you some food for thoughts so just you just not listen to him but you can also put your brain into work ask yourself who requires data layer ones and layer twos or dabs and the second question can we deliver data to dapps omitting on chain storage so these are two different questions but very important ones and the third last

if not can on-chain delivery happen on demand instead of a heartbeat right because we already see the Harvard or deviation can there be some other rules upon which we update the the data so answer to the first questions dabs require data for their smart contracts logic like if you push data to ethereum ethereum is not going to send you like a thank you for data I mean it's useless for ethereum as the chain it's rather the adapts that are built on top that needs that we can deliver data directly to dapps omitting on-chain storage because as I said like on-chain storage doesn't require it the dabs require it so we can instead of pushing on chain push it to dapps and then their job would be to deliver it on chain last but not least if the architecture of the DAP doesn't

allow us to put it to the dub directly because sometimes that's the case with the architecture we can at least optimize the flow if adapt and cannot it requires only storage you can still optimize their conditions upon which are the data updated on chain so for example we can adjust the heartbeat to them or make it more like on demand level as adapts for a specific app and now I'll pass it to Jacob on the more technical part so the easy part is over okay so Network like ethereum and all of the equivalents following the AVM specification we're never designed to start a large amount of data actually

that putting the information on time is penalized and designed device as you need to to do a lot of hops in the miracle trees fetching the data a lot of input out of operation Etc so it's very costly and therefore as we express the price in gas let's imagine that you want to put like one gigabits of data on China until we are going to pay about 80 millions of dollars why there are alternatives so when we started working on that solution we looked for uh chain that is decentralized enough but was designed and built with the purpose of a storage layer and we discovered our we started working on that so for the power

resistance storage of data feeds we utilize riff and then get a lots of saving compared to putting data directly on chains that are going to consume the information and still when the data is being put on the Ruf Network somehow we need to access that in our contracts that are run on the ethereum network but we still can avoid getting through storage and basically use only a call data structure so the the data is fmrl and only available within the context of a single transaction and the call data as you may look compared to other storage solution is

the cheapest alternative so if we keep the data only intercal data during a transaction then compared to getting that from storage and first putting that into storage we can have a huge savings so the traditional Oracle Motors work like there are multiple data providers that are pushing data to various chains and you may notice some redundancy so the the arrows on the left side of this picture usually are the expensive operation because you need to take data put it into storage and all of the data providers will need to do the same job again and again pushing the data to

different chains and if you imagine having 20 even compatible chains then you need to pay the gas price of each of them and then the the apps can go to that chain fetch the information and make the user happy for having the available data on chain what we changed in the design was the introduced introduction of a intermediary layer we call it like a data delivery Network which is combined of the streamer which is at the centralized pubstep Network it's great for keeping the data for a short period of time and

broadcasting it through the network we also as I mentioned utilize RV for the persistent storage actually it's a very nice combination because one gives you a very fast distribution another one gives you like a full persistence and we also use our own gateways just to make the interaction easier for the apps so in our case all of the data providers are pushing the data to the data delivery Network it stays there and only when a user wants to interact with a application with an application or a protocol then the data is injected automatically the user transaction and consume on

chain so this and the same information the physically physically the same data packages could be consumed on various chains because the data is only injected to a transaction when it's needed the data Network Remains the Same for across all of the various chance so there are a lot of savings as the storage in the data delivery network is very cheap and obviously there are a lot of nice benefits as the same application can basically use the same architecture if it's deploying on multiple Networks yeah so as you can see on the first Target layer once layer twos these are

like all EVMS layer ones and layer twos but we also started going Beyond so the first non-evm connector that we created is for starknet right now we are finishing one for fuel we also have one for stacks and there are other on the way under the development so on evm it works out of the box if we go outside of the VM it's still possible but it requires a bit of you know research and custom development from us yeah but to know the system is very modular so even if you are targeting a non-avm chain it doesn't mean that we need to deploy the infrastructure from scratch we just need to prepare a new adapter something we call a connector on a dedicated Network and it can consume the same sets of data

but there isn't a solution that fits it all and definitely when we are talking about D5 protocols a lot of innovation happening there so we I've been describing to you the on-demand model when a user interacts with them chain and the data data is automatically injected but also recently we started working on something we call model X which was inspired by the comparison with GMX especially the work on the V2 and in that model we try to totally prevent any front running possibilities so in that situation whenever a user interacts with an application we record the intention to make a transaction like

open a position or increase a position in perpetual and then that intention is being settled in the very next block with the price delivered by Oracle but the price is not known both to their protocol and to the users so it cannot be front run because with a standard Oracle model there is always a small delay between the the data that's already on time and the moment when a user is interacting with a protocol so the user can have access to the current state of the market can discover the price before it's been put on chain then there is

obviously an opportunity for Arbitrage and explore the protocol but when the user needs to commit to a transaction before no Enterprise and the price is settled after that then we eliminate all of the possibilities of Arbitrage and also when we started working on that solution and cooperating with various protocols some of them are more traditional so they got a code base that was well outdated they are used to work in a certain way and they do not want to experiment with oracus and use a standard approach based on the interfaces implemented by incumbents like like chaining but still you can benefit from having this decentralized distribution

Network using a classical approach by specifying what will be the rules of pushing data on chain automatically so we are not limited by the scenario when a Syndicate decides how the data has been pushed on time you can Define your own rules providing a relayer and still fetch the data from the same Source whenever it's required by being 100 compatible with the old interfaces so basically how it looks from a point of the user it's exactly the same as interacting with the standard dab apart from the fact that behind the scenes we are injecting an extra payload to a user

transaction it's all automated through our wrapper on eters.js and this extra information are the packages of sine data so despite we Aggregate and keep the data off chain from the point of view of a Target chain when the protocol is deployed still the verification happened on chain so we derived the security from the target Network when we are deploying that on ethereum all of the verification of signatures and timestamp happens on ethereum we also are integrated with multiple data sources so for the I think there are more than 50 sources and for the most popular tokens like for example ethereum we got like 40 sources and we pair this data about all of the

individual sources and are publicly available on our roof so if you are interested in the history of the price for example of ethereum in the past and we'd like to compare the data coming from various sources then you can have access to that as well by the way the price of ethereum wasn't from today like easy I mean I saw that some of you that might be shorting had a heart attack but yeah now it's from the next week yeah so we provide custom data if it's not only the the process of tokens but also some Commodities currencies of the uh derivatives like stake tokens lsds we gotta provide prices for LP tokens

and also for some hackathons people are creating a really interesting use cases we we've been on one hackathon Ukraine so they decided to put all of the information about the war on time and the protocol is very customizable and Opel for anyone to put any data fits they want yeah so uh as you could see like the bottom line is in 2023 we need more customization depending on adapt we cannot think about in the same terms as we did in 2020 D5 summer that there is like one approach to oracles and let's push it to any dab that will use it in the same way the

apps want to be capable of defining uh what's the heartbeat or the rules what data they require like what are the data feeds and in our model we also allow the dapps to see who from they consume the data which means you don't just receive at the very end the final aggregation you can track like who the specific price it came from so we take the data off chain from Enterprise grade data providers kaiko flow Traders going vehicle coin market cap and many more and for example if you as a user don't like a specific data provider you can disregard this data provider to give you a real world

example imagine we are in August 2022 you already smelled that something is bad with FTX which apparently was a data provider for many oracles and you could potentially for example disregard the data that they provided and omit a potential crash of theirs later right or even if you are consuming you have the information that you're consuming from FTX and when you see the FTX crash you know the animality is because you're consuming data from them not because of the whole Market is volatile and so on so you have whether like transparency across all the whole usage and we also integrate data from 50 over 50 biggest centralized exchanges but it's not limited to that we also take data from

on-chain sources so we can provide you a t-wap LP tokens specific tokens for the ecosystem that you can ask for liquid stake tokens you know like right now it's very trendy topic or nft and other types of data so a couple of benefits of that design to sum up so it's scalable so more networks and it doesn't require from us to have like higher costs of of keeping the the uh the system we cover right now over one thousands of assets and non-startered data and Nothing Stops us from adding like new sources if you need so

we right now in a core model update price feed every 10 seconds and with the Redstone X so this no front running model we can go even sub second so right now on arbit room we are testing delivering price feed every block which is like 0.4 seconds as far as I remember and it's cross Chain by Design so there is no waste of gas when you require data so the data is delivered where you need it when you need it you can check out the interface with the data that is available on app.redstone.finance and our documentation is very much updated as well it's docs.redstone.finance if you want to dig

yourself and check out what's possible there so maybe a bit about the market Trend in D5 so as you know last year the whole D5 shrinked whereas the specific D5 protocols such as derivatives perps options grew when it comes to tvl and basically the interest from from users so this Redstone X model here is a bit of a more of a breakdown is a perfect fit for them to leverage and the frequent update and omit the front running because when you have like a lot of Trades of course from running seems like a local trip option so let's recap on a on an example so first you have a user that for example his request on GMX

would be to open a short position this request is registered in block number n on arbitrum and if by a via GMX the price is not known yet anyone who works as a resolver can basically pick that transaction pick a price from our data delivery Network connect the two so you have Price p with block n on the transaction give it back to GMX and GMX makes the settlement in the very next block so between one and this n and n plus one you have 0.4 seconds so then there is truly like no time for any front running for other users so when it comes to protocols that trusted us we've

got a bunch on various networks so for example Delta Prime in February was what a top three quickest growing protocol when it comes to TV and d5lama because we provided them feeds that no other Oracle could like glp token you know like in February it was a very hot one and other like staked avacs and so on zkx is on starknet so it's our long-term partner Moola on cello and so on from the notable ones that we are right now finishing integration for it's mental apps so it's the biggest D5 protocol on cello pool shark on fuel Network so the one that is coming fairly soon and we are also chatting with Olympus Dao to prepare like specific dedicated

solutions for them um so here is like Oracle in practice how the Delta Prime model works I know you want to yeah okay I can jump in get some rest so um it's very interesting protocol kind of a decentralized from brokerage service that allows you to multiply the effects of your money so you get an account let's put you and you're putting their let's say like 100 usdc but actually you can trade you can invest or you can farm with for example 500 dollars and so you can borrow much more that you can deposit so that's the opposite of

Landing protocols like our and on any action that the user executes in that protocol we attach the information about the prices all of the assets so whatever the the user is doing the value of all the assets that's being held all of the invested positions in for example LP tokens or stake tokens needs to exceed in an initial margin and so that and that's checks are automatically applied to any user action but obviously what's going to happen let's say I put 100 I invested into LP tokens and now the cumulative value of

that position is something like 420 dollars so we are getting close to our limit by Martin which was this 100 supplied up front so for the security and for the solvents of the protocol we'll need to liquidate the user position and in that case also the Bots that are monitoring the system and then could be run by any of the external users need to monitor the price read the price from from contracts using our oracles and Liquidator position so it's both the data is injected to use this transaction but also in the same way injected to the liquidation Bots transaction

now as I mentioned the the protocol could be used for trading staking or liquidity mining yeah so at the very end we also wanted to invite all of you for the partner event of ethereum Suri which is like E4 so conference in hackathon starting 30th of August and happening onto the 3rd of uh September so over here you have the university Vibe right over there we also organize it at Warsaw University of Technology it's a 19th century building which is fairly cool so I would love to see all of devices over here also over there in Poland thanks a lot for listening I hope there is a moment for questions yeah we are very much open to hear your feedback and

questions we are a bit over time uh but uh it's just the whole day don't worry not about you guys but we have time for for one tops maximum two questions so do I understand correctly that if you're providing very frequent updates for example more frequent than the block time of ethereum which is 12 seconds then the user of your Oracle actually gets to choose which of the time points they submit yes so it's up to a protocol to to specify what's the allowed delay of a price fit so even if you are only two

you can specify for example that you are going to accept only the price that is like say like five seconds out so it's it's been enforced and checked by at the level of a smart contract and then there is the validation of a timestamp so it depends on the protocol usually the let's say the the acceptance margin is larger but if you are afraid of any kind of tricks done by user picking the most uh beneficial price you can simply shorten the window but as a trade of some of the transaction may not be mined if there are outside of that window thank you very much for the presentation very interesting I'm wondering are we introducing new centralized attack

vectors here like when the depth of 10 talks to the resolver then that's like a URL he needs to resolve to get the result for data and access the data pool and I mean the verification on chain then it's clear there we can check the signature but what are the central attack vectors between in the whole process I think yes this is an excellent question because if we got this intermediary layer like how can we trust into that and was there the security guarantees of this intermediary layer so therefore we we decided not to only build our own solution with something we call like a Gateway or cast

nodes that are using the networks and they're like a passive element they just need to take a sign package and push it forward so they cannot tamper with the the content but they may let's say stop working and on that front the code is open source anyone can spin up as many nodes as possible but we also decided to work with an external social provider in that case the streamer Network I think they are even based in here they are from Switzerland and got a very good and interesting and well for True solution for the decentralized and accessible public subscribe Network and we utilize that also as an alternative to our own notes just to have a higher level of security

because we do not control the network it's only a very passive mechanism when we push through the assigned packages and we benefit from I think around like 50 000 streamer nodes that are broadcasting the information thank you if you have further questions join our Discord and follow us on Twitter Redstone underscore defy perfect exactly I was just going to say the same thing everybody put your hands together for marching company [Applause] perfect