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

Loading player…

Infura Transaction Relays for Better UX - Patrick McCorry

Ethereum DenverSat, Oct 9, 2021, 12:00 AM

This talk is from ETHDenver & ColoradoJam , the world’s largest Web3 BUIDLathon and Community Gathering. ETHDenver’s content is crypto and blockchain focused. Learn more: ethdenver.com Subscribe to our channel to learn more + connect on Twitter: https://twitter.com/EthereumDenver. Speaker: Patrick McCorry, Infura This talk was recorded Saturday, February 6th 2021. ETHDenver 2021’s content themes included DeFi & Money Legos, NFTs & the Creator Economy, ColoradoJam & the Next Frontier of Statehood, Protocols & Interoperability, Open Source & Public Goods, The Ownership Economy & Digital Orgs, Usability Design & Adoption and Legal, Privacy & Identity. Industry experts also weighed in on topics like decentralization, privacy, identity, non-fungible tokens, scaling, governance, diversity, and arts and culture in blockchain technology. The 2021 event was February 5-12 and hosted virtually in 2021 with 5000+ blockchain enthusiasts, developers and community members from 80 countries and 50 U.S. states. 🔴 SUBSCRIBE ETHDenver’s YouTube https://www.youtube.com/channel/UCgz9NU06t_FkT0Py1Vadczw 💡 LEARN ETHDenver’s Official Website https://www.ethdenver.com/ 👋 CONNECT ETHDenver Twitter https://twitter.com/EthereumDenver 📖 READ ETHDenver News on Medium https://medium.com/ethdenver 🛍️ SHOP ETHDenver Official Merchandise bufficorn.com 💬 CHAT Telegram https://t.me/Ethdenver Discord https://discord.gg/AxFmNdCVnU 📱 FOLLOW LinkedIn https://www.linkedin.com/company/ethdenver Instagram https://www.instagram.com/ethdenver/ Facebook https://www.facebook.com/ETHDenver/

Transcript

we have uh infuria coming up next patrick awesome hi how you doing i'm good i'm good how are you i'm good i'm really jealous of your cosmos background i wish that um came prepared i just got my inferior t-shirt was like the cutest thing at the moment well we spent if you could actually see in my little studio here that we've built i mean this is this is quite the preparation let's put it away have you got a green screen it's like proper green screen we got a proper green screen i got two giant gaff lightings right here i got a boom mic above me i got a cinematography camera right here so like it's it's yeah that's pretty epic yeah it's it's pretty good but more importantly we're interested in hearing about an inferior what's going on with you all and um yeah let's let's go you're ready you're on so take uh take the stage awesome hi everyone so uh my name is patrick mccory and today what i'm going to present is basically the inferior transaction service it's been under wraps now for about i guess six months and in inferior i really want to highlight the following is one why you should be really excited for it two how you can get started you know yeah we can try new software and three we have like this really exciting bounty for the hackathon and it's actually a bounty that's sort of close to my heart because i wanted to see this deployed for over a year so if you stayed at the end you'll hear about the really cool bounty for this hackathon you know yeah if denver um but before i begin i guess the the first question i want to ask and there's i know there's a little chat room here so hopefully someone can reply um when was the last time you had a stuck transaction and how did you deal with it and i guess also you know how did it make you feel so if anyone has a good answer for that i'm just going to scroll through the chat here you know please leave it in the chat and we can gossip about it because basically everyone who ever interacts with ethereum at one point or another has a stock transaction and really what is the problem behind stock transactions you know when you when you're on meta mask and you sign oh yesterday yeah crying exactly we're always crying about stuff transactions but why do they get stuck for so the way i like to think about it is that the network is a funnel okay and you send transactions through this funnel now really what happens is that you know there's a there's a block every 14 seconds and every block has around 12 million gas so when we have too many transactions in the funnel you know there's a huge list of pending transactions and it exceeds the block capacity then it's just you know physically impossible for every pending transaction to get in the next block and then be bind and that's basically the source of stock transactions so now miners need to decide you know given this list of pending transactions which transactions do i include in the next block and which transactions am i going to ignore and that is why we have the fee market i set a high fee but i can out-compete everyone else in the fee market then hopefully i'll entice the miner to include my transaction next and that's actually what's really exciting about ethereum is this global permissionless fee market it's basically an awk and auction mechanism where we all place bids and the manager gets to pick the biz that they like sounds like the source of these uh stuck transactions there's also various different you know network rules that sort of have an impact on why transactions get stuck the first one is everyone's aware you know sometimes your transaction just gets dropped by the network you've signed it you've set a fee that you're happy with you send it to ethereum and for some reason it just gets dropped and it never gets mined on the network and this typically happens you know when the network's under high congestion and that's because when you run like a co-etherium node a go ethereum nodes only go in the hold around 4096 or so pending transactions if there's no 4 900 or 4097 pending transaction then one has to get dropped from the pending pool and the simplest way to describe it is if you have a low fee transaction you're going to get dropped from the pending pool there's also more awkward more quirky rules around the pending you know pool one example is you have 16 transactions you've said sorry you've sent 17 transactions but the pending poll only guarantees to keep around 16 transactions so the 17th could be dropped from the network as well and these are rules that not everyone's really familiar with and that's why transactions get dropped now what's the problem with drop transactions the problem is this thing called announce gap so let's just say you send five transactions in a row you have transaction one transaction two transaction three but for some reason transaction three gets dropped from the network if transaction three gets dropped then you know you send transaction for transaction five and transaction six what's going to happen is that transaction four five and six are going to be stuck and they can never be confirmed by a minor and that's because there's a special network rule where for every ethereum account every time i send a transaction the nouns must increment strictly by one so you know one two three four but in this case transaction three got dropped transaction three gets dropped it's impossible for forty ever be mined and that's a really frustrating scenario to be in but you know how theoretical is this you know do we really get drop transactions so i stole this you know this chart from a block native i've given the blog post there's a very good blog post if you want to learn about the met the pending poll or the memory pool but around black thursday back in march over 50 000 transactions an hour were being dropped you can see here from the pending pool and um you know what happens next is really sad i don't know if everyone's aware of it but maker dao has an auction mechanism that you know helps secure the make sure there's always enough collateral for die uh the issue back in black thursday was that he had a liquidation auction you had a you know a bunch of bots and all the bots are sending bids to each auction then some of the bids got dropped by the network such that all their other bids bids can never be confirmed by the network so in this example you know i have bid one bid two bid three gets dropped by the network then all the other bids get stuck and what the good old keeper bots did was that when they send a new they tried to republish some of their bids they even set it an outrageous fee of 4 500 way 10x the normal gas price and even that transaction gets stuck and that's mostly because these bots had really bad relay infrastructure and really bad relay code and i think now it's been improved you know since march and that's why you know the liquidation office have been a bit better and not have many stuck transactions but that's like you know that's a horrible situation to be in if you're trying to you know see a maker and in the end you know they were under collateralized by millions of dollars another dude that i think was like a token sale to save the day the second problem during high congestion is again if you have a queue of transactions you have to make sure that all the transactions have a high fee so in this example you have a high fee a low fee a high fee high for a high fee if you have a low fee in the middle of your queue it's nearly as bad as having a drop transaction because for some reason ethereum miners aren't very smart and they don't look at your dependent transactions so in this case again you would get stuck if this was a low fee you know that's the opposite of bitcoin actually because in bitcoin this would be child pays for parent the child has a high fee parent has a low fee that's how you do price pumping in bitcoin but for some reason ethereum miners don't do a very good job of that so again another reason why you make it a stock transaction and finally the third problem as everyone's aware gas prices are too high and this is more this is more like when you put duct tape and try to solve the problem you know you actually make the problem a little bit worse so what so most people do is they go in eighth gas station they get the trader rate they plus 50 gray and then they send that to the network and for the most part that's going to work you pay a premium fee you're going to get minded in the next few blocks of course sometimes the price are so volatile that even that doesn't work because the fee skyrocket by the time you do 50 or more quay from the time you sent it but the consequences everyone overpays the fee and so this is where i tax comes in so yesterday i sent a transaction the fast food was 418 trader it was 4.95 i got my transaction in accepted of 343 gray and that only took three blocks it's not like we're waiting around for like you know 20 50 60 blocks i got that in three blocks and that's because we just have a very simple bidding strategy that outcompetes everyone else on the network which is uh really crazy to be honest and you know lots of people have built their own in-house relayers you know if you use a wallet contract like arjun dharma um genosis see if they have their in-house relayers and if you talk to their teams i'm sure they agree with me i don't want to put words in their mouth but the relay our software is really fiddly it's you know sending transactions to a theorem as a pin in the ass it's uh surprisingly very difficult to get this relay software correct it also requires a dedicated infrastructure you need this really early on 24 7 and sending transactions reliably to the network and even if you build your own in-house real layer it's also really hard to get satisfactory guarantees because the you know the fee market is so volatile it can just result in bad ux if you again get a stuck transaction and if you get the real air software wrong as i mentioned you can get a potential loss of funds maker dials under collateralized by millions of dollars because of the the bots relay software and there's other apps that i don't really want to talk about too much but they've also lost funds because they couldn't see of cdp's and again it was because of their relay software so really the whole point of this is you know no more stock transactions please the whole point of itx is anyone using itx we're going to do our best to make sure you never deal with a stuck transaction again um that's you know the guarantee that we try to provide how does it work well basically you're a developer you're thinking about building your in-house relay and then you think no i don't want to go through that boring task i'm going to hook into the itx api and then i'm going to send my transaction to infuria and fewer is going to guarantee this gets delivered to ethereum and i no longer deal with stock transactions how does itx solve the problem first we republish the transaction periodically you know every few minutes but we publish it so even if your transaction gets dropped you know we don't have to check if it gets dropped or not we just republish it because we're really cheeky that way two we organize the transaction coup has fee at the start of the queue lowest fee at the end of the queue it's a bit like a right angle triangle you know uh just to make sure you never get stuck behind a low fee transaction and we have a very you know that's to say sophisticated bidding strategy um so i'm laughing the cheeky comment there uh we have a you know a somewhat sophisticated bidding strategy so that we always pay the best price at the best time we really our current strategy tries to get it in within 10 blocks that's you know our target but sometimes it's you know actually a lot of times it's normally before 10 blocks hopefully i'll be able to show you later you might find itx useful i already mentioned crypto wallet providers you know like again like argentinosis dharma at all uh they like to handle transactions on behalf of their users but if you're getting stuck transactions on their services you should you know you should lobby them and tell them to use itx or if you're building your own wallet use itx and solve that problem for your users one of the use cases i'm really excited for is for roll-up providers roll-up providers have to create large blocks like seven eight ten million gas and they have to somehow i'll compete the rest of the network and get their block confirmed on ethereum and itx will work out of the box for that and that's actually the main use case i'm really excited for another one is server side scripts and d5 bots so one example is the ethereum name service your registering party.eth you have to send three or four transactions before your you know your domain is set up really i just want to send each to your contract and then ens can register that on my behalf and just deal with all the transactions for me that would be really awesome user experience and that's also goes in the dapps you know adapts or if you're getting complaints about stuff transactions you could try to send transactions on behalf of your users and itx makes that really easy for you so how do we get started you know this is a hackathon we want to talk about cool products that people can try and use so to get started one ethan's money you know first you you have a if deposit on the service and that will act as your virtual gas tank and then we'll use that if to pay for gas on the network you know eth is the payment mechanism ether's money use it as money and deposit into the itx service that way the second one is an ethereum account the way we authenticate new new relay requests is that you sign it and you give us the job and we just use ethereum you know signing keys because that's way easier for most developers to deal with and third you need a coding project you need a hack on something you need a script that's going to send a transaction to the network read a hackathon it's eve denver i've also stolen the old uh i don't really know what that is an ox i guess i've stolen the old docks from 2019 but you get the point you need you need a project to use itx with so the way we've implemented itx is that we have three new json rpc commands so if you're using etherjs you can just do provider.send and then you can send up the rpc command to infura uh there's three commands and i'll go through each one you know get balance you know watch the bottles of my gas tank send transaction we'll take a pre-signed relay transaction you send it up to inferior and then we'll return you back a relay transaction hush and then third get transaction status as you're going to see we're going to give you a list of transactions and then you can verify which one gets mined so let's get to some code examples okay well the first one actually is you need a deposit so i'm not going to demo this part but you go on the website you go to the contract there's a deposit for function you put in the address you're depositing for and the amount you're going to deposit you with 10 blocks and then you're ready to go and you can start using itx again ethan's money is how we take the payment and how we fill up your gas tank um and what's really nice is that you can program this into your script so then actually you can use itx to then re-top up your gas tank every time it gets low so it's like an automated process and that's really cool good balance you know it's a really boring command you're going to send you know relay get balance so i think i have it over here this is the balance one and we're just going to run the balance command so here in the code you have the provider it's called itx because i'm really exciting that way you have a wallet you do itx that's send relay get balance and it returns your balance you know it's the most boring piece of code ever but you need to know your balance and i have 0.16 ethernet net at the moment with itx oh yeah and that's that's the sample code the next one's a bit more exciting because we're going to we're going to send a transaction to ethereum so the way you do it is that you get your transaction you know the to address the transaction data the gas limit and the chin id you pass this together you sign it and then you pass that up to itx you can see two data gas and the signature itself then what we're going to return to you is a relay transaction hash that would allow you to use your status api to track your relay transaction and this is an example but you know what you know showing like you know little scripts on slides you're a bit boring let's just run a demo let's see the feed bump in real time so this is the demo contract we're going to use there's an echo event there's an echo function that's going to be the most expensive uh hello world in the world and we're going to emit a message that says echo okay now in the code itself you know again we have the provider itx we're going to call it we have the signer we create the transaction here with the demo contract address the function for echo hello world on the gas limit we sign it you know we hash it we sign it and we pass both to itx here the transaction the signature we got to get back the relay transaction hush so now i'm going to run this and hopefully i've got you know it'll send out live demos are always exciting there you go it's now ascending the first transactions be sent at 102 so while that's sending we'll jump we'll jump back to the slides so what we need to think about next is if i can get here you know how do we track that gas price bump in real time you see here there's an etherscan link with the gray so what we actually what you send up is you know relay get transaction status you include the relay transaction hash like so and then we return you back a list of transactions you know the transaction hash the gas price the broadcast time and you'll get each of these and hopefully here you'll see uh maybe that's been mined actually uh let's find out no it's still pending so it's going to say it's going to take 12 hours it's been about 50 seconds so far there you go we've got a second bump it's now 116 grey and hopefully it's going to get mine shortly so uh let's keep an eye on that they do i can close that one now and what is the current fee actually the current fee is you know 196 176 there we go we got a mind oh beautiful beautiful my friends took me five blocks i got this mind at 116 gray um yep 116 way the fast rate is 176.

trader is 196. i love it when a demo comes together you know thank you senpai um that was really exciting about you know itx you know we're actually saving people money even you know even with our our fee included on top of that it's still cheaper to use itx than it is to send it yourself i mean it's it's ridiculous um well there is one gotcha oh and one last point actually is um there's no gas overhead so there's uh i've lost a transaction but when you send a transaction using itx there's no extra gas um as you know we just take your data and we send it there there's no uh intermediary contract that you have to deal with we just send your transaction as if you're sending it but there is one got you and every third-party relayer has this issue and if you're going to build on using a third-party relay you're going to run into this gotcha and you're going to see it's not that big it got you but i highlight it because that's the fun thing about you know development and also the most annoying thing about ethereum so it's called the message.sender problem so we when a relay sends the transaction on your behalf you know we're going to execute a target contract the target contract typically authenticates the user using messes.sender but messages.sender is the immediate caller of the contract and that's going to be the relayers address and not your ethereum account so there's some implications there you know most erc20s you're going to have to do a pre-approval before you can use the service but one you know if the truck contracts meta transaction capable like die usdc uni then actually you know ihx works out of the box you know there's no real actual configuration you need to worry about you just run the permit function and then for example use the unispot router if your user has a wallet contract like again you haven't like i think believe dharma origin genocide safe everything works out of the box everything's immediately compatible and it's beautiful and it works really well well that's the big gotcha with uh you know relayers and um every third-party relay service has that issue um and there's some you know proposals that fix this at the evm level and hopefully it does get perfected the evm level because it's a bit annoying but generally speaking uh when you're developing your dap you can fix most of these problems so it's not even that big a problem for you anymore so now let's get to the challenge you know the most exciting thing for uh what i really want someone to build what i really want someone to build is itx loves uni swap you know the challenge i want someone to build an intermediary service that sits between the user and assist between uni swap the user gives the intermediary service you know a uni swap that they want to a swap that they want to perform this intermediary service will suddenly check the transaction you know let's go in the uni swap it's swapping tokens it's going to reward you for you know processing the transaction and if you're going to get paid for this transaction or this swap you're then going to pass as the itx and checks will broadcast out to the network and you know make sure it gets mined in a reliable fashion when the transaction gets mined you're going to get paid for the swap you know because you're covering the cost of the transaction you get a payment then the user gets the swap tokens so ideally the user experience is i go on your website i hit swap you take care of that for me and then i just get my swap tokens at the end and i pay you via the swap okay so this is a relay enable exchange it's a really fun challenge and really your challenge is going to be one i wanted to work with any meta transaction capable erc20 contract you know there's uni usdc die they should all work out of the box for any user coming to your website what you could also do is if the user does a pre-approval you know so they send an approved message for we to the router contract then that will also then work out of the box as well you know that's the one small hiccup of the ux but you know what to be honest you do that pre-approval once and you never have to do it again because everyone does the fine art of infinite approval two the user should not require any eth when they visit your website the user requires no pre-deposit and itx the user has no idea that itx is even being used and they can just pay you via the swap so if i'm swap and die to uni i want to pay you in uni you know via the output of the off the off the swap you could give me the input if you want i could pay you and die and then you do the swap and then you transfer you know then i get the uni back but regardless i don't want eth i just want to pay you via the swap could be the input of the output for me the output probably makes more sense um and really the big challenge here is treasury management so your intermediary service has a gas tank is covering the cost of the transactions and you're you know an eth and you're being rewarded in dai uni usdc or any token that you that you're willing to take and of course you can always do you know die to eat usd whatever so now you have the several tokens and it's up to you to work out how can you swap that back to each top up your gas tank and then cover future transactions and ideally by running this service you should be making profit you know and i'm gonna if you're gonna swap tokens for someone maybe you take 0.

5 of the swap and that's enough to cover the cost of the transaction and then they make a little bit of money for yourself for the relay enabled exchange and then you've improved everyone's user experience when they use uni swap and the whole point here is that itx takes care of the relay and sending transactions to a theorem on your behalf and all you have to care about again is this treasury management and that treasury management is i think it's gonna be a little tricky which is why it's really fun for a hackathon but you know the big bulk of the back end is done for you and as you've seen this you know we've done our best to minimize or avoid vendor lock-in so if you deploy this it could be used for any relay service you know the actual router contract does not it doesn't it's not aware that itx even exists you know the router contract doesn't care about itx so there should be minimal vendor lock-in as well if you if you do this heck of all and we're going to do everything our and our you know i'm going to do everything in my i mean i'm sure the team will as well to support you to build this because i would love to see a real air enabled exchange like i have my girlfriend trying to do uni swap and she didn't know how to deal with um and i want my girlfriend to use uni spot but not a centralized exchange so i'm here to bounce ideas if you want to build this type of project get up the speed on what the mvp should do what it can do we have a modified router contract that's a starting point it only needs one more function and it should do everything you need on the contract level and you know what if this becomes like if there's an mvp it's really exciting it improves user experience we're going to submit a uni swap grant and assuming uni swap accepts it and the mvp is awesome i would love to see the mvp go to production and then you make money by dealing with the treasury management and uses relay transactions on behalf of others and then you can have a startup and you never require vc funding because you know the grant should be hopefully big enough to help you bring it to production um and we have one thousand five hundred dollars up for grabs you know itx enough you're i've gone all in on this challenge you know we could have had other projects but to me this is the closest to my heart and i would love to see this on a build on top of uni-swap and finally you know itx is on all test nets we have a private me and net and there's zero gods overhead to use it so i think that's my final slide i don't even have a question slide um i don't really know what to do now because i guess there's not really any questions so thank you for listening and i really hope you enjoy the hackathon i'm really excited to see the projects that come out of this even if they're not anti-actually at it i'd love to see the projects that comes out of the heath global events so um yeah awesome patrick you have some fans in the chat man no no questions but a lot of great presentation um really interesting because yeah there's there's a real world use case for the treasury management minimizing volatility you know relaying between kinds of things and then obfuscating the ux i mean we actually work with this quite a bit in our payroll application at opolis so uh this might be something we'd be interested in talking about later too if you get it all figured out yeah i think the tragedy was like the trickiest thing for this so that's why i wanted to that's the main focus of the challenge really is to deal with that because everything else is sort of taken care of but awesome cool well thank you for for everything i'm just sort of cueing my friends over here to like keep it down a little bit so anyways um thank you very much for the wonderful presentation we'll see around the ether space you're going to be in the gamer jive space of the consensus desk yeah i'll be around i assume so i'll be around to some some capacity all right cool i'll see you around later bye guys thanks

Automatic transcript — names and jargon may be misspelled.