-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Is there an existing issue for this?
- I have looked through the existing issues
Which method was used to setup Scaffold-ETH 2 ?
npx create-eth@latest
Current Behavior
First here is the code that is being used:
const {
data: sentMessages,
isLoading: isLoadingSentMessages,
error: errorReadingSentMessages,
} = useScaffoldEventHistory({
contractName: "ArbAddressTableExample",
eventName: "MessageSent",
blocksBatchSize: 100000,
filters: { sender: address },
});
Here is what I am seeing when I copy all the RPC logs for eth_getLogs
.
As a result, setting the batch size doesn't help create fewer queries since it will send a call for each block between the last event found's block and the toBlock. Then it is only incrementing the fromBlock by one for each call. Effectively not proceeding to search a new span of blocks until a single request has been made for every block in current range!! Yikes!
Expected Behavior
I would expect that each request would only search each fromBlock <> toBlock span once and then move on to the next span.
Assuming a batch size of 10 It should go through them like this:
0 - 10
10 - 20
20 - 30
...
Steps To Reproduce
If you need to recreate it exactly you can use npx create-eth -e BuidlGuidl/arbitrum-extension
. Then deploy the contract to arbitrumSepolia. Make a few transactions (if you even can, the default RPC is usually too overloaded to estimateGas properly).
Might would be useful to create a specific test case on a local hardhat network and see if it could be recreated there.
Anything else?
I know that we added the batchSize limit of 500 because of some changes to Alchemy. I read somewhere that some RPCs may have an event limit (not block range limit) though it seemed to say it was 10,000 for this specific RPC. We should just keep that in mind that potentially we would need to grab the latest event block instead of the last toBlock but that would only apply if we reached that maximum for events returned (if the query returned 10,000 events).