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

go/runtime/txpool: Remove rechecked transactions from seen cache #5542

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

kostko
Copy link
Member

@kostko kostko commented Jan 25, 2024

In case a transaction is rejected because it fails a re-check pass, it should also be removed from the seen cache as it may be resubmitted later when it could become valid.

In case a transaction is rejected because it fails a re-check pass, it
should also be removed from the seen cache as it may be resubmitted
later when it could become valid.
@kostko kostko force-pushed the kostko/fix/rt-txpool-seencache-remove branch from 150e62c to d2b2d6f Compare January 25, 2024 11:22
@kostko kostko marked this pull request as ready for review January 25, 2024 11:24
t.seenCache.Remove(h)
}

t.HandleTxsUsed(hashes)
Copy link
Contributor

Choose a reason for hiding this comment

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

A bit confusing... Are rejected transactions "processed in a block" (description of HandleTxsUsed)?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, but the logic is the same (e.g. they should be removed from queue). Maybe the naming is a bit awkward.

Copy link
Contributor

@peternose peternose left a comment

Choose a reason for hiding this comment

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

Looks good.

  • Why is this better than submitting a new transaction?
  • Do we simplify DoS attacks with these changes?
  • Is it possible that rejected transactions will travel from node to node and never be removed from the network?
  • Do we need to limit the number of retries?

@@ -83,6 +83,11 @@ type TransactionPool interface {
// ClearProposedBatch clears the proposal queue.
ClearProposedBatch()

// RejectTxs indicates that given transaction hashes have been rejected during block processing.
// Queues that can remove those transactions will do so. Additionally, these transactions will
// be removed from the already seen cache as they can potentially become valid in the future.
Copy link
Contributor

Choose a reason for hiding this comment

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

The final two sentences might be too detailed for an interface as they delve into implementation specifics. But so are some other comments.

@kostko
Copy link
Member Author

kostko commented Jan 25, 2024

Why is this better than submitting a new transaction?

Because the same transaction may become valid in the future. The future may also be due to the async nature of the network where some nodes may be slightly behind others.

Do we simplify DoS attacks with these changes?

Just in the sense that there may be more load on transaction checks (which are very fast). But someone can already generate slightly different transactions and spam those. Also note that it is already the case that transactions which are rejected immediately are not added to the already seen cache (for the same reason). This just makes rechecks consistent.

Is it possible that rejected transactions will travel from node to node and never be removed from the network?

Nodes only forward transactions that pass checks. Also the p2p layer has its own deduplication logic.

Do we need to limit the number of retries?

You mean like having a separate cache that would count the number of times a tx hash was rejected and after a certain amount just immediately reject without passing any checks? We could consider this if it becomes a problem in practice.

@kostko kostko merged commit 84cb3ab into master Jan 25, 2024
4 checks passed
@kostko kostko deleted the kostko/fix/rt-txpool-seencache-remove branch January 25, 2024 14:00
@peternose
Copy link
Contributor

some nodes may be slightly behind others.

This makes sense.

But someone can already generate slightly different transactions and spam those.

If he takes this action now, the impact will be more significant, as the rejected transactions will accumulate in the network. However, according to your answer, these transactions will not be forwarded so I guess this is not a problem.

You mean like having a separate cache that would count the number of times a tx hash was rejected and after a certain amount just immediately reject without passing any checks?

Yes.

We could consider this if it becomes a problem in practice.

Ok.

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.

3 participants