You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds tx metadata validation to the transaction fetcher announce path, plumbs a new validateMeta callback from the txpool, introduces tx-type filtering on txpools and subpools, tightens trie-related key handling and depth accounting, and includes a few minor behavioral and test adjustments.
Sequence diagram for tx announcement metadata validation in TxFetcher.Notify
sequenceDiagram
actor Peer
participant Handler
participant TxFetcher
participant TxPool
Peer->>Handler: Remote tx announcement
Handler->>TxFetcher: Notify(peer, types, sizes, hashes)
loop For each hash
TxFetcher->>Handler: validateMeta(hash, type)
Handler->>TxPool: Has(hash)
alt tx already known
TxPool-->>Handler: true
Handler-->>TxFetcher: txpool.ErrAlreadyKnown
TxFetcher->>TxFetcher: duplicate++
else tx not known
TxPool-->>Handler: false
Handler->>TxPool: FilterType(type)
alt unsupported tx type
TxPool-->>Handler: false
Handler-->>TxFetcher: types.ErrTxTypeNotSupported
TxFetcher->>TxFetcher: ignore announcement
else supported tx type
TxPool-->>Handler: true
Handler-->>TxFetcher: nil
TxFetcher->>TxFetcher: isKnownUnderpriced(hash)
alt underpriced
TxFetcher->>TxFetcher: underpriced++
else new and priced
TxFetcher->>TxFetcher: append to unknownHashes
TxFetcher->>TxFetcher: append to unknownMetas
end
end
end
end
TxFetcher-->>Handler: Processed announcement statistics
Loading
File-Level Changes
Change
Details
Files
Replace TxFetcher hasTx callback with a metadata validation callback and enforce metadata checks during transaction announcements.
Extend TxFetcher struct to hold a validateMeta(hash, kind) error callback instead of hasTx(hash) bool
Update NewTxFetcher and NewTxFetcherForTests signatures and initializers to accept and wire validateMeta
Change Notify logic to call validateMeta for each announced tx, treating txpool.ErrAlreadyKnown as duplicate, skipping invalid/unsupported types, and only queuing unknown + supported hashes and metadata
Update all TxFetcher tests and fuzzers to use the new validateMeta signature and add a dedicated test ensuring wrong metadata types are ignored while valid ones are kept
Expose and implement tx-type filtering in the txpool and its subpools, and use it from the eth handler to drive metadata validation.
Extend txPool interface with FilterType(kind byte) bool
Implement TxPool.FilterType by delegating to subpools via their new FilterType method
Refactor BlobPool and LegacyPool Filter methods to use new FilterType helpers and implement the helpers with the appropriate supported transaction kinds
Implement FilterType on the eth handler test txpool stub to match the supported tx types
Create validateMeta in eth handler to combine Has + FilterType into the new TxFetcher metadata validation callback
Minor configuration behavior fix for developer mode KDF setting.
Change DeveloperFlag handling so UseLightweightKDF follows the actual boolean flag value instead of being forced to true whenever the flag is set
cmd/utils/flags.go
Tips and commands
Interacting with Sourcery
Trigger a new review: Comment @sourcery-ai review on the pull request.
Continue discussions: Reply directly to Sourcery's review comments.
Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with @sourcery-ai issue to create an issue from it.
Generate a pull request title: Write @sourcery-ai anywhere in the pull
request title to generate a title at any time. You can also comment @sourcery-ai title on the pull request to (re-)generate the title at any time.
Generate a pull request summary: Write @sourcery-ai summary anywhere in
the pull request body to generate a PR summary at any time exactly where you
want it. You can also comment @sourcery-ai summary on the pull request to
(re-)generate the summary at any time.
Generate reviewer's guide: Comment @sourcery-ai guide on the pull
request to (re-)generate the reviewer's guide at any time.
Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
pull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore.
Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
request to dismiss all existing Sourcery reviews. Especially useful if you
want to start fresh with a new review - don't forget to comment @sourcery-ai review to trigger a new review!
Reviewer's Guide
Adds tx metadata validation to the transaction fetcher announce path, plumbs a new validateMeta callback from the txpool, introduces tx-type filtering on txpools and subpools, tightens trie-related key handling and depth accounting, and includes a few minor behavioral and test adjustments.
Sequence diagram for tx announcement metadata validation in TxFetcher.Notify
sequenceDiagram actor Peer participant Handler participant TxFetcher participant TxPool Peer->>Handler: Remote tx announcement Handler->>TxFetcher: Notify(peer, types, sizes, hashes) loop For each hash TxFetcher->>Handler: validateMeta(hash, type) Handler->>TxPool: Has(hash) alt tx already known TxPool-->>Handler: true Handler-->>TxFetcher: txpool.ErrAlreadyKnown TxFetcher->>TxFetcher: duplicate++ else tx not known TxPool-->>Handler: false Handler->>TxPool: FilterType(type) alt unsupported tx type TxPool-->>Handler: false Handler-->>TxFetcher: types.ErrTxTypeNotSupported TxFetcher->>TxFetcher: ignore announcement else supported tx type TxPool-->>Handler: true Handler-->>TxFetcher: nil TxFetcher->>TxFetcher: isKnownUnderpriced(hash) alt underpriced TxFetcher->>TxFetcher: underpriced++ else new and priced TxFetcher->>TxFetcher: append to unknownHashes TxFetcher->>TxFetcher: append to unknownMetas end end end end TxFetcher-->>Handler: Processed announcement statisticsFile-Level Changes
eth/fetcher/tx_fetcher.goeth/fetcher/tx_fetcher_test.gotests/fuzzers/txfetcher/txfetcher_fuzzer.goeth/handler.goeth/handler_test.gocore/txpool/txpool.gocore/txpool/subpool.gocore/txpool/blobpool/blobpool.gocore/txpool/legacypool/legacypool.gocore/stateless/stats.gotriedb/pathdb/lookup.gotriedb/pathdb/flush.gotriedb/pathdb/disklayer.gocmd/utils/flags.goTips and commands
Interacting with Sourcery
@sourcery-ai reviewon the pull request.issue from a review comment by replying to it. You can also reply to a
review comment with
@sourcery-ai issueto create an issue from it.@sourcery-aianywhere in the pullrequest title to generate a title at any time. You can also comment
@sourcery-ai titleon the pull request to (re-)generate the title at any time.@sourcery-ai summaryanywhere inthe pull request body to generate a PR summary at any time exactly where you
want it. You can also comment
@sourcery-ai summaryon the pull request to(re-)generate the summary at any time.
@sourcery-ai guideon the pullrequest to (re-)generate the reviewer's guide at any time.
@sourcery-ai resolveon thepull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore.
@sourcery-ai dismisson the pullrequest to dismiss all existing Sourcery reviews. Especially useful if you
want to start fresh with a new review - don't forget to comment
@sourcery-ai reviewto trigger a new review!Customizing Your Experience
Access your dashboard to:
summary, the reviewer's guide, and others.
Getting Help
Originally posted by @sourcery-ai[bot] in #69 (comment)