Decentralized Block Building

ETHCC 7 · 10 Jul 2024 · 20:20

Shay Ketsdever, who leads Layer One product at Flashbots, argues that the ideal block builder must be fast, private and decentralized, a MEV trilemma that has lacked a full solution. He reviews MEV-Geth, MEV-Boost and MEV-Share, then proposes trusted execution environments (TEEs) as the answer. He says Flashbots open-sourced a Rust builder that builds blocks in about 100 milliseconds, including inside TEEs, and that production TEE builders performed on par once latency was accounted for. He also describes second-price refunds for all submitters and a roadmap toward decentralization and rollup sequencing.

Speakers

Topics

From ETHCC 7, hosted by Ethereum France.

Transcript

Hi everyone, my name is Shay Ketzdever, and I lead Layer One product at FlashBots. For those of you who don't know us, we're a research and development organization focused on MEV. And I'm excited to be here today to share with you some updates about MEV and block building on Ethereum. And I want to talk about a few things. First, why block building is key to creating great crypto apps and great financial outcomes for everyone who uses Ethereum. But there's a trilemma in MEV, which is that to get those outcomes, we need a block builder that's both fast, private, and decentralized.

And it's very clear to me that a builder with these properties is the end game, but for years it's been a major trilemma as to how we can actually get all three of these properties at once. And I want to show you the next generation block builder that we think will be created with this, and in fact, that we're already building today. So three years ago, we introduced the first block building product, MevGeth, which created a marketplace where any miner and searcher could extract MEV.

And this had a couple benefits. It reduced spam on Ethereum because competition moved out of the mempool, which reduced fees for everybody. And it also unlocked new use cases like bundles. Soon after MevGeth, we introduced a private RPC for ordinary users to protect them from front running and avoid paying for failed transactions. And again, this lowered costs for users and unlocked very useful new features like free reverts for more people. Two years ago, we introduced MevBoost, which allowed validators to outsource their entire block to a market of block builders, and this created both more profitable blocks for validators and also enabled more creative features that leverage the full block. Finally, this year or last year, we introduced Mev Share, which allowed users to auction off their transactions in exchange for a refund.

And this again created more value for users because they were refunded, more profitable blocks for validators because it created new bundle types. And it also unlocked a whole wave of new features for users and for apps. So there are tons of refund products out there today. So really I think the TLDR is this. Block builders let us build both better experiences and also capture more value either by reducing fees or improving profit. And if you look today, I think you'll find that many of the experiences and applications that we want to build in crypto actually rely on block builders. They're the back end for the transacting experience.

But what makes a great block builder that can support these things? It gives you both great UX and maximal value. It's clear to me that the ultimate block builder will have three properties. It will be fast, meaning it's performant, it lands transactions very quickly on chain. It'll be private, meaning it keeps sensitive data from being leaked or being front-run. And it'll be decentralized, meaning no one party controls the system, so everyone can rely on it to treat them fairly. And I'm gonna break each of these down in a bit more detail.

First is speed. The optimal builder is fast. I mean this both in terms of UX and also from a performance standpoint. So from a UX standpoint, a great builder should obviously land transactions as quickly as possible on chain. This is key to making crypto apps usable. You all probably know that. There are also, though, more sophisticated actors like searchers who require a lot of simulation. And faster that builders can perform those simulations, the faster searchers can respond to price signals, which makes their bundles and therefore the block a lot more valuable. Which brings me to the other thing that we want, which is decentralization.

Now I would argue that a decentralized builder will actually produce higher value blocks than a centralized one. And this is why decentralization, or at least one of the main reasons it's really important for block building. And there are a couple of reasons for that. There are very clear economies of scale in block building. So having more order flow tends to result in higher value blocks. This is because value in block building actually increases combinatorially, not linearly. Because bundles can interact with each other and merge in interesting ways that actually create more value than the sum of the individual parts. And a decentralized builder would be able to actually maximize this economy of scale because it allows otherwise competitive parties to collaborate with each other.

So a classic example here might be you have top trading firms that run their own block builders, and they don't trust the block builder that the other trading firm runs because maybe it would censor their transactions or not treat their cancellations correctly, but they could actually both trust a decentralized builder that neither of them fully controls. And what this means is that a decentralized builder will actually capture more flow from both trading firms and more emergent value from the interactions between their flow. In addition to producing more value in each block, I also think that decentralization ensures a builder will stay incentive-aligned with its users over time.

It prevents the builder from censoring transactions, and censorship tends to reduce the value of your blocks if you have fewer transactions to choose from. It also can help prevent rent seeking, which takes value out of the pockets of users and validators. Privacy is essential in block building, it actually has financial value. If you leak that you're gonna make a trade, somebody can front-run you and cause you to be executed at a worse price.

And this is especially important because many of the useful features that we want builders to provide might actually not be incentive-compatible for the operator of that block builder to do. So without privacy, searchers could be unbundled. Refund bundles might actually be deprioritized because a different version would be more valuable for the builder to include. And this is true both in the pre-trade case, you know, before a transaction lands on chain, but also in the failed trade case, where transactions never land on chain. We don't want builders to learn or leak information about failed transactions because those transactions could actually contain alpha about searching strategies, for example.

And if those strategies get leaked, then other people might use that information to compete and reduce profit for the original searcher. So this is the MEV trilemma, which is that we can't optimize for all three of speed, privacy, and decentralization at the same time. All we really have today are partial solutions. So you know, centralized builders today are fast and private, but obviously not decentralized. The public mempool is also reasonably fast and obviously decentralized, but it's not private, which means that users might get front-run and start fragmenting their transactions to other private mempools. And finally, I think cryptographic privacy could actually solve this, but today it's unfortunately not performant enough for MEV use cases where basically every single millisecond counts.

So certain cryptographic techniques just actually aren't applicable either. And so this is where we stand today. There is no fast private decentralized builder. Trusting, the best alternative we have is trust, so like trusting a centralized builder to keep your transactions private. But unfortunately, obviously, trust does not scale. So it requires side deals, monitoring, enforcement, and this all causes a bunch of fragmentation where you basically have different order flow going to different block builders, which we know because value in block building increases combinatorially, this just reduces block value. And it also, I would I would point out creates a very inconsistent UX.

So you have users who now can't actually rely on a feature being available in every block, because not every builder might support it. I would say that solving this is the problem to solve in MEV. And that's what we've been focused on for the last two, three years at Flashbots, which is studying and testing different technologies to create a block builder that everyone can trust, or actually, to be more precise, that nobody has to trust. And we think there's something that can work, which is trusted execution environments. Now, if you're not familiar with trusted execution environments, the TLDR is that hardware manufacturers like Intel have manufacture machines that have very strong privacy and integrity guarantees.

And they give you a few things. You can encrypt data to an enclave on the machine, and that data can't be leaked even to the person operating the machine. You can also attest that a very specific piece of public code and only that code is running. And together these things mean that anyone can run this software without compromising on security. So a trading firm could send their bundles to a TEE run by another trading firm and not worry that they're going to treat them differently. And also that other firm can't see your unlanded trades and try to train its models on them or something.

This is quite cool. And together, these things unlock something else, which is that we can get lots of people to spin up lots of these nodes. You could have a distributed network of TEEs, which are co-located with every important trading signal, every important validator. And this gives us architectural decentralization. So there's no longer a single point of failure. But can you run block building in this? Specifically, is it fast enough? So we tried that actually.

This is the Flashbots Rust builder. It's a new block builder. We just open sourced it last week. It's written in Rust and it's very fast, so it builds blocks as these charts show in about 100 milliseconds. And it's also gonna be really fast when we get some other things like the state root down. But we basically wanted to know if you took this builder, this fast builder, and you put it in TEEs, would it still be fast? So we did that. And it was. It built blocks in about sub 100 milliseconds. So once we saw this, we thought, wow, okay, that's that's interesting.

But benchmarks are pretty easy to game. Uh we don't really trust these. So you know what? Let's let's actually try this for real. Let's run half of our production builders in TEEs. So we did that. And they started landing about half as many blocks as the normal builders did. So this is a screenshot, I think, from April. And it's actually quite surprising because as it turns out, our TDX builders are in a different data center. Uh, so there's a huge latency penalty for us to send them bundles. And that discrepancy is a little bit more apparent if you look at more recent market share. Uh, but what's very interesting is when we normalize for that, we find that they're actually on par.

So you can run block building and trusted hardware at near native performance, and we're doing it today. This is pretty cool. With a builder like this that builds blocks in sub 100 milliseconds, you can deliver the experience that even some of the most sophisticated and demanding use cases like stat arb searching need. A really important part of this that I also want to highlight is that the code itself is open source. So if you have a feature that you really want to see, you can just ship it. And we're not just open sourcing this as a reference implementation if you're familiar with the FlashBots geth builder.

We are actually going to be very active in improving it and incorporating new features. So please make PRs. And for that reason, I just highlighted a couple things, but our builder comes with a bunch of testing tools and synthetic data and things to get you started. So it's built not only to be really fast, but also to be very contributor-friendly and modular. But I also call this out because the combination of public code and TEEs is quite powerful because we can actually attest to the code that's running in the TEE. So if you submit a contribution today to R Builder, you can prove that it's running in prod on one of our TEE builders.

And likewise, if you submit bundles to it, you can check exactly which version of the repo is running in the builder. And I say you can do this because we have a attested TLS connection to one of our TEE builders right now. And there's actually gonna be a demo on that later this week. All of this is pretty cool because for the first time, the statement actually is true. If you send to this attested TE builder, not even Flashbots can see your bundle data. It's encrypted in transit. When it's in the TEE, we can't see what's happening, and the only point when it's revealed is when it has to be sent to a relay, which is quite cool.

Altogether, these things create a very credible auctioneer. You know, the T operators can't tamper with your transactions, they can't selectively include or exclude or censor transactions because they don't actually know what's in them. And they must execute the rules of the auction as stated. Specifically, at Flashbots, we think that the optimal MEV auction for blocks today is second price, where users are refunded, so they only pay the second best bid for, say, a piece of state that they're competing for. And we think this type of auction is quite sound because it encourages everyone to bid their true value.

And it also removes the incentive for people to deviate through side deals or side channels. And what's very cool with the credible auctioneer that we get with a TE builder is that we can actually enforce a second price MEV auction. So as of this week, we're giving refunds to everyone who submits to Flashbots. If we could include you at a lower price, you'll get a share of our builder's profits. And this is very simple, it happens automatically for all bundles and transactions, it doesn't change how they're executed, and it doesn't take any extra steps. You don't have to do anything.

We just sort of build blocks as usual, and after the fact, we calculate if you are due a refund. And there are two things that I think are particularly notable about this refund product. The first thing is that refunds are applied to everybody without restriction. There's no whitelist, there's no special rules. We just use one rule to calculate what we think is a fair second price for every transaction, and the profits get split proportionally amongst the people who contributed the most in the block. And this has a really nice property, actually, which is incentive alignment. So in order to grow your own slice of refund, you have to grow the whole pie of profit for everybody else.

I also want to call out briefly, there's no trade-off here actually between refunds and speed. We will multiplex your transaction to other builders if FlashBots doesn't win the block, so you can always be sure that you're going to get included. I said there are two things I wanted to call out. And in addition to being permissionless, the second thing I want to call out is that these refunds are also transparent and can be made secure in TEEs. So the definition and implementation of our refund rule is open source today. This is a screenshot from the FlashBots docs.

And this means that the refunds can actually be run verifiably in a TEE. So not only is there no way for us to tamper with transactions or the TEE operator in the permissionless setting, there's also no way to tamper with the refunds themselves. The TEE builder can't favor one searcher or seek rent because it actually can't change the code without invalidating its own attestation. And you can see that permissionlessly if it's if it's been validated. So this is our problem statement from earlier. Looking back on this, I think we have a path forward now, which is a performant builder that's secure and incentive aligned for everyone, where that incentive alignment is actually enshrined in the builder and verifiable through open source code and TE attestations.

And I would contend this this solves the MEV trilemma. We can get speed, privacy, and decentralization with block building in TEEs, which is pretty cool. So now that we have this open source performant incentive aligned TE builder, that's a mouthful. I want to talk about the things that we can do with it. Because we're actually building this builder right now at Flashbots, and you can use it today. So for the rest of this talk, I want to look ahead at where we are today, where we're going, and especially I want to call out all the ways that we hope to work with the community to research and develop this next phase of block building. So to recap, this is where we are today.

We have a TEE builder with near native performance that gives refunds. And this is where we want to go next. We want the builder to become architecturally, sorry, architecturally and politically decentralized. We want the TEE builder and TE proofs to be used to reduce trust in other parts of the MEV supply chain. And we use want to use this same modular system to sequence roll ups too. If we get here, I think we'll have not only an optimal block building solution on Ethereum, but also a dramatically improved MEV supply chain in general, with fewer trusted parties. And this will be not only on L1, but also on every roll-up.

So this is very ambitious, and our roadmap reflects that. I've written here a few of the main goals that we want to hit to take us from where we are today to where we want to be tomorrow. And I'm not going to go into detail about all of these because frankly they could each be their own talk. But feel free to screenshot the slide if you want to. And we'll also be talking more about each of these topics throughout the rest of the week at ECC, as well as in an ongoing fashion through our public research forum, and as I showed before, the open source Rust Builder code base. So on that note, I'm going to end by inviting you to join us in this very ambitious open source project.

I think if block building is more than the sum of its parts, then so is the overall project of MEV. And if you're interested, you can join us here. Thank you.

Related talks