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

New filter restricting delegations in txpool #8022

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

Conversation

ak88
Copy link
Contributor

@ak88 ak88 commented Jan 7, 2025

This is a new filter for tx pool, introducing limitations to delegated accounts.
Originally mitigations are described in the EIP itself:
https://eips.ethereum.org/EIPS/eip-7702#transaction-propagation

As the EIP suggests this will limit delegated accounts to only one transaction in the pool at a time.

Also will restrict any transaction with the same nonce and source as a pending authorization tuple in the pool.

@ak88 ak88 changed the title Feature/delegations in txpool New filter restricting delegations in txpool Jan 7, 2025
return AcceptTxResult.Accepted;
Transaction[] currentTxs;

if (standardPool.TryGetBucket(tx.SenderAddress!, out currentTxs) || blobPool.TryGetBucket(tx.SenderAddress!, out currentTxs))
Copy link
Member

Choose a reason for hiding this comment

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

TryGetBucket locks and then copies all the transactions. Maybe we can have some kind of SearchInBucket(Predicate) where we could avoid creating the array?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively returning a pooled array instead? Keeping the lock while searching inside the bucket, could have other side effects.
@benaadams what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Should keep the lock if changing the txs in the bucket? What if another tx came in from same sender doing same thing?


Why is it or?

If there are regular txs does it not matter if are blob txs? And do the blob txs only matter if not regular ones?

Copy link
Member

Choose a reason for hiding this comment

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

Though probably lock at bucket level rather than whole pool

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should keep the lock if changing the txs in the bucket? What if another tx came in from same sender doing same thing?

Why is it or?

If there are regular txs does it not matter if are blob txs? And do the blob txs only matter if not regular ones?

  1. The idea is not to change the bucket at all, only to check if the incoming transaction is a replacement, in which case it should be accepted.

  2. Its not possible to have a blob transaction and another type in the pool at the same time.

Copy link
Member

Choose a reason for hiding this comment

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

Fair; add comment for 2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have any suggestions for Lukasz comment?

Copy link
Member

Choose a reason for hiding this comment

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

The search below is very fast. I would rather have this search under the lock as I think it won't be much slower than allocating an array?

@ak88 ak88 marked this pull request as ready for review January 15, 2025 09:32
Comment on lines 447 to 454
if (tx.HasAuthorizationList)
{
foreach (var auth in tx.AuthorizationList)
{
if (auth.Authority is not null)
_pendingDelegations.IncrementDelegationCount(auth.Authority!, auth.Nonce);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Let's have AddPendingDelegations for symmetry

src/Nethermind/Nethermind.TxPool/DelegationCache.cs Outdated Show resolved Hide resolved
return AcceptTxResult.Accepted;
Transaction[] currentTxs;

if (standardPool.TryGetBucket(tx.SenderAddress!, out currentTxs) || blobPool.TryGetBucket(tx.SenderAddress!, out currentTxs))
Copy link
Member

Choose a reason for hiding this comment

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

The search below is very fast. I would rather have this search under the lock as I think it won't be much slower than allocating an array?

@ak88 ak88 requested a review from marcindsobczak January 16, 2025 22:44
@@ -530,6 +530,14 @@ public bool TryGetBucketsWorstValue(TGroupKey groupKey, out TValue? item)
return false;
}

public bool BucketEmptyExcept(TGroupKey groupKey, Func<TValue, bool> predicate)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe better name BucketAny?

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