Account Abstraction (ERC-4337 & OpenGSN & Polkadot) - Lumír Mrkva | BeerFi#2
BeerFi Prague - Web3 Builders Meetup·Fri, Oct 7, 2022, 12:00 AM
Slides: https://github.com/gweicz/beerfi/blob/master/events/2022-07-26-beerfi2/slides/Account%20Abstraction%20(ERC-4337%20%26%20OpenGSN%20%26%20Polkadot)%20-%20Lum%C3%ADr%20Mrkva.pdf https://beerfi.gwei.cz/ #ethereum #opengsn #polkadot #smartcontracts
Transcript
okay okay my topic will be a little bit lighter and like more surface level uh than previous one but i think it will be still quite interesting it's interesting for me uh so like i said before i'm lumiere i am building two chains on polka dot and kusama and today i want to speak with you about account abstraction which i think it's quite related to the pre like proxies previous topic so as you know currently like like to like do any transaction on the ethereum you basically have to interact with it with external owned account basically like some some private key that has like some ether in in the storage and and you can use it to to pay gas right so so for example you will call that proxy and like interact with maker dao or or whatever like you always have to have account like that so basically itra is cool with like you can change whatever like it's it's basically you can program what is executed on the chain but you cannot really program currently like uh how you validate the transactions right so like we have this fixed eoa thing and like you always interact with it the same way the transactions are completely the same and and it's like one of the current limitations so like like obviously eoas are really simple and like they are not really secure if you want to manage funds of dao or some company so you are using multi-sigs and like different smart conv smart contract bullets where you can change who can like delegate the funds where you can like control stuff like that where you have like basic contract about things but like still if you had contract wallet if you have the multisig or some delegated wallet you still need to have some account that has your like uh it's externally owned and has the gas money to pay for it so account abstraction is trying to like resolve this issue so basically the contract wallets can become like first-class citizens and ultimately like you can get rid of like external accounts at all like you you can just use the you can just use your contract bullets so so why you you would need to do that right because um like i said before like you have different like multi-six schemes you can change like what kind of signature are you using because right now like if you are using external wallet you only can use like a ecliptic curve of ether and like that's it like you cannot use any different like signing scheme so you are stuck with it but like with a smart contract wallet or or account extract like you can use whatever like signature you want right you can use bls signatures or even like the signatures polka dot uses that i cannot uh like remember how it's called but uh so it has like a lot of advantages like that like and all the advantages of like normal smart track bullet like social recovery and you can have different multi-sticks and then we get to even like more interesting use cases for account abstraction where you can actually like can say okay maybe i don't want to pay with ether for my gas i maybe want to pay like with die for it or whatever else i'm using in my protocol right so if i'm like dab developer and i have native token like now if i want somebody to interact with my dap i have to like somehow on board them not with my own tokens but even like but with ether as well so they can actually pay for the transactions and this is like a pretty big ux hardware for a lot of new users so they have to like yeah tackle this and and like for protocols we always try to we always try to find a way how we can basically on board do i would say like normies and like the the crypto beginners easier to adapt especially when we are we're making games we were really trying to like mobile games you can imagine like on mobile game you don't have any metamask and like you you don't really have treasure connected to it you don't want to like every like game move that you do you don't want to like sign the transaction for example right so we always try to like how we can make it better and simpler and not just like the interaction with the game so you don't have to like basically read whatever bytecode you are signing but you don't have to care about like okay now i want to start playing with this game but i first need to go to some exchange and buy ether and then transfer it to my wallet and stuff like that we wanted always to onboard the people through our like company so we were like okay with like paying for example gas for them like if they are banners and they are just getting into the game we want to onboard them like we will sponsor the gas for them so this is the way how to you can do it like through smart contract bullets you can you can pay for gas of the users so so you can effectively have like uh schemes like that and also what is interesting you can uh start like interacting with what that is maybe that doesn't have like anything like you just like make it from the thin air and you don't have to link it to the kraken to get your eater and then withdraw tornado cache you can directly withdraw with another question create effectively new wallet now this this this is uh account abstractions allows you to do something like this so you can basically submit transaction for the free you can say because the transaction itself is validated okay if like the turnout okay should we travel goes through i will get like i i can i will get portion of it for example right so like you you are still paying for the transaction but you don't have to necessarily pay like you don't have to have it up front in your wallet right so this allows you to for example create new uh accounts for tornado cache or withdraw from bridges claim from some van vesting schemes stuff like that so it's really useful and i was really like excited when basically uh vitaly was was pushing this uh and like original idea was in erc or eip uh that was directly part of the protocol so guys were saying okay we will change how solid it works how the protocol works how the signing transactions is done and we will integrate this functionality into it but because the heater is like the big boat and it turns very slowly it's like not really like they were like quickly seeing like this is never going to happen like at least not if we don't have like some traction behind this idea even if it's like really cool idea right so they had to come up with like compromise i would say which is like the like i guess year old eip 4337 and it basically tries to achieve the same thing but like with no protocol change so how it actually does it is if you are familiar with like gas station network which which is protocol basically built that allows you to do stuff like sponsor somebody's transactions like basically you can clear create these meta transactions and relayers will sign them and pay pay for gas and and like it will happen whatever you signed it will happen like it's it's like just this use case basically so this is like improved version of it and it's actually built by the same guys as they did the open gsm and it was also audited by open zapalim so like this this scheme basically has few parts interacting with it uh so you obviously need the wallets which are the like smart contract wallets where they like is the special functionality in that can be the multisig or the smart contract world with different schema stuff like that and you have and these wallets have two parts like they have the execution part which is like obvious which is like normal smart contract part but they also have like validation part so violation part is added there uh so like uh bundlers which basically take these meta transactions and tries to try to bundle them and submit it to the like real mempool can first validate okay this transaction will go through so it they are not wasting gas and they can also validate okay somebody will pay me for this gas if i like bundle it and submit it so so users actually use these wallets signed the transactions and like distributed in separate memphi from like the regular mempool of the ether and where like bundlers are listening and they are bundling these transactions and sending them to do to do a chain so and this role or role of bundler would be like normally i guess minor or or validator like if the bundler like if all these functionality if erc 2938 the initial idea would come true like it would be done by the actual like block producer by the validators so this is always the future that bundlers will be like the block producers so but like now they are it's not part of the protocol they're they're just like any other like uh yeah it can be basically anyone like it even you can bundle your own i guess metal transaction right but it doesn't make mo much sense and there is like additional role of paymasters which are separated from your bundlers and they are like the just roll which was like filled by gsm before those this is the role that like actually pays for for the gas so the wallet itself doesn't have to pay for the gas it can be some paymaster and this enables for example payment for gas with different currency because paymaster will pay in ether for for the transaction but then when a transaction goes through they will get die from you so they will like make their money back thanks to that and there is like entry point contract which is like central entity which uh everybody interacts with or like basically calls any other contracts in this scheme so there is diagram actually how it works so first bundler that like looks into the mempool makes transactions like picks whatever they want to bundle in like in this case there is just like one transaction right so it's a really small bundle so first they will verify signature of the contract and verify that like you can you can basically execute it obviously this whole process is like just one transaction so they can execute it and like try to execute it like just dry run it and see if it can go through so and this is the process of the dry run or like the run actually will be the same but uh they will first uh like call the check on the wallet contract and this is and the check contract itself like or to check portion of the contract is optimized and it's it has actually limited op codes what you can do in the check so you are not spending too much gas on this check and you cannot like uh ddos thanks to like super expensive check that will change because like you can imagine you can flood the chain with your or like not to change like the second mempool with your transactions that will all be invalid in the next block so obviously in this blog check will pass but like when the bundler will send it out to the blockchain then on chain it will fail so these situations they are trying to prevent those by like limiting what you can actually do in the check so you cannot do schemes like that so that's the first part like checks has check has to go through then there is the interaction with the paymaster that will actually pay for the transaction if paymaster is included so and there is important thing to note that paymasters are uh staked so yeah this is this is like way how how you can prevent them like flooding bundlers with like work that that they are not paid because even if bundles are not spending any gas or or fees you have to consider they have to always like take these transactions from the pool and try to validate them and and bundle them so so like uh they they have to be covered by checking function of the paymaster that actually they can pay and if everything goes through if the vote contract is okay if the paymaster is okay then finally we will execute whatever was signed and whatever can the vote do and finally the wallet uh finally their option there is optional part for paymaster to call something to get their money back so they can maybe withdraw something from your account or whatever is part of your setup with the paymaster so this is the convoluted way how you can do all this without changing the heat itself right so you still need eoa eoa is the bundler but the users actually just can sign the transactions send it into not to the regular mempool but to do like bundles mempool and get get it uh processed i would say so this solution of econ abstraction is already audited and deployed on like i guess any l1 l2 and if it's not you can always deploy it yourself like the biggest issue always with these things are like you have to have some uh network of the bundlers and playmasters that are actually willing to like like you need ecosystem around this like of the wallets that are compatible with it you need like uh people that are bundling it that are basically running the network and yeah people developing on it so definitely what you can do is to build something build your like smart contract wallet that is compatible with this so and that way we can only kill eoa but i guess not before the merge i don't know how i'm on the time but uh this is the part how how the account ups actually is solved on ether and now because i'm mostly working lately on polkadot i would like to show you how we do things little bit differently so this is a polkadot network for those not familiar with like go over the parts and like explain it a little bit so basically uh polka dot is a relay chain which is you can say like interest beacon chain and they are like attached these little parachains around it do you have question oh okay and yeah i just wanted to pause sorry so there is the dance of the like parachutes around it and these like baguettes or like whatever pills are actually validators of the rely chain because the polka dot relay chain is delegated proof of stake so they have like hundreds and hundreds of validators and these validators like over time take turns and they are actually not just validating blocks of the relay chain but they are also validating blocks of these para chains and these power chains they are their own you can say side chains or in ether lingo it would be shards i would say and they have their own blockburn roosters which are colliders so and they have their own runtime basically they have their own like uh change uh like state change function which is like executed here and also executed or by the validator so actually how the parachain block is produced the users on the power chain signed transaction send it to the parashin mempool collators will pick it up create block from it and they will submit it to the nearest validator that they have just assigned to and validator actually runs like check function that like validator is not connected to the parachute in any way they are just like getting these like blocks from the colliders and taking basically the validation function which is stored on the relay chain paired to the power chain and they are checking if the block produced is valid so that way like the validators can like one block validate one para chain next block they are relating different power parachain so they are not like affiliated to the parachains in any way but they can still fulfill their role and they are actually what is like producing the blocks of the parachains and providing the security of the parachains collaterals are more like the composers of the block you can say right all right they are just like keeping up with the uh with the mempool and picking blocks like creating blocks from it so so when you actually build the power chain uh which is like the shard interacting in the network you have you can change almost everything like uh almost everything like including the peer-to-peer networking rpc method consensus scheme and the obviously the biggest and most important is the vasim runtime itself which is the part that is actually like governing how how you can change the state and this part is also stored under on the relay chain so validators can check it but what is important thing is that you can change really anything so you can change the consensus part so you can say like in your power chain okay i will not accept these like parameters in my transaction my transaction can be built completely differently right i can have different signing scheme i can have like different rules what i accept i i don't have to have any fees i can like like you can basically move the checking part or of the transaction to the consensus layer so the collectors can serve as the bundlers right they are checking the development pool and thanks to the validation that is like stored in the consensus they they can they can like include online valid transactions so this is obviously like any power chains like power chains are typically like focused on some use case you have power chain for the landing you have power chain for swapping you have power chain there is the bridge you have power chain there is the stable coin stuff like that right so so every power chain tries to uh modify how they work based on their use case so for example one of the parachains one of the one of the power chain has evm smart contracts and and they are like basically more of the ether side chain so they as the like default signing schema use the same as as either users right so you you as the user can go from eater and use the same metamask but now you are interactive with the production you don't even know it right so what actually yeah i can talk about this uh maybe a little bit after but point is you like power chains are in control of the protocol itself so if you need some special signing schema you can just change it right you can add the new functionality into it you don't have to make sure as ether does okay everybody is okay with this change like we can have this on the protocol layer like nobody is against it in the purchasing world like just the focused group that is managing the dao can decide okay this makes sense for our protocol so we will do it so what we are actually handling as the problems in the purchasing world is that like every little chart uses actually their own native token like their protocol token as their transaction fee token so if you want to do something with lending protocol you have to use the lending protocol token to pay for it right if you so so this gets complicated really quickly that's why most of the power chains actually and our person as well support some way of like accepting payment in more currencies and they they will just accept payment in other parachutes currency and then they will swap it later or just gather it like depends on their strategy or they don't accept it but like they will probably accept more than like just one currency to pay for transactions so so this is really important because uh imagine if you want to send the token from one parachute to another you have to pay somehow to receive that token on that second power chain right so if that second parachute wouldn't accept the token you are sending uh i don't know like uh you you need to send basically two tokens like one token for the gas and second token for that you actually want to send but this way you can just subtract portion of the transfer like portion of the transfer and keep it as the fee so so it's much more simpler and like users don't have to really deal deal with it and what is nice about our users they can just swap like whatever currency they want to pay with like how they like if they run out of our tokens they they can swap for different ones and we will accept that as the payment for the fees because we don't have problem with it as the swapping platform obviously because it's advantages for us but other platforms are actually using us to like get whatever they are accumulating in their treasure actually because like again every parachain is not just their own token they are just they are their own dao like every parachute has their own treasury and organization behind them so also you need to link it somehow usually if you go into the power chain world so so for example like you cannot create the parachain wallet from the eat wallet so you have to you have to somehow like link these two and how would you do that if you don't have like any tokens in our platform yet so we will allow you to just uh call claim without any any fee like you will just sign it and because we validated okay you will actually claim something and we will take part of the claim as the fee you can call the claim right so in in our case the validation function is moved to the consensus layer and you can see it like you can you can do also all sorts of stuff but yeah mostly its own specific use case so we don't have to deal with problems that it deals with because it resolution for the abstracted accounts has to be has to work for everybody on the system and they can always deploy arbitrary code to it and break it in our case it's it's much more restricted what you can actually upload as the user to to code to the chain right so yeah we we don't de-elevate uh yeah because we are just like subset of the network like we don't have to deal with the rest of the issues of the whole network oh do you have some two minutes okay i am i'm actually ended so uh if you have any more questions yeah did i like did somebody understood me uh i can't skip this question about polka dot so so you kill the real chain and you have like uh the buyer chains so when what you are deploying deploying you want to deploy whatever let's say you're just swapping something or something stupid like witcher you are creating like your own app yeah with the contracts and the front-end as well when you deploy your contract to which you will target one of the power chains like relay chain is just for us it's just uh the security provider they are not providing any other functionality than that okay so basically in polka dots there's no smart contract no no everything is is delegated to the party oh okay okay cool thanks so you will pick the power chain that more mostly suits your needs and deploy it on there or you will create your own power chain yeah but for that you need to do this auction and get the swap then yeah it's complicated but uh it's one of the options so actually somebody does it like some of you like let's say like if you want to run some bigger adapter yes definitely if you want to like if you have big projects for example if you want to build stablecoin it's worth it to run the whole parachain in this case okay okay thanks yeah or if you have special use case that like you if you have a specific use case where you want to change how the consensus works for example you want to have chain where you are like uh reordering transactions in the block you have special order to match for example trace against each other like you you have you have some use for this like you cannot do it without making your own parachute right polkadot allows you to create your own power chain and implement this functionality but you don't have to deal with like okay where do i find like hundreds of millions of dollars that of the state liquidity that will like validate my chain right you don't have to deal with it because you are sharing the validators from the polkard network and this is actually super close because if you want to change the consensus like somewhere else you're basically thought you can relate yes try to convince ether to change the protocol how it works right but if you are owning the protocol you can change it it's actually what's the difference between this what you show and the normal implementation of transactions yeah it's like uh like i said it's like next-generation gas of gas network basically uh it's but it's trying to mimic basically the following eip or like the older eip to basically test this and hopefully push it to the protocol level so it's it's actually extended gsm it's it's not just meta transaction because because you have yeah you have different api basically uh mostly for the like smart contract part like the the interfaces of the of the entry point interfaces of the paymaster how paymaster work like the whole like this whole system it's it's like uh much more general than just a gas station network so you you can do you can do more cool stuff like biggest problem with it is that like it still requires like setup like gas station network like it's not built into the contract uh to do a protocol so it's like kind of complicated to create for example your own wallet contract right and you have to rely on like a functioning uh network of bundlers to to get it i'll ask here there is do you guys know the meta transactions or is there anyone who doesn't know transactions yeah the the key point here uh for it and also for the meta transactions is that you have someone else who is paying for your transaction that's uh with attending ease no no no this is different this is different i know i know about injury right in general no in this case it's paymaster generally meta transaction me somebody else is your pay master but but i didn't actually show the other way around you actually can pay as your wallet itself you don't have to have like the bundler actually uh doesn't have to pay for a transaction like it will it will get it back immediately right so for example if you are withdrawing from the uh withdrawing from the tornado cache the bundler will get it immediately in this one block right so so this is how it's different this is this wasn't like uh you weren't able to do this with gas station network i would bundler is it say that already exists in the protocol or it's a new role that needs to be no this is not part of the protocol it's just like some like coordination of the smart contracts and the bots that are running this on top of the current ether protocol so in order to implement this we would need someone to actually deploy this solution this is already deployed like only only thing you need to do is to create a wallet contract and start using it yeah i'm just trying to understand whether this boundary has conventional issues that that's part of that difference which i was asking for if you use the magic transactions as uh as such we want to implement them besides the contract you actually had to implement also both or basically uh some uh some backend call off chain code which would be collecting those transactions doing the money and interacting with the yeah this is definitely it has the option part as well because it has basically second mempool which is like one of the biggest issues of this solution because obviously with second mempool you have like opportunity for some censorship and stuff like that so i understood that in this case the standard itself actually creates that that they created like a way for the for the economical players to participate on being rebound lawyers and so on that's correct yes and mainly the unified api how you can create a wallet that can interact with this right so so they basically uh this is the this is the most important thing that that that should all also be compatible with with like if this makes it to the like protocol level the wallets should be like like compatible still with it so if you are using this or you you will use the protocol solution it should still work so this is basically you can think about it as like canary network or beta version and like ether validating okay this is something it makes sense to integrate if directly on the protocol level before they do it so uh just to give the example on the meta transactions and also potentially music updates when you transfer like usdc or diary which you mentioned today xbrc20 token when you transfer those you have you have to have a heat for gas and whatever layer you know on the layer one or any other two you like to have the ease for an actual token in this case and a method transaction you don't need to have that that's what you can already experience with the causeway for instance that they are like paying for that transaction but they withdraw it value-wise from from your assets which you are you know handling with that yeah but they have custom solution that is like they have their own mempool they own like off-chain part how they're handling it so this is like something that should work for anyone interacting with the ether it's more standardized and can become more decentralized i would say right oh yeah it's it's currently it's currently like eip 4337 and the original idea comes from eip2938 which will start getting like actually change in solid as well so you would be able to define okay this is the smart contract what so it has like it will it has different like uh functions that that it can implement and stuff like that so uh yeah but like this is two years old this is one year old so it's not getting like five more years but but like you have to imagine like this was i guess it's just three months like this is deployed just three months on the l1 so it was updated like three months ago i guess so it's not it's not that used yet so we need definitely more builders like one of the things i have on my hack list is definitely to create the wallet which has signing mechanism from polkadot actually so our users can go on that like evm para chain and use their own wallet they don't have to create like new metamath wallet they can like already they have wallet from our network so they can just use that on on their network all right so something so it enables uh some stuff for us as well yeah any more questions or we can move to the another break [Applause]
Automatic transcript — names and jargon may be misspelled.