Skip to content

Comments

perf(provider): use get_header instead of get_block in get_block_number_by_id#3640

Merged
mattsse merged 2 commits intoalloy-rs:mainfrom
snazzysam933:perf
Feb 5, 2026
Merged

perf(provider): use get_header instead of get_block in get_block_number_by_id#3640
mattsse merged 2 commits intoalloy-rs:mainfrom
snazzysam933:perf

Conversation

@snazzysam933
Copy link
Contributor

We only need the block number here, no reason to fetch the entire block with all its transactions. Now that get_header exists, let's use it.

@snazzysam933
Copy link
Contributor Author

Updated to use fallback: try get_header first, fall back to get_block if not supported. Turns out eth_getHeaderByHash isn't part of the standard JSON-RPC spec, so Anvil/Hardhat don't support it. This way we get the perf win on nodes that support it without breaking compatibility.

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

this is problematic, because not all clients/providers have this

@mattsse mattsse closed this Feb 5, 2026
@github-project-automation github-project-automation bot moved this to Done in Alloy Feb 5, 2026
@mattsse mattsse reopened this Feb 5, 2026
@github-project-automation github-project-automation bot moved this from Done to In Progress in Alloy Feb 5, 2026
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

actually this seems okay with the fallback

@github-project-automation github-project-automation bot moved this from In Progress to Reviewed in Alloy Feb 5, 2026
@mattsse mattsse enabled auto-merge (squash) February 5, 2026 22:20
@mattsse mattsse merged commit 15be269 into alloy-rs:main Feb 5, 2026
59 checks passed
@github-project-automation github-project-automation bot moved this from Reviewed to Done in Alloy Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants