A DEX on Cosmos is working on a way to prevent front running

Quick Take

  • Front running and the extraction of MEV are big problems for decentralized exchanges.
  • The biggest DEX in the Cosmos ecosystem is working on a way to prevent both issues.

Osmosis, a decentralized exchange in the Cosmos ecosystem, is working on a way to prevent front running and the extraction of MEV. The solution is expected to go live in the first half of 2022, according to Osmosis co-founder Sunny Aggarwal.

But to really understand the solution, we need to first take a look at the problem.

What is front running and MEV?

Front running is a particular problem when it comes to decentralized exchanges. 

Since blockchain transactions are broadcast publicly, those keeping watch can see large trades about to happen and then submit their own trades to take advantage of the situation. All they need to do is operate quickly and bid high gas fees to have their trades processed more quickly. 

Another issue is called MEV. This refers to when a miner (usually on behalf of another user) deliberately organises transactions in a block for their own benefit. Since transactions in each block are processed linearly, this gives priority to the first transactions — and can lead to advantages such as front running trades or getting in early on NFT drops.

It’s a big issue. According to the MEV Explore dashboard, $743 million has been extracted in this way on Ethereum — the clear majority of which was for making arbitrage transactions (taking advantage of inefficiencies in the market). 

There are some ways to avoid getting front-run when performing transactions. 

One example is the Eden Network, which incentivizes miners to prioritise the network's transactions. There are ways to submit transactions directly to miners to have them included in blocks without being broadcast to the network first.

While the majority of MEV extraction is happening on Ethereum, the practice is beginning to spread to other chains, including ones within the Cosmos ecosystem. 

“On Osmosis we’ve recently started to see it. Volumes have got to the point where it’s profitable now,” Aggarwal said.

As a result, Osmosis is trying to get ahead of what could be a worsening headache.

Solving the problem of front running

Osmosis has a different approach to solving these issues, one that’s possible because it’s built within the Cosmos ecosystem and is therefore able to dictate how its own blockchain works.

For context: Cosmos is a set of blockchains that are able to talk to one another. Its approach leans toward each application running its own blockchain, enabling greater customization and the ability to manage throughput. Blockchains can choose which consensus mechanism to run, but most use a version of proof of stake (which is fast and provides cheap transactions).

Osmosis’s key idea is to encrypt all transactions until they are finalized on the network. 

This means the miners and other blockchain observers won’t be able to see what the transactions do until they have been made. If it is successful, it could eliminate front running on its blockchain.

The strategy works by encrypting the transactions when they are broadcast to the network. They are decrypted when a block is produced on the network. The decryption key is provided by the two-thirds of validators that are needed to approve the block.

So when the block has been finalized, the transactions will be publicly available but it will be too late for anyone to try and front-run the trades.

Protecting against time bandit attacks

The way that Osmosis works also enables it to protect against front running being done retroactively, something known as a time bandit attack.

This type of attack can work on blockchains that have probabilistic finality, referring to how the end of the blockchain is constantly changing as it looks to find the longest chain. For these blockchains, sometimes a block can appear to be in the chain only to be replaced by another one. 

During a time bandit attack, the last few blocks in a chain are replaced by a longer chain. This allows the miner doing this to front-run any of the transactions in those blocks. It’s a difficult attack to do because it requires a lot of computing power but if the rewards are big enough, then it might be worth attempting.

This attack can affect some proof-of-stake blockchains. For example, while validators may take it in turns to submit blocks, they are not considered final until a certain number of blocks have been approved. Theoretically, some of the blocks could be replaced if a longer chain appeared.

Unlike this approach, Osmosis uses safety-favouring proof of stake, through which all the validators vote on a block and if two-thirds of validators approve it, then the block is considered final. As a result, blocks can’t be reorganized.

This is relevant to MEV because while Osmosis will hide transactions until they’re included in a block — it could have been possible for someone to rewrite the chain for the previous few blocks and front-run the transaction retroactively. 

But since such rewrites are not possible on its blockchain, that option won’t be available either.

© 2023 The Block. All Rights Reserved. This article is provided for informational purposes only. It is not offered or intended to be used as legal, tax, investment, financial, or other advice.