First, the pending_tx_count is counted; let's denoted the value to $\alpha$.
Second, read nonce from the chain data; let's denoted the value to $N$.
At last, return the sum of the above two values: $N + \alpha$.
Notice that, there is a very very small gap time between the first action and the second second.
If any new block is committed in that gap time, what would be happpened?
The result will become to $\alpha + (N + \alpha) = 2\alpha + N$.
So, in unit tests, when the code calls RPC methods eth_getTransactionCount(..., "pending") again and again.
The result could be:
0x30,
0x31,
0x32,
0x33,
0x34,
0x3a, <-- See THIS!
0x36.
After the transaction with nonce 0x3a is committed, the all remained already-sent transactions after it would never be committed, since the nonce are not allowed to be decreased.
These transactions will be stuck in mempool forever.
Proposal
I have no idea how to fix that base on current codes.
But I noticed that there is two fields named timeout_gap and timeout_config in the mempool.
I don't know what does these fields do but they contains block numbers.
Description
Let's focus on the following code:
https://github.com/axonweb3/axon/blob/0457119f5bf51b311f3a7f5740c626485dd3a52c/core/api/src/jsonrpc/impl/web3.rs#L357-L369
This function does two things:
pending_tx_count
is counted; let's denoted the value to $\alpha$.nonce
from the chain data; let's denoted the value to $N$.Notice that, there is a very very small gap time between the first action and the second second.
If any new block is committed in that gap time, what would be happpened? The result will become to $\alpha + (N + \alpha) = 2\alpha + N$.
So, in unit tests, when the code calls RPC methods
eth_getTransactionCount(..., "pending")
again and again. The result could be:0x30
,0x31
,0x32
,0x33
,0x34
,0x3a
, <-- See THIS!0x36
.After the transaction with nonce
0x3a
is committed, the all remained already-sent transactions after it would never be committed, since thenonce
are not allowed to be decreased. These transactions will be stuck in mempool forever.Proposal
I have no idea how to fix that base on current codes.
But I noticed that there is two fields named
timeout_gap
andtimeout_config
in the mempool. I don't know what does these fields do but they contains block numbers.https://github.com/axonweb3/axon/blob/0457119f5bf51b311f3a7f5740c626485dd3a52c/core/mempool/src/pool.rs#L26-L27
So, maybe Axon could do the following changes:
p.s. This issue is created via GitHub CLI.