Open dhvanipa opened 3 weeks ago
Latest commit: 0aa7cc6965747e47d519f0b09e2930eac4b96145
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
Context: https://indexsupply.com/shovel/docs/#unsynchronized-ethereum-nodes
3rd party Ethereum API providers may load balance RPC requests across a set of unsynchronized nodes. In rare cases, the eth_getLogs request will be routed to a node that doesn’t have the latest block.
Solution: Batch fetch the latest block number with the logs, and ensure that the latest block number is past the
toBlock
. Otherwise, wait for the RPC to catch up to the latest block.For the sync stack, the
fromBlock
is decided from a local variable and thetoBlock
is decided by a subscription to the latest block number. So we need an additional filter from the latest block number subscription to not emit when thetoBlock
is behind thefromBlock
, which happens with unsynchronized RPCs.toBlock
is less thanfromBlock
, no error is thrown, and no logs are fetched either, as this while loop will resolve false. So in this PR, we add a filter to not emit incorrecttoBlock
's and also a safety error check to throw if this case occurs.