What MEV is
MEV (maximal extractable value) is profit made by controlling the order of transactions in a block. Typically a bot places its own trades just before and just after someone else's.
Staking sandwich attack
Staking TAO into a subnet swaps it for that subnet's alpha through a pool, and a big stake pushes the alpha price up. A sandwich bot stakes just before you and unstakes just after you, in the same block. It pockets the price move your stake caused, and you get a little less alpha.
To do that, the bot has to get its first trade in ahead of yours.
The Sandwich attack (now blocked)
Here's one such attack, which the taostats research team uncovered. We provided this vector to the chain developers through private channels, and the developers moved quickly to shut down this vector.
Step 1: get in line every block
Every block, the bot sent a call to its own smart contract. That call didn't say what to trade. When it ran, it first checked for instructions. Because it was sent early, it sat near the front of the queue.
The operator watched pending transactions. Most blocks had nothing worth attacking, so it sent nothing else. The contract call ran, found no instructions and did nothing.
When the operator saw a trade it could sandwich, it sent a second transaction from a separate signal wallet. That transaction called set_heap_pages, which only the chain's admin is allowed to use, so it always failed.
But failure was the point. The bot only cared about the tip that was included in the call, not the call itself. A failed transaction still pays its fee and tip. The tip amount was a code that said what to do (stake or unstake), which subnet, and which size from a fixed list of stakes. The code was scrambled with a key that changed every block, so you couldn't read it just by looking at the tips.
Before release 492, set_heap_pages counted as an "Operational" call. That class gets top priority, so the failed signal executed before the waiting contract call, even though it was sent later.
The wallet that sent the call had the transaction fee, and the tip balance removed from it's account balance.
When the contract call ran, it checked how much the signal wallet's balance had dropped. Take away the known fee and what's left is the tip, which gives the order. (We include how the tip was decoded in the deep dive at the end of this article.) The contract has two options:
Stake into the target subnet, let the victim's trade go through, unstake straight after in the same block. MEV accomplished.
Do nothing. Pay the small transaction fee for an empty extrinsic.
The bot paid for one small contract call every block, and for a signal fee plus tip only when it attacked. Watching was cheap, and it paid more only when there was money to make.
While analysing the pattern, Taostats worked out how these attacks were being made and alerted the Opentensor Foundation (OTF) through a private channel. The fix was subtensor PR #3341, shipped in runtime 492. It went live at block 9,542,321 on 19 Nov 2026.
Now only Operational calls signed by the admin key keep top priority. A signal from an ordinary wallet waits in line like any other transaction, so it can't get ahead of the contract call any more.
The bots we tracked stopped trading in the hours before 492 went live and moved their stake back to root. We've seen no trading from their known wallets since.
This closes one route. It doesn't end MEV on Bittensor.
The five steps above are the whole idea. This section shows the actual numbers, for the bot we call Tip Bot.
Before runtime 492, every transaction got a priority number from its type:
- Operational calls such as
set_heap_pages: 10,000,000,000 - Normal calls, including the bot's contract call: 1.
- Among equal-priority transactions, the one that was ready first went first. That's why the bot sent its contract call early.
The set_heap_pages order tip was always between 65,536 and 131,071 rao (well under 0.001 TAO). The top bit marked it as a real order, and the 16 bits below it held the code. Before reading it, the contract unscrambled those 16 bits with a key built into its code and the block number, so the same order looked different in every block.
Tip Bot order, 16 bits, after unscrambling:
- Action: 2 bits
- Subnet: 7 bits
- Size: 4 bits
- Other: 3 bits
What each term meant:
- Action: stake, or unstake.
- Subnet: which subnet to trade.
- Size: a number from 0 to 15 that picks a stake from a fixed list: 3, 5, 8, 11, 16, 22, 30, 40, 52, 66, 82, 100, 120, 145, 170 or 199 TAO.
- Other: we never found a role for these bits.
The contract call carried the signal wallet's balance from the block before. When the call ran, the contract measured what was left in the wallet. The drop was the signal's fee plus its tip. Taking off the known fee left the tip, which the contract unscrambled into the order.
If the balance hadn't dropped, there was no order and the contract stopped without trading.
| Extrinsic | What happened | Ready at our node |
|---|---|---|
| 4 | Signal: set_heap_pages fails, tip 67,652 rao | 0.04 s after the slot started |
| 6 | Tip Bot stakes 16 TAO | 11.2 s before |
| 14 | Another bot stakes 4.66 TAO | 7.0 s before |
| 16 | User stakes | 9.97 TAO |
| 17 | The other bot unstakes | not recorded |
| 24 | Tip Bot unstakes, gets 16.0456 TAO back | 0.04 s after |
The contract call was ready 11 seconds early, and the signal arrived at the last moment. The signal still ran first. Tip Bot put in 16 TAO and took out 16.0456 TAO. That is before costs, and it isn't a measured loss for the user.
PR #3341 keeps the Operational priority only for calls signed by the sudo key. A failing set_heap_pages from an ordinary wallet now gets normal priority and no longer jumps the line. The signal can't arrive before the contract call, so the contract has nothing to read when it runs.
Observed on Bittensor mainnet, runtime v486, November 2026. For the full investigation, including a second bot that used the same trick, see the technical paper.


