Skip to content

# Sequence diagram for tx announcement metadata validation in TxFetcher.Notify #70

@Dargon789

Description

@Dargon789

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 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
eth/fetcher/tx_fetcher.go
eth/fetcher/tx_fetcher_test.go
tests/fuzzers/txfetcher/txfetcher_fuzzer.go
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
eth/handler.go
eth/handler_test.go
core/txpool/txpool.go
core/txpool/subpool.go
core/txpool/blobpool/blobpool.go
core/txpool/legacypool/legacypool.go
Harden trie-related accounting and key composition in stateless witness stats and pathdb snapshot flushing.
  • Clamp account and storage trie leaf depths to the last bucket when paths exceed the stats array size
  • Introduce storageKeySlice to construct the storage snapshot key as a slice without repeated append allocations
  • Refactor snapshot flush and disk layer storage lookups to use storageKeySlice consistently for clean-cache keys and generation markers
core/stateless/stats.go
triedb/pathdb/lookup.go
triedb/pathdb/flush.go
triedb/pathdb/disklayer.go
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!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Originally posted by @sourcery-ai[bot] in #69 (comment)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdependenciesPull requests that update a dependency filedocumentationImprovements or additions to documentationduplicateThis issue or pull request already existsenhancementNew feature or requestgoPull requests that update go codegood first issueGood for newcomersinvalidThis doesn't seem rightquestionFurther information is requested

Projects

Status

Backlog

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions