chain/ethereum: Reduce unnecessary eth_getBlockByHash and eth_getBlockByNumber RPC calls by lutter · Pull Request #6491 · graphprotocol/graph-node
added 2 commits
April 8, 2026 11:03…block_pointer_from_number Both methods previously always made an eth_getBlockByNumber RPC call. is_on_main_chain is called every reconciliation cycle for subgraphs that are beyond the reorg threshold, so with many syncing subgraphs this generated a flood of unnecessary calls for blocks already in the cache. Both methods now check chain_store.block_ptrs_by_numbers first and only fall back to RPC when the cache has no entry or an ambiguous result (multiple blocks at the same number due to a recorded reorg).
…_rpc fetch_full_block_with_rpc previously called adapter.block_by_hash() directly, bypassing the block cache and always making an eth_getBlockByHash RPC call. It is called from ancestor_block when the cached block has no receipts, or after walking back the chain via parent_ptr (which populates the cache). In both cases the block may already be available in the cache. Change it to delegate the light block fetch to fetch_light_block_with_rpc, which goes through adapter.load_blocks() and chain_store.blocks() — checking recent_blocks_cache and the DB before falling back to RPC.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters