Counter TPS Spam from Arbitrage Bots

Hi !

I am a professional arbitrageur started to look at Klaytn Blockchain couple days ago. I’ve seen that your blockchain is struggling with an (or couple) arbitrageurs because of their bots which put 3k-4k transactions everytime an arbitrage is possible.

I’ve seen couple of your blog posts, where you analysed those transactions and tried to counter this arbitrage method by changing the way Tx are priorized for smart contracts which are throwing too much reverted transactions. I’ve seen that the arbitrageur has modified their smart contracts in order to counter your modification.

Finally, you are working on increase the gas cost of each transaction in order to make him stop spamming like this on every occasion. This solution is good but penalize every user because of a couple of arbitrageurs and potentially won’t work as much as expected.

I’m here to tell you the reason why this (those) arbitrageur are working like this and proposing another solution you should think of:

First, an arbitrageur wants to make the less transactions possible in order to have the best return of investment. Also, an arbitrageur needs to be the first to do the arbitrage, there is no space for other arbitrageur, so they have to make a really fast algorithm looking for opportunities and send related transactions to the network.

As I can see in your blockchain code, when a transaction is sent, it is stored in a Transaction Pool, then the block creator randomly takes transactions in this pool and put them in a block. This is this behaviour which makes the arbitrageur spam the Transaction Pool !

Because, even if an arbitrageur has the fastest algorithm, he can’t be sure he will be the winner of the arbitrage because of that random behaviour. To be sure to win, the arbitrageur HAS to create thousands of Tx from Thousands of different wallets in order to be statistically sure that one of his transaction will work.

So, there is two solutions that could fix the problem :

  1. Dynamic gas fees, like Ethereum and other blockchains, but maybe a pain to dev and during flood of transaction, other users can be penalized.

  2. Second possibility (the best for me), stop selecting randomly the transaction in the transaction pool and make a FIFO order (first in / first out). In that way, an arbitrageur will have no advantage to spam transaction to be the first, it will just have to work on his algorithm speed !

3개의 좋아요

@AlgoChain I totally agree with you, and we already developing features similar to your suggestion.

As you can see the PR and the mileston of Klaytn repository, we are implementing tx ordering mechanism in “First Come, First Serve” way. After v1.8.3, miner nodes will include old transactions first in a block (This is the same way of Ethereum). And, all nodes will propagate transactions in the same order. This is the short-term mitigation for spam transactions.

Also, we are considering a dynamic gas fee as you mentioned. The feature will be implemented in v1.9.0 (it will be released this summer). But, we don’t decide the exact mechanism of the dynamicity. As you mentioned, it makes dApp developers hard to estimate fee and EIP1559 doesn’t have good DX. After we find some candidates, we gonna get feedback from the Ecosystem developers to decide on a new mechanism. Please, share your novel ideas at that time also.

Thank you for your interest and kind suggestion. Klaytn will adopt both of your suggestions!

2개의 좋아요

Thanks a lot for your answer.

Really happy to see that you are already implementing the FIFO order for the transaction pool.

When adding dynamic gas fee, the Klaytn DeX users will be more easily victim of “Sandwich Attack” when they will swaps tokens, because some bots can read the Tx Pool and “sandwich” the user transaction in order to make a profit from a user swapping big amount of tokens. While Arbitrage makes the market more fair for everyone, a “sandwich attack” just make money against real users.

If that dynamic gas fee is only intended to counter Arbitrageur Spamming the Tx Pool, making it FIFO only will solve the problem. Of course, if you want to implement dynamic gas fee for other reason, I will be happy to share my thoughts when you’ll ask Ecosystem feedback ! :slight_smile:

3개의 좋아요

Hi, we just proposed the new dynamic gas fee policy here. Please take a look if you interested!

2개의 좋아요

Thanks for that proposal !

Have you ever seen that tx order is not random in recent blocks?

I wonder if you’ve done any analysis.

related thread 클레이튼 블록 Tx 순서 원리 - user22님의 글 #21 ( unfortunately it’s korean :frowning: )

and, related address scope : Klaytnscope

Most of the transactions destined for this contract are included as the first transaction in the block.

Haven’t done analysis about this, but I can see two thing you could think of :

1- That related address found a way to be priorized in the block, if it’s the case, the FIFO ordering will solve this issue

2 - Related address found a way to get priorized by the block creators. If it’s the case, it won’t stop after FIFO Ordering

Wait & See !