Skip to content

test(firehose): cover the mapper and pin the tracer's call-data limits - #101

Merged
maoueh merged 1 commit into
streamingfast:release/reth-2.xfrom
valvecitydev:sf/mapper-tests
Nov 12, 2026
Merged

maoueh merged 1 commit into
streamingfast:release/reth-2.xfrom
valvecitydev:sf/mapper-tests

Conversation

@valvecitydev

Copy link
Copy Markdown

This PR adds tests only. It changes no code outside #[cfg(test)].

Mapper unit tests (crates/firehose/src/mapper.rs)

The tests cover u64_to_trimmed_bytes, to_block_data (header fields, withdrawals, uncles), signed_tx_to_tx_event (legacy, EIP-1559, EIP-2930 with an access list), receipt_data_from_parts, to_receipt_data, finalized_ref_from_num_hash and to_genesis_alloc. Until now, these functions had coverage only through the prestate goldens, which show a wrong field as an opaque protobuf diff.

Tracer-behavior tests (crates/firehose/src/inspector/tests/call_data.rs)

Two inspector tests pin firehose-tracer rules end to end through the reth inspector:

  • A KECCAK256 preimage stays only when its hash is a written storage slot. A preimage whose hash is never used as a slot is dropped.
  • Past 50 MiB of internal call input in a transaction, later calls keep only their 4-byte selector. Past 25 MiB of return data, later calls keep none. The cuts are flagged, and the root call is never cut.

The tracer owns these rules. A tracer bump that changes this part of the FIRE output then fails here first, before downstream consumers see it.

Evidence

All 12 new tests pass on release/reth-2.x, because they test existing behavior. To show that they can fail, I ran negative controls:

  • max_fee_per_gas mapped as max_fee_per_gas + 1: signed_tx_to_tx_event_eip1559 fails.
  • The SSTORE removed from the keccak test's contract: keccak_preimage_is_kept_only_when_it_explains_a_written_slot fails.
  • 20 identity calls instead of 55 (below both limits): call_input_and_return_data_are_truncated_past_the_per_tx_limits fails.

All reth-firehose tests pass (96). cargo +nightly fmt --check is clean. cargo clippy -p reth-firehose --all-targets -- -D warnings fails on release/reth-2.x already, on lines this PR does not touch (doc_markdown, missing_const_for_fn, use_self, if_then_some_else_none, clone_on_copy). With those lints allowed, clippy is clean.

Unit tests cover to_block_data (header fields, withdrawals, uncles),
signed_tx_to_tx_event (legacy, EIP-1559, EIP-2930 with an access list),
receipt mapping, finalized_ref_from_num_hash and to_genesis_alloc.

Inspector tests pin two firehose-tracer rules end to end: a KECCAK256
preimage stays only when its hash is a written storage slot, and call
input and return data are cut past the per-transaction limits (50 MiB
of input, 25 MiB of return data), while the root call is never cut. A
tracer bump that changes FIRE output then fails here first.
@maoueh
maoueh merged commit 32cd2ed into streamingfast:release/reth-2.x Nov 12, 2026
4 checks passed
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.

2 participants