This reproduces the issue with events emitted by contracts deployed with MUD.
The gist is that a viem publicClient.watchEvents
listener won't always catch events, so it will miss some logs, that are actually present in the block. In fact, it will miss most of the logs, and only be triggered sporadically.
This started happening early this week/end of last week.
When creating multiple publicClient.watchEvents
over the same client, it happens that one of them will be triggered while the others won't.
The App contains the logic for the reproduction. It just creates both a publicClient.watchEvents
and a publicClient.watchBlocks
listeners. The first one will increment whenever it receives an event, and the second one will increment whenever it receives a block that contains some logs. The contract increment
function is called every 10 seconds (and you can call it manually on the page).
git clone git@github.com:primodiumxyz/caldera-rpc-bug-minimal-reproduction.git
pnpm i
cd packages/client && pnpm vite
If you would like to deploy on another chain:
- Add the chain to the config.
- Add the deploy command as well as the deployment profile.
- Update
PRIVATE_KEY
in packages/contracts/.env. - Run your deploy command.
- Update the params in the URL (
chainId
,worldAddress
,initialBlockNumber
) to match the deployment (see in worlds.json).