Decentralizing your web3 backend / Hilmar Orth

EthereumZuri.ch 2023 · April 2023 · 26:31

Hilmar Orth makes the case for decentralizing the backend of web3 applications and explains how developers can go about it. Speaking at EthereumZuri.ch 2023, he covers both why a decentralized application should not depend on a centralized backend and the practical steps for moving that infrastructure onto decentralized alternatives.

Speakers

Topics

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

Transcript

[Music] foreign okay we have uh microphone is working quite well so thanks everyone for coming um because we are highly concentrated crowd we can make it very interactive so if there are any questions in the middle or something just uh try to interrupt me and ask me what this talk is basically about uh it's just I want to I want to give you a quick overview about gelato what we do um our mission which is uh helping projects decentralizing their web free back end realizing the need for not only having smart contracts be run by a

decentralized network like ethereum but also some other components that are quite necessary for your application to be used by users and you not becoming the central point of failure when you're actually the developers or the projects them themselves building the applications um yeah so if you have questions definitely just interrupt me and we can talk about it let me just see if the clicker works this one cool so we will very briefly go through um sort of like back-end architecture with three applications today um they sort of assume still this notion of not being on your own chain like not

on your own application specific chain I think there are certain things that get added if you go into that area as well but it focuses more on like let's say if you Deploy on in ethereum or polygon for example and then basically the services that we offer um and um how you can decentralize your backend using gelato and what we do what we don't do Etc cool so this is sort of I think many people when they join the space and they let's say on the hackathon like here they they think about how the application will like look like from an architected point of view they got their front end they got a couple of smart contracts um and they think okay hey the the smart contracts will be my back end and that

sort of it for for most Parts I can write my business logic in there I can get my data storage in there but of course we all know this isn't really uh everything that is needed and sophisticated applications look quite different to that and there are several problems with smart contracts or not problems but limitations from Smart contracts that make it so that you need a bunch of other things actually to build really scalable sophisticated and user-friendly web3 applications and so the first one that we realized with gelato very early on is that um yeah smart contract actually not that smart they're quite dumb they just store

some business logic they store some data some states but they don't really self-execute their business logic or they can't they don't have this notion of event-driven execution or recurring execution cron jobs these type of things um and so for a lot of use cases you need that sort of um outside you require an outside impulse to your smart contracts and actually to move data from A to B into to change State and to actually execute the business logic that you define within them and this is actually quite interesting because smart contracts they're not smart then of course we all know blockchains are very isolated environments you need that sort of deterministic nature of an evm or any other sort of contained virtual machine

and that means that you can't have them talk to or it's not natively supported to talk to the outside world because you would introduce a bunch of uncertainty to the underlying blockchain and so you need again other middleware to actually enable you to communicate to let's say a web 2 server or something else then and we all know the user experience is terrible because we still require users to interact directly with the blockchain rather than sort of making it so we have this abstraction layer and we interact on their behalf on the blockchain um which is sort of like letting users directly write in your database or something in web 2 world using some

queries or whatever and or calling apis themselves even though for like a Chrome extension what sounds also weird and then of course data is really really difficult to actually get especially historical data for your applications if you want to show what happened a year ago yeah making that detecting straight with the blockchain is very cumbersome and very very inefficient so oh turns out there are probably some other things as well but this is sort of like how it usually looks like if you build an application these are like a bunch of things that you require in order to to have a truly truly um scalably user friendly with free

applications in place so first of all you have like to index the data of the blockchain sort of in parallel to um new blocks being created um to then be able to let's say go back in time a hundred days and see from 100 days to now what was the return that someone got by investing in a certain pool let's say right um this sort of like helps you solve this issue about data indexing and making it available for that you of course need databases sometimes you can opt in for centralized ones then there are of course like ipfs or RVs which which uh hope to be more decentralized and then you have this notion of okay these smart contracts they they can't trigger themselves right you can't

update their state programmatic based on certain events happening and so for that you need like job schedulers you need like event driven event-driven transaction services and you combine this job scheduler aspect with like transaction relaying which is just a matter of okay how can I write to the blockchain in order to update its state right and you combine these together and then you make your smart contracts actually smart and reactive and event driven then of course you need off-chain data fetching to fetch data from off chain you need a private key Vault or some notion of someone sending transactions and signing transactions in order to actually update the state on chain right and then of course you want notifications and alerting because let's

say you run a an investment sort of pool or a vehicle and something goes wrong whether it's a hack or something weird happens there's a deep pack right you want to alert you want to get alerted as a team your customer should get alerted if something happens like a transaction in order was executed from on their behalf right all these sort of Notions are things you have to work and build in parallel to the underlying system the underlying blockchain and this is just like an example arracus is this decentralized Market making service and web free and this is sort of uh how like some of the functionalities they need to do in order to actually off chain which is not supported by like the smart contracts themselves to actually

build the applications in the right way they have to do a bunch of computation of change they build they're building these very sophisticated strategies where they let get the price data volatility volume and they run AI models to then Define when to rebalance basically liquidity and when to rebalance money in unison V3 and of course they need to execute these strategies automatically right they need to send the rebalance transactions and they need to send alerts to the team so the team knows when something is maybe not rebalancing correctly they have to have emergency stops right if some sort of weird thing happens they need to stop maybe and send a transaction to their smart contracts and yeah then of course on the UI they

need to display to users hey what is actually the current price what are the current prices what are the aprs that you as a customer um have gotten over the over the past 30 days let's say when is your deposit when did you withdraw and this is just a lot of a lot of data a lot of calculations that have to happen off chain in order to actually make it work so a really a bunch of things and um yeah there are of course a bunch of problems if you want to do all of that yourself um just from a like managerial point of view um like the first ones but then at the end like the the sort of notion of centralization so of course you need to manage scale and maintain a bunch of server resources especially if you go

multi-chain you basically have to sort of like replicate that um and and it goes linearly for every new chain you add that you want to support especially if you go to more sort of exotic chains rpcs are still a huge issue you still need to you can't really rely on a single provider right you need to have two three redundant two three rpcs to have redundancy in order to actually connect or even run your own node to have like um a stable connection to a certain certain Network and even then it's not really guaranteed and then you need to maybe if you use other providers you need to pay a bunch of them in different tokens and deposit them here and your money is fragmented of course there's this notion of the key storage which is always very sensitive

but then if you do that all yourself then well you basically become the center point of failure within your system I think Michael from liquidity did a great talk two days ago about like why decentralization matters right uh your application the goal is your application shouldn't be just be able to switch off if someone comes in right or or demands that you do something but if you control all the data view control the system that actually sends transactions to updates the state then basically the the application will be made useless if you don't have a more decentralized system where yeah it can withstand some sort of uh censorship attack yeah and this is like what we try to do

with gelato we try to help you with that um and build your smart contract where pre-applications in a more reliable user-friendly scalable way without trying to sacrifice the centralization sensor resistance this is like the high level goal um and for that we really have like three main services that try to solve that or solve parts of the aspects we don't do everything we there are other really cool middleware providers in the space that do a bunch of other really useful interesting things what we're really focusing on is like the smart contract automation part helping you to do this event-driven recurring transaction like writing to the blockchain system so um whenever an event gets fired you want to react to it

and send a transaction you want to check certain conditions off chain every minute or so this is what our automation service helps you what free functions uh I think I had a talk on Friday about it it's it's really about bringing that notion of um like right into the blockchain and programmatically on your behalf but like using off-chain computation and data like you used to just be able to Define smart contracts and these smart contracts where you are like on chain sort of computation environments that would tell gelato when to execute a transaction but now with free functions you can write like a typescript file of chain that you deploy to ipfs let's say you say to gelato nodes please run that particular

basically back-end sort of Lambda function for me based on certain events happening or every minute and then if the logic is met please execute that's for example what a Ruckus is using if they are running strategies of chain they're using these functions that are being called let's say every time someone swaps in uni swap they will trigger this logic off chain which then sees okay can I rebalance my liquidity to now again like create some spread in the market that I want to want to achieve right this is all based also on like transaction relaying which is versus notion of like hey help me get transactions written to the blockchain um and next to that of course you still need a bunch of other things you need data

storage um like an ipfs or are we if you need like indexing like a the graph for example right you can actually on top of where three functions also add for more data Integrity stuff like uh um full-based oracles where you can actually pull data from Oracles in and then run some Logic on this and see if you want to send a transaction on chain to update the price actually and you can do it right so it's really focused on this computation and then writing to the blockchain for you and and this is so like how it works um gelato consists of a bunch of of validator nodes gelato nodes and these are right now Wireless parties that we onboard Case by case some of them are

for example like staking facilities that they I think also the the biggest slider node operators um beware labs and some others and what they do is they run this or like base client where they have to stake gel in order to get whitelisted and have to undergo some sort of white listing criteria and then they can choose that they want to run some of these Services they can run like an automation service just a transaction relaying service with free function service they all have different sort of um they all it's like a micro microservices-based system so you can sort of opt in what you want to do but if you want to optimize and increase your or maximize your Revenue you basically want to run all of them

because it provides you with most work and for all of these all of this work that you run you actually get paid as an odd operator so there are two sort of fees in the general system they depend also on the services there's one there's a computation based fee and one is transaction based V every time let's say you need to run a web free function which is like this Lambda function right of chain on behalf of a project you incur of course some some CPU courses some memory some RPC costs and so on and for that you basically charge the project the we built this whole like payment system like an off-chain payment system which is super efficient where you deposit UCC on polygon and you can pay for computation and you can pay for transaction on all

chains on ethereum on binance chain or Avalanche Arbitron whatever just with depositing uscc on polygon or you can deposit uses your RV term and you can pay for transaction on optimism right so it's all handled and abstracted from you under the hood with gelato basically fronting the network token always and that money basically gets deducted for all users um in certain intervals so we we push basically Merkel routes that Define the state of everyone's balance on gelato every like half an hour or so to all the chains and this updates their costs basically that they incur with us and um yeah if you if you basically run this computation of China and then you might end up in sending a transaction on

chain and this is really what that is about then you actually sign a message you send it to another party which are executive executor node operators and this executor not operators they are just very sort of simple dumb parties they just like take transactions and they have to follow certain rules like go via flashbots go via this private Gateway or or go there and then they get the transaction mind on chain the goal for us right now is to make it so that everyone in the world can run these Executives to to actually send the transactions on chains and then the validator set is a bit uh harder to make completely permission is because there's some non-deterministic nature to that and some some data Integrity that is important to to uphold so so there uh

yeah we are right now basically making this approach of whitelisting people uh whitelisting individuals companies and projects in the space that have reputation that will run this according to our spec but yeah as soon as the transaction gets on chain you hit the protocol it does some checks like hey does this node have sufficient stake and stuff sends it to the Target contract which might be make a dial let's say and then guess in mind um to give you a bit of context for like our automation service let's say um you have these let's say uh like three customers that you probably know like you earn like how does urine use it again does it use it uses our automate system to just how like harvest the

rewards and fees of these walls that they run right so they they pull a die from everyone they put it into other or another product called they harvest some yield farming rewards there and some fees and then they sell them all in one batch every day or so and then recompound it into the pool and so your assets increase in value over time there maker Dao has a bunch of um in protocol related tasks they have to do um they have to change parameters based on votes and do a lot of like clean up sell fees that are incurred and burned to maker and these sort of things all these operations that have to happen under the

hood that's what they use gelato for to automate that they actually build a very nice sort of protocol specific automation system where they can just plug into gelato and just easily create all of these on chain it's actually quite cool and then optimism what they do use it for is they have to constantly push um they have to have these sequences right they have to constantly push transactions on chain on ethereum right um with all the data of the transactions that are being executed on their L2 and this means they're burning through a lot of eth I think uh yeah the the L2 sort of sequences they're burning through a lot of these I think they're like the the biggest East consumers on ethereum

actually um and so these nodes that do that have to be constantly chopped up and have to be constantly monitored to have sufficient ease to pay for transactions and so what they have they have the centralized smart contract this is where they collect all the fees that they collect and all the ease from their system and then they have gelato basically monitor the balances of all these nodes that send transactions and then they send them to the nodes and chop them up periodically in order to make sure their system isn't down and transactions get executed on chain so this is like a um this is like a common use case there topping up systems monitoring this and then they can actually send alerts when these transactions are Ascend and so on

um yeah for for transaction relaying this is really more about like ux so this is really how can you level up the ux on your application you might have it's very uh like you might have heard about the kinds of account abstraction right uh transaction relaying is a big part of it um and especially the problem here is not really like how can I get my transaction included in the chain right you have like Concepts like user operations in esc437 that you can use you can use traditional just transactions where uh you just send a transaction via the regular like ESU 457 was just a different mempool that you can use so to say to get transactions mind you can also use the regular mempool or you can use flashbots right um but it's really about the payment so

how do you pay for these transactions and how can you as a project sponsor a transaction how can users use tokens let's say that are in their nozosave to send transactions and pay for transactions and this is where like this whole relay system comes together it has a multi-chain payment system which works across many chains and as a couple of use case for example the safe team I think it was actually two days ago or three days ago um integrated um relay on their UI so you can now I think they're starting with noses chain you can now basically um just rather than having some signer of your nozosafe multisig have to send the transaction you can just like click

a button and then gelato will send it on your behalf um if all the signatures have been collected so you you don't especially if you have sales on multiple chains you don't always want to like Bridge your funds over to all the chains to then have someone that can click the button and send the transaction so yeah you can basically uh just click a button and have gelato do it and they will roll it out on all the other chains right so at some point no one has to pay for transactions anymore and when uh sending transactions on the save app and we're actually working on the system right now they're sponsoring it so the safe team is sponsoring all these transactions knows this chain is quite cheap so I think it's not breaking their bank but we were actually working with them on the way where we can use the

funds in your noser safe to pay for the transaction so you just have to collect the funds and you're safe and then you page a lot in the transaction with that connects is basically doing the same there just cluster mastering protocol or Bridge uh if you send a transaction on the on the on the on the on the home chain you need to they will send a transaction for you on the destination chain to bridge your assets let's say and actually use gelato's relay system under the hood so the only thing they have to do is they have to um deal with the liquidity of having sufficient assets on chain a and chain B and they have to deal with the security of the system to make sure that uh the the data is correct and the users actually allow to Mint tokens here on

burn them here and for all the transaction part I use our relay system then of course you have like gasless nft drops we know that one with us last year in December for example and this is just very cool if you especially if you combine it with like smart contract wallets and web3os to have really like a super seamless user experience I demoed it in the workshop um on Friday where you can literally just sign up with like your Gmail and then win some nft and they pay for it right so it's really cool well free functions is our like newer system right and and there uh I'm super excited about um and we just like rolled it out very recently but they are what we are seeing is um that

um projects leverage it to basically what you can do is you can call off-chain apis right and then run some computations and transactions based on that and how projects are using it is um before something like with free functions if you wanted to let's say periodically um sell let's say you accrue fees in your protocol and you want to sell them right to your native token to usdc let's say right you had to build like a smart contract that routes through Sushi swap uni swap curve whatever to always tap into like liquidity and now this whole routing you can just do off-chain with like one inch called the one inch API and then just like send the transaction on chain um and don't you basically save a ton of

smart contracts and and this is actually something we see more and more the more like they are all Outsourcing logic that is not core to their protocol to off chain and just do everything they can do off-chain and then just send a transaction that includes a route and a payload on chain and just do it and I think this is actually where this space is going I think protocols might actually look like just like nozosaves and then you just do all the computation that you want to do off-chain and then send a transaction and then you if your application is nothing else than just enabling people to go from other to compound and then swap on uni Swap and then go back like back in in the past you have to build these smart contract

systems that do that all right and these were like then urine or whatever but you can do all of this off chain and just send a transaction on chain and then do the one transaction and have the funds be in the user safe right I think this is actually what we're seeing and this will actually make a bunch of protocols not that interesting anymore um but yeah other use cases other than like one inch apis are calling subgraphs right iterating through millions of nfts and then sending transactions to buy or sweep the floor and do something like that so yeah these are a bunch of use cases we see but also like prediction markers Dynamic nfts Etc so um yeah this is this is so like the free function service and some use cases there

um yeah and what's the mission here for us over the long run is we tried with gelato to get as close as possible to ethereum security and decentralization um you should not be able to stop if you set up a task with gelato that should for your protocol update certain State periodically you shouldn't be able to stop it like no one should be able to stop this process and right now I think we're not quite there yet but we are looking into a lot of different ways of achieving this one thing that actually goes live right now is the gel staking slashing not quite yet but but also this year um where no the price have to stake and

so they have some more crypto they they have some crypto economic incentives to actually do what they're supposed to do not only like off-chain contracts um then we're actually looking into having ethereum nodes run gelato clients as well through something like eigenlayer let's say where we would like open up the system to not only allow gel stickers to run nodes but also East stakers basically and this would really enable us to get as close possible to ethereum's decentralization so this is something we're discussing quite heavily um and then of course you have the whole notion of CK proofs especially if you deal with deterministic of chain computation that we are very much

looking into and though most of the cool stuff that developers are doing right now with gelato is with like a non-deterministic stuff and like off-train data that is very hard to like zk5 so that's why I think this is still a bit out there in terms of actual like real applications yep I think we also like right on time so this is some of our ecosystem map a bunch of projects that we work with maybe one of your projects is also on there um yeah and if you are building something and need something like what we do definitely reach out to us let us know and yeah I think that's already it

thanks for coming here this morning guys and if you have questions just shoot at me [Applause] thank you