0

Consider your transaction is pending in mempool for too long and you want it to be validated ASAP (I) or cancelled (II).

I) AFAIK In this case you are suggested to make the same transaction again (with same nonce) but with increased gas price. In this case the second transaction should be validated faster (due to higher gas price) and the first transaction should not be validated ever (due to nonce conflict)

II) AFAIK In this case you should also send second transaction with same nonce and higher gas price. But the second transaction should be meaningless. For example, you can send 0 ETH to yourself. It should be validated faster (due to higher gas price) and the real transaction (the first one) should not be validated ever (due to nonce conflict)

This mechanism is stated here and here

However, I did not fid any source code proving this mechanism. But I find this function, that sorts transactions in mempool. It contradicts with the mechanism since transactions with same nonce would be randomly sorted

1 Answer 1

1

However, I did not fid any source code proving this mechanism. But I find this function, that sorts transactions in mempool. It contradicts with the mechanism since transactions with same nonce would be randomly sorted

Looking at the function referenced, the client first sorts by nonce, (lower nonces first), this is so that if 2 transactions are submitted with consecutive nonces for example, say 0 and 1, the transaction with nonce 0 gets executed first, and then nonce 1.

The function then sorts by price, but it only compares the price with the head transaction of the generated heap. This is so that those matching nonces are the transactions competing against one another for price.

Given that, it seems that the function satisfies the requirements.

1
  • When you send 2 transactions with same nonces and different gas prices you don't know which of them would be the head transaction. The transaction with smaller price can be the head transaction so it would be placed prior to the transaction with higher price. Given that, I don't think that the function satisfies the requirements Aug 21, 2022 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.