Fine tune already seen txs tracker when a tx is removed from the pool#7755
Merged
fab-10 merged 3 commits intobesu-eth:mainfrom Oct 17, 2024
Merged
Fine tune already seen txs tracker when a tx is removed from the pool#7755fab-10 merged 3 commits intobesu-eth:mainfrom
fab-10 merged 3 commits intobesu-eth:mainfrom
Conversation
991d608 to
135397d
Compare
garyschulte
reviewed
Oct 11, 2024
Contributor
garyschulte
left a comment
There was a problem hiding this comment.
Looks solid. What is the risk of a regression for underpriced transactions filling the pool however?
| * we could re-accept it in the future. | ||
| */ | ||
| BELOW_MIN_SCORE; | ||
| BELOW_MIN_SCORE(true); |
Contributor
There was a problem hiding this comment.
Seems like we could thrash on malicious underpriced transactions
Contributor
Author
There was a problem hiding this comment.
there is no added risk here, because a malicious actor can already send a bunch of those txs and the layered txpool already has protection for this, moreover in this PR the tx is removed from the pool and the possibly re-added, so not increasing the count, so this path is definitely more complex, that just sending new tx.
Contributor
Author
There was a problem hiding this comment.
@garyschulte do you need any other clarification/detail?
...jsonrpc/websocket/subscription/pending/PendingTransactionDroppedSubscriptionServiceTest.java
Outdated
Show resolved
Hide resolved
...eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/PeerTransactionTracker.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
135397d to
f4bea0e
Compare
fab-10
commented
Oct 17, 2024
...eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/PeerTransactionTracker.java
Outdated
Show resolved
Hide resolved
…ransactions/PeerTransactionTracker.java Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
garyschulte
approved these changes
Oct 17, 2024
Comment on lines
+69
to
+88
| public void shouldStopTrackingSeenTransactionsWhenRemovalReasonSaysSo() { | ||
| tracker.markTransactionsAsSeen(ethPeer1, ImmutableSet.of(transaction2)); | ||
|
|
||
| assertThat(tracker.hasSeenTransaction(transaction2.getHash())).isTrue(); | ||
|
|
||
| tracker.onTransactionDropped(transaction2, createRemovalReason(true)); | ||
|
|
||
| assertThat(tracker.hasSeenTransaction(transaction2.getHash())).isFalse(); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldKeepTrackingSeenTransactionsWhenRemovalReasonSaysSo() { | ||
| tracker.markTransactionsAsSeen(ethPeer1, ImmutableSet.of(transaction2)); | ||
|
|
||
| assertThat(tracker.hasSeenTransaction(transaction2.getHash())).isTrue(); | ||
|
|
||
| tracker.onTransactionDropped(transaction2, createRemovalReason(false)); | ||
|
|
||
| assertThat(tracker.hasSeenTransaction(transaction2.getHash())).isTrue(); | ||
| } |
8 tasks
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR description
If a tx is removed from the pool due to eviction policies, but it is valid, we should be able to accept that tx again in future, but now this could not happen, since we keep track, in a cache, of all the tx hashes that we have seen, to avoid reprocessing txs, and so if the hash of the evicted txs is still in the cache, it will not be accepted again.
This PR tune the already seen txs tracker to stop tracking a valid tx that is removed from the pool, opening to the possibility to re-accept it in future.
Fixed Issue(s)
fixes #7081
Thanks for sending a pull request! Have you done the following?
doc-change-requiredlabel to this PR if updates are required.Locally, you can run these tests to catch failures early:
./gradlew build./gradlew acceptanceTest./gradlew integrationTest./gradlew ethereum:referenceTests:referenceTests