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

core/txpool: move setcode tx validation into legacyPool #31209

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

rjl493456442
Copy link
Member

In this PR, several improvements have been made:

Authorization-related validations have been moved to legacyPool.
Previously, these checks were part of the standard validation procedure,
which applies common validations across different pools. Since these
checks are specific to SetCode transactions, relocating them to legacyPool
is a more reasonable choice.

Additionally, authorization conflict checks are now performed regardless
of whether the transaction is a replacement or not.

Copy link
Member

@lightclient lightclient left a comment

Choose a reason for hiding this comment

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

The changes look correct to me, but not sure I understand the motivation in the PR?

We have a mechanism for defining tx validation checks that is currently used by both pools. Not every method is implemented by both pools, e.g. FirstNonceGap is not implemented by the legacy pool. KnownConflicts is similar where it is optional for pools to implement and so only the legacy pool implements it.

If we go through this PR, we also need to change the comment for UsedAndLeftSlots because it is currently listed as "mandatory" for pools to implement.

authorization conflict checks are now performed regardless
of whether the transaction is a replacement or not.

could you point out this change for me also? having trouble seeing this in the diff

exists = queue.Contains(tx.Nonce())
}
}
// Replace the existing inflight transaction for delegated accounts
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Replace the existing inflight transaction for delegated accounts
// Replace the existing in-flight transaction for delegated accounts

queue := pool.queue[from]
if queue != nil {
count += queue.Len()
if !exists {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if !exists {
exists = queue.Contains(tx.Nonce()) || exists

simpler ?

@rjl493456442
Copy link
Member Author

The changes look correct to me, but not sure I understand the motivation in the PR?

The primary motivation is to keep common validation as generic as possible and not to
pile up additional checks endlessly. KnownConflict is very SetCodeTx specific and
won't be required for blobPool, do the validation inside of legacyPool is a better option
to me.

e.g. FirstNonceGap is not implemented by the legacy pool

It's true that legacyPool doesn't need to check the nonce gap. But it's the technical debt
and the legacypool might be refactored later to abstract the nonce checking in the common
validation.

Checking nonce is a very common requirement, while auth conflict is very specific to
certain types of transaction.

could you point out this change for me also? having trouble seeing this in the diff

This KnownConflict check is only performed the transaction with same nonce is not
existent. For transaction replacement, this check is skipped. I feel it could be an attack
vector to bypass the restriction.

@lightclient
Copy link
Member

Okay I see what you mean where KnownConflicts only runs when the tx is new and not replacing another pending tx. Definitely want to resolve that. I feel indifferent about the more broad change of removing KnownConflicts and stopping the use of UsedAndLeftSlots. I think we are seeing this interface was trying to be generic, but turns out it is hard to define validation options across the pools that can be reused.

Since you have already implemented I suppose we can just accept this. Once we fix the nits on this PR it can be merged.

@rjl493456442
Copy link
Member Author

Yep, we should definitely fix the KnownConflict validations for transaction replacement.

@fjl How do you feel about the changes of relocating the setcode-tx specific validations to the legacypool?
I feel the txpool.Validation should be the common validations across different pools and Matt thinks it's a
generic validation framework and different rules can be added.

Would be nice to have some inputs from your side

Copy link
Member

@lightclient lightclient left a comment

Choose a reason for hiding this comment

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

LGTM - will give Felix a couple days in case he wants to weigh in

Copy link
Member

@MariusVanDerWijden MariusVanDerWijden left a comment

Choose a reason for hiding this comment

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

LGTM, but I agree with @lightclient that we should probably get rid of the validationOptionsWithState in favor of some code duplication since it isn't a great abstraction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants