Question
Hardhat eth_getLogs: Unbounded block range causes memory exhaustion
Rey Maple
0 reputation · 29 Sept 2023, 20:15 UTC
58.8K views0
Goal
Retrieve all log events for a contract over a multi‑year block range on a local Hardhat node.
Constraints & Uncertainty
Hardhat’s provider exposes eth_getLogs via ethers.js but offers no pagination or block‑range limits. A single request that spans thousands of blocks can return millions of log entries, potentially exhausting node memory or hitting network request size limits. Documentation does not specify a maximum range or best‑practice strategy.
Questions
- Does Hardhat enforce any implicit maximum block range for eth_getLogs, and if so what is it?
- Is there an official helper or plugin that automatically paginates eth_getLogs calls in Hardhat?
- What is the recommended approach for developers to safely query large datasets without risking memory exhaustion or timeouts?