Can I ‘snipe’ a pending transactions stuck in the mempool?

I am curious to learn further about how the mempool operates. Here are a couple of hypotheticals to help me understand:

Assumptions:
The mempool is full with 50,000 mojo needed to clear the mempool

  1. There is a pending offer that a user has already accepted with 0 fee. The transaction is stuck in the mempool until the mempool clears. Could someone include a fee and accept the same offer and cut in front of them and ‘snipe’ the transaction out from under them?

  2. A new NFT offer is listed and two separate users accept this offer with the minimum fee at relatively the same time. In theory, who would get their offer accepted? If the transaction fails, does it fail for both?

If there is a better place to ask this, please let me know !

4 Likes

I have collected the answers to these questions from CNI developers:

  1. No, they can’t. To replace the offer via additional fee, they’ll need to spend the same coins and add their own spend on top. But if they spend the same coins, then the tx will fail as amounts won’t balance (for example, one NFT but two addresses trying to claim it).

  2. One will succeed. One will fail.

    Which one actually wins depends on the mempool of the farmer making the block. Normally only one TX will be accepted into the mempool, and the other will fail. This is like 99% of the time. But it is possible (network segmentation eg.) where Alice’s node has offer A in the mempool (and rejects offer B), and Bob’s node has offer B in the mempool (and rejects offer A). In this case, Bob will make a block with B and Alice will make a block with A.

It comes down to maximizing probability that your tx ends up in more mempools than the other tx. It takes about 2 seconds for a new tx to propagate across the network. So that time is probably what people have to compete for the offer.

Chia’s gossip protocol is quite efficient, there are probably ways to model out the P2P process, but you don’t have much time for conflicts. But the upshot is you CAN be in the mempool and not get in a block and then be rejected out of the mempool.

Also, a farmer in theory can include any txs they want in the block - they don’t have to pick things out of the mempool if they don’t want. So for example, in theory, if I was making the block and I wanted the NFT, I could include my own offer for it and not any of the ones in the mempool.

Chia is nicely decentralized, so this kind of thing is quite hard practically. In many PoS, it’s rather trivial and in fact the former ETH pools relied on this to include their own payments without paying fees

2 Likes

What’s happen when:

  1. We accept an offer with 0 fees.
  2. It get stuck in mempool.
  3. We delete unconfirmed transaction.
  4. Accept it again with a higher fee.

How come, in this scenario, we can “snipe” our own offer but someone else cannot?

Am I missing something?

Do “Delete unconfirmed transaction” remove it from the mempool? I have understand that this is only a local “unlock” of the coins.

1 Like

Replace By Fee (RBF) does work, but it requires that you select the same coins with the new transaction. Because of this, you can “snipe” your own offer but others cannot.

At some point we will make it easier to do RBF, but for now it’s a bit complicated to make sure it will happen.

“Delete unconfirmed transactions” should delete them from the mempool. However, when you cancel an offer, if you don’t cancel on the blockchain, it will just do a local “unlock” of the coins.

2 Likes