👾 How MEV can be useful for bridges?

Cyber Academy
7 min readJul 27, 2022

--

Alex Shevchenko, CEO of Aurora, MEV from an unexpected perspective at our meetup in Paris. People usually consider MEV as a bad phenomenon that needs to be got rid of. But the developers of Aurora managed to use the exceptional ability of MEV bots to instantly find the necessary transactions. They built a solution for the security of the entire protocol on this.

We made a summary of the main theses of the report. Enjoy!

P.S. You can read this article in Russian here.

What is MEV (Miner Extractable Value)

Ethereum’s miners can change the transaction order in the block, and they are capable of extracting some additional value. There is a specific API developed in a very particular Ethereum node implementation. It gives you an ability to tell people who are searching for opportunities in arbitrage that they can submit to particular API points of the miners. If you are going to put this transaction right after this particular transaction, then the miner will get paid some additional amount of money. And the reason why some people want to submit such transactions is that the first transaction (the transaction they are referring to) creates unbalance in a pool and an arbitrage opportunity.

Imagine a user who is using just a simple DEX, not even an aggregator, for the swap. And he is swapping the size of $1 million of the pool for around $10 million. So he is creating an insane arbitrage opportunity. I recommend reading the article «Ethereum is a dark forest». The key thought in the article is about the fact that there are lots of bots that are constantly monitoring the Ethereum mempool (is a waiting area for the transactions that haven’t been added to a block and are still unconfirmed). And some people can make a lot of money from this.

And all of this is because of MEV. Miners can choose the order of transaction execution and change them like LEGO. Some experts think MEV is bad for the network because it is removing value from the ecosystem. Others say that it’s extremely bad because there is a risk of a sandwich attack on the users. But I can tell you that sometimes MEV can solve some problems from the multichain world.

I am the CEO of the company that builds Aurora protocol. It is an EVM solution, smart contract, and a bridge to Ethereum working on top of Near. Near is a scalable protocol and there was no need to copy already existing consensus. Near’s native runtime is not EVM compatible and people that already developed their solutions for Ethereum are not capable to launch their apps there.

For an ordinary user, Aurora is performed as a separate chain. Aurora has a web3 compatible interface and can connect to existing DeFi tools like Metamask, Etherscan, etc. Our native token is ETH, and we are not forcing people to buy another token in order to operate on our platform. And also, we just launched Aurora+ which helps people to get free transactions.

Multichain story: Rainbow bridge overview

Also, we have developed the Rainbow bridge. The Rainbow Bridge is a trustless, permissionless, and generic protocol for connecting blockchains. And there is no such thing as a validator of the bridge. But there is quite a unique and extremely complicated approach instead. We implemented Near and Ethereum light clients as smart contracts on the opposite chains. From time to time we have some external services that help to keep these light clients synchronized with the main chain. We call these services the «relayers». A relayer takes individual orders and organizes them into an order book to simulate the experience of an exchange without actually being one. Every 14 seconds there is a translation on the Near blockchain where our relayer is taking a freshly generated Ethereum block and sends it to the Ethereum light clients on the Rainbow bridge. And every four hours we are sending the Near blocks to Ethereum. The only thing that the light client does is that it is verifying that the block was created according to the consensus rules of the blockchain.

And now we are ready for the Merge, which means the total change of the consensus, which is a big thing. «Just to do anything» — is the first thing that developers tell anyone. But not for my team. Because we will need to change everything in Rainbow bridge. And the major part of our solution — is the Ethereum light clients on PoW implemented on Near.

There is a nice concept following the light client’s idea. We have the Near node operating inside Ethereum. This means that to break Near you need to break that node as well. This means that you need to break Ethereum.

Signatures, validation, and security

The complicated part of the solution is the Near transactions are super cheap. And we can include in a single transaction the whole verification for the Ethereum block. The cost of the blocks’ relaying is around $2.000 per month if all the Ethereum blocks are relayed to Near. The transactions in the reverse directions are much more complicated. The thing is that the native Near’s cryptography is not Secp but EdDSA25519 signature instead. And Ethereum is not included in the list to precompile for checking this kind of signature. This means that to check the validator’s signature in the Near blockchain — we need to write a smart contract to check this staff which is an extremely complicated approach. It has like 600 lines of code generated by a program and is an assembly code.

But to check the multiple signatures in a single Ethereum block is not an easy task. Even without checks of the signatures, all the other Near transactions require 1.5 m Ethereum gas. One single signature requires an additional 1.5 m. Near has around a hundred validators already so that is why we decided to build Near to Ethereum interaction.

This interaction is Optimistic. Somebody submits a new block to the light client on the Ethereum side. This light client checks everything from this block: validator list, structure, etc. And it assumes that all the signatures are correct, but the block is still kept untrusted. There are outside services that we call the watchdogs which are checking the blocks. And these watchdogs can send some signatures to the additional check. To become a relayer, you need to stake 5 ETH. And if you provided the wrong signature this amount is sent to the watchdog. This is the economical reason to run the watchdog service. This is the design decision we had to take because EIP-665 is not still included in the protocol (vote for this, btw, this stops a lot of good integrations with great blockchains).

Aurora is permissionless. Anyone can become a relayer as there are no limitations and anyone can submit a block you just need to stake 5 ETH. This opens a vector of attack as anyone can fabricate the block and try to take liquidity from the Near and release liquidity on the Ethereum side. We have got an attempt at such an attack at the level of 1.5 b liquidity. He applied to be a relayer in a single transaction and sent the fabricated block to our Near light client. Watchdog immediately spotted this and bots monitoring the pool somehow figured out that they can submit the same transaction from a different address and get 5 ETH to the account. And this transaction was immediately frontrunned. Within seconds the attack was mitigated automatically.

So why we are talking about MEV?

After this attempt to hack we decided to keep the design of this part of the bridge the same but with some renovation — only half of the stack would be sent to the person who submits the challenge transaction. And obviously, we expected this to be the MEV bot. Another half is sent to the person who submitted the frontrunned transaction. And we are capable to find out who it was because usually, these transactions fail pretty fast which means that miners include this transaction in the same block.

Why do we need MEV bot? We could use another solution like applying watchdogs to become watchdogs and submit challenges. But in case of an attack on your permissionless and trustless protocol, the only thing to resist the attack is a quick reaction. In our case, it was four hours window. And the best system that can quickly submit blocks is the MEV bots. They surprisingly turned out to be not only the bad guys.

How to participate

In case you want to participate in Aurora development and if you are using Aurora of Rainbow Bridge you can help to increase the security of the bridge by running a watchdog service. It costs around $5 per month. This script doesn’t require any complicated things. Once in 10 mins it is checking the state of the smart contract of the Near light client on the Ethereum and if the block is correct or not. In case the network somehow can redirect MEV’s income to the users it might be super cool. This is forwarded to the miners in current conditions.

Cyber Academy — образовательная платформа для блокчейн-разработчиков. Присоединяйтесь к нам ✨

Поддержите нас на Gitcoin

Анонсы | Website | Twitter | Телеграм-чат | GitHub | Facebook | Linkedin

--

--

Cyber Academy
Cyber Academy

Written by Cyber Academy

Образовательная платформа для блокчейн-разработчиков

No responses yet