Skip to content

Reduce clones and cleanup in block cache path#6431

Merged
incrypto32 merged 5 commits intomasterfrom
krishna/reduce-clones-json-roundtrips
Mar 11, 2026
Merged

Reduce clones and cleanup in block cache path#6431
incrypto32 merged 5 commits intomasterfrom
krishna/reduce-clones-json-roundtrips

Conversation

@incrypto32
Copy link
Member

Addresses review feedback from #6400.

  • Migrate check_blocks to use typed blocks() instead of raw JSON
  • Remove blocks_as_json from ChainStore trait
  • Wrap LightEthereumBlock in Arc inside CachedBlock::Light to avoid expensive deep clones
  • Inline EthereumJsonBlock into CachedBlock::from_json and delete the wrapper

Copy link
Collaborator

@lutter lutter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Just a few very minor comments, feel free to ignore

Use the typed `blocks()` method instead of `blocks_as_json()` so that
block comparisons go through the same alloy serialization on both the
cached and provider sides. This gives a fairer diff by normalizing
both blocks through the same types, and only compares the block data
(without receipts) since `eth_getBlockByHash` does not return receipts.
All callers now use the typed `blocks()` method. The resolver serializes
the CachedBlock to JSON at the GraphQL boundary. This eliminates the
separate raw-JSON code path from the trait.
Arc-wrap the Light variant to avoid expensive deep clones of AnyBlock.
into_light_block now borrows self and returns Arc via cheap refcount bumps.
Remove the single-consumer EthereumJsonBlock wrapper and inline its
deserialization and patching logic directly into CachedBlock::from_json.
@incrypto32 incrypto32 force-pushed the krishna/reduce-clones-json-roundtrips branch from a904dbe to 1a06f0d Compare March 11, 2026 07:51
@incrypto32 incrypto32 force-pushed the krishna/reduce-clones-json-roundtrips branch from 1a06f0d to 1024a1b Compare March 11, 2026 08:43
@incrypto32 incrypto32 merged commit 019c4c0 into master Mar 11, 2026
11 of 12 checks passed
@incrypto32 incrypto32 deleted the krishna/reduce-clones-json-roundtrips branch March 11, 2026 09:42
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