Skip to content

Transaction Pool unwrap() in Production Code #2347

@aquariusluo

Description

@aquariusluo

Describe the bug

Affected Component

Transaction Pool (crates/transaction-pool/src/tempo_pool.rs)

Description

The Tempo transaction pool contains unwrap() calls in production code at lines 352 and 361. While these unwraps are protected by Reth's API contract (which guarantees one result per input transaction), they could theoretically panic if Reth's implementation changes behavior.

Root Cause

The code calls add_transactions() with single-item inputs and assumes it will always return at least one result:

// Line 449
.add_transactions(origin, std::iter::once(TransactionValidationOutcome::Valid { ... }))
    .pop()
    .unwrap()

// Line 468
.add_transactions(origin, Some(invalid))
    .pop()
    .unwrap()

The .pop() returns Option<T> and .unwrap() will panic if the Vec is empty.

Steps to reproduce

Empty Result from Valid Transaction (Theoretical Only)

  1. The current code path only executes for transactions with nonce_key = 0 (standard protocol nonces)
  2. Would require Reth's add_transactions() to return empty Vec
  3. If Reth returns empty Vec for any reason, the .pop().unwrap() will panic
  4. This would crash the transaction pool service

Logs


Platform(s)

Linux (x86)

Container Type

Not running in a container

What version/commit are you on?

v1.0.2 - the Presto release

If you've built from source, provide the full command you used

No response

Code of Conduct

  • I agree to follow the Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions