Skip to content

perf(primitives-traits): hash txs before rpc block clone - #89

Merged
mattsse merged 1 commit into
mainfrom
mattsse/to-rpc-block-full
Nov 14, 2026
Merged

mattsse merged 1 commit into
mainfrom
mattsse/to-rpc-block-full

Conversation

@mattsse

@mattsse mattsse commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

clone_into_rpc_block with full transactions cloned the whole block and hashed the transactions of the clone. Transactions read from the database carry no hash, so the hashes never reached the shared block, and every full-transaction response for a cached block computed them again.

This adds clone_into_rpc_block_full, which hashes each transaction through the reference before cloning it, and routes clone_into_rpc_block through it. The hashes are computed on the first full conversion and stay cached on the block.

Used in paradigmxyz/reth#28552

`clone_into_rpc_block` with full transactions cloned the whole block and
hashed the transactions of the clone. Transactions read from the database
carry no hash, so the hashes never reached the shared block and every
call computed them again.

Add `clone_into_rpc_block_full`, which hashes each transaction through
the reference before cloning it, and route `clone_into_rpc_block` through
it.
@tempoxyz-bot

tempoxyz-bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

👁️ Cyclops Security Review

✅ Reviewed b08c750 (latest) · Coverage: partial · no open findings · report
⚠️ Not checked: Downstream RPC handlers, shared-block cache lifecycles, deployment feature selection, and out-of-repository custom body or transaction implementations were not supplied. Their exposure and compatibility are not covered by the scoped closure
⚠️ Not checked: The hash-cache closure is established only for alloy_consensus::Signed. TxHashRef implementations of other transaction types that can be a BlockBody::Transaction (downstream or non-Signed envelope variants) were not cited, so their behaviou
⚠️ Not checked: Interior mutation of a shared (cached) block: hashing alloy_consensus::Signed transactions through &self and keeping the hash on the block: ruled out without reading the cited code at this commit
ℹ️ Not verifiable from the source alone (needs running code or deployed state): No build, regression test, concurrency test, or performance benchmark was executed. Runtime correctness and performance ratios are not claimed. To verify it: Execute the rpc-compat regression tests an (1 more in the report)

mattsse added a commit to paradigmxyz/reth that referenced this pull request Nov 14, 2026
Drop the hashing pass from the state cache's block fetch. It ran for
every fetched block, including for callers that never read transaction
hashes (fee history rewards, header and count lookups).

reth-core's `clone_into_rpc_block` now hashes each transaction through
the reference before cloning it, so the first full-transaction response
fills the hashes on the cached block and later responses reuse them.

Bumps reth-core to paradigmxyz/reth-core#89, which also brings in the
codec changes from paradigmxyz/reth-core#72, #81, #83 and #84.
@mattsse
mattsse merged commit 5dabd39 into main Nov 14, 2026
36 checks passed
mattsse added a commit to paradigmxyz/reth that referenced this pull request Nov 14, 2026
paradigmxyz/reth-core#89 merged as 5dabd396f4, with the same tree as
the PR commit pinned before.
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