Skip to content
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

Merged
merged 3 commits into from
Oct 17, 2024

Conversation

fab-10
Copy link
Contributor

@fab-10 fab-10 commented Oct 10, 2024

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?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests

@fab-10 fab-10 force-pushed the fine-tune-peer-txs-tracker branch 5 times, most recently from 991d608 to 135397d Compare October 10, 2024 12:55
@fab-10 fab-10 marked this pull request as ready for review October 10, 2024 12:55
Copy link
Contributor

@garyschulte garyschulte left a 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);
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
@fab-10 fab-10 force-pushed the fine-tune-peer-txs-tracker branch from 135397d to f4bea0e Compare October 16, 2024 08:46
…ransactions/PeerTransactionTracker.java

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
@fab-10 fab-10 enabled auto-merge (squash) October 17, 2024 07:49
Copy link
Contributor

@garyschulte garyschulte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

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();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@fab-10 fab-10 merged commit dfbfb96 into hyperledger:main Oct 17, 2024
43 checks passed
@fab-10 fab-10 deleted the fine-tune-peer-txs-tracker branch October 17, 2024 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transaction that is added to a node's pool may not be propagated to the pools of its peer nodes
3 participants