New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Austin Griffith & Yoav Weiss: Meta Transactions, Gitcoin Labs, and TabooKey | ETHDenver

Ethereum DenverWed, Oct 9, 2019, 12:00 AM

#BUIDL the future at https://ethdenver.com This talk was part of the ETH Stage at ETHDenver 2019. ETH Stage is ETHDenver’s Main Stage which features talks and workshops by top leading blockchain impactors, influencers and experts. ETHDenver is the largest Web3 #BUIDLathon in the world (fka hackathon) for Ethereum and other blockchain protocol enthusiasts, designers and developers. The community attending ETHDenver shows up to contribute to the global blockchain ecosystem, whether by #BUIDLing decentralized applications (dApps), contributing to or starting infrastructure level projects, writing documentation/tutorials/white-papers, designing UI/UX, or info-graphics, or to learn, connect, and get more involved. So bring your inner awesomeness and some friends. We’ll provide mentors, resources, and all of the educational content you can consume. Follow ETHDenver on Twitter: https://twitter.com/ethereumdenver Follow ETHDenver on Instagram: https://instagram.com/ethdenver Join the Bufficorn #BUIDL Brigade on Opensea: https://opensea.io/collection/bufficornbuidlbrigade Join the conversation on Discord: https://discord.gg/sporkdao Subscribe to our channel: https://www.youtube.com/ethdenver

Transcript

[Music] foreign so hi everyone um so today so I'm your advice and with me say Austin Griffith and um wow this is loud so um So today we're going to talk about the gas station network and how it is centralized The Meta transactions now before we uh before we dive into the gas station network let's talk a little bit about what about why gas is a challenge what are we trying to solve so um this is something I call the da paradox when you're building when you're building a dab when you're building a decentralized app its value typically comes from a network from Network effect this means that your first users are getting little value but as the as more and more users joined it up it becomes more valuable for everyone for everyone this means that we need to make it really easy for the first users to join now so let's look at Facebook for example Facebook is a probably the best example of a network effect so in the old days when Facebook was just getting started the first users it probably it wasn't very interesting to be one of the first users of Facebook because nobody was there but at least it was easy to join so uh so you would sign in look around there's nothing to do you forget about it but then as time goes by you start getting more and more notifications about friends of yours joining So eventually you click it again you go back in and now it's interesting now now your friends are there so that's how Network effect works now imagine what would happen if in order to join Facebook the first time you would need to go to an exchange pass kyc process you know prove your identity then then you need to transfer money from your bank to The Exchange by Ether install metamask pass the ether to your uh from The Exchange to your metamask learn how to use that all there just to be able to pay for gas to register for Facebook I imagine we wouldn't have Facebook right now so um so we need to make it much easier to uh much easier to a on-board new users to adapt in order to create network effect so I think this is probably one of the most important problems we need to solve for the ethereum ecosystem and there's already a there's already a solution for this called The Meta transactions so I recognize a lot of faces in the room I bet a lot of people know what meta transactions are but we'll kick through it real quick basically uh since you already have a key pair key pair is really easy to generate right but eth is really hard to get so gas is hard to get keepers are really easy so what if you could sign a transaction that's very similar to a real transaction but instead you don't send it on chain you send it to a relayer the relayer wraps that transaction up puts it on chain pays the gas for you and you could do kind of like this little Atomic swappy thing in there where they get paid a little reward too right so you don't have any eth you just sign transactions within the DAP you send them off to a relayer that relay is incentivized somehow either from you or by the DAP or a lot of different ways and then the DAP the relayer submits it into the contract the contract EC recovers it you can cryptographically prove that that person signed it even though they didn't have gas they were still able to interact with your smart contract so the problem with this is and if you ever used any of my demos there's basically like this one Central server that lives out on AWS that does this relaying and that's awful right it goes against our entire ethos of how we like to do things so we've always been pushing we we kind of created the the metacartel that solved this problem into kind of create create standards around it and what we were after was a way where we could have a decentralized network where we could actually not have this one central point of failure and what we were doing was we were thinking it would be a pool it would be similar to ethereum transactions where we would take a meta transaction we'd put it out in a pool and then a set of relayers through Game Theory and other stuff that's over my head would just happen to get your your transaction through for you right as long as they were economically incentivized what we found was it was just incredibly complicated and there may still be a solution in there somewhere but this guy and his crew at tabuki came up with a really really good solution uh that I call relay returns but he calls 1-800 ethereum okay all right so um so the problem so the problem that the problem with having everything with having a secondary fund Action Pool is a synchronization problem when a new when you try to add when you try to send a transaction through such a secondary pool all of the relayers are looking at the same pool they are not synchronized so each of them is going to pick the same transaction the most expensive one because that's how they make money so they all end up they all end up taking the same transaction putting it on chain and all of them except one get to get reverted because transactions should only go on the Chain once and all the other transactions never never get to the blockchain so that's the so we decided instead of trying to solve this problem we try to approach it to try and to try to turn the problem upside down we realized that the sender is the the sender is already the most incentivized party to get the transaction through but we need to give you the tools to do so and then we don't have to we don't we don't have to use a transaction Port we can talk to a single relay and still be decentralized so the tools needed for that first the sender needs a way to discover relays and then it also needs to be able to verify the um to verify the service to know that it's getting the service without waiting for mining to occur and if we can if we can provide these two things somehow then we turn the problem upside down instead of creating a transaction pool we let the transaction we create a relays pool and let the transaction go to the relay instead of doing it the other way around so the approach we took is based on is based on a single tone smart contract called relay Hub there's exactly one on the entire blockchain and all the relays have to all the relays have to register with it when they register they put a stake that's a certainly that's like a performance bond let's say it's like a performance bond that guarantees that the relay is going to provide the service and then and it also announces there really also announces what what its fee is going to be how much it expects to get compensated a URL that tells us that tells users how to reach it and then as as it gets used really Hub also emits emits events that allow that allow anyone to calculate a reputation to decide whether a certain relay is worth interacting with now in order to in order to really make it work we needed to find a way to uh to get immediate feedback so we don't need to um so we don't need to wait for money because otherwise it would be really easy to take the system down or to make it very slow by just creating a bunch of relays that tell you they are going to tell you that they are providing the service and then not put anything on the blockchain so the client will just connect provide and provide a transaction wait and until until it waits for long enough and see that it doesn't appear on the blockchain so say Okay so this relay is not reliable go to another one if you create a bunch of these relays you make the system unusable so so what we did instead is we said that when the sender gives a transaction when a client sends a transaction to the to the relay there really needs to do two things with it one is to put it on the blockchain but the other is within the same HTTP connection return the signed transaction the same one that it's supposed to put on the blockchain just return it to the user immediately so this is an immediate operation and now the client the client can actually take this transaction and put it on the blockchain because the transaction is signed by the relayer and it already has gas you can put it on the blockchain and so you know you can verify the transaction and know that it's actually going to happen there are still a few kernel cases a few attacks that would have been possible here and hopefully we addressed all of them but I don't think time will allow us to go into each and every attack here so if you want to learn more about the about these details about the attacks mitigations you can read the my medium post here or you can go to EAP 1613 where we describe the the internals of the network and there you can also scroll down to a section to a section about attacks and mitigations you can see the metrics of attacks and how they are mitigated so but now I think uh I think we just switched to a demo so yeah so this is so the network is live we actually have a relay is running it's not on mainnet but it's a but it exists on Rob stand and on the xdi network thank you so um so what I'm going to show in the demo is uh we took the we took meta coin metacorn is a sample app that a sample app that comes with truffle so anyone who is developing with truffle here probably familiar with it and we made the small modifications to a to meta coin to use our gas station network when when you use it the client what happens behind the scene is the client will actually will actually find the relay from relay Hub agree on agree on a fee perform the transactions through that so I'm going to show you how it works and then we look behind the scene we just look at ether scan and see what really happened behind the scene so here I have two instances running one of them in incognito mode so they have two different addresses I'm going to copy this address and we're going to send one token so it already went to the relay now we are waiting for a Rob stand to mine it so uh let's give it a let's give it a second [Laughter] and yeah actually would have been faster yeah next time so okay yeah we really should have Zero's X die the reason why is because of etherscan right yeah because I yeah I wanted to show it on I wanted to show it on etheroscam because when you use xdi the interface for looking at transaction is just not as nice the well if if it doesn't get mine soon we just switch yeah it could be so well I haven't I still have tabs open from when we tested it earlier so I'm just going to show it with that uh so here this is oh okay yeah mining works okay so now first let's look at this address we soon we see that uh so this is the address that sent the token and we see that the token count went down if I now refresh on the other side we should see six now we have six so now I'm so now if we look at these others for a second we'll see something interesting you see that there are no transactions from this address like ever because it never had the money to pay for gas but you see that it does have token transfers so token transfers happened through a relay and that's why there are no transactions now let's look at the transaction see what really happened so here we see that the transaction went from that address it's a different address from the one we used if we look at this one for a second you see that it has a lot of ether and it has I'm sorry zoom in oh ah I don't I don't know how I could do that here uh control plus maybe is that better okay so um so you see that this address actually has a it has a ether this is the relayer so the relay science transaction we see that one minute ago there was a transaction here now going back to the transaction let's see what uh what it was so the transaction came from the relayer and it went to relay Hub which we'll see in a second during the transaction a one one elc20 token was transferred from the address of the wallet to another to the other wallet and the call here was a relay call so so you see that behind the scene the client made a relay call now I'm going to switch to the to the relay Hub contract so it really help contract we see the transaction that happened two minutes ago and if we look at the internal transaction at what happened there internally we see that the transaction actually um it was actually three different internal transactions that's because the first one was checking the contract to see whether it's going to accept the transaction we like to we let the DAP decide whether it's willing to accept the reverse charges since the DAP is going to pay for it so we pass the transaction to Red app the dub tells tells us yeah I'm going to pay for it I want the transaction from that moment on even if the transaction reverts it still gets compensated the second one is the transaction itself this was the token transfer in this case and the third one is an accounting call it's a it just tells the contract how much how much it ended up costing it so and which user is responsible for it that's in case you have your own accounting system and now but now the interesting uh the interesting thing to look at is how did we even find a relay and all we know is the address of relay Hub so like I said when you register relay you end up when you register relay it appears there in a so it appeals in the events in really Hub let's look for it so I'm just looking at the number here and okay so we see that this is the relay transaction and we see that it went from this relay we saw this transaction now let's look for it some more okay so here we see there was a relay added event this is the register the register command that came from the relay so this is how we discover the relay you see that the relay added was called when the it gets cold every time it really registers or refreshes itself which it tends to do occasionally and so what we see is that it provided us with its address its transaction fee stake size and most importantly the URL so we know how to reach it let's change it to text so here you see the actual relay that was used for this transaction and every time it will be a different relay so you can have as many as you like and the relays are just competing over a fear fear and reputation in order to to handle the transactions so that so I think that shows how the how the system works now What's um so now if you want to add this to your own contract let's see what do you need to do if you have a Dap and you want adapt to start using the gas station network the changes are really minimal what you need to do what you need to do here is first you need to inherit from a contract called relay recipient be the recipient is it just provides you with all the code you need in order to interact with with relay Hub and then you need to implement two functions so one function is except really cool except really cool is a view function that you need to implement and it tells the relay whether it's going to get compensated it's supposed to look at the transaction in the sender decide whether it's a whether it's a transaction that it actually wants to handle you can call it as a view function from the relay so it doesn't cost you anything and then it gets close it gets cold again during the transaction to see whether whether the relay should be compensated the second function is the post-related call this is transaction that tells you how much the transaction ended up costing you which consists of the actual gas price multiplied by the transaction fee the transaction fee let's say that's the markup that the relay is requesting which you agreed on now finally you need to go through your contract and change message dot sender to a get Sender call everywhere that's because message.sender is now the relay address it's not the address of the it's not the address of the real standard so what gets sender does is it usually just returns message dot sender so it's identical except if the call came through relay Hub if it came from really Hub then it calculates it finds the real sender and Returns the address of the real Center here so if you want to um if you want to look at it if you want to look at it and try to edit to your dab we have a Hands-On tutorial that we posted yesterday you see the link here you can this tutorial walks you through taking meta coin and adding the and and adding this functionality so you can do the same for your own app and during the hackathon I'm going to be available here so if anyone wants to uh if anyone wants to add it to a to his project here just talk to me and I can help you through the process you know I think we still have enough time so I want to let uh so I wanted Austin here demonstrate something so just to do a little too long didn't read there basically we were going out and we were trying to make a pool right he came up with a way to do relay returns which is basically he queries for a relay he queries for a decentralized relay from a from a smart contract that you can stake and you can slash on and so you can make those calls quickly within a block right you can make a couple re you can find your right relay with just an HTTP request and then you send that off and he handles your call for you just too long to read okay so now we have uh we have implemented this live into production of the burner wallet so there is a moment in the burner wallet where you want to send let's go back real quick make sure that let me make sure my bow ties right okay make sure so this guy's got zero dollars it's a brand new account right in fact you don't even have to have an account yet right like we could be sitting on Google right now we're just using this for the QR Code Reader so uh yeah control platform okay so uh what we're going to do is just use the QR Reader what I'm going to do over here is I'm going to package up a link for 25 cents and I'm going to send that to an escrow contract this is just this is basically just link sending you can send funds through a link to someone else that doesn't even have a wallet yet it will land it will generate them a wallet and it will pull uh the funds in so uh this is the share link so far if you guys stole that you would be able to uh grab it but what's going to happen here is he doesn't have any gas to uh claim this right he's got to claim this from the smart contract so what we're going to do is your app's team like basically just threw me a pull request one day and it was like hey we implemented the gas station and it totally works so if if I put this up here what it's going to do is it's going to go pick one of his relayers I hope it's mine too we're both running relayers that make it more decentralized right right right so it's going to pick one of his relayers and then that relayer is going to pay the gas for it it's going to get it's it's uh prize which is like a percentage of the gas price right and then it's going to deliver us our funds 25 cents all right thank you so uh now so now that the transaction passed and we see the 25 cents we can actually look at the um so we can actually look at the relay Hub on the on the xdi network Let me refresh it here okay so 41 seconds ago we had a transaction this is the transaction this was transaction through relay hub so we see that it picked some picked some relay and used that [Laughter] okay so this was the relay call the relay call went to this D3 so it's everything so this is the this ended up being the relay call and here we can see that it was a transaction relayed now let's look at this relay and see if it's Austin's relay or one of mine so hold on a second yeah I'm less familiar with this interface but this one's open source uh yeah I just look here so that's the actual transaction and now hopefully this is the registration let's look at that no this was transaction relay that's the wrong one it's less searchable than six hours yeah that's them yeah that's the one so here you see this was a register relay call and it came from relay one really One X die yeah this is one of mine when we tested this it went to a his relay the point is that it doesn't matter which relay it takes it just it negotiates he takes one relay and uses it so that's uh so anyone can start a relay and what's cool here is that at this point even I mean once the network is up we at tabuki don't matter anymore let's say to let's say right now I'm shutting down all of my relays it doesn't it doesn't affect the system because once other people like Austin started relays and so Austin also has a relay on the same network the network goes on it's a I have no way of shutting it down at this point and it took me about maybe 15 minutes on AWS to sign it up yeah okay yeah so yeah so starting starting a new relay is uh it should take you minutes because there's a Docker that there's a Docker that does everything for you just start it you fund the relay and you're good to go you start making money by relaying transactions and modifying an app is also a rather simple so um so anyone can start using this yeah so yep so thank you uh congratulations first this is truly amazing thank you two quick questions first one uh do you know how much extra gas uh you are paying for relaying um one of these transactions instead of sending a near C20 directly easier yeah probably yeah history cover is probably the most important the most expensive I I don't remember the exact numbers but yes it does make the transaction a little bit more expensive the point is that uh it's not I don't think it's the right thing to do to compare it to the house of to the cost of an ether transaction because it's the cost of acquiring users that otherwise you wouldn't be getting I mean they wouldn't be I mean it's not that these users would come because they pay less gas they wouldn't come because they don't own if so that's the that's so that's a great answer and uh my second quick uh question and I'm gonna sound a like a broken record but uh when can we pay gas we die on like main map where when you go to mainnet um are you going to be able to pay for the gas in other tokens uh other than if yes so this is uh so this is actually outside the scope of the system because the way we designed it is um you can charge your uh we have the really recipient contract that you have to inherit from but you can subclass it you can create a subcontract of a subcontract and Implement your own model so for example if you have an internal token in your lab you could charge the user with tokens we actually have a sample that does just that you know git repository so there's a sample really called real talking really recipient where you implement your own token you have a balance for each user and you can and whenever a user whenever a user makes a transaction through a relay you um you accept the charges but you charge the user with your own token and you could do this for example with a credit card you know just a assign users credit externally put it into your contract and you can start charging users you implement your own models so you see it's outside our context because we created a which we created a system in a way that makes it easy for you based on your model for example if you are if you're implementing a Dao maybe you don't want to charge your users directly but you want to have a wide list of Dow participants and if someone abuses it and sends a lot of useless transaction the others can just vote him out get him out of the Dow if it's a game then maybe you'll want to monetize on your users separately or pay with your own token so it depends on your logic but you can Implement whatever you like here great perfect congratulations thank you hi I may have missed this part but how does the relayer Hub choose which relay you get to use so it's not the Hub choosing the point is we wanted to give all the power to the user to the to the sender so now the sender then the client picks it they really have just uh yeah that yeah no it's it's yeah it's the adapt developer chooses so uh it's a you have all the information you have all of these relay added events the registration events you can see them as you can see them as events emitted from really Hub and each of these events give you a URL and the fee you are going to pay so you can select it based on a fee or on your reputation or even hard code one if you like it it doesn't matter and then the sender get the client gets to pick which one to use normally it just connects to three of them at a time you know just pings them and talks to the fastest one it also you it does something interesting with the other ones making them inspect the first one but that's uh that's a bit of a longer explanation why why we do that thanks so what happens if you relay it get out of money the I mean if your layer get out of it you have to put it right or yes you have a yes you have to be funded first of all if you don't have enough funding then the register call Will Fail really have actually verifies that that the relay the relay address is funded and and since you have to re-register every once in a while then you are going to be thrown out of the system so to speak if you if you don't fund it besides the client can also check your balance so when the the client picks a relay it it not only looks at its URL and fee it also gets the balance for this relay if the relay is not good for it if it's not if it can't afford a transaction you just don't don't pick it go to a different one thanks hey great job guys um so I have a quick question if the relayers were kind of malicious and they had like maybe they were a rival dap and they decided to come out and they wanted to shut down the DAP um that's calling out to like get these relays would they be able to do some damage there you know like so you have a doubt that's trying to relay transactions and they're a rival so they're they're relayers and they're gonna you know try to just shut it down is that possible I mean a lot about mitigation of that oh so good question and the system is designed totally trustless so uh dubs don't trust relays users don't trust relays relays don't trust anyone everything is incentivized and trustless so if it really doesn't provide a service if it doesn't provide a service since you know about it immediately because it didn't provide you with the same transaction you switch to another one and you don't wait minutes you wait maybe two seconds so it delayed you for two seconds you go to the next one but from now on you're also going to ignore this relay so if the relay is so they really will just stop getting traffic and since it put a stake you can't spawn as many relays as you like you have to put like 10 ether stake when you create it and if you want to change the address of the relay you need to you need to unregister wait for 30 days only then get your stake back and register a new relay the idea here is that if it really doesn't give a good service and it stops getting traffic in order to redeploy the stake you need to wait a you know you're in a wait for 30 days awesome thank you Carter he helped me for the burner water okay my question is how do you guarantee that the relay gets paid because if you are also like a changing in in a token or uh maybe directly how do you take like that's the uh or do guarantee that part so the relay always gets paid with the native currency of the system be it X die or or if even if internally you're going to charge your users by other tokens and the way it's guaranteed is that when a Dap wants to start using this then aside from changing the code it also has to put a small deposit that's enough for the next few transactions so you have to put the deposit in relay Hub you put like half ether or something like this this should last you for quite a while you put that so you put a small deposit and this and whenever whenever the relay call gets to get to your dap your dap is asked using the accept relay call function it is asked whether it's willing to accept a transaction if it does then if it does then this then the relay will get compensated from your deposit so uh so the Relay can verify that by calling this function as a view function earlier it knows that it knows that it's going to get compensated it will not put it on chain if it's not I give you um can you give some clarity on the uh the slashing conditions so if uh if I'm adapt right and a user uses my dap and it gets uh that query gets forwarded to a relayer and you said that relay is supposed to give me a signed message response well now let's say it doesn't right the real error is offline or it's malicious or something how what kind of proof can I compile to then send to the relay or hop contract that hey this relayer sucks and slashes stake what how does that uh what what information does the DAP have and how does that get verified yeah good question so the so this is a so this is taking care of the way the way the protocol works because I mean if there if they really wants to uh not serve you you can do one of one of several things one thing you can do is just not return anything to you but then it only delayed you for two seconds you switch to the next one and now we will Blacklist this relay it doesn't you don't need to report it to really happy just that you I mean your dab whether it's from the client side or centrally in your uh in your back end you're going to Blacklist this relay so if it just doesn't provide service that's fine just you know you discover it within two seconds and you don't talk to it again if it's uh and you can't have many such relays because you need to deploy 10 ether for each of them so uh that's not a scalable attack another thing it could do is uh it could it could create a sign transaction return it to you so you think you are getting service but no but he doesn't put it on the blockchain this case is again not really an attack because you have the transaction you can just go and put it on the blockchain yourself when you can just go it's already signed it has it has gas so you put it there yourself and it still happens but for the Relay it's a really bad thing to do because now there really doesn't know whether you're going to put it there or not so it doesn't know if it should Advance the Norms or not so it's stuck when it wants to do the next transaction should it Advance the Norms or not and if it doesn't then this opens an interesting attack and that's what the stake is for you actually get penalized someone can take away your steak this is provable on the blockchain uh what can what happens in this case let's suppose that the relay tries to cause a more significant delay by giving you the so he's giving you a signed transaction but at the same time he puts a different transaction with the same nonce on the blockchain so your transaction will get to the blockchain but it will get reverted on bad Norms but this will take like two minutes at worse so now it costs the delay of two minutes but the thing is that now this is provable because you have a signed transaction with a certain ons and now you see on the blockchain a different transactions signed by the same relayer with the same nouns and this should there's never a legitimate reason for that so you take these two transactions you give the two transactions to a penalized function in relay Hub and once this is verified on chain the penalized function is going to unregister this relay take the 10 ether stake and give it to whoever reported it so there's a very strong disincentive here but since we didn't want the app to actually we didn't want the app to keep monitoring the blockchain for that because we want it to be I wanted to be a siren forget thing you know you just put it there and forget about it so that's why you talk to more than one relay when you get a signed transaction you don't put it on the blockchain you give it to another relay or to two other relays so those those relays now those relays now we have an incentive to look at the blockchain to look at the of the first relay and to look at the transactions and see whether it puts a different transaction with the same loans now or in the future if it ever does that then the other relays are going to take away the stake we probably better call it I think yeah that'll answer my question thank you okay thanks guys thank you [Applause]

Automatic transcript — names and jargon may be misspelled.