flashbots / pm

Everything there is to know about Flashbots
2.53k stars 273 forks source link

Using flashbots as a backdoor path to account abstraction #24

Open vbuterin opened 3 years ago

vbuterin commented 3 years ago

One of the long-running desires of many in the Ethereum protocol community is to add some form of account abstraction. Account abstraction (see also: this video where I talk about the concept) is the idea that instead of every transaction needing to start from an "externally-owned account" (EOA) controlled by a private key, transactions could start directly from contracts (and EOAs could eventually even be deprecated entirely).

There are many use cases for this: smart contract wallets (eg. see here where I make the case for social recovery wallets), privacy-preserving tools like Tornado Cash, etc. Today, smart contract wallets are difficult to use because a transaction must start from an EOA, and the EOA must pay the gas fees, so someone using a smart contract wallet must have some of their ETH in an EOA to pay for gas, adding significant complexity (and wasted gas). Centralized relayers can mitigate this to some extent, but some inefficiency ultimately still remains.

Flashbots can solve this! Flashbots is basically a very powerful and more efficient generalized and decentralized relayer protocol, and it should be possible to build a plugin to turn it into a relayer for smart contract wallets:

There is a lot of room for creativity in what those verification rules could be. One simple option is to check for four conditions:

  1. The fee is sufficiently high
  2. The contract wallet fits a template that shows that it can accept the encoding
  3. The contract has enough funds to pay the fee
  4. If you execute the contract, the execution gets past the signature verification stage

Another option is more limited but simpler: if the total gaslimit is low enough (eg. under 400000?), the system could simply check that the block.coinbase's balance increases by a sufficient amount during transaction execution. This could allow the privacy-preserving use cases as well as smart contract wallet creation.

This could give us most of the benefits of account abstraction without needing to make deep changes to the Ethereum protocol itself (eg. EIP 2938), and so it seems worth making a serious effort to explore and implement.

PhiMarHal commented 3 years ago

the idea that _ every transaction needing to start from an "externally-owned account" (EOA) controlled by a private key,

This might be missing "instead of" or "rather than".

vbuterin commented 3 years ago

Thanks! Fixed.

adietrichs commented 3 years ago

Ah, really interesting! Most of our work on EIP-2938 was on creating the mempool rules for identifying "safe" transactions. I think those could potentially be adapted to this new use case. In addition to these safe rules, flashbot relayers could also offer to accept packages with more complex payment behaviour, similar to the general MEV case.

zhous commented 3 years ago

Wow, so everyone owns a machine gun! That's an incredible excited spectacle!

Multimyst commented 3 years ago

Wow,This is a brand new attempt!

amanusk commented 3 years ago

Some thoughts on this since I had a very similar idea. Basically described here: https://twitter.com/amanusk_/status/1370642493621080071

The interesting part for me was that by using flashbots, no extra contracts were needed. This means that anyone can be the relayer, including the EOA itself that had no ETH.

This solution has downsides. In this simple scenario, the bundle had to be executed to its completion, otherwise, the account would not have enough ETH to cover the costs of the transaction. If a third-party relayer (with ETH) would have sent the bundle on behalf of the EOA, the miner could theoretically only mine the Tx that pays them, without doing all the actual work. This must be taken into consideration, even if currently miners execute bundles as-is. (Edit: it is also true that Txs in this case could only execute in-order because of the nonce, but it is still true that this would not have been the case if a third party executed these on the EOA's behalf)

Wrapping and executing the bundle in a smart contract wallet, and only paying the block.coinbase would solve this, but solutions similar to that already exist (e.g. any.sender -> ITX)

Another limitation here that is currently in place is that there is currently only one bundle in each block. "Regular" txs would find it hard to compete with other bots that use the bundles to extract MEV (e.g. by sandwiching DEX trades). This can make more sense once multiple independent bundle can be included in each block. Correct and fair ordering of bundles in a block is an interesting problem to solve.

ErikBjare commented 3 years ago

How is this affected by EIP-1559? Specifically what @koeppelmann mentioned here: https://twitter.com/koeppelmann/status/1381922898617757696

livingrock7 commented 3 years ago

If a third-party relayer (with ETH) would have sent the bundle on behalf of the EOA, the miner could theoretically only mine the Tx that pays them, without doing all the actual work. This must be taken into consideration, even if currently miners execute bundles as-is.

@amanusk can you elaborate more on this Also, could you pay to particular pool address instead of block.coinbase and relay bundles to them?

sidutta commented 3 years ago

If a third-party relayer (with ETH) would have sent the bundle on behalf of the EOA, the miner could theoretically only mine the Tx that pays them, without doing all the actual work. This must be taken into consideration, even if currently miners execute bundles as-is.

@amanusk can you elaborate more on this Also, could you pay to particular pool address instead of block.coinbase and relay bundles to them?

A bundle is a set of txns. If the miner bribe comes from a 3rd party relayer with its txn nonce not being dependent on the rest, a miner can only execute the bribe txn while dropping the rest of the txns in the bundle.