-
Notifications
You must be signed in to change notification settings - Fork 860
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
Fine tune already seen txs tracker when a tx is removed from the pool #7755
Conversation
991d608
to
135397d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks solid. What is the risk of a regression for underpriced transactions filling the pool however?
*/ | ||
BELOW_MIN_SCORE; | ||
BELOW_MIN_SCORE(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we could thrash on malicious underpriced transactions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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
...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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
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(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
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-required
label 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