-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve mempool eviction policy #5317
Comments
I've seen some similar behavior, not sure if it's the same issue or different:
There are definitely many such transactions in the mempool today. But I don't think they're blocking following txs. |
I'm beginning to understand what's going on here - although I'm also beginning to suspect that these are two separate (possibly related?) issues and that we might need more information to troubleshoot OP's issue. The issue as I understand it is that transactions at present can only have three possible internal states in the node: go-spacemesh/common/types/transaction.go Lines 123 to 134 in 92b7762
We may want to add an As soon as a tx has been parsed (its header has been read, i.e., it's syntactically valid), it's assigned state go-spacemesh/sql/transactions/transactions.go Lines 171 to 177 in 92b7762
This doesn't mean it's contextually valid, e.g., its counter may be wrong. It also doesn't mean the tx is actually in the mempool. It may only be in the database -- and I guess we save all txs in the database, even ones that will never be effective. So there's also a question of whether we should drop these txs from the database, and on what logic. (Even a tx that appears that it'll never be effective because, e.g., a tx from the same principal with a higher counter has already been processed, could theoretically appear in a valid older block that a node missed, or due to a reorg.) |
This issue is still actual and should be solved.
All of them has mempool status, does not change account nonce, and blocks from submitting tx (with the same nonce). And if they actually persist in a mempool, then it might be an attack vector. Here is one of my transactions:
|
Okay, I run another test on standalone network and published 2 self spawn transactions (with nonces 0 and 1) with zero balance. Once I got positive balance this transactions were applied, one processed and one rejected.
|
A few points. First off, there are three related but distinct issues/questions here:
It seems like our goals for the third are:
Roughly speaking, once a user submits a tx to a node, these are the possible outcomes:
Am I missing anything? I'll do a little more homework into how other nodes/protocols handle this. |
One another case:
On TestNet 13.
Processed one: |
I spoke to this in my previous comment. This is an antipattern and wallets shouldn't allow this - you should not be able to submit a spend for more than your account contains. If you do, the correct thing to do is RBF with a valid transaction. Having said that, we still need to understand how other nodes/protocols handle this and we may just want to evict bad txs after some time, as I also said in my previous comment. |
Completely agree. On the Wallet side we should definitely add validation for "not possible to send more than the current balance". We definitely should do RBF, just because people can do mistakes. And one of the easiest thing to do when you want to cancel, is to replace it with transaction to yourself. But additionally on top of that I think we need some auto expiry for mempool transactions. But it's my gut feeling not an educated suggestion. |
That's good news. Thanks for taking a look. |
Btw, another inconsistency in the behavior:
I believe either both txs should be rejected or both should be accepted into the mempool. |
Most of the issues here should be solved with the merging of #6185. @brusherru If you have other suggestions we could handle them in future issues. |
I'm using Smapp 1.2.9 on Mac. Steps to produce:
1)I create a fully new address with no gas in it, then I build a spawn transaction to test my sdk. the transaction is broadcast successfully to the node and the SubmitTransactionResponse tells me that the state is in mempool
However, the transaction is still in the mempool and seems not removed.
2) I transfer some smidge to this account ,after the tx is applied, the transaction is still in the mempool, neither removed or mined.
3) I try to build another spawn tx, but its nonce from projected state is still 0, causing this tx fails, reporting:
"Failed to verify transaction: tx already exists"
4) Even if I use TransactionState api to check this transaction, it still show state "TRANSACTION_STATE_MEMPOOL"
.I think if the transaction does not have enough fund to pay balance/gas, it should be removed immediately and reporting states like "TRANSACTION_STATE_REJECTED"
Is this expected behavior? How to bypass it?
The text was updated successfully, but these errors were encountered: