Money Stuff: Crypto Brothers Front-Ran the Front-Runners talks about a fascinating case, with further details in Money Stuff: The Endless Shrimp Investigation under header “ETH consensus”, the linked CoinDesk article: What the DOJ’s First MEV Lawsuit Means for Ethereum, as well as the Flashbots postmortem. Until now, I wasn’t actually aware of how Bitcoin/Ethereum transactions happened, but the article provides a good explanation:

Time in crypto is measured in blocks. Intuitively, people submit orders to do transactions on a crypto blockchain, and then periodically a batch of those transactions is enshrined in the official ledger of that blockchain. In Bitcoin, a block contains roughly 10 minutes’ worth of transactions; in Ethereum, it’s seconds.

So intuitively, Ethereum transactions happen in big simultaneous bunches every 12 seconds. But the bunches can’t really be simultaneous: If there is one rare nonfungible token for sale, and two people want to buy it, only one of them can. One transaction has to be first. So the transactions within a block are ordered; they happen in sequence. But they are not necessarily ordered by time.

How does the blockchain decide which transactions to record, and in what order? In Ethereum, the answer is: with money. […] People can also bid more — a “priority fee” or “tip” — to get their transactions executed quickly. Every 12 seconds, some computer [a validator] on the Ethereum network is selected to record the transactions in a block. […] The block proposer will naturally prioritize the transactions that pay more fees, because then it will get more money.

This mechanism however is what allows generalized front-runners to exist on Ethereum: they see you are trying to do a profitable trade, so they will copy your trade, but bid more, so their trade gets executed instead of yours. In fact, they don’t even need to know if your trade will be profitable: if they see that you are trying to buy an illiquid coin and therefore push up the price, they will front-run you by buying it first, and then selling it to you at an inflated price: the highest price your order will still trade at.

This is a rough environment to trade in! Ethereum is a Dark Forest indeed. But, apparently, all of this is completely legal, insofar as any crypto gets to be legal: by existing in a perpetual gray zone. But yeah, unless you know what you are doing, it doesn’t seem like a good idea to meddle.

Well, as it turns out, two brothers at MIT did know what they were doing, and they managed to front-run the frontrunners by exploiting a bug in the software that block proposers use (MEV-Boost). Now they are facing charges:

Two brothers who studied at MIT were charged with exploiting a weakness in the Ethereum blockchain and stealing $25 million in 12 seconds, in what prosecutors called a first-of-its-kind caper.

Anton Peraire-Bueno, 24, and James Peraire-Bueno, 28, were charged by federal prosecutors in Manhattan with fraud and money laundering offenses. They are accused of carrying out the lightning-fast heist, plotted over the course of months, from their keyboards last year.

“The brothers, who studied computer science and math at one of the most prestigious universities in the world, allegedly used their specialized skills and education to tamper with and manipulate the protocols relied upon by millions of Ethereum users across the globe,” Damian Williams, the US attorney for the Southern District of New York, said in a statement.

The case is very controversial! One might be inclined to read it as “front-running is legal, but front-running the frontrunners is illegal”, but that is not the quite true: my read is that the case is more about hacking: exploiting a behaviour that was not intended or understood in software (i.e. a bug), and using it for financial gain. The scheme was brilliant, and my understanding is that it worked like so:

  1. Buy some shitcoin or another to next to nothing.
  2. Set up your own validator and wait until it’s selected to be the block proposer. Now your own software gets to decide how to order the transactions!
  3. Put a huge transaction to buy the same shitcoin for a hugely inflated price. This will trigger the front-runners: they want to be able to sell you that shitcoin for that ridicolous price!
  4. In order to do that, they will execute what’s called a “sandwich attack”: they will first put an order to buy the coin at its market price, then they put a second order after the victim’s to sell it to them for their inflated price.
  5. The block proposer normally doesn’t get to see what the transactions do. Here is where exploiting bug comes in: it allowed the brothers’s software to circumvent that, and construct a block with full knowledge of the transactions contained therein.
  6. See the transactions of the front-runners, and re-order them so that instead of buying from the market, they buy the coins you bought in step 1 for inflated prices.
  7. Profit?

I’m not exactly clear on how step 6 worked, and the sources I found don’t seem to elaborate.

“If you hope Ethereum will always be a ‘dark forest’ where on-chain predators compete with each other for arbitrage opportunities, then you probably dislike this prosecution,” Consensys General Counsel Bill Hughes told CoinDesk in an interview. “Thankfully, I think there are only a few who are actually like that. If you prefer predatory behavior like this be curtailed, which is the vast majority, then you are likely to feel the opposite.”

“All of the defendants' preparation for the attack and their completely ham-fisted attempts to cover their tracks afterwards, including extensive incriminating google searches, just helps the government prove they intended to steal. All that evidence will look very bad to a jury. I suspect they plead guilty at some point,” he added.

As brilliant as their attack was, the brothers made a major blunder by performing some rather questionable Google searches:

Before they did the trade, Anton Peraire-Bueno allegedly “searched online for cryptocurrency exchanges with limited ‘know your customer’ protocols and ways to launder cryptocurrency, including searches for ‘how to wash crypto’ and ‘cefi exchanges with no kyc.’” And after the trade, as they were allegedly “laundering the fraud proceeds from the Exploit,” James Peraire-Bueno allegedly “searched online for, among other things, ‘money laundering,’ ‘exploit,’ ‘computer fraud abuse act,’ and ‘does the united states extradite to [foreign country].’”

The Justice Department, reasonably, cites these searches as evidence of a guilty conscience. Also though I wonder how well they worked? Like, has anyone ever (1) acquired $25 million of ill-gotten money, (2) googled “money laundering” and (3) successfully used to results to launder the money?

I think that is hilarious, but also a bit strange. You would think that somebody being able to plan and execute such a sophisticated attack would know better than to Google such terms. But that’s probably not fair: software hacking and finance are both commonly viewed as games of a sort: you get to make a lot of money by solving very complicated puzzles. And the ability to solve puzzles well does not necessarily correlate with having the wisdom to understand how and when you can do that.

Nonetheless, the case is highly controversial. As Matt Lavine put it:

But to me what is wild about this case is that the Justice Department is bringing down the full weight of US federal criminal law to protect Ethereum front-running bots. The word “front-run” is right there in the indictment! The Justice Department has a long history of prosecuting people for front-running! Because it is traditionally a crime!

But here! I mean! Ethereum and its decentralized exchanges have a market structure that is like “bots can look at your transactions and front-run them if that’s profitable.” And these guys, allegedly, front-ran the front-runners; they turned the market structure around so that they could get an early look at the front-running bots’ front-running transactions and front-run them instead. By hacking, sure, sure, it’s bad. But it leaves the Justice Department in the odd position of saying that the integrity of crypto front-running is important and must be defended.

Or, as an anonymous researcher has said a bit less delicately:

It’s a little hard to sympathize with MEV bots and block builders getting f-cked over by block proposers, in the exact same way they are f-cking over end users.

Yeeeeeahh. The USA DOJ is in a weird place here, and I do not understand the point of them bringing this case. Do they really have nothing better to do?