core/txpool: add 7702 protection to blobpool #31526#1930
core/txpool: add 7702 protection to blobpool #31526#1930AnilChinchawale merged 1 commit intoXinFinOrg:dev-upgradefrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR adds support for EIP-7702 SetCode transactions (type 0x04) with protection mechanisms to prevent transaction pool abuse. The key changes introduce a lazy transaction wrapper to defer full transaction resolution until needed, a reservation system to prevent address conflicts across subpools, and specialized handling for delegated accounts.
Key changes:
- Introduced
LazyTransactionwrapper to optimize transaction handling by deferring full resolution - Added cross-subpool address reservation tracking via
ReservationTrackerandReserverto prevent conflicts - Implemented delegation limits restricting accounts with deployed or pending delegations to a single in-flight transaction
- Moved transaction ordering logic from
core/typestominerpackage with support for lazy transactions
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| miner/ordering.go | New transaction ordering implementation using LazyTransaction with miner fee calculation |
| miner/ordering_test.go | Comprehensive tests for transaction ordering including legacy, EIP-1559, and special transaction separation |
| miner/worker.go | Updated to use LazyTransaction wrapper and new ordering functions |
| core/txpool/reserver.go | New reservation tracking system to ensure address exclusivity across subpools |
| core/txpool/txpool.go | Updated to create and pass reservation tracker to subpools |
| core/txpool/subpool.go | Added LazyTransaction type and updated SubPool interface signatures |
| core/txpool/validation.go | Added Prague fork validation for SetCode transactions and authorization checks |
| core/txpool/errors.go | Added new error types for account limits, reservations, and in-flight limits |
| core/txpool/legacypool/legacypool.go | Major changes: reservation tracking, SetCode validation, delegation limit enforcement, authority tracking |
| core/txpool/legacypool/legacypool_test.go | Extensive tests for SetCode transactions, delegations, and reorgs |
| core/txpool/legacypool/legacypool2_test.go | Updated test initialization to include reserver |
| core/types/transaction.go | Removed ordering code (moved to miner), added SetCodeAuthorities() and Time-related helper methods |
| core/types/transaction_test.go | Removed tests that were moved to miner package |
| core/types/tx_setcode.go | Changed SignSetCode parameter order from (auth, prv) to (prv, auth) |
| eth/protocol.go | Updated txPool interface Pending signature to return LazyTransaction |
| eth/sync.go | Updated to resolve LazyTransaction before appending to transaction list |
| eth/api_backend.go | Updated to resolve LazyTransaction when retrieving pool transactions |
| eth/helper_test.go | Updated test helper to return LazyTransaction from Pending |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| warped := lazyTx.Resolve() | ||
| if warped == nil || warped.Tx == nil { | ||
| break |
There was a problem hiding this comment.
Missing nil check for resolved transaction. If lazyTx.Resolve() returns nil or warped.Tx is nil, the code breaks at line 1089 when calling tx.To(). The break statement at line 1086 prevents processing nil transactions, but the logic should also handle the case where Resolve succeeds but Tx is nil, or skip to the next transaction instead of breaking the entire loop.
| break | |
| log.Debug("Skipping nil resolved transaction") | |
| txs.Pop() | |
| continue |
| normalCount := 0 | ||
| for tx := txset.Peek(); tx != nil; tx = txset.Peek() { | ||
| resolved := tx.Resolve() | ||
| if resolved == nil || resolved.Tx.To() == nil || *resolved.Tx.To() == common.BlockSignersBinary { |
There was a problem hiding this comment.
Potential nil pointer dereference. At line 253, the code checks if resolved is nil or resolved.Tx.To() is nil. However, if resolved is not nil but resolved.Tx is nil, the code will panic when accessing resolved.Tx.To(). The check should be updated to include resolved.Tx != nil before accessing resolved.Tx.To().
| if resolved == nil || resolved.Tx.To() == nil || *resolved.Tx.To() == common.BlockSignersBinary { | |
| if resolved == nil || resolved.Tx == nil || resolved.Tx.To() == nil || *resolved.Tx.To() == common.BlockSignersBinary { |
| // acquire the subpool lock until the transaction addition is completed. | ||
| for _, tx := range pool.all.locals { | ||
| senderAddr, _ := types.Sender(pool.signer, tx) | ||
| pool.reserver.Release(senderAddr) | ||
| } | ||
| for _, tx := range pool.all.remotes { | ||
| senderAddr, _ := types.Sender(pool.signer, tx) |
There was a problem hiding this comment.
The Clear method iterates over pool.all.locals and pool.all.remotes to release reservations, but this doesn't handle the case where multiple transactions from the same account are in the pool. Since each unique account should only have one reservation, calling Release for each transaction from the same sender will result in multiple Release calls for the same address. This will trigger the "pool attempted to unreserve non-reserved address" error logged at line 102 of reserver.go for all but the first transaction from each account. The code should track unique sender addresses and only release each address once.
| // acquire the subpool lock until the transaction addition is completed. | |
| for _, tx := range pool.all.locals { | |
| senderAddr, _ := types.Sender(pool.signer, tx) | |
| pool.reserver.Release(senderAddr) | |
| } | |
| for _, tx := range pool.all.remotes { | |
| senderAddr, _ := types.Sender(pool.signer, tx) | |
| // acquire the subpool lock until the transaction addition is completed. | |
| senders := make(map[common.Address]struct{}) | |
| for _, tx := range pool.all.locals { | |
| senderAddr, _ := types.Sender(pool.signer, tx) | |
| if _, seen := senders[senderAddr]; seen { | |
| continue | |
| } | |
| senders[senderAddr] = struct{}{} | |
| pool.reserver.Release(senderAddr) | |
| } | |
| for _, tx := range pool.all.remotes { | |
| senderAddr, _ := types.Sender(pool.signer, tx) | |
| if _, seen := senders[senderAddr]; seen { | |
| continue | |
| } | |
| senders[senderAddr] = struct{}{} |
698b691 to
2f16bf9
Compare
2f16bf9 to
2ae0b41
Compare
Proposed changes
Ref: ethereum#31526
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which part of the codebase this PR will touch base on,
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that