Why smart contract wallets are the future with EIP-4337 and Account Abstraction -@kristofgazso
ETHDubai 2022 · 31 Mar 2022 · 25:08
Kristof Gazso explains why smart-contract wallets need account abstraction and how EIP-4337 can support it without consensus-level changes. The talk explores allowing smart contracts to initiate transactions.
Speakers
Topics
From ETHDubai 2022, hosted by DeFi Dubai.
Transcript
hey guys um so yeah i'm going to be presenting today about why smart contract walls are the future with eip-4337 so as a little teaser um i as mentioned before i'm working in another mind i'm a core developer and you all probably realize what this is right this is a board ape oh almost not a crypto funk a board ape but something i've been seeing recently with these board apes is the following right so as you guys can see it quite
often happens that these board games get stolen it's important to realize though that they don't get stolen because of some problem in the efferent protocol rather they get stolen because of phishing attacks so the problem is with the ux of ethereum i don't think it should be this easy to lose four hundred thousand dollars right just entering your seat phrase and seeing it go away in a flash so this is kind of the motivation of this talk right i'm going to be talking about why eoas suck why smart contract waltz are better the current problems with smart contract waltz and how our eip eip 4337 tries to solve this so
first of all what are smart contract wallets this is a seat phrase and this is what controls your smart contract wallet well to be specific the private key derived from the seat phrase does and while this is cryptographically incredibly secure there are still major problems instead of talking about it for a few minutes i'm just going to let you read this amazing skcd so as you can see the problem is with the humans it's not with the cryptography we shouldn't expect the next financial system to rely on people storing their life savings on 12 words on a piece of paper
another problem with eoa accounts is their signature scheme while ecds8 doesn't have any major problems by itself it's quite restrictive right in ethereum you can only use the signature scheme for eoa signatures nothing else even though there have already been developed quite a few better alternatives so eos suck we've established that but why are smart contract walls better well first of all their signature schemes are a lot more flexible so an example of a smart contract wallet team is a multi-sig right imagine that you have say three keys that allow you to control your wallet but you need two of them to actually
interact with it so say if you hold one of the keys and someone finds it you fall for a phishing attack they just have that one key and they can't do anything with it by itself another example is social recovery wallets what this means is that you have one central controlling key that can do basic functions in your smart contract world but it's time limited and it can be replaced by a set of guardians right so if say you lose your controlling key for the smart contract world you can go to your guardians and request them to replace it for you okay so while smart contract wallets are amazing
they have some issues the biggest of all probably for the average efferent user is the gas cost you pay a very high gas overhead for using smart contract vaults and we really shouldn't expect the average ethereum user to be willing to pay 50 60 70 extra dollars for a simple trade a simple transfer another problem which is kind of the main focus of this presentation is the following all smart contract walls on ethereum right now have to be relayed with an eoa all efferent transactions must be initiated with these eoa accounts and this is a problem this means that if you want to interact
with your smart contract world you either have to maintain a separate eoa filled with some if to be able to transact or you can rely on some separate relayer service so for example argent one of the walled providers they maintain their separate relay mechanism where if you want to make a transaction using your argent world they will use one of their own relayers and call your award for you now there's a problem with this which is that each dap right now needs to develop their own relayer mechanism if they want to use it and it's quite centralized because if it goes down for whatever reason it's going to be incredibly difficult to transact with your wallets this is what account abstraction tries
to solve account abstraction has to do with trying to get rid of the requirement for eoas to initiate transactions so how does eip 4537 help us get there this eip is called account abstraction via entry point contract specification well this means nothing so let's explain what actually happens with this before we get into that this is a collaboration between us here nethermind opengsn um with help from vitalik as well so the way this proposal works is that it introduces the concept of user operations these are sort of pseudo transactions that allow you to encode whatever you want to do with your wallet
similarly to transactions these user operations get created by the user willing to use their wallet and these users are going to send it to a special user operation pool that lives above the normal transaction pool this is going to be validated and then broadcast over p2p like normal transactions then it's going to be picked up by entities called bundlers these bundlers can be anyone they can be miners they can be any researchers um they can be you as well these bundles are going to take these user operations they're going to bundle them into one transaction vanilla ethereum transaction and include them in an ethereum block like any other
transaction so an important thing to note is that the way bundling happens is that these bundlers route these user operations for a special entry point smart contract now how does this actually work so the bundler has their user operations they call a special handle ops function in this contract what it does is it goes through every single user operation that's being bundled and it calls a special validate user up function in the world contract what this does is that it allows the walls to verify the signature of these operation it is probably going to implement some nonce mechanism and very importantly
it's going to compensate the bundler for having bundled these operations after it's gone through the validation for every single user operation it's going to execute them one by one but with this eip we also introduced a special new capability as well pay masters so instead of having uh to rely on your wallet paying each every single time you can have your user operations sponsored by a paymaster with this flow what would happen is that first the signature would be verified by the world contract but it would not pay instead a stake would be deducted from the paymaster and it would be relied on to
pay for the transaction for user operation afterwards the user operation gets executed like any other and then a special accounting function called post op is called on the pay master so if you want to actually implement this interface what do you do well in your wallet you have the validate user up function this takes in a user operation the request id which is kind of like a hash of the operation and the required pre-fund what you're probably going to want to do is validate the signature in whatever way you want important to note is that you can do any signature validation right an example here is ecdsa like with normal eoas but you can use any verification that you want next you're going to increment the nonce and
then transfer the required if to the bundler okay when this validation happens um then we're gonna go back to the entry point and it's gonna after a while call the vault again specifically it's gonna call the exec from entry point function and here you can encode whatever you want you can include uh multiple uh batched operations basically just up to the wall what it wants to do if you want to include a paymaster then it's slightly different as well the paymaster is going to have to write a validate paymasteruserop function this simply decides whether you act whether paymaster actually wants to
sponsor the operation or not if you don't want to you just revert if you do you let it happen and you don't do anything special and finally the post op would take care of any extra accounting so in the case of the tokenpay master as you can see here we're checking we're allowing the walls to pay with special tokens so in this case for a valid payment user would check whether whether the user has enough of the tokens and the post off would deduct and sort the tokens for if and pay the bundler with that so why is this good why does this solve the problems that we've outlined before well most importantly i think
we get account abstraction now as antscar mentioned in his previous talk um there are lots of eips that are going to be included in the future forks and there's very little space to play around with these sorts of utility eips this means that since this eip doesn't require a consensus consensus change no hard work required we can include it right now without having to rely on core developers to implement the proposal we're going to incentivize smart contract vault adoption um as mentioned before eoas suck right so the more ux benefits we can bring to
smart contract worlds the better and we believe that this proposal is going to allow for lots of amazing composability following on on that point this provides a universal and widespread interface what this means is that special dapps can now make their own paymasters and they can interact seamlessly with um with walls that implement the interface as well this means lots of sponsoring lots of cool new use cases for ethereum users custom signature schemes as mentioned before whatever you can code in solidity to verify the signature it can work right so instead of relying on ecdsa we can already rely on more amazing signature schemes like bls or
even post quantum safe ones like for example lanport or winternets paymasters so paymasters are remember are the things that sponsor user operations they allow for lots of cool use cases as shown before you can pay with tokens instead of eve if you use paymasters you can also withdraw privately from zk mixers so tornado cache right now relies on their own relay system to allow you to withdraw anonymously but they are looking to move away from that as well and this is a great mechanism for that you can do a very wacky use case as well like paying off chain with a credit card
so imagine that you have a pay master which holds a special private key behind some cloud server and if you go through their stripe api and pay for the user operation they'd be willing to sponsor your operation for you right so you won't even need to hold any tokens or let alone if to transact on a failure this would be very useful for interfacing more with the current financial system as well since we're working with smart contract wallets we can do multi-operations so right now if you want to do a uni-swap swap you need to first approve in one transaction and then do the transfer and swap in the other transaction right
this is quite ux unfriendly friendly as we know um so if we use smart contract wallets this all goes away decentralized so since user operations are propagated using a p2p layer there's no one central entity that's required and that's trusted for this to work right it's it's quite in line with the ideals of ethereum and we quite like that because of that incentive aligned so bundlers important to note they get compensated for bundling user operations on chain what this means is that we don't actually need minor support initially to make this proposal
work instead we can just rely on mev searchers to take care of most of the work right so as we all know if you've been to the flashball searcher discord channel they will devour any sort of profitable opportunity the moment it gets there so they're quite reliable when it comes to working in their own self-interest so you know they're going to be good tools for this following on from the previous point it's very possible to do a slow rollout on ethereum mainnet miners are very hesitant to adopt new changes to their client architecture so we wouldn't expect them to adopt this mempool logic and all this p2p logic initially
um instead as mentioned before we can get started with this proposal on mainnet with meb searchers and then as miners see that oh wow this is actually pretty cool and we should use this because we can make money it's still going to work future proof ethereum there's a vision in ethereum to move away from eoa walls eventually as mentioned before they're very restrictive you need to pay with eve you need to use ecdsa and smart contract walls have kind of been in the vision of ethereum from the start this eip provides a very good stepping stone for that so imagine eventually if we replace all currently used eoa accounts with a
default upgradable smart contract well that eventual smart contract could follow the interface of this eip and be incredibly composable from day one from its launch so this has been a lot of talk about this eip but let's actually give an example of how you might use it say you have 1 000 die in your total cash and this is what you want to pay with your transaction for you have your wallet which has 10 000 usdc and you want to swap it for a uni on uni swap okay so you craft user operation and you send it to one of the compatible nodes right it gets propagated using p2p and the bundler picks it up sees that it's
profitable and wants to include it on chain great so they're going to call the entry point smart contract and this is going to validate first of all that the signature is correct and that the tornado cash is willing to pay for the transaction great so now it's going to execute the wallet rip it's going to execute the wallet now your wallet is going to do its swap as it would it might first approve the transaction and then it's going to swap using uni swap as you would normally then we see that this has worked we did what we wanted to do we swapped usdc for uni now remember we have to pay the
bundler for having included this user operation on chain okay so the entry point calls tornado cache and the paymaster and it's going to do another uni swap swap to swap die for if which is what the bundler so we're going to get back if and we're going to transfer back to the entry point which is going to compensate the bundler for their actions if you think about this this is like 10 or more separate operations if you wanted to do this with eoas it would take you a lot of gas and a really bad ux experience so this is kind of
trying to show how much of an improvement smart contract walls can give to the average firm user but what is the state of the eip right now well the eip has two main parts right it has the entry point contract first so the entry point contract already built opengsn has done an amazing job with that and it's currently undergoing all this by open zeppelin which should finish this week or next already we're launching on mainnet straight after we also want some software to support the bundling of user operations and the mempool behavior that we mentioned previously so here at nethermind we've been working on supporting this aip for our nethermine client and for geth as well
we have already built that and our gurley validator is already bundling user operations as we speak so you can already test out this proposal right now okay so we've talked about why eoa suck why smart contract wallets are better the problems with smart contract wallets and how eip437 solves these problems so what can you do well if you're a smart contract walt dev consider trying to adopt this proposal and making your wallet compatible already with these interfaces if you're adaptive and you want to sponsor users transactions consider making a paymaster which suits your use
case for example you could make it so that the first 10 transactions that a user does with your dap get sponsored by you or you could make it so that and they get sponsored if they hold enough of your special token or if they have if they stake some nft with you there's lots of use cases it's very custom because it's all written in solidity if you're tooling dev consider trying to implement some of the verification and mempool logic that we've developed in your libraries and finally if you're an ethereum user consider trying to pressure our friends over here at metamasks and metamask and other wall providers to start adopting smart contract wallet designs
and also consider switching to smart contract worlds yourself you might think that there's this extra cost that you're gonna have to pay but in the long run if you hold any significant amount of funds in your wallet it's going to be worth it you don't want to end up like the people that i've portrayed at the start with their board apes that have been lost so we're hiring nevermind if you're interested in this sort of stuff we'd love to have you interview and yeah i'm going to open up to any questions thanks all right so if you guys can uh stand up and raise your hand if you have
questions regarding the entry point contract who deploys that or like regarding the entry point contract like who deploys that or will there be only one entry point contract or multiple great questions so the entry point contract is going to be a singleton we expect that there's only going to be one deployed on any specific chain at the time because this results in better network effects for users right since all smart contract wallets are going to be specific to a specific entry point we want kind of composability with that right hello thank you for the application uh i have a question about the security issue so if i was a double developer and then would like to use the entry point to sponsor
my users then uh so in that case um however than some malicious people and just create some dummy or utilize um you know applications and to for example join the drink some tokens or drink some sponsor tokens from this so you mentioned the security issue but i didn't quite catch what specifically you were referring to yeah yes uh like the uh civil resistance uh civil resistance okay um
so that that isn't that big of an issue right because um like if you want to i'm not sure quite what you mean with that right because what what happens with this is that you would make your user operation specific to one wallet and one paymaster if you choose to use one there's no real civil resistance we have several security mechanisms that we put in place to stop dos attacks especially during the validation phase of the entry point call but when it comes to simple resistance there i can't think of anything that might be of concern hello
so what do you think are the incentives for big wallets like argent or genosis to adopt this proposal instead of running their own uh relayers because in this proposal you need to pay an extra like transaction fee to the to the people that are including the the transactions in the entry point so what is the benefit of argent for example to to include this vip okay so one is more resilience right if they're maintaining their own relay or system that's very risky for them and second of all maybe more importantly it's the composability right composability with other walls and especially with paymasters if
if arjun ever wants their user operation user operations to be sponsored or then they're going to have to adopt the interface and this is quite a good ux bonus for the users i have a question on the scalability or at least the increase in inefficiency in these bundled transactions is there actually does it take less gas to make these cut more complex operations than doing them independently okay so you ask about the scalability of bonding multiple user operations yeah good question so right now the overhead per op is 26 000 gas but there's also 28 000 shared gas
in the whole bundling operation right so um this shared gas would be divided by as many user operations as are bundled by the bundler so there's a very good incentive for for users and for bundlers to try and bundle as many as they can into one batch who else had a question are you for a regular ethereum user what are some sample smart control wallets that one can try today oh it's louder and clearer okay what are some of the smart contract wallets a regular ethereum user can try today what are some smart contracts what are we trying to uh smart contract wallets
that we can try today in case i want to try some of these what should i look for i'm not sure i understand what smart contract wallets exist yes right now that you could um play around with to oh yeah with this yeah so none yet right because we haven't completed our audits but um people like argent and gnosis safe they're already hacking um on proof of concepts with um this erc so um you're probably gonna see some soon okay that's all the time we have for questions right now um in a few minutes we're gonna have another speaker up so we're gonna change over and yeah just wait a few minutes thank you very much give him a hand please you