latticexyz / mud

MUD is a framework for building autonomous worlds
https://mud.dev
MIT License
692 stars 174 forks source link

Fix(store-sync): Handle unsynced RPC nodes #2901

Open dhvanipa opened 3 weeks ago

dhvanipa commented 3 weeks ago

Context: https://indexsupply.com/shovel/docs/#unsynchronized-ethereum-nodes

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 the toBlock 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 the toBlock is behind the fromBlock, which happens with unsynchronized RPCs.

changeset-bot[bot] commented 3 weeks ago

⚠️ No Changeset found

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.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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