feat: reannounce local pending transactions #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This feature is copied from BSC: bnb-chain/bsc#570
When the network traffic is heavy, transactions that have been broadcast may be truncated in peers' tx_pools, while these local pending transactions have been marked as known, the source node won't broadcast them again, so they have no chance to be mined.
We add a timer to check whether the local pending transactions stay in tx_pool exceed a threshold, once transactions exceed the threshold, they will be announced to some peers again. The TxPool.ReannounceTime is used to control the threshold, the default value of TxPool.ReannounceTime is too big to be exceeded, users can config this parameter to enable this feature.
Also need to pay attention, this feature only announce the local pending transactions. If your node is configured TxPool.NoLocals=false, then the transactions sent to this RPC node will be treated as local transactions, otherwise you should add your addresses to the TxPool.Locals, only the transactions from the local addresses will be treated as local transactions.
Rationale
This feature is introduced to handle some extreme situations, it won't affect the original function, and it is disabled by default. Users can enable this feature by setting TxPool.ReannouceTime according to their needs.
Example
Set TxPool.ReannounceTime to 5 minutes:
geth --config ./config.toml --datadir ./node --cache 8000 --rpc.allow-unprotected-txs --txlookuplimit 0 --txpool.reannouncetime 5m
Changes
Notable changes: